[gnome-boxes] Update coding style, that seems to be our common ground
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Update coding style, that seems to be our common ground
- Date: Tue, 4 Oct 2011 21:48:28 +0000 (UTC)
commit 68e118fb273b83c0c56a5e49f08904b3bafc6350
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Tue Oct 4 23:42:06 2011 +0200
Update coding style, that seems to be our common ground
We may still have a few iterations but I think we should be close.
Perhaps someday I will revise my "this." everywhere opinion.
src/box.vala | 194 ++++++++++++++++++++-------------------------
src/boxes.vala | 139 ++++++++++++++-------------------
src/collection-view.vala | 142 +++++++++++++---------------------
src/collection.vala | 36 ++-------
src/sidebar.vala | 91 ++++++++--------------
src/spice-display.vala | 42 +++--------
src/topbar.vala | 129 ++++++++++++-------------------
src/util.vala | 160 +++++++++++++++++---------------------
8 files changed, 367 insertions(+), 566 deletions(-)
---
diff --git a/src/box.vala b/src/box.vala
index dfaa0ed..63562ae 100644
--- a/src/box.vala
+++ b/src/box.vala
@@ -1,33 +1,11 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using GLib;
using Clutter;
using Gdk;
using Gtk;
using GVir;
-public abstract class Boxes.Display: GLib.Object {
+private abstract class Boxes.Display: GLib.Object {
protected HashTable<int, Gtk.Widget?> displays;
public signal void show (int display_id);
@@ -39,7 +17,7 @@ public abstract class Boxes.Display: GLib.Object {
public abstract void disconnect_it ();
public override void constructed () {
- this.displays = new HashTable<int, Gtk.Widget> (direct_hash, direct_equal);
+ displays = new HashTable<int, Gtk.Widget> (direct_hash, direct_equal);
}
~Boxes() {
@@ -47,13 +25,13 @@ public abstract class Boxes.Display: GLib.Object {
}
}
-public class Boxes.Box: Boxes.CollectionItem {
+private class Boxes.Box: Boxes.CollectionItem {
public Boxes.App app;
public BoxActor actor;
public DomainState state {
get {
try {
- return this.domain.get_info ().state;
+ return domain.get_info ().state;
} catch (GLib.Error error) {
return DomainState.NONE;
}
@@ -62,9 +40,9 @@ public class Boxes.Box: Boxes.CollectionItem {
private GVir.Domain _domain;
public GVir.Domain domain {
- get { return this._domain; }
+ get { return _domain; }
construct set {
- this._domain = value;
+ _domain = value;
}
}
@@ -74,12 +52,12 @@ public class Boxes.Box: Boxes.CollectionItem {
Object (domain: domain);
this.app = app;
- this.name = domain.get_name ();
- this.actor = new BoxActor (this);
+ name = domain.get_name ();
+ actor = new BoxActor (this);
- this.update_screenshot.begin ();
+ update_screenshot.begin ();
Timeout.add_seconds (5, () => {
- this.update_screenshot.begin ();
+ update_screenshot.begin ();
return true;
});
@@ -90,29 +68,29 @@ public class Boxes.Box: Boxes.CollectionItem {
return;
try {
- this.actor.show_display (this.display.get_display (0));
+ actor.show_display (display.get_display (0));
} catch (Boxes.Error error) {
- warning (error.message);
+ warning (error.message);
}
}
});
}
public Clutter.Actor get_clutter_actor () {
- return this.actor.actor;
+ return actor.actor;
}
public async bool take_screenshot () throws GLib.Error {
- if (this.state != DomainState.RUNNING &&
- this.state != DomainState.PAUSED)
+ if (state != DomainState.RUNNING &&
+ state != DomainState.PAUSED)
return false;
- var stream = this.app.connection.get_stream (0);
- var file_name = this.get_screenshot_filename ();
+ var stream = app.connection.get_stream (0);
+ var file_name = get_screenshot_filename ();
var file = File.new_for_path (file_name);
var output_stream = yield file.replace_async (null, false, FileCreateFlags.REPLACE_DESTINATION);
var input_stream = stream.get_input_stream ();
- this.domain.screenshot (stream, 0, 0);
+ domain.screenshot (stream, 0, 0);
var buffer = new uint8[65535];
ssize_t length = 0;
@@ -125,18 +103,18 @@ public class Boxes.Box: Boxes.CollectionItem {
}
public bool connect_display () {
- this.update_display ();
+ update_display ();
- if (this.display == null)
+ if (display == null)
return false;
- this.display.connect_it ();
+ display.connect_it ();
return true;
}
private string get_screenshot_filename (string ext = "ppm") {
- var uuid = this.domain.get_uuid ();
+ var uuid = domain.get_uuid ();
return get_pkgcache (uuid + "-screenshot." + ext);
}
@@ -145,8 +123,8 @@ public class Boxes.Box: Boxes.CollectionItem {
Gdk.Pixbuf? pixbuf = null;
try {
- yield this.take_screenshot ();
- pixbuf = new Gdk.Pixbuf.from_file (this.get_screenshot_filename ());
+ yield take_screenshot ();
+ pixbuf = new Gdk.Pixbuf.from_file (get_screenshot_filename ());
} catch (GLib.Error error) {
if (!(error is FileError.NOENT))
warning (error.message);
@@ -156,7 +134,7 @@ public class Boxes.Box: Boxes.CollectionItem {
pixbuf = draw_fallback_vm (128, 96);
try {
- this.actor.set_screenshot (pixbuf);
+ actor.set_screenshot (pixbuf);
} catch (GLib.Error err) {
warning (err.message);
}
@@ -178,7 +156,7 @@ public class Boxes.Box: Boxes.CollectionItem {
int size = (int) (height * 0.5);
var icon_info = IconTheme.get_default ().lookup_icon ("computer-symbolic", size,
- IconLookupFlags.GENERIC_FALLBACK);
+ IconLookupFlags.GENERIC_FALLBACK);
Gdk.cairo_set_source_pixbuf (context, icon_info.load_icon (),
(width - size) / 2, (height - size) / 2);
context.rectangle ((width - size) / 2, (height - size) / 2, size, size);
@@ -198,7 +176,7 @@ public class Boxes.Box: Boxes.CollectionItem {
string type, gport, socket, ghost;
try {
- var xmldoc = this.domain.get_config (0).doc;
+ var xmldoc = domain.get_config (0).doc;
type = extract_xpath (xmldoc, "string(/domain/devices/graphics/@type)", true);
gport = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@port)");
socket = extract_xpath (xmldoc, @"string(/domain/devices/graphics[ type='$type']/@socket)");
@@ -210,24 +188,24 @@ public class Boxes.Box: Boxes.CollectionItem {
}
if (type == "spice") {
- this.display = new SpiceDisplay (ghost, gport.to_int ());
+ display = new SpiceDisplay (ghost, gport.to_int ());
} else {
warning ("unsupported display of type " + type);
return;
}
- this.display.show.connect ((id) => {
- this.app.ui_state = Boxes.UIState.DISPLAY;
+ display.show.connect ((id) => {
+ app.ui_state = Boxes.UIState.DISPLAY;
});
- this.display.disconnected.connect (() => {
- this.app.ui_state = Boxes.UIState.COLLECTION;
+ display.disconnected.connect (() => {
+ app.ui_state = Boxes.UIState.COLLECTION;
});
}
}
-public class Boxes.BoxActor: Boxes.UI {
+private class Boxes.BoxActor: Boxes.UI {
public Clutter.Box actor;
private GtkClutter.Texture screenshot;
@@ -249,36 +227,36 @@ public class Boxes.BoxActor: Boxes.UI {
layout.vertical = true;
var cbox = new Clutter.Box (layout);
- this.screenshot = new GtkClutter.Texture ();
- this.screenshot.name = "screenshot";
+ screenshot = new GtkClutter.Texture ();
+ screenshot.name = "screenshot";
- this.scale_screenshot ();
- actor_add (this.screenshot, cbox);
- this.screenshot.keep_aspect_ratio = true;
+ scale_screenshot ();
+ actor_add (screenshot, cbox);
+ screenshot.keep_aspect_ratio = true;
- this.vbox = new Gtk.VBox (false, 0);
- this.gtkactor = new GtkClutter.Actor.with_contents (this.vbox);
- this.label = new Gtk.Label (box.name);
- this.vbox.add (this.label);
- this.entry = new Gtk.Entry ();
- this.entry.set_visibility (false);
- this.entry.set_placeholder_text ("Password"); // TODO: i18n stupid vala...
- this.vbox.add (this.entry);
+ vbox = new Gtk.VBox (false, 0);
+ gtkactor = new GtkClutter.Actor.with_contents (vbox);
+ label = new Gtk.Label (box.name);
+ vbox.add (label);
+ entry = new Gtk.Entry ();
+ entry.set_visibility (false);
+ entry.set_placeholder_text ("Password"); // TODO: i18n stupid vala...
+ vbox.add (entry);
- this.vbox.show_all ();
- this.entry.hide ();
+ vbox.show_all ();
+ entry.hide ();
- actor_add (this.gtkactor, cbox);
+ actor_add (gtkactor, cbox);
- this.actor = cbox;
+ actor = cbox;
}
public void scale_screenshot (float scale = 1.5f) {
- this.screenshot.set_size (128 * scale, 96 * scale);
+ screenshot.set_size (128 * scale, 96 * scale);
}
public void set_screenshot (Gdk.Pixbuf pixbuf) throws GLib.Error {
- this.screenshot.set_from_pixbuf (pixbuf);
+ screenshot.set_from_pixbuf (pixbuf);
}
public void show_display (Gtk.Widget display) {
@@ -287,67 +265,67 @@ public class Boxes.BoxActor: Boxes.UI {
return;
}
- actor_remove (this.screenshot);
+ actor_remove (screenshot);
this.display = display;
- this.width_req_id = display.notify["width-request"].connect ( (pspec) => {
- this.update_display_size ();
+ width_req_id = display.notify["width-request"].connect ( (pspec) => {
+ update_display_size ();
});
- this.height_req_id = display.notify["height-request"].connect ( (pspec) => {
- this.update_display_size ();
+ height_req_id = display.notify["height-request"].connect ( (pspec) => {
+ update_display_size ();
});
- this.vbox.add (display);
- this.update_display_size ();
+ vbox.add (display);
+ update_display_size ();
display.show ();
display.grab_focus ();
}
public void hide_display () {
- if (this.display == null)
+ if (display == null)
return;
- this.vbox.remove (this.display);
- this.display.disconnect (this.width_req_id);
- this.display.disconnect (this.height_req_id);
- this.display = null;
+ vbox.remove (display);
+ display.disconnect (width_req_id);
+ display.disconnect (height_req_id);
+ display = null;
- this.actor.pack_at (this.screenshot, 0);
+ actor.pack_at (screenshot, 0);
}
public override void ui_state_changed () {
switch (ui_state) {
case UIState.CREDS:
- this.scale_screenshot (2.0f);
- this.entry.show ();
+ scale_screenshot (2.0f);
+ entry.show ();
// actor.entry.set_sensitive (false); FIXME: depending on spice-gtk conn. results
- this.entry.set_can_focus (true);
- this.entry.grab_focus ();
+ entry.set_can_focus (true);
+ entry.grab_focus ();
break;
case UIState.DISPLAY: {
int width, height;
- this.entry.hide ();
- this.label.hide ();
- this.box.app.window.get_size (out width, out height);
- this.screenshot.animate (Clutter.AnimationMode.LINEAR, Boxes.App.duration,
- "width", (float) width,
- "height", (float) height);
- this.actor.animate (Clutter.AnimationMode.LINEAR, Boxes.App.duration,
- "x", 0.0f,
- "y", 0.0f);
+ entry.hide ();
+ label.hide ();
+ box.app.window.get_size (out width, out height);
+ screenshot.animate (Clutter.AnimationMode.LINEAR, Boxes.App.duration,
+ "width", (float) width,
+ "height", (float) height);
+ actor.animate (Clutter.AnimationMode.LINEAR, Boxes.App.duration,
+ "x", 0.0f,
+ "y", 0.0f);
break;
}
case UIState.COLLECTION:
- this.hide_display ();
- this.scale_screenshot ();
- this.entry.set_can_focus (false);
- this.entry.hide ();
- this.label.show ();
+ hide_display ();
+ scale_screenshot ();
+ entry.set_can_focus (false);
+ entry.hide ();
+ label.show ();
break;
@@ -359,13 +337,13 @@ public class Boxes.BoxActor: Boxes.UI {
}
private void update_display_size () {
- if (this.display.width_request < 320 || this.display.height_request < 200) {
+ if (display.width_request < 320 || display.height_request < 200) {
// filter invalid size request
// TODO: where does it come from
return;
}
- this.box.app.set_window_size (this.display.width_request, this.display.height_request);
+ box.app.set_window_size (display.width_request, display.height_request);
}
}
diff --git a/src/boxes.vala b/src/boxes.vala
index 54704ac..36717c7 100644
--- a/src/boxes.vala
+++ b/src/boxes.vala
@@ -1,26 +1,4 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using Config;
using Gtk;
using Gdk;
@@ -32,7 +10,7 @@ using GVir;
// FIXME: vala includes header incorrectly, this will make sure config.h comes on top...
static const string foo = GNOMELOCALEDIR;
-public enum Boxes.UIState {
+private enum Boxes.UIState {
COLLECTION,
CREDS,
DISPLAY,
@@ -40,11 +18,11 @@ public enum Boxes.UIState {
WIZARD
}
-public errordomain Boxes.Error {
+private errordomain Boxes.Error {
INVALID
}
-public class Boxes.App: Boxes.UI {
+private class Boxes.App: Boxes.UI {
// FIXME: Remove these when we can use Vala release that provides binding for gdkkeysyms.h
private const uint F11_KEY = 0xffc8;
private const uint F12_KEY = 0xffc9;
@@ -71,6 +49,7 @@ public class Boxes.App: Boxes.UI {
GLib.Environment.set_application_name (_("GNOME Boxes"));
GtkClutter.init (ref args);
+
Gtk.Window.set_default_icon_name ("gnome-boxes");
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
var provider = new Gtk.CssProvider ();
@@ -89,110 +68,110 @@ public class Boxes.App: Boxes.UI {
}
public App() {
- this.setup_ui ();
- this.collection = new Collection ();
+ setup_ui ();
+ collection = new Collection ();
- this.collection.item_added.connect((item) => {
+ collection.item_added.connect((item) => {
if (item is Box) {
var box = item as Box;
var actor = box.get_clutter_actor ();
actor.set_reactive (true);
- actor.button_press_event.connect ((actor, event) => { return this.box_clicked (box, event); });
+ actor.button_press_event.connect ((actor, event) => { return box_clicked (box, event); });
}
- this.view.add_item (item);
+ view.add_item (item);
});
- this.setup_libvirt.begin ();
+ setup_libvirt.begin ();
}
public void set_category (Category category) {
- this.topbar.label.set_text (category.name);
+ topbar.label.set_text (category.name);
}
private async void setup_libvirt () {
- this.connection = new GVir.Connection ("qemu:///system");
+ connection = new GVir.Connection ("qemu:///system");
try {
- yield this.connection.open_async (null);
- this.connection.fetch_domains (null);
+ yield connection.open_async (null);
+ connection.fetch_domains (null);
} catch (GLib.Error e) {
warning (e.message);
}
- foreach (var domain in this.connection.get_domains ()) {
+ foreach (var domain in connection.get_domains ()) {
var box = new Box (this, domain);
- this.collection.add_item (box);
+ collection.add_item (box);
}
}
private void setup_ui () {
- this.window = new Gtk.Window ();
- this.window.set_default_size (640, 480);
- this.embed = new GtkClutter.Embed ();
- this.embed.show ();
- this.window.add (this.embed);
- this.stage = this.embed.get_stage () as Clutter.Stage;
+ window = new Gtk.Window ();
+ window.set_default_size (640, 480);
+ embed = new GtkClutter.Embed ();
+ embed.show ();
+ window.add (embed);
+ stage = embed.get_stage () as Clutter.Stage;
var actor = new GtkClutter.Actor (); // just to have background
- actor.add_constraint (new Clutter.BindConstraint ((Clutter.Actor) this.stage, BindCoordinate.SIZE, 0));
- ((Clutter.Container) this.stage).add_actor (actor);
+ actor.add_constraint (new Clutter.BindConstraint ((Clutter.Actor) stage, BindCoordinate.SIZE, 0));
+ ((Clutter.Container) stage).add_actor (actor);
- this.state = new Clutter.State ();
- this.state.set_duration (null, null, this.duration);
+ state = new Clutter.State ();
+ state.set_duration (null, null, duration);
- this.window.destroy.connect (quit);
- this.window.key_press_event.connect (this.on_key_pressed);
- this.window.configure_event.connect ( (event) => {
+ window.destroy.connect (quit);
+ window.key_press_event.connect (on_key_pressed);
+ window.configure_event.connect ( (event) => {
if (event.type == Gdk.EventType.CONFIGURE)
save_window_size ();
return false;
});
- this.box_table = new Clutter.TableLayout ();
- this.box = new Clutter.Box (this.box_table);
- this.box.add_constraint (new Clutter.BindConstraint ((Clutter.Actor) this.stage, BindCoordinate.SIZE, 0));
- ((Clutter.Container) this.stage).add_actor (this.box);
+ box_table = new Clutter.TableLayout ();
+ box = new Clutter.Box (box_table);
+ box.add_constraint (new Clutter.BindConstraint ((Clutter.Actor) stage, BindCoordinate.SIZE, 0));
+ ((Clutter.Container) stage).add_actor (box);
- this.topbar = new Topbar (this);
- this.sidebar = new Sidebar (this);
- this.view = new CollectionView (this);
+ topbar = new Topbar (this);
+ sidebar = new Sidebar (this);
+ view = new CollectionView (this);
var size_group = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
- size_group.add_widget (this.topbar.corner);
- size_group.add_widget (this.sidebar.notebook);
+ size_group.add_widget (topbar.corner);
+ size_group.add_widget (sidebar.notebook);
- this.window.show ();
+ window.show ();
ui_state = UIState.COLLECTION;
}
public void go_back () {
ui_state = UIState.COLLECTION;
- this.selected_box = null;
+ selected_box = null;
}
public override void ui_state_changed () {
message ("Switching layout to %s".printf (ui_state.to_string ()));
- foreach (var o in new Boxes.UI[] { this.sidebar, this.topbar, this.view }) {
+ foreach (var o in new Boxes.UI[] { sidebar, topbar, view }) {
o.ui_state = ui_state;
}
- this.box.set_layout_manager (this.box_table);
+ box.set_layout_manager (box_table);
switch (ui_state) {
case UIState.DISPLAY:
- this.box.set_layout_manager (new Clutter.FixedLayout ());
- this.state.set_state ("display");
+ box.set_layout_manager (new Clutter.FixedLayout ());
+ state.set_state ("display");
break;
case UIState.CREDS:
- this.state.set_state ("creds");
+ state.set_state ("creds");
break;
case UIState.COLLECTION:
restore_window_size ();
- this.state.set_state ("collection");
+ state.set_state ("collection");
break;
default:
warning ("Unhandled UI state %s".printf (ui_state.to_string ()));
@@ -206,19 +185,19 @@ public class Boxes.App: Boxes.UI {
if (ui_state == UIState.DISPLAY)
return;
- this.window.get_size (out w, out h);
- this.window.default_width = (int)w;
- this.window.default_height = (int)h;
+ window.get_size (out w, out h);
+ window.default_width = (int)w;
+ window.default_height = (int)h;
}
public void restore_window_size () {
- this.window.resize (this.window.default_width, this.window.default_height);
+ window.resize (window.default_width, window.default_height);
}
public void set_window_size (int width, int height, bool save=false) {
if (save)
save_window_size ();
- this.window.resize (width, height);
+ window.resize (width, height);
}
public void quit () {
@@ -227,10 +206,10 @@ public class Boxes.App: Boxes.UI {
private bool on_key_pressed (Widget widget, Gdk.EventKey event) {
if (event.keyval == F11_KEY) {
- if (WindowState.FULLSCREEN in this.window.get_window ().get_state ())
- this.window.unfullscreen ();
+ if (WindowState.FULLSCREEN in window.get_window ().get_state ())
+ window.unfullscreen ();
else
- this.window.fullscreen ();
+ window.fullscreen ();
return true;
}
@@ -244,8 +223,8 @@ public class Boxes.App: Boxes.UI {
private bool box_clicked (Box box, Clutter.ButtonEvent event) {
if (ui_state == UIState.COLLECTION) {
- this.selected_box = box;
- if (this.selected_box.connect_display ())
+ selected_box = box;
+ if (selected_box.connect_display ())
ui_state = UIState.CREDS;
}
@@ -253,11 +232,11 @@ public class Boxes.App: Boxes.UI {
}
}
-public abstract class Boxes.UI: GLib.Object {
+private abstract class Boxes.UI: GLib.Object {
public UIState ui_state { get; set; }
public UI () {
- this.notify["ui-state"].connect ( (s, p) => {
+ notify["ui-state"].connect ( (s, p) => {
ui_state_changed ();
});
}
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 2d394b0..6a67b66 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -1,30 +1,8 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using GLib;
using Clutter;
-public class Boxes.CollectionView: Boxes.UI {
+private class Boxes.CollectionView: Boxes.UI {
private App app;
private Clutter.Group actor; // the surrounding actor, for the margin
@@ -34,55 +12,54 @@ public class Boxes.CollectionView: Boxes.UI {
public CollectionView (App app) {
this.app = app;
- this.setup_view ();
+ setup_view ();
}
public override void ui_state_changed () {
switch (ui_state) {
case UIState.CREDS:
- this.remove_item (this.app.selected_box);
- this.app.selected_box.actor.ui_state = UIState.CREDS;
+ remove_item (app.selected_box);
+ app.selected_box.actor.ui_state = UIState.CREDS;
- this.top_box.pack (this.app.selected_box.get_clutter_actor (),
- "x-align", Clutter.BinAlignment.CENTER,
- "y-align", Clutter.BinAlignment.CENTER);
+ top_box.pack (app.selected_box.get_clutter_actor (),
+ "x-align", Clutter.BinAlignment.CENTER,
+ "y-align", Clutter.BinAlignment.CENTER);
- this.boxes.set_layout_manager (new Clutter.FixedLayout ());
+ boxes.set_layout_manager (new Clutter.FixedLayout ());
break;
case UIState.DISPLAY: {
float x, y;
- var actor = this.app.selected_box.get_clutter_actor ();
+ var actor = app.selected_box.get_clutter_actor ();
/* move box actor to stage */
actor.get_transformed_position (out x, out y);
- if (actor.get_parent () == this.top_box)
- this.top_box.remove_actor (actor);
- if (actor.get_parent () != this.app.stage)
- this.app.stage.add_actor (actor);
+ if (actor.get_parent () == top_box)
+ top_box.remove_actor (actor);
+ if (actor.get_parent () != app.stage)
+ app.stage.add_actor (actor);
actor.set_position (x, y);
- this.app.selected_box.actor.ui_state = UIState.DISPLAY;
+ app.selected_box.actor.ui_state = UIState.DISPLAY;
break;
}
case UIState.COLLECTION:
- this.boxes.set_layout_manager (this.layout);
+ boxes.set_layout_manager (layout);
- if (this.app.selected_box == null)
+ if (app.selected_box == null)
break;
- var actor = this.app.selected_box.get_clutter_actor ();
- if (actor.get_parent () == this.top_box)
- this.top_box.remove_actor (actor);
- this.add_item (this.app.selected_box);
+ var actor = app.selected_box.get_clutter_actor ();
+ if (actor.get_parent () == top_box)
+ top_box.remove_actor (actor);
+ add_item (app.selected_box);
break;
default:
-
break;
}
}
@@ -92,7 +69,7 @@ public class Boxes.CollectionView: Boxes.UI {
var box = (Box)item;
box.actor.ui_state = UIState.COLLECTION;
- actor_add (box.get_clutter_actor (), this.boxes);
+ actor_add (box.get_clutter_actor (), boxes);
} else
warning ("Cannot add item %p".printf (&item));
}
@@ -101,54 +78,43 @@ public class Boxes.CollectionView: Boxes.UI {
if (item is Box) {
var box = (Box)item;
var actor = box.get_clutter_actor ();
- if (actor.get_parent () == this.boxes)
- this.boxes.remove_actor (actor); // FIXME: why Clutter warn here??!
+ if (actor.get_parent () == boxes)
+ boxes.remove_actor (actor); // FIXME: why Clutter warn here??!
} else
warning ("Cannot remove item %p".printf (&item));
}
private void setup_view () {
- this.layout = new Clutter.FlowLayout (Clutter.FlowOrientation.HORIZONTAL);
- this.actor = new Clutter.Group ();
- this.boxes = new Clutter.Box (this.layout);
- this.layout.set_column_spacing (35);
- this.layout.set_row_spacing (25);
- this.actor.add (this.boxes);
- this.app.box.pack (this.actor, "column", 1, "row", 1, "x-expand", true, "y-expand", true);
-
- this.boxes.set_position (15f, 15f);
- this.boxes.add_constraint_with_name ("boxes-width",
- new Clutter.BindConstraint (this.actor, BindCoordinate.WIDTH, -25f));
- this.boxes.add_constraint_with_name ("boxes-height",
- new Clutter.BindConstraint (this.actor, BindCoordinate.HEIGHT, -25f));
+ layout = new Clutter.FlowLayout (Clutter.FlowOrientation.HORIZONTAL);
+ actor = new Clutter.Group ();
+ boxes = new Clutter.Box (layout);
+ layout.set_column_spacing (35);
+ layout.set_row_spacing (25);
+ actor.add (boxes);
+ app.box.pack (actor, "column", 1, "row", 1, "x-expand", true, "y-expand", true);
+
+ boxes.set_position (15f, 15f);
+ boxes.add_constraint_with_name ("boxes-width",
+ new Clutter.BindConstraint (actor, BindCoordinate.WIDTH, -25f));
+ boxes.add_constraint_with_name ("boxes-height",
+ new Clutter.BindConstraint (actor, BindCoordinate.HEIGHT, -25f));
// FIXME! report bug to clutter about flow inside table
- this.actor.add_constraint_with_name ("boxes-left", new Clutter.SnapConstraint (this.app.stage,
- SnapEdge.RIGHT,
- SnapEdge.RIGHT,
- 0));
- this.actor.add_constraint_with_name ("boxes-bottom", new Clutter.SnapConstraint (this.app.stage,
- SnapEdge.BOTTOM,
- SnapEdge.RIGHT.BOTTOM,
- 0));
-
- this.top_box = new Clutter.Box (new Clutter.BinLayout (Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL));
- this.top_box.add_constraint_with_name ("top-box-size",
- new Clutter.BindConstraint (this.actor, BindCoordinate.SIZE, 0));
- this.top_box.add_constraint_with_name ("top-box-position",
- new Clutter.BindConstraint (this.actor, BindCoordinate.POSITION, 0));
- this.app.stage.add_actor (this.top_box);
-
- this.app.state.set_key (null, "creds", this.boxes, "opacity", AnimationMode.EASE_OUT_QUAD, (uint) 0, 0, 0);
- this.app.state.set_key (null, "display", this.boxes, "opacity", AnimationMode.EASE_OUT_QUAD, (uint) 0, 0, 0);
- this.app.state.set_key (null,
- "collection",
- this.boxes,
- "opacity",
- AnimationMode.EASE_OUT_QUAD,
- (uint) 255,
- 0,
- 0);
- this.app.state.set_key (null, "display", this.top_box, "x", AnimationMode.EASE_OUT_QUAD, (float) 0, 0, 0);
- this.app.state.set_key (null, "display", this.top_box, "y", AnimationMode.EASE_OUT_QUAD, (float) 0, 0, 0);
+ actor.add_constraint_with_name ("boxes-left",
+ new Clutter.SnapConstraint (app.stage, SnapEdge.RIGHT, SnapEdge.RIGHT, 0));
+ actor.add_constraint_with_name ("boxes-bottom",
+ new Clutter.SnapConstraint (app.stage, SnapEdge.BOTTOM, SnapEdge.RIGHT.BOTTOM, 0));
+
+ top_box = new Clutter.Box (new Clutter.BinLayout (Clutter.BinAlignment.FILL, Clutter.BinAlignment.FILL));
+ top_box.add_constraint_with_name ("top-box-size",
+ new Clutter.BindConstraint (actor, BindCoordinate.SIZE, 0));
+ top_box.add_constraint_with_name ("top-box-position",
+ new Clutter.BindConstraint (actor, BindCoordinate.POSITION, 0));
+ app.stage.add_actor (top_box);
+
+ app.state.set_key (null, "creds", boxes, "opacity", AnimationMode.EASE_OUT_QUAD, (uint) 0, 0, 0);
+ app.state.set_key (null, "display", boxes, "opacity", AnimationMode.EASE_OUT_QUAD, (uint) 0, 0, 0);
+ app.state.set_key (null, "collection", boxes, "opacity", AnimationMode.EASE_OUT_QUAD, (uint) 255, 0, 0);
+ app.state.set_key (null, "display", top_box, "x", AnimationMode.EASE_OUT_QUAD, (float) 0, 0, 0);
+ app.state.set_key (null, "display", top_box, "y", AnimationMode.EASE_OUT_QUAD, (float) 0, 0, 0);
}
}
diff --git a/src/collection.vala b/src/collection.vala
index 01745c6..ca970ad 100644
--- a/src/collection.vala
+++ b/src/collection.vala
@@ -1,48 +1,26 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using GLib;
-public class Boxes.CollectionItem: GLib.Object {
+private class Boxes.CollectionItem: GLib.Object {
public string name;
}
-public class Boxes.Collection: GLib.Object {
+private class Boxes.Collection: GLib.Object {
public signal void item_added (CollectionItem item);
GenericArray<CollectionItem> items;
public Collection () {
- this.items = new GenericArray<CollectionItem> ();
+ items = new GenericArray<CollectionItem> ();
}
public void add_item (CollectionItem item) {
- this.items.add (item);
- this.item_added (item);
+ items.add (item);
+ item_added (item);
}
}
-public class Boxes.Category: GLib.Object {
+private class Boxes.Category: GLib.Object {
public string name;
public Category (string name) {
diff --git a/src/sidebar.vala b/src/sidebar.vala
index a107627..883f3d1 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -1,32 +1,10 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using Gtk;
using Gdk;
using Clutter;
using GLib;
-public class Boxes.Sidebar: Boxes.UI {
+private class Boxes.Sidebar: Boxes.UI {
public Notebook notebook;
public TreeView tree_view;
@@ -50,14 +28,14 @@ public class Boxes.Sidebar: Boxes.UI {
public Sidebar (App app) {
this.app = app;
- this.width = 180;
+ width = 180;
- this.setup_sidebar ();
+ setup_sidebar ();
}
public override void ui_state_changed () {
if (ui_state == UIState.DISPLAY)
- pin_actor(this.actor);
+ pin_actor (actor);
}
private void list_append (ListStore listmodel,
@@ -76,17 +54,17 @@ public class Boxes.Sidebar: Boxes.UI {
}
private void setup_sidebar () {
- this.notebook = new Gtk.Notebook ();
- this.notebook.set_size_request ((int)this.width, 100);
+ notebook = new Gtk.Notebook ();
+ notebook.set_size_request ((int)width, 100);
var vbox = new Gtk.VBox (false, 0);
- this.notebook.append_page (vbox, new Gtk.Label (""));
+ notebook.append_page (vbox, new Gtk.Label (""));
- this.tree_view = new Gtk.TreeView ();
- var selection = this.tree_view.get_selection ();
+ tree_view = new Gtk.TreeView ();
+ var selection = tree_view.get_selection ();
selection.set_select_function (selection_func);
- tree_view_activate_on_single_click (this.tree_view, true);
- this.tree_view.row_activated.connect ( (treeview, path, column) => {
+ tree_view_activate_on_single_click (tree_view, true);
+ tree_view.row_activated.connect ( (treeview, path, column) => {
Gtk.TreeIter iter;
Category category;
var model = treeview.get_model ();
@@ -97,16 +75,16 @@ public class Boxes.Sidebar: Boxes.UI {
model.get (iter, 2, out selectable);
if (selectable)
- this.app.set_category (category);
+ app.set_category (category);
});
- vbox.pack_start (this.tree_view, true, true, 0);
- this.notebook.page = 0;
- this.notebook.show_tabs = false;
- this.notebook.show_all ();
+ vbox.pack_start (tree_view, true, true, 0);
+ notebook.page = 0;
+ notebook.show_tabs = false;
+ notebook.show_all ();
- this.actor = new GtkClutter.Actor.with_contents (this.notebook);
- app.box.pack (this.actor, "column", 0, "row", 1, "x-expand", false, "y-expand", true);
+ actor = new GtkClutter.Actor.with_contents (notebook);
+ app.box.pack (actor, "column", 0, "row", 1, "x-expand", false, "y-expand", true);
var listmodel = new ListStore (5,
typeof (string),
@@ -114,38 +92,33 @@ public class Boxes.Sidebar: Boxes.UI {
typeof (bool),
typeof (string),
typeof (Category));
- this.tree_view.set_model (listmodel);
- this.tree_view.headers_visible = false;
+ tree_view.set_model (listmodel);
+ tree_view.headers_visible = false;
var pixbuf_renderer = new CellRendererPixbuf ();
// pixbuf_renderer.width = 20;
// pixbuf_renderer.mode = CellRendererMode.INERT;
// pixbuf_renderer.xalign = 1f;
pixbuf_renderer.xpad = 5;
- this.tree_view.insert_column_with_attributes (-1, "", pixbuf_renderer, "icon-name", 3);
+ tree_view.insert_column_with_attributes (-1, "", pixbuf_renderer, "icon-name", 3);
var renderer = new CellRendererText ();
- this.tree_view.insert_column_with_attributes (-1, "", renderer, "text", 0, "height", 1, "sensitive", 2);
+ tree_view.insert_column_with_attributes (-1, "", renderer, "text", 0, "height", 1, "sensitive", 2);
- this.list_append (listmodel, new Category ("New and Recent"));
+ list_append (listmodel, new Category ("New and Recent"));
selection.select_path (new Gtk.TreePath.from_string ("0"));
- this.list_append (listmodel, new Category ("Favorites"), "emblem-favorite-symbolic");
- this.list_append (listmodel, new Category ("Private"), "channel-secure-symbolic");
- this.list_append (listmodel, new Category ("Shared with you"), "emblem-shared-symbolic");
- this.list_append (listmodel, new Category ("Collections"), null, 40, false);
+ list_append (listmodel, new Category ("Favorites"), "emblem-favorite-symbolic");
+ list_append (listmodel, new Category ("Private"), "channel-secure-symbolic");
+ list_append (listmodel, new Category ("Shared with you"), "emblem-shared-symbolic");
+ list_append (listmodel, new Category ("Collections"), null, 40, false);
// TODO: make it dynamic
- this.list_append (listmodel, new Category ("Work"));
- this.list_append (listmodel, new Category ("Game"));
+ list_append (listmodel, new Category ("Work"));
+ list_append (listmodel, new Category ("Game"));
var create = new Gtk.Button.with_label ("Create");
create.margin = 5;
vbox.pack_end (create, false, false, 0);
create.show ();
- this.app.state.set_key (null,
- "display",
- this.actor,
- "x", AnimationMode.EASE_OUT_QUAD,
- -(float) this.width,
- 0,
- 0); // FIXME: make it dynamic depending on sidebar size..
+ // FIXME: make it dynamic depending on sidebar size..:
+ app.state.set_key (null, "display", actor, "x", AnimationMode.EASE_OUT_QUAD, -(float) width, 0, 0);
}
}
diff --git a/src/spice-display.vala b/src/spice-display.vala
index e89f27a..d6f97ee 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -1,43 +1,21 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using Gtk;
using Spice;
-public class Boxes.SpiceDisplay: Boxes.Display {
+private class Boxes.SpiceDisplay: Boxes.Display {
private Session session;
public SpiceDisplay (string host, int port) {
- this.session = new Session ();
- this.session.port = port.to_string ();
- this.session.host = host;
+ session = new Session ();
+ session.port = port.to_string ();
+ session.host = host;
}
public override Gtk.Widget get_display (int n) throws Boxes.Error {
var display = displays.lookup (n);
if (display == null) {
- display = new Spice.Display (this.session, n);
+ display = new Spice.Display (session, n);
}
if (display == null) {
@@ -49,9 +27,9 @@ public class Boxes.SpiceDisplay: Boxes.Display {
public override void connect_it () {
// FIXME: vala does't want to put this in ctor..
- this.session.channel_new.connect ((channel) => {
+ session.channel_new.connect ((channel) => {
if (channel is Spice.MainChannel)
- channel.channel_event.connect (this.main_event);
+ channel.channel_event.connect (main_event);
if (channel is Spice.DisplayChannel) {
var display = channel as DisplayChannel;
@@ -61,11 +39,11 @@ public class Boxes.SpiceDisplay: Boxes.Display {
}
});
- this.session.connect ();
+ session.connect ();
}
public override void disconnect_it () {
- this.session.disconnect ();
+ session.disconnect ();
}
private void main_event (ChannelEvent event) {
diff --git a/src/topbar.vala b/src/topbar.vala
index 2c0dfc0..6dafbf1 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -1,30 +1,8 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using Clutter;
using Gtk;
-public class Boxes.Topbar: Boxes.UI {
+private class Boxes.Topbar: Boxes.UI {
public Widget corner;
public Gtk.Label label;
@@ -40,88 +18,79 @@ public class Boxes.Topbar: Boxes.UI {
public Topbar (App app) {
this.app = app;
- this.height = 50;
+ height = 50;
- this.setup_topbar ();
+ setup_topbar ();
}
private void setup_topbar () {
- this.notebook = new Gtk.Notebook ();
- this.notebook.set_size_request (50, (int)this.height);
- this.actor = new GtkClutter.Actor.with_contents (this.notebook);
- this.app.box.pack (this.actor,
- "column", 0,
- "row", 0,
- "column-span", 2,
- "x-expand", true,
- "y-expand", false);
-
- this.hbox = new Gtk.HBox (false, 0);
- this.hbox.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
-
- this.corner = new Gtk.EventBox ();
- // FIXME.. this.corner.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
- this.hbox.pack_start (this.corner, false, false, 0);
-
- this.toolbar_start = new Gtk.Toolbar ();
- this.toolbar_start.icon_size = Gtk.IconSize.MENU;
- this.toolbar_start.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
+ notebook = new Gtk.Notebook ();
+ notebook.set_size_request (50, (int)height);
+ actor = new GtkClutter.Actor.with_contents (notebook);
+ app.box.pack (actor,
+ "column", 0,
+ "row", 0,
+ "column-span", 2,
+ "x-expand", true,
+ "y-expand", false);
+
+ hbox = new Gtk.HBox (false, 0);
+ hbox.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
+
+ corner = new Gtk.EventBox ();
+ // FIXME.. corner.get_style_context ().add_class (Gtk.STYLE_CLASS_SIDEBAR);
+ hbox.pack_start (corner, false, false, 0);
+
+ toolbar_start = new Gtk.Toolbar ();
+ toolbar_start.icon_size = Gtk.IconSize.MENU;
+ toolbar_start.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
var back = new Gtk.ToolButton (null, null);
back.icon_name = "go-previous-symbolic";
back.get_style_context ().add_class ("raised");
- back.clicked.connect ( (button) => { this.app.go_back (); });
- this.toolbar_start.insert (back, 0);
- this.toolbar_start.set_show_arrow (false);
- this.hbox.pack_start (this.toolbar_start, false, false, 0);
+ back.clicked.connect ( (button) => { app.go_back (); });
+ toolbar_start.insert (back, 0);
+ toolbar_start.set_show_arrow (false);
+ hbox.pack_start (toolbar_start, false, false, 0);
- this.label = new Gtk.Label ("New and Recent");
- this.label.name = "TopbarLabel";
- this.label.set_halign (Gtk.Align.START);
- this.hbox.pack_start (this.label, true, true, 0);
+ label = new Gtk.Label ("New and Recent");
+ label.name = "TopbarLabel";
+ label.set_halign (Gtk.Align.START);
+ hbox.pack_start (label, true, true, 0);
var toolbar_end = new Gtk.Toolbar ();
toolbar_end.icon_size = Gtk.IconSize.MENU;
toolbar_end.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
- this.spinner = new Gtk.ToolButton (new Gtk.Spinner (), null);
- this.spinner.get_style_context ().add_class ("raised");
- toolbar_end.insert (this.spinner, 0);
+ spinner = new Gtk.ToolButton (new Gtk.Spinner (), null);
+ spinner.get_style_context ().add_class ("raised");
+ toolbar_end.insert (spinner, 0);
toolbar_end.set_show_arrow (false);
- this.hbox.pack_start (toolbar_end, false, false, 0);
-
- this.notebook.append_page (this.hbox, null);
- this.notebook.page = 0;
- this.notebook.show_tabs = false;
- this.notebook.show_all ();
-
- this.app.state.set_key (null,
- "display",
- this.actor,
- "y",
- AnimationMode.EASE_OUT_QUAD,
- -(float) this.height,
- 0,
- 0); // FIXME: make it dynamic depending on topbar size..
+ hbox.pack_start (toolbar_end, false, false, 0);
+
+ notebook.append_page (hbox, null);
+ notebook.page = 0;
+ notebook.show_tabs = false;
+ notebook.show_all ();
+
+ // FIXME: make it dynamic depending on topbar size..:
+ app.state.set_key (null, "display", actor, "y", AnimationMode.EASE_OUT_QUAD, -(float) height, 0, 0);
}
public override void ui_state_changed () {
switch (ui_state) {
case UIState.COLLECTION:
- this.toolbar_start.hide ();
- this.spinner.hide ();
-
+ toolbar_start.hide ();
+ spinner.hide ();
break;
case UIState.CREDS:
- this.toolbar_start.show ();
- this.spinner.show ();
-
+ toolbar_start.show ();
+ spinner.show ();
break;
case UIState.DISPLAY:
- pin_actor(this.actor);
-
+ pin_actor(actor);
break;
default:
diff --git a/src/util.vala b/src/util.vala
index ee4713d..9cb0c65 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -1,120 +1,100 @@
-/*
- * Copyright (C) 2011 Red Hat, Inc.
- *
- * Authors: Marc-Andrà Lureau <marcandre lureau gmail com>
- * Zeeshan Ali (Khattak) <zeeshanak gnome org>
- *
- * This file is part of GNOME Boxes.
- *
- * GNOME Boxes is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * GNOME Boxes is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
+// This file is part of GNOME Boxes. License: LGPL2
using GLib;
using Gtk;
using Config;
using Xml;
-public string get_pkgdata (string? file_name = null) {
- return Path.build_filename (DATADIR, Config.PACKAGE_TARNAME, file_name);
-}
+namespace Boxes {
+ private string get_pkgdata (string? file_name = null) {
+ return Path.build_filename (DATADIR, Config.PACKAGE_TARNAME, file_name);
+ }
-public string get_style (string? file_name = null) {
- return Path.build_filename (get_pkgdata (), "style", file_name);
-}
+ private string get_style (string? file_name = null) {
+ return Path.build_filename (get_pkgdata (), "style", file_name);
+ }
-public string get_pkgcache (string? file_name = null) {
- var dir = Path.build_filename (Environment.get_user_cache_dir (), Config.PACKAGE_TARNAME);
+ private string get_pkgcache (string? file_name = null) {
+ var dir = Path.build_filename (Environment.get_user_cache_dir (), Config.PACKAGE_TARNAME);
- try {
- var file = GLib.File.new_for_path (dir);
- file.make_directory_with_parents (null);
- } catch (GLib.Error e) {
- if (!(e is IOError.EXISTS))
- warning (e.message);
- }
+ try {
+ var file = GLib.File.new_for_path (dir);
+ file.make_directory_with_parents (null);
+ } catch (GLib.Error e) {
+ if (!(e is IOError.EXISTS))
+ warning (e.message);
+ }
- return Path.build_filename (dir, file_name);
-}
+ return Path.build_filename (dir, file_name);
+ }
-public void tree_view_activate_on_single_click (Gtk.TreeView tree_view, bool should_activate) {
- var id = tree_view.get_data<ulong> ("boxes-tree-view-activate");
+ private void tree_view_activate_on_single_click (Gtk.TreeView tree_view, bool should_activate) {
+ var id = tree_view.get_data<ulong> ("boxes-tree-view-activate");
- if (id != 0 && should_activate == false) {
- tree_view.disconnect (id);
- tree_view.set_data<ulong> ("boxes-tree-view-activate", 0);
- } else {
- id = tree_view.button_press_event.connect ((w, event) => {
- Gtk.TreePath? path;
- unowned Gtk.TreeViewColumn? column;
- int x, y;
+ if (id != 0 && should_activate == false) {
+ tree_view.disconnect (id);
+ tree_view.set_data<ulong> ("boxes-tree-view-activate", 0);
+ } else {
+ id = tree_view.button_press_event.connect ((w, event) => {
+ Gtk.TreePath? path;
+ unowned Gtk.TreeViewColumn? column;
+ int x, y;
- if (event.button == 1 && event.type == Gdk.EventType.BUTTON_PRESS) {
+ if (event.button == 1 && event.type == Gdk.EventType.BUTTON_PRESS) {
tree_view.get_path_at_pos ((int)event.x, (int)event.y, out path, out column, out x, out y);
if (path != null)
tree_view.row_activated (path, column);
- }
+ }
- return false;
- });
- tree_view.set_data<ulong> ("boxes-tree-view-activate", id);
+ return false;
+ });
+ tree_view.set_data<ulong> ("boxes-tree-view-activate", id);
+ }
}
-}
-public async void output_stream_write (OutputStream stream, uint8[] buffer) throws GLib.IOError {
- var length = buffer.length;
- ssize_t i = 0;
+ private async void output_stream_write (OutputStream stream, uint8[] buffer) throws GLib.IOError {
+ var length = buffer.length;
+ ssize_t i = 0;
- while (i < length)
- i += yield stream.write_async (buffer[i:length]);
-}
+ while (i < length)
+ i += yield stream.write_async (buffer[i:length]);
+ }
-public string? extract_xpath (string xmldoc, string xpath, bool required = false) throws Boxes.Error {
- var parser = new ParserCtxt ();
- var doc = parser.read_doc (xmldoc, "doc.xml");
+ private string? extract_xpath (string xmldoc, string xpath, bool required = false) throws Boxes.Error {
+ var parser = new ParserCtxt ();
+ var doc = parser.read_doc (xmldoc, "doc.xml");
- if (doc == null)
- throw new Boxes.Error.INVALID ("Can't parse XML doc");
+ if (doc == null)
+ throw new Boxes.Error.INVALID ("Can't parse XML doc");
- var ctxt = new XPath.Context (doc);
- var obj = ctxt.eval (xpath);
- if (obj == null || obj->stringval == null) {
- if (required)
- throw new Boxes.Error.INVALID ("Failed to extract xpath " + xpath);
- else
- return null;
- }
+ var ctxt = new XPath.Context (doc);
+ var obj = ctxt.eval (xpath);
+ if (obj == null || obj->stringval == null) {
+ if (required)
+ throw new Boxes.Error.INVALID ("Failed to extract xpath " + xpath);
+ else
+ return null;
+ }
- if (obj->type != XPath.ObjectType.STRING)
- throw new Boxes.Error.INVALID ("Failed to extract xpath " + xpath);
+ if (obj->type != XPath.ObjectType.STRING)
+ throw new Boxes.Error.INVALID ("Failed to extract xpath " + xpath);
- return obj->stringval;
-}
+ return obj->stringval;
+ }
-public void actor_add (Clutter.Actor actor, Clutter.Container container) {
- if (actor.get_parent () == (Clutter.Actor) container)
- return;
+ private void actor_add (Clutter.Actor actor, Clutter.Container container) {
+ if (actor.get_parent () == (Clutter.Actor) container)
+ return;
- actor_remove (actor);
- container.add (actor);
-}
+ actor_remove (actor);
+ container.add (actor);
+ }
-public void actor_remove (Clutter.Actor actor) {
- var container = actor.get_parent () as Clutter.Container;
+ private void actor_remove (Clutter.Actor actor) {
+ var container = actor.get_parent () as Clutter.Container;
- if (container == null)
- return;
+ if (container == null)
+ return;
- container.remove (actor);
+ container.remove (actor);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]