[gnome-boxes] Put two classes in seperate modules



commit cc43b73ba07816a826d170720a4c43ad0b43b839
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 25 01:36:06 2011 +0300

    Put two classes in seperate modules
    
    Put UI and DisplayPage classes into separate modules/files.

 src/Makefile.am       |    2 +
 src/app.vala          |  160 -------------------------------------------------
 src/display-page.vala |  135 +++++++++++++++++++++++++++++++++++++++++
 src/ui.vala           |   30 +++++++++
 4 files changed, 167 insertions(+), 160 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index cd3cca2..1211a12 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,6 +25,8 @@ bin_PROGRAMS = gnome-boxes
 
 gnome_boxes_SOURCES =				\
 	app.vala				\
+	ui.vala				\
+	display-page.vala				\
 	collection-view.vala			\
 	collection.vala				\
 	display.vala				\
diff --git a/src/app.vala b/src/app.vala
index f00434f..74528b2 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -4,16 +4,6 @@ using Gtk;
 using Gdk;
 using GtkClutter;
 using Clutter;
-using GVir;
-
-private enum Boxes.UIState {
-    NONE,
-    COLLECTION,
-    CREDS,
-    DISPLAY,
-    SETTINGS,
-    WIZARD
-}
 
 private errordomain Boxes.Error {
     INVALID
@@ -232,153 +222,3 @@ private class Boxes.App: Boxes.UI {
     }
 }
 
-private abstract class Boxes.UI: GLib.Object {
-    public abstract Clutter.Actor actor { get; }
-
-    private UIState _ui_state;
-    [CCode (notify = false)]
-    public UIState ui_state {
-        get { return _ui_state; }
-        set {
-            if (_ui_state != value) {
-                _ui_state = value;
-                ui_state_changed ();
-                notify_property ("ui-state");
-            }
-        }
-    }
-
-    public abstract void ui_state_changed ();
-}
-
-private class Boxes.DisplayPage: GLib.Object {
-    public Gtk.Widget widget { get { return overlay; } }
-    private Gtk.Overlay overlay;
-    private Boxes.App app;
-    private Gtk.EventBox event_box;
-    private Gtk.Toolbar toolbar;
-    private uint toolbar_show_id;
-    private uint toolbar_hide_id;
-    private ulong display_id;
-    private ulong cursor_id;
-    private Gtk.Label title;
-
-    public DisplayPage (Boxes.App app) {
-        this.app = app;
-
-        event_box = new Gtk.EventBox ();
-        event_box.set_events (Gdk.EventMask.POINTER_MOTION_MASK);
-        event_box.above_child = true;
-        event_box.event.connect ((event) => {
-            if (event.type == Gdk.EventType.MOTION_NOTIFY) {
-                var y = event.motion.y;
-
-                if (y <= 20 && toolbar_show_id == 0) {
-                    toolbar_event_stop ();
-                    toolbar_show_id = Timeout.add (app.duration, () => {
-                        toolbar.show_all ();
-                        toolbar_show_id = 0;
-                        return false;
-                    });
-                } else if (y > 5)
-                    toolbar_event_stop (true, false);
-            }
-
-            if (event_box.get_child () != null)
-                event_box.get_child ().event (event);
-            return false;
-        });
-        overlay = new Gtk.Overlay ();
-        overlay.margin = 0;
-        overlay.add (event_box);
-
-        toolbar = new Gtk.Toolbar ();
-        toolbar.icon_size = Gtk.IconSize.MENU;
-        toolbar.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) => { app.ui_state = UIState.COLLECTION; });
-        toolbar.insert (back, 0);
-        toolbar.set_show_arrow (false);
-
-        title = new Gtk.Label ("Display");
-        var item = new Gtk.ToolItem ();
-        item.add (title);
-        item.set_expand (true);
-        toolbar.insert (item, -1);
-
-        toolbar.set_halign (Gtk.Align.FILL);
-        toolbar.set_valign (Gtk.Align.START);
-
-        overlay.add_overlay (toolbar);
-        overlay.show_all ();
-    }
-
-    ~DisplayPage () {
-        toolbar_event_stop ();
-    }
-
-    private void toolbar_event_stop (bool show = true, bool hide = true) {
-        if (show) {
-            if (toolbar_show_id != 0)
-                GLib.Source.remove (toolbar_show_id);
-            toolbar_show_id = 0;
-        }
-
-        if (hide) {
-            if (toolbar_hide_id != 0)
-                GLib.Source.remove (toolbar_hide_id);
-            toolbar_hide_id = 0;
-        }
-    }
-
-    public void show_display (Boxes.Machine machine, Gtk.Widget display) {
-        remove_display ();
-        toolbar.hide ();
-        title.set_text (machine.name);
-        event_box.add (display);
-        event_box.show_all ();
-
-        display_id = display.event.connect ((event) => {
-            switch (event.type) {
-            case Gdk.EventType.LEAVE_NOTIFY:
-                toolbar_event_stop ();
-                break;
-            case Gdk.EventType.ENTER_NOTIFY:
-                toolbar_event_stop ();
-                toolbar_hide_id = Timeout.add (app.duration, () => {
-                    toolbar.hide ();
-                    toolbar_hide_id = 0;
-                    return false;
-                });
-                break;
-            }
-            return false;
-        });
-
-        cursor_id = display.get_window ().notify["cursor"].connect (() => {
-            event_box.get_window ().set_cursor (display.get_window ().cursor);
-        });
-
-        app.notebook.page = Boxes.AppPage.DISPLAY;
-    }
-
-    public void remove_display () {
-        var display = event_box.get_child ();
-
-        if (display_id != 0) {
-            display.disconnect (display_id);
-            display_id = 0;
-        }
-        if (cursor_id != 0) {
-            display.get_window ().disconnect (cursor_id);
-            cursor_id = 0;
-        }
-        if (display != null)
-            event_box.remove (display);
-
-    }
-
-}
diff --git a/src/display-page.vala b/src/display-page.vala
new file mode 100644
index 0000000..73e7676
--- /dev/null
+++ b/src/display-page.vala
@@ -0,0 +1,135 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+using Gdk;
+
+private class Boxes.DisplayPage: GLib.Object {
+    public Widget widget { get { return overlay; } }
+    private Overlay overlay;
+    private Boxes.App app;
+    private EventBox event_box;
+    private Toolbar toolbar;
+    private uint toolbar_show_id;
+    private uint toolbar_hide_id;
+    private ulong display_id;
+    private ulong cursor_id;
+    private Label title;
+
+    public DisplayPage (Boxes.App app) {
+        this.app = app;
+
+        event_box = new EventBox ();
+        event_box.set_events (EventMask.POINTER_MOTION_MASK);
+        event_box.above_child = true;
+        event_box.event.connect ((event) => {
+            if (event.type == EventType.MOTION_NOTIFY) {
+                var y = event.motion.y;
+
+                if (y <= 20 && toolbar_show_id == 0) {
+                    toolbar_event_stop ();
+                    toolbar_show_id = Timeout.add (app.duration, () => {
+                        toolbar.show_all ();
+                        toolbar_show_id = 0;
+                        return false;
+                    });
+                } else if (y > 5)
+                    toolbar_event_stop (true, false);
+            }
+
+            if (event_box.get_child () != null)
+                event_box.get_child ().event (event);
+            return false;
+        });
+        overlay = new Overlay ();
+        overlay.margin = 0;
+        overlay.add (event_box);
+
+        toolbar = new Toolbar ();
+        toolbar.icon_size = IconSize.MENU;
+        toolbar.get_style_context ().add_class (STYLE_CLASS_MENUBAR);
+
+        var back = new ToolButton (null, null);
+        back.icon_name =  "go-previous-symbolic";
+        back.get_style_context ().add_class ("raised");
+        back.clicked.connect ((button) => { app.ui_state = UIState.COLLECTION; });
+        toolbar.insert (back, 0);
+        toolbar.set_show_arrow (false);
+
+        title = new Label ("Display");
+        var item = new ToolItem ();
+        item.add (title);
+        item.set_expand (true);
+        toolbar.insert (item, -1);
+
+        toolbar.set_halign (Align.FILL);
+        toolbar.set_valign (Align.START);
+
+        overlay.add_overlay (toolbar);
+        overlay.show_all ();
+    }
+
+    ~DisplayPage () {
+        toolbar_event_stop ();
+    }
+
+    private void toolbar_event_stop (bool show = true, bool hide = true) {
+        if (show) {
+            if (toolbar_show_id != 0)
+                GLib.Source.remove (toolbar_show_id);
+            toolbar_show_id = 0;
+        }
+
+        if (hide) {
+            if (toolbar_hide_id != 0)
+                GLib.Source.remove (toolbar_hide_id);
+            toolbar_hide_id = 0;
+        }
+    }
+
+    public void show_display (Boxes.Machine machine, Widget display) {
+        remove_display ();
+        toolbar.hide ();
+        title.set_text (machine.name);
+        event_box.add (display);
+        event_box.show_all ();
+
+        display_id = display.event.connect ((event) => {
+            switch (event.type) {
+            case EventType.LEAVE_NOTIFY:
+                toolbar_event_stop ();
+                break;
+            case EventType.ENTER_NOTIFY:
+                toolbar_event_stop ();
+                toolbar_hide_id = Timeout.add (app.duration, () => {
+                    toolbar.hide ();
+                    toolbar_hide_id = 0;
+                    return false;
+                });
+                break;
+            }
+            return false;
+        });
+
+        cursor_id = display.get_window ().notify["cursor"].connect (() => {
+            event_box.get_window ().set_cursor (display.get_window ().cursor);
+        });
+
+        app.notebook.page = Boxes.AppPage.DISPLAY;
+    }
+
+    public void remove_display () {
+        var display = event_box.get_child ();
+
+        if (display_id != 0) {
+            display.disconnect (display_id);
+            display_id = 0;
+        }
+        if (cursor_id != 0) {
+            display.get_window ().disconnect (cursor_id);
+            cursor_id = 0;
+        }
+        if (display != null)
+            event_box.remove (display);
+
+    }
+
+}
diff --git a/src/ui.vala b/src/ui.vala
new file mode 100644
index 0000000..95a296f
--- /dev/null
+++ b/src/ui.vala
@@ -0,0 +1,30 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+
+private enum Boxes.UIState {
+    NONE,
+    COLLECTION,
+    CREDS,
+    DISPLAY,
+    SETTINGS,
+    WIZARD
+}
+
+private abstract class Boxes.UI: GLib.Object {
+    public abstract Clutter.Actor actor { get; }
+
+    private UIState _ui_state;
+    [CCode (notify = false)]
+    public UIState ui_state {
+        get { return _ui_state; }
+        set {
+            if (_ui_state != value) {
+                _ui_state = value;
+                ui_state_changed ();
+                notify_property ("ui-state");
+            }
+        }
+    }
+
+    public abstract void ui_state_changed ();
+}
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]