[gnome-boxes] topbar: Split out wizard toolbar
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] topbar: Split out wizard toolbar
- Date: Fri, 6 Jun 2014 12:29:57 +0000 (UTC)
commit e75349f948cbe4ba68f25a2065ebb3aaf68efefe
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun Mar 16 13:53:02 2014 +0100
topbar: Split out wizard toolbar
Put wizard toolbar code and UI definition into a seperate class and
template, respectively.
https://bugzilla.gnome.org/show_bug.cgi?id=726252
data/gnome-boxes.gresource.xml | 1 +
data/ui/topbar.ui | 97 +---------------------------------------
data/ui/wizard-toolbar.ui | 98 ++++++++++++++++++++++++++++++++++++++++
src/Makefile.am | 1 +
src/topbar.vala | 19 ++------
src/wizard-toolbar.vala | 24 ++++++++++
src/wizard.vala | 8 ++--
7 files changed, 134 insertions(+), 114 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index e29afe7..08aa9ee 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -27,5 +27,6 @@
<file preprocess="xml-stripblanks">ui/wizard-scrolled.ui</file>
<file preprocess="xml-stripblanks">ui/wizard-source.ui</file>
<file preprocess="xml-stripblanks">ui/wizard-summary.ui</file>
+ <file preprocess="xml-stripblanks">ui/wizard-toolbar.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/topbar.ui b/data/ui/topbar.ui
index 5770a9e..7b70cff 100644
--- a/data/ui/topbar.ui
+++ b/data/ui/topbar.ui
@@ -30,93 +30,8 @@
<!-- Wizard -->
<child>
- <object class="GtkBox" id="wizard_hbox">
+ <object class="BoxesWizardToolbar" id="wizard_toolbar">
<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_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>
-
- <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_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>
- </object>
-
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="padding">0</property>
- </packing>
- </child>
</object>
<packing>
@@ -150,14 +65,4 @@
</child>
</template>
- <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>
-
</interface>
diff --git a/data/ui/wizard-toolbar.ui b/data/ui/wizard-toolbar.ui
new file mode 100644
index 0000000..05fec70
--- /dev/null
+++ b/data/ui/wizard-toolbar.ui
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+ <template class="BoxesWizardToolbar" parent="GtkHeaderBar">
+ <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="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="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>
+
+ <child>
+ <object class="GtkButton" id="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="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>
+ </template>
+
+ <object class="GtkSizeGroup" id="sizegroup">
+ <property name="mode">horizontal</property>
+ <widgets>
+ <widget name="cancel_btn"/>
+ <widget name="back_btn"/>
+ <widget name="continue_btn"/>
+ <widget name="create_btn"/>
+ </widgets>
+ </object>
+
+ <object class="GtkSizeGroup" id="wizard_sizegroup">
+ <property name="mode">horizontal</property>
+ <widgets>
+ <widget name="cancel_btn"/>
+ <widget name="back_btn"/>
+ <widget name="continue_btn"/>
+ <widget name="create_btn"/>
+ </widgets>
+ </object>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index f27a527..df8c1cf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -138,6 +138,7 @@ gnome_boxes_SOURCES = \
libvirt-system-vm-importer.vala \
vnc-display.vala \
wizard-source.vala \
+ wizard-toolbar.vala \
wizard.vala \
downloader.vala \
empty-boxes.vala \
diff --git a/src/topbar.vala b/src/topbar.vala
index 26d14c2..a40e07f 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -17,20 +17,13 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
public UIState ui_state { get; protected set; }
[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 CollectionToolbar collection_toolbar;
[GtkChild]
private SelectionToolbar selection_toolbar;
[GtkChild]
private DisplayToolbar display_toolbar;
+ [GtkChild]
+ public WizardToolbar wizard_toolbar;
[GtkChild]
private Gtk.HeaderBar props_toolbar;
@@ -46,16 +39,14 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
collection_toolbar.click_back_button ();
break;
case UIState.WIZARD:
- if (App.window.wizard.page != WizardPage.INTRODUCTION)
- wizard_back_btn.clicked ();
+ wizard_toolbar.click_back_button ();
break;
}
}
// Clicks the appropriate forward button dependent on the ui state.
public void click_forward_button () {
- if (App.window.wizard.page != WizardPage.REVIEW)
- wizard_continue_btn.clicked ();
+ wizard_toolbar.click_forward_button ();
}
// Clicks the appropriate cancel button dependent on the ui state.
@@ -66,7 +57,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
App.app.selection_mode = false;
return;
case UIState.WIZARD:
- wizard_cancel_btn.clicked ();
+ wizard_toolbar.cancel_btn.clicked ();
return;
}
}
diff --git a/src/wizard-toolbar.vala b/src/wizard-toolbar.vala
new file mode 100644
index 0000000..ed90f98
--- /dev/null
+++ b/src/wizard-toolbar.vala
@@ -0,0 +1,24 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-toolbar.ui")]
+private class Boxes.WizardToolbar: HeaderBar {
+ [GtkChild]
+ public Button cancel_btn;
+ [GtkChild]
+ public Button back_btn;
+ [GtkChild]
+ public Button continue_btn;
+ [GtkChild]
+ public Button create_btn;
+
+ public void click_back_button () {
+ if (App.window.wizard.page != WizardPage.INTRODUCTION)
+ back_btn.clicked ();
+ }
+
+ public void click_forward_button () {
+ if (App.window.wizard.page != WizardPage.REVIEW)
+ continue_btn.clicked ();
+ }
+}
diff --git a/src/wizard.vala b/src/wizard.vala
index e544763..8b48f63 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -535,21 +535,21 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
}
public void setup_ui () {
- cancel_button = App.window.topbar.wizard_cancel_btn;
+ cancel_button = App.window.topbar.wizard_toolbar.cancel_btn;
cancel_button.clicked.connect (() => {
cleanup ();
wizard_source.page = SourcePage.MAIN;
App.app.set_state (UIState.COLLECTION);
});
- back_button = App.window.topbar.wizard_back_btn;
+ back_button = App.window.topbar.wizard_toolbar.back_btn;
back_button.clicked.connect (() => {
page = page - 1;
});
- continue_button = App.window.topbar.wizard_continue_btn;
+ continue_button = App.window.topbar.wizard_toolbar.continue_btn;
continue_button.clicked.connect (() => {
page = page + 1;
});
- create_button = App.window.topbar.wizard_create_btn;
+ create_button = App.window.topbar.wizard_toolbar.create_btn;
create_button.clicked.connect (() => {
page = WizardPage.LAST;
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]