[gnome-boxes] Move properties topbar setup to topbar class/UI file



commit d0272efd8b5e535ad02277fb4970c7e209e7d81d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Feb 1 17:17:12 2014 +0100

    Move properties topbar setup to topbar class/UI file

 data/ui/topbar.ui   |   32 +++++++++++++++++++++++++++++---
 src/properties.vala |   31 -------------------------------
 src/topbar.vala     |   23 +++++++++++++++++++++++
 3 files changed, 52 insertions(+), 34 deletions(-)
---
diff --git a/data/ui/topbar.ui b/data/ui/topbar.ui
index 558317a..c156e37 100644
--- a/data/ui/topbar.ui
+++ b/data/ui/topbar.ui
@@ -316,10 +316,36 @@
 
     <!-- Properties -->
     <child>
-      <object class="GtkBox" id="props_hbox">
+      <object class="GtkHeaderBar" id="props_toolbar">
         <property name="visible">True</property>
-        <property name="orientation">horizontal</property>
-        <property name="spacing">0</property>
+        <property name="show-close-button">True</property>
+        <style>
+          <class name="titlebar"/>
+          <class name="menubar"/>
+        </style>
+
+        <child>
+          <object class="GtkButton" id="props_back_btn">
+            <property name="visible">True</property>
+            <property name="valign">center</property>
+            <signal name="clicked" handler="on_props_back_btn_clicked"/>
+            <style>
+              <class name="image-button"/>
+            </style>
+
+            <child internal-child="accessible">
+              <object class="AtkObject" id="a11y-button5">
+                <property name="accessible-name" translatable="yes">Back</property>
+              </object>
+            </child>
+
+            <child>
+              <object class="GtkImage" id="props_back_image">
+                <property name="visible">True</property>
+              </object>
+            </child>
+          </object>
+        </child>
       </object>
     </child>
 
diff --git a/src/properties.vala b/src/properties.vala
index 0043cfc..bd254e0 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -15,23 +15,13 @@ private class Boxes.Properties: GLib.Object, Boxes.UI {
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
 
-    public string title {
-        set {
-            // Translators: The %s will be replaced with the name of the VM
-            toolbar.title = _("%s - Properties").printf (App.app.current_item.name);
-        }
-    }
-
     public Gtk.Widget screenshot_placeholder;
     private GtkClutter.Actor gtk_actor;
     private Gtk.Notebook notebook;
-    private Gtk.Button back;
-    private Gtk.HeaderBar toolbar;
     private Gtk.ListStore listmodel;
     private Gtk.TreeModelFilter model_filter;
     private Gtk.TreeView tree_view;
     private Gtk.Button shutdown_button;
-    private GLib.Binding toolbar_label_bind;
     private MiniGraph cpu;
     private MiniGraph io;
     private MiniGraph net;
@@ -219,26 +209,6 @@ private class Boxes.Properties: GLib.Object, Boxes.UI {
         gtk_actor.x_expand = true;
         gtk_actor.y_expand = true;
 
-        /* topbar */
-        var hbox = App.app.topbar.get_nth_page (Boxes.TopbarPage.PROPERTIES) as Gtk.Box;
-
-        toolbar = new Gtk.HeaderBar ();
-        toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
-        toolbar.get_style_context ().add_class ("titlebar");
-        toolbar.show_close_button = true;
-        hbox.pack_start (toolbar, true, true, 0);
-        var back_icon = (toolbar.get_direction () == Gtk.TextDirection.RTL)? "go-previous-rtl-symbolic" :
-                                                                             "go-previous-symbolic";
-        var back_image = new Gtk.Image.from_icon_name (back_icon, Gtk.IconSize.MENU);
-        back = new Gtk.Button ();
-        back.set_image (back_image);
-        back.valign = Gtk.Align.CENTER;
-        back.get_style_context ().add_class ("image-button");
-        toolbar.pack_start (back);
-        back.clicked.connect ((button) => { App.app.set_state (App.app.previous_ui_state); });
-
-        hbox.show_all ();
-
         /* sidebar */
         var vbox = App.app.sidebar.get_nth_page (Boxes.SidebarPage.PROPERTIES) as Gtk.Box;
 
@@ -333,7 +303,6 @@ private class Boxes.Properties: GLib.Object, Boxes.UI {
             }
 
             populate ();
-            toolbar_label_bind = App.app.current_item.bind_property ("name", this, "title", 
BindingFlags.SYNC_CREATE);
         } else if (previous_ui_state == UIState.PROPERTIES) {
             for (var i = 0; i < PropertiesPage.LAST; i++) {
                 var page = notebook.get_data<PageWidget> (@"boxes-property-$i");
diff --git a/src/topbar.vala b/src/topbar.vala
index 855bf35..d397a86 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -57,6 +57,13 @@ private class Boxes.Topbar: Gtk.Notebook, Boxes.UI {
     [GtkChild]
     private DisplayToolbar display_toolbar;
 
+    [GtkChild]
+    private Gtk.HeaderBar props_toolbar;
+    [GtkChild]
+    private Gtk.Image props_back_image;
+
+    private GLib.Binding props_name_bind;
+
     public string? _status;
     public string? status {
         get { return _status; }
@@ -67,6 +74,13 @@ private class Boxes.Topbar: Gtk.Notebook, Boxes.UI {
         }
     }
 
+    public string properties_title {
+        set {
+            // Translators: The %s will be replaced with the name of the VM
+            props_toolbar.title = _("%s - Properties").printf (App.app.current_item.name);
+        }
+    }
+
     public Topbar () {
         notify["ui-state"].connect (ui_state_changed);
 
@@ -81,6 +95,7 @@ private class Boxes.Topbar: Gtk.Notebook, Boxes.UI {
         var back_icon = (get_direction () == Gtk.TextDirection.RTL)? "go-previous-rtl-symbolic" :
                                                                      "go-previous-symbolic";
         back_image.set_from_icon_name (back_icon, Gtk.IconSize.MENU);
+        props_back_image.set_from_icon_name (back_icon, Gtk.IconSize.MENU);
 
         search_btn.bind_property ("active", App.app.searchbar, "search-mode-enabled", 
BindingFlags.BIDIRECTIONAL);
         search2_btn.bind_property ("active", App.app.searchbar, "search-mode-enabled", 
BindingFlags.BIDIRECTIONAL);
@@ -150,6 +165,9 @@ private class Boxes.Topbar: Gtk.Notebook, Boxes.UI {
 
         case UIState.PROPERTIES:
             page = TopbarPage.PROPERTIES;
+            props_name_bind = App.app.current_item.bind_property ("name",
+                                                                  this, "properties-title",
+                                                                  BindingFlags.SYNC_CREATE);
             break;
 
         case UIState.WIZARD:
@@ -180,4 +198,9 @@ private class Boxes.Topbar: Gtk.Notebook, Boxes.UI {
     private void on_cancel_btn_clicked () {
         App.app.selection_mode = false;
     }
+
+    [GtkCallback]
+    private void on_props_back_btn_clicked () {
+        App.app.set_state (App.app.previous_ui_state);
+    }
 }


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