[gnome-boxes/wip/ui-files: 2/5] Move Topbar widget setup to .ui files



commit be075b99ec1ff0079b939b7d116172b76c1d060d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Jan 7 18:36:48 2014 +0000

    Move Topbar widget setup to .ui files

 data/gnome-boxes.gresource.xml |    1 +
 data/ui/topbar.ui              |  373 ++++++++++++++++++++++++++++++++++++++++
 po/POTFILES.in                 |    1 +
 src/app.vala                   |    2 +-
 src/properties.vala            |    2 +-
 src/topbar.vala                |  180 ++++++-------------
 src/wizard.vala                |   43 +----
 7 files changed, 438 insertions(+), 164 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 67fdb49..8fc071f 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -6,6 +6,7 @@
     <file>icons/boxes-create.png</file>
     <file>icons/boxes-dark.png</file>
     <file>icons/boxes-gray.png</file>
+    <file preprocess="xml-stripblanks">ui/topbar.ui</file>
     <file preprocess="xml-stripblanks">ui/unattended-setup-box.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard.ui</file>
     <file preprocess="xml-stripblanks">ui/wizard-media-entry.ui</file>
diff --git a/data/ui/topbar.ui b/data/ui/topbar.ui
new file mode 100644
index 0000000..a2bc436
--- /dev/null
+++ b/data/ui/topbar.ui
@@ -0,0 +1,373 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.9 -->
+  <template class="BoxesTopbar" parent="GtkNotebook">
+    <property name="visible">True</property>
+    <property name="show-tabs">False</property>
+
+    <!-- Separate page for each UI state and mode -->
+
+    <!-- Collection -->
+    <child>
+      <object class="GtkBox" id="collection_hbox">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <property name="spacing">0</property>
+
+        <child>
+          <object class="GtkHeaderBar" id="collection_toolbar">
+            <property name="visible">True</property>
+            <property name="show-close-button">True</property>
+            <style>
+              <class name="titlebar"/>
+              <class name="menubar"/>
+            </style>
+
+            <child>
+              <object class="GtkButton" id="new_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="label" translatable="yes">_New</property>
+                <signal name="clicked" handler="on_new_btn_clicked"/>
+                <style>
+                  <class name="text-button"/>
+                </style>
+              </object>
+            </child>
+
+            <child>
+              <object class="GtkButton" id="back_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <signal name="clicked" handler="on_back_btn_clicked"/>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="a11y-button1">
+                    <property name="accessible-name" translatable="yes">Back</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage" id="back_image">
+                    <property name="visible">True</property>
+                  </object>
+                </child>
+              </object>
+            </child>
+
+            <child>
+              <object class="GtkSpinner" id="spinner">
+                <property name="visible">True</property>
+                <property name="hexpand">True</property>
+                <property name="vexpand">True</property>
+                <property name="active">True</property>
+                <property name="margin">6</property>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkToggleButton" id="search_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="a11y-button2">
+                    <property name="accessible-name" translatable="yes">Search</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage" id="search_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">edit-find-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkButton" id="select_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <signal name="clicked" handler="on_select_btn_clicked"/>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="a11y-button3">
+                    <property name="accessible-name" translatable="yes">Select Items</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage" id="select_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">object-select-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+          </object>
+
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="padding">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+
+    <!-- Collection (selection mode) -->
+    <child>
+      <object class="GtkBox" id="selection_hbox">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <property name="spacing">0</property>
+
+        <child>
+          <object class="GtkHeaderBar" id="selection_toolbar">
+            <property name="visible">True</property>
+            <property name="show-close-button">False</property>
+            <style>
+              <class name="selection-mode"/>
+              <class name="titlebar"/>
+              <class name="menubar"/>
+            </style>
+
+            <child type="title">
+              <object class="GtkMenuButton" id="selection_menu_button">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="menu-model">selection-menu</property>
+
+                <style>
+                  <class name="selection-mode"/>
+                  <class name="titlebar"/>
+                  <class name="menubar"/>
+                </style>
+              </object>
+            </child>
+
+            <child>
+              <object class="GtkToggleButton" id="search2_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child internal-child="accessible">
+                  <object class="AtkObject" id="a11y-button4">
+                    <property name="accessible-name" translatable="yes">Search</property>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkImage" id="search2_image">
+                    <property name="visible">True</property>
+                    <property name="icon-name">edit-find-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkButton" id="cancel_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="label" translatable="yes">_Cancel</property>
+                <signal name="clicked" handler="on_cancel_btn_clicked"/>
+                <style>
+                  <class name="text-button"/>
+                </style>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+          </object>
+
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="padding">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+
+    <!-- Wizard -->
+    <child>
+      <object class="GtkBox" id="wizard_hbox">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <property name="spacing">0</property>
+
+        <child>
+          <object class="GtkHeaderBar" id="wizard_toolbar">
+            <property name="visible">True</property>
+            <property name="title" translatable="yes">Create a Box</property>
+            <style>
+              <class name="titlebar"/>
+              <class name="menubar"/>
+            </style>
+
+            <child>
+              <object class="GtkButton" id="wizard_cancel_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="label" translatable="yes">_Cancel</property>
+                <style>
+                  <class name="text-button"/>
+                </style>
+              </object>
+
+              <packing>
+                <property name="pack-type">start</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkButton" id="wizard_back_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="label" translatable="yes">_Back</property>
+                <style>
+                  <class name="text-button"/>
+                </style>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkButton" id="wizard_continue_btn">
+                <property name="visible">True</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="label" translatable="yes">C_ontinue</property>
+                <style>
+                  <class name="text-button"/>
+                  <class name="boxes-continue"/>
+                </style>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+
+            <child>
+              <object class="GtkButton" id="wizard_create_btn">
+                <property name="visible">False</property>
+                <property name="valign">center</property>
+                <property name="use-underline">True</property>
+                <property name="label" translatable="yes">C_reate</property>
+                <style>
+                  <class name="text-button"/>
+                  <class name="boxes-continue"/>
+                </style>
+              </object>
+
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+          </object>
+
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="padding">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+
+    <!-- Properties -->
+    <child>
+      <object class="GtkBox" id="props_hbox">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <property name="spacing">0</property>
+      </object>
+    </child>
+
+    <!-- Display -->
+    <child>
+      <object class="GtkBox" id="display_hbox">
+        <property name="visible">True</property>
+        <property name="orientation">horizontal</property>
+        <property name="spacing">0</property>
+      </object>
+    </child>
+  </template>
+
+  <!-- We need a sizegroup to ensure the spinner is the same size as the buttons so it centers correctly -->
+  <object class="GtkSizeGroup" id="collection_sizegroup">
+    <property name="mode">horizontal</property>
+    <widgets>
+      <widget name="spinner"/>
+      <widget name="select_btn"/>
+    </widgets>
+  </object>
+
+  <object class="GtkSizeGroup" id="wizard_sizegroup">
+    <property name="mode">horizontal</property>
+    <widgets>
+      <widget name="wizard_cancel_btn"/>
+      <widget name="wizard_back_btn"/>
+      <widget name="wizard_continue_btn"/>
+      <widget name="wizard_create_btn"/>
+    </widgets>
+  </object>
+
+  <menu id="selection-menu">
+    <section>
+      <item>
+        <attribute name="action">win.select-all</attribute>
+        <attribute name="label" translatable="yes">Select All</attribute>
+        <attribute name="accel">&lt;Primary&gt;a</attribute>
+      </item>
+      <item>
+        <attribute name="action">win.select-running</attribute>
+        <attribute name="label" translatable="yes">Select Running</attribute>
+      </item>
+      <item>
+        <attribute name="action">win.select-none</attribute>
+        <attribute name="label" translatable="yes">Select None</attribute>
+      </item>
+    </section>
+  </menu>
+
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ce30237..9aa343e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@ data/gnome-boxes.appdata.xml.in
 data/gnome-boxes.desktop.in.in
 [type: gettext/ini]data/gnome-boxes-search-provider.ini.in
 data/org.gnome.boxes.gschema.xml.in
+[type: gettext/glade]data/ui/topbar.ui
 [type: gettext/glade]data/ui/unattended-setup-box.ui
 [type: gettext/glade]data/ui/wizard.ui
 [type: gettext/glade]data/ui/wizard-media-entry.ui
diff --git a/src/app.vala b/src/app.vala
index f3fe83f..93960a2 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -584,7 +584,7 @@ private class Boxes.App: GLib.Object, Boxes.UI {
 
         stage.add_child (vbox_actor);
 
-        window.set_titlebar (topbar.widget);
+        window.set_titlebar (topbar);
 
         searchbar_revealer = new Boxes.Revealer (true);
         searchbar_revealer.resize = true;
diff --git a/src/properties.vala b/src/properties.vala
index 7f4f319..748d942 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -220,7 +220,7 @@ private class Boxes.Properties: GLib.Object, Boxes.UI {
         gtk_actor.y_expand = true;
 
         /* topbar */
-        var hbox = App.app.topbar.notebook.get_nth_page (Boxes.TopbarPage.PROPERTIES) as Gtk.Box;
+        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);
diff --git a/src/topbar.vala b/src/topbar.vala
index 0256025..68f6e4a 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -10,7 +10,8 @@ public enum Boxes.TopbarPage {
     DISPLAY
 }
 
-private class Boxes.Topbar: GLib.Object, Boxes.UI {
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/topbar.ui")]
+private class Boxes.Topbar: Gtk.Notebook, Boxes.UI {
     // FIXME: This is really redundant now that App is using widget property
     // instead but parent Boxes.UI currently requires an actor. Hopefully
     // soon we can move more towards new Gtk classes and Boxes.UI requires
@@ -26,19 +27,36 @@ private class Boxes.Topbar: GLib.Object, Boxes.UI {
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
 
-    public Gtk.Widget widget { get { return notebook; } }
-    public Notebook notebook;
+    [GtkChild]
+    public Gtk.Button wizard_cancel_btn;
+    [GtkChild]
+    public Gtk.Button wizard_back_btn;
+    [GtkChild]
+    public Gtk.Button wizard_continue_btn;
+    [GtkChild]
+    public Gtk.Button wizard_create_btn;
 
+    [GtkChild]
     private Gtk.Spinner spinner;
+    [GtkChild]
     private Gtk.Button search_btn;
+    [GtkChild]
     private Gtk.Button search2_btn;
+    [GtkChild]
     private Gtk.Button select_btn;
-    private Gtk.Button cancel_btn;
+    [GtkChild]
     private Gtk.Button back_btn;
+    [GtkChild]
+    private Gtk.Image back_image;
+    [GtkChild]
     private Gtk.Button new_btn;
+    [GtkChild]
     private Gtk.MenuButton selection_menu_button;
-    private Gtk.HeaderBar selection_toolbar;
+    [GtkChild]
     private Gtk.HeaderBar collection_toolbar;
+    [GtkChild]
+    private Gtk.Box display_hbox;
+
     private Gtk.HeaderBar display_toolbar;
 
     public string? _status;
@@ -62,133 +80,29 @@ private class Boxes.Topbar: GLib.Object, Boxes.UI {
     }
 
     private void setup_topbar () {
-        notebook = new Gtk.Notebook ();
-
-        /* TopbarPage.COLLECTION */
-        var hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
-        notebook.append_page (hbox, null);
-
-        var toolbar = new Gtk.HeaderBar ();
-        toolbar.get_style_context ().add_class ("titlebar");
-        collection_toolbar = toolbar;
-        toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
-        toolbar.show_close_button = true;
-        hbox.pack_start (toolbar, true, true, 0);
-
-        new_btn = new Gtk.Button.with_mnemonic (_("_New"));
-        new_btn.valign = Gtk.Align.CENTER;
-        new_btn.get_style_context ().add_class ("text-button");
-        toolbar.pack_start (new_btn);
-        new_btn.clicked.connect ((button) => { App.app.set_state (UIState.WIZARD); });
-
-        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_btn = new Gtk.Button ();
-        back_btn.set_image (back_image);
-        back_btn.valign = Gtk.Align.CENTER;
-        back_btn.get_style_context ().add_class ("image-button");
-        toolbar.pack_start (back_btn);
-        back_btn.get_accessible ().set_name (_("Back"));
-        back_btn.clicked.connect ((button) => { App.app.set_state (UIState.COLLECTION); });
-
-        // We need a sizegroup to ensure the spinner is the same size
-        // as the buttons so it centers correctly
-        var spinner_sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
-
-        spinner = new Gtk.Spinner ();
-        spinner.start ();
-        spinner.hexpand = true;
-        spinner.vexpand = true;
-        spinner.margin = 6;
-        toolbar.pack_end (spinner);
-        spinner_sizegroup.add_widget (spinner);
-
-        var search_image = new Gtk.Image.from_icon_name ("edit-find-symbolic", Gtk.IconSize.MENU);
-        search_btn = new Gtk.ToggleButton ();
-        search_btn.set_image (search_image);
-        search_btn.valign = Gtk.Align.CENTER;
-        search_btn.get_style_context ().add_class ("image-button");
-        toolbar.pack_end (search_btn);
-        search_btn.get_accessible ().set_name (_("Search"));
+        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);
+
         search_btn.bind_property ("active", App.app.searchbar, "visible", BindingFlags.BIDIRECTIONAL);
+        search2_btn.bind_property ("active", App.app.searchbar, "visible", BindingFlags.BIDIRECTIONAL);
 
-        var select_image = new Gtk.Image.from_icon_name ("object-select-symbolic", Gtk.IconSize.MENU);
-        select_btn = new Gtk.Button ();
-        select_btn.set_image (select_image);
-        select_btn.valign = Gtk.Align.CENTER;
-        select_btn.get_style_context ().add_class ("image-button");
-        toolbar.pack_end (select_btn);
-        select_btn.get_accessible ().set_name (_("Select Items"));
-        spinner_sizegroup.add_widget (select_btn);
-        select_btn.clicked.connect (() => {
-            App.app.selection_mode = true;
-        });
         App.app.notify["selection-mode"].connect (() => {
-            notebook.page = App.app.selection_mode ?
-                TopbarPage.SELECTION : notebook.page = TopbarPage.COLLECTION;
+            page = App.app.selection_mode ?
+                TopbarPage.SELECTION : page = TopbarPage.COLLECTION;
         });
         update_select_btn ();
         App.app.collection.item_added.connect (update_select_btn);
         App.app.collection.item_removed.connect (update_select_btn);
-
-        /* TopbarPage.SELECTION */
-        hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
-        notebook.append_page (hbox, null);
-        selection_toolbar = new Gtk.HeaderBar ();
-        selection_toolbar.get_style_context ().add_class ("selection-mode");
-        selection_toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
-        selection_toolbar.get_style_context ().add_class ("titlebar");
-
-        var menu = new GLib.Menu ();
-        menu.append (_("Select All"), "app.select-all");
-        menu.append (_("Select Running"), "app.select-running");
-        menu.append (_("Select None"), "app.select-none");
-
-        selection_menu_button = new Gtk.MenuButton ();
-        selection_menu_button.valign = Gtk.Align.CENTER;
-        selection_menu_button.set_menu_model (menu);
-        selection_toolbar.set_custom_title (selection_menu_button);
-        hbox.pack_start (selection_toolbar, true, true, 0);
-
         update_selection_label ();
 
-        search_image = new Gtk.Image.from_icon_name ("edit-find-symbolic", Gtk.IconSize.MENU);
-        search2_btn = new Gtk.ToggleButton ();
-        search2_btn.set_image (search_image);
-        search2_btn.valign = Gtk.Align.CENTER;
-        search2_btn.get_style_context ().add_class ("image-button");
-        selection_toolbar.pack_end (search2_btn);
-        search2_btn.bind_property ("active", App.app.searchbar, "visible", BindingFlags.BIDIRECTIONAL);
-
-        cancel_btn = new Gtk.Button.with_mnemonic (_("_Cancel"));
-        cancel_btn.valign = Gtk.Align.CENTER;
-        cancel_btn.get_style_context ().add_class ("text-button");
-        selection_toolbar.pack_end (cancel_btn);
-        cancel_btn.clicked.connect (() => {
-            App.app.selection_mode = false;
-        });
-
-        /* TopbarPage.WIZARD */
-        hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
-        notebook.append_page (hbox, null);
-
-        /* TopbarPage.PROPERTIES */
-        hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
-        notebook.append_page (hbox, null);
-
-        /* TopbarPage.DISPLAY */
-        hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
         display_toolbar = App.app.display_page.title_toolbar;
-        hbox.pack_start (display_toolbar, true, true, 0);
-        notebook.append_page (hbox, null);
+        display_hbox.pack_start (display_toolbar, true, true, 0);
+        display_toolbar.show_all ();
 
         update_search_btn ();
         App.app.collection.item_added.connect (update_search_btn);
         App.app.collection.item_removed.connect (update_search_btn);
-
-        notebook.show_tabs = false;
-        notebook.show_all ();
     }
 
     private void update_search_btn () {
@@ -214,7 +128,7 @@ private class Boxes.Topbar: GLib.Object, Boxes.UI {
     private void ui_state_changed () {
         switch (ui_state) {
         case UIState.COLLECTION:
-            notebook.page = TopbarPage.COLLECTION;
+            page = TopbarPage.COLLECTION;
             back_btn.hide ();
             spinner.hide ();
             select_btn.show ();
@@ -223,7 +137,7 @@ private class Boxes.Topbar: GLib.Object, Boxes.UI {
             break;
 
         case UIState.CREDS:
-            notebook.page = TopbarPage.COLLECTION;
+            page = TopbarPage.COLLECTION;
             new_btn.hide ();
             back_btn.show ();
             spinner.show ();
@@ -232,20 +146,40 @@ private class Boxes.Topbar: GLib.Object, Boxes.UI {
             break;
 
         case UIState.DISPLAY:
-            notebook.page = TopbarPage.DISPLAY;
+            page = TopbarPage.DISPLAY;
             spinner.hide ();
             break;
 
         case UIState.PROPERTIES:
-            notebook.page = TopbarPage.PROPERTIES;
+            page = TopbarPage.PROPERTIES;
             break;
 
         case UIState.WIZARD:
-            notebook.page = TopbarPage.WIZARD;
+            page = TopbarPage.WIZARD;
             break;
 
         default:
             break;
         }
     }
+
+    [GtkCallback]
+    private void on_new_btn_clicked () {
+        App.app.set_state (UIState.WIZARD);
+    }
+
+    [GtkCallback]
+    private void on_back_btn_clicked () {
+        App.app.set_state (UIState.COLLECTION);
+    }
+
+    [GtkCallback]
+    private void on_select_btn_clicked () {
+        App.app.selection_mode = true;
+    }
+
+    [GtkCallback]
+    private void on_cancel_btn_clicked () {
+        App.app.selection_mode = false;
+    }
 }
diff --git a/src/wizard.vala b/src/wizard.vala
index d31cf08..ca870bc 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -27,7 +27,6 @@ private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
     private Gtk.Button next_button;
     private Gtk.Button continue_button;
     private Gtk.Button create_button;
-    private Gtk.SizeGroup toolbar_sizegroup;
     private CollectionSource? source;
 
     [GtkChild]
@@ -565,53 +564,22 @@ private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
         gtk_actor.x_expand = true;
         gtk_actor.y_expand = true;
 
-        /* topbar */
-        var hbox = App.app.topbar.notebook.get_nth_page (Boxes.TopbarPage.WIZARD) as Gtk.Box;
-
-        var toolbar = new Gtk.HeaderBar ();
-        toolbar.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUBAR);
-        toolbar.get_style_context ().add_class ("titlebar");
-        hbox.pack_start (toolbar, true, true, 0);
-
-        toolbar.title = _("Create a Box");
-
-        toolbar_sizegroup = new Gtk.SizeGroup (Gtk.SizeGroupMode.HORIZONTAL);
-        cancel_button = new Gtk.Button.with_mnemonic (_("_Cancel"));
-        cancel_button.valign = Gtk.Align.CENTER;
-        cancel_button.get_style_context ().add_class ("text-button");
-        toolbar.pack_start (cancel_button);
+        cancel_button = App.app.topbar.wizard_cancel_btn;
         cancel_button.clicked.connect (() => {
             destroy_machine ();
             vm_creator = null;
             wizard_source.page = SourcePage.MAIN;
             App.app.set_state (UIState.COLLECTION);
         });
-        toolbar_sizegroup.add_widget (cancel_button);
-
-        back_button = new Gtk.Button.with_mnemonic (_("_Back"));
-        back_button.valign = Gtk.Align.CENTER;
-        back_button.get_style_context ().add_class ("text-button");
-        toolbar.pack_end (back_button);
+        back_button = App.app.topbar.wizard_back_btn;
         back_button.clicked.connect (() => {
             page = page - 1;
         });
-        toolbar_sizegroup.add_widget (back_button);
-
-        continue_button = new Gtk.Button.with_mnemonic (_("C_ontinue"));
-        continue_button.valign = Gtk.Align.CENTER;
-        continue_button.get_style_context ().add_class ("text-button");
-        continue_button.get_style_context ().add_class ("boxes-continue");
-        toolbar.pack_end (continue_button);
+        continue_button = App.app.topbar.wizard_continue_btn;
         continue_button.clicked.connect (() => {
             page = page + 1;
         });
-        toolbar_sizegroup.add_widget (continue_button);
-
-        create_button = new Gtk.Button.with_mnemonic (_("C_reate"));
-        create_button.valign = Gtk.Align.CENTER;
-        create_button.get_style_context ().add_class ("text-button");
-        create_button.get_style_context ().add_class ("boxes-continue");
-        toolbar.pack_end (create_button);
+        create_button = App.app.topbar.wizard_create_btn;
         create_button.clicked.connect (() => {
             create.begin ((obj, result) => {
             if (create.end (result))
@@ -620,9 +588,6 @@ private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
                 App.app.notificationbar.display_error (_("Box creation failed"));
             });
         });
-        toolbar_sizegroup.add_widget (create_button);
-
-        hbox.show_all ();
     }
 
     public void open_with_uri (string uri, bool skip_review_for_live = true) {


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