[gnome-boxes] Move DisplayToolbar into seperate file



commit c517c6dc2537d36c68f81ff6c91d1f3505efc54f
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jan 8 14:57:02 2014 +0000

    Move DisplayToolbar into seperate file
    
    Its not private to DisplayPage class anymore.

 src/Makefile.am          |    1 +
 src/display-page.vala    |  131 ---------------------------------------------
 src/display-toolbar.vala |  133 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+), 131 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 8a402df..239b86b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -95,6 +95,7 @@ gnome_boxes_SOURCES =                         \
        collection-view.vala                    \
        collection.vala                         \
        display-page.vala                       \
+       display-toolbar.vala                    \
        display.vala                            \
        editable-entry.vala                     \
        i-properties-provider.vala              \
diff --git a/src/display-page.vala b/src/display-page.vala
index d5693df..3fef46c 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -2,137 +2,6 @@
 using Gtk;
 using Gdk;
 
-[GtkTemplate (ui = "/org/gnome/Boxes/ui/display-toolbar.ui")]
-private class Boxes.DisplayToolbar: Gtk.HeaderBar {
-    public bool overlay { get; construct; }
-    public bool handle_drag { get; construct; } // Handle drag events to (un)fulscreen the main window
-
-    [GtkChild]
-    private Gtk.Image back_image;
-    [GtkChild]
-    private Gtk.Image fullscreen_image;
-    [GtkChild]
-    private Gtk.Button back;
-    [GtkChild]
-    private Gtk.Button fullscreen;
-    [GtkChild]
-    private Gtk.Button props;
-
-    public DisplayToolbar (bool overlay, bool handle_drag) {
-        Object (overlay: overlay,
-                handle_drag: handle_drag);
-    }
-
-    construct {
-        add_events (Gdk.EventMask.POINTER_MOTION_MASK |
-                    Gdk.EventMask.BUTTON_PRESS_MASK |
-                    Gdk.EventMask.BUTTON_RELEASE_MASK);
-
-        if (overlay) {
-            get_style_context ().add_class ("toolbar");
-            get_style_context ().add_class ("osd");
-        } else {
-            get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
-            show_close_button = true;
-        }
-
-        back_image.icon_name = (get_direction () == Gtk.TextDirection.RTL)? "go-previous-rtl-symbolic" :
-                                                                            "go-previous-symbolic";
-        if (!overlay) {
-            back.get_style_context ().add_class ("raised");
-            fullscreen.get_style_context ().add_class ("raised");
-            props.get_style_context ().add_class ("raised");
-        }
-
-        App.app.notify["fullscreen"].connect_after ( () => {
-            if (App.app.fullscreen)
-                fullscreen_image.icon_name = "view-restore-symbolic";
-            else
-                fullscreen_image.icon_name = "view-fullscreen-symbolic";
-        });
-    }
-
-    private bool button_down;
-    private int button_down_x;
-    private int button_down_y;
-    private uint button_down_button;
-
-    public override bool button_press_event (Gdk.EventButton event) {
-        var res = base.button_press_event (event);
-        if (!handle_drag)
-            return res;
-
-        // With the current GdkEvent bindings this is the only way to
-        // upcast a GdkEventButton to a GdkEvent (which we need for
-        // the triggerts_context_menu() method call.
-        // TODO: Fix this when vala bindings are corrected
-        Gdk.Event *base_event = (Gdk.Event *)(&event);
-
-        if (!res && !base_event->triggers_context_menu ()) {
-            button_down = true;
-            button_down_button = event.button;
-            button_down_x = (int) event.x;
-            button_down_y = (int) event.y;
-        }
-        return res;
-    }
-
-    public override bool button_release_event (Gdk.EventButton event) {
-        button_down = false;
-        return base.button_press_event (event);
-    }
-
-    public override bool motion_notify_event (Gdk.EventMotion event) {
-        if (!handle_drag)
-            return base.motion_notify_event (event);
-
-        if (button_down) {
-            double dx = event.x - button_down_x;
-            double dy = event.y - button_down_y;
-
-            // Break out when the dragged distance is 40 pixels
-            if (dx * dx + dy * dy > 40 * 40) {
-                button_down = false;
-                App.app.fullscreen = false;
-
-                var window = get_toplevel () as Gtk.Window;
-                int old_width;
-                window.get_size (out old_width, null);
-
-                ulong id = 0;
-                id = App.app.notify["fullscreen"].connect ( () => {
-                    int root_x, root_y, width;
-                    window.get_position (out root_x, out root_y);
-                    window.get_window ().get_geometry (null, null, out width, null);
-                    window.begin_move_drag ((int) button_down_button,
-                                            root_x + (int) ((button_down_x / (double) old_width) * width),
-                                            root_y + button_down_y,
-                                            event.time);
-                    App.app.disconnect (id);
-                } );
-            }
-        }
-        if (base.motion_notify_event != null)
-            return base.motion_notify_event (event);
-        return false;
-    }
-
-    [GtkCallback]
-    private void on_back_clicked () {
-        App.app.set_state (UIState.COLLECTION);
-    }
-
-    [GtkCallback]
-    private void on_fullscreen_clicked () {
-        App.app.fullscreen = !App.app.fullscreen;
-    }
-
-    [GtkCallback]
-    private void on_props_clicked () {
-        App.app.set_state (UIState.PROPERTIES);
-    }
-}
-
 private class Boxes.DisplayPage: GLib.Object {
     public Widget widget { get { return box; } }
 
diff --git a/src/display-toolbar.vala b/src/display-toolbar.vala
new file mode 100644
index 0000000..6b74875
--- /dev/null
+++ b/src/display-toolbar.vala
@@ -0,0 +1,133 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/display-toolbar.ui")]
+private class Boxes.DisplayToolbar: Gtk.HeaderBar {
+    public bool overlay { get; construct; }
+    public bool handle_drag { get; construct; } // Handle drag events to (un)fulscreen the main window
+
+    [GtkChild]
+    private Gtk.Image back_image;
+    [GtkChild]
+    private Gtk.Image fullscreen_image;
+    [GtkChild]
+    private Gtk.Button back;
+    [GtkChild]
+    private Gtk.Button fullscreen;
+    [GtkChild]
+    private Gtk.Button props;
+
+    public DisplayToolbar (bool overlay, bool handle_drag) {
+        Object (overlay: overlay,
+                handle_drag: handle_drag);
+    }
+
+    construct {
+        add_events (Gdk.EventMask.POINTER_MOTION_MASK |
+                    Gdk.EventMask.BUTTON_PRESS_MASK |
+                    Gdk.EventMask.BUTTON_RELEASE_MASK);
+
+        if (overlay) {
+            get_style_context ().add_class ("toolbar");
+            get_style_context ().add_class ("osd");
+        } else {
+            get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
+            show_close_button = true;
+        }
+
+        back_image.icon_name = (get_direction () == Gtk.TextDirection.RTL)? "go-previous-rtl-symbolic" :
+                                                                            "go-previous-symbolic";
+        if (!overlay) {
+            back.get_style_context ().add_class ("raised");
+            fullscreen.get_style_context ().add_class ("raised");
+            props.get_style_context ().add_class ("raised");
+        }
+
+        App.app.notify["fullscreen"].connect_after ( () => {
+            if (App.app.fullscreen)
+                fullscreen_image.icon_name = "view-restore-symbolic";
+            else
+                fullscreen_image.icon_name = "view-fullscreen-symbolic";
+        });
+    }
+
+    private bool button_down;
+    private int button_down_x;
+    private int button_down_y;
+    private uint button_down_button;
+
+    public override bool button_press_event (Gdk.EventButton event) {
+        var res = base.button_press_event (event);
+        if (!handle_drag)
+            return res;
+
+        // With the current GdkEvent bindings this is the only way to
+        // upcast a GdkEventButton to a GdkEvent (which we need for
+        // the triggerts_context_menu() method call.
+        // TODO: Fix this when vala bindings are corrected
+        Gdk.Event *base_event = (Gdk.Event *)(&event);
+
+        if (!res && !base_event->triggers_context_menu ()) {
+            button_down = true;
+            button_down_button = event.button;
+            button_down_x = (int) event.x;
+            button_down_y = (int) event.y;
+        }
+        return res;
+    }
+
+    public override bool button_release_event (Gdk.EventButton event) {
+        button_down = false;
+        return base.button_press_event (event);
+    }
+
+    public override bool motion_notify_event (Gdk.EventMotion event) {
+        if (!handle_drag)
+            return base.motion_notify_event (event);
+
+        if (button_down) {
+            double dx = event.x - button_down_x;
+            double dy = event.y - button_down_y;
+
+            // Break out when the dragged distance is 40 pixels
+            if (dx * dx + dy * dy > 40 * 40) {
+                button_down = false;
+                App.app.fullscreen = false;
+
+                var window = get_toplevel () as Gtk.Window;
+                int old_width;
+                window.get_size (out old_width, null);
+
+                ulong id = 0;
+                id = App.app.notify["fullscreen"].connect ( () => {
+                    int root_x, root_y, width;
+                    window.get_position (out root_x, out root_y);
+                    window.get_window ().get_geometry (null, null, out width, null);
+                    window.begin_move_drag ((int) button_down_button,
+                                            root_x + (int) ((button_down_x / (double) old_width) * width),
+                                            root_y + button_down_y,
+                                            event.time);
+                    App.app.disconnect (id);
+                } );
+            }
+        }
+        if (base.motion_notify_event != null)
+            return base.motion_notify_event (event);
+        return false;
+    }
+
+    [GtkCallback]
+    private void on_back_clicked () {
+        App.app.set_state (UIState.COLLECTION);
+    }
+
+    [GtkCallback]
+    private void on_fullscreen_clicked () {
+        App.app.fullscreen = !App.app.fullscreen;
+    }
+
+    [GtkCallback]
+    private void on_props_clicked () {
+        App.app.set_state (UIState.PROPERTIES);
+    }
+}


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