[gnome-boxes] sidebar: Split-out wizard code into its own module
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] sidebar: Split-out wizard code into its own module
- Date: Tue, 12 Aug 2014 17:40:29 +0000 (UTC)
commit 829b9ce3af4e1aac736b7480090111ad17bdcc60
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Aug 12 18:32:34 2014 +0100
sidebar: Split-out wizard code into its own module
Lets have separate class/module for wizard sidebar.
data/gnome-boxes.gresource.xml | 1 +
data/ui/sidebar.ui | 89 +-------------------------------------
data/ui/wizard-sidebar.ui | 94 ++++++++++++++++++++++++++++++++++++++++
src/Makefile.am | 1 +
src/sidebar.vala | 41 +----------------
src/wizard-sidebar.vala | 42 ++++++++++++++++++
src/wizard.vala | 2 +-
7 files changed, 142 insertions(+), 128 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 08aa9ee..6c53ff6 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -25,6 +25,7 @@
<file preprocess="xml-stripblanks">ui/wizard.ui</file>
<file preprocess="xml-stripblanks">ui/wizard-media-entry.ui</file>
<file preprocess="xml-stripblanks">ui/wizard-scrolled.ui</file>
+ <file preprocess="xml-stripblanks">ui/wizard-sidebar.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>
diff --git a/data/ui/sidebar.ui b/data/ui/sidebar.ui
index 68d6553..d00cb6f 100644
--- a/data/ui/sidebar.ui
+++ b/data/ui/sidebar.ui
@@ -25,95 +25,8 @@
<!-- Wizard -->
<child>
- <object class="GtkBox" id="wizard_vbox">
+ <object class="BoxesWizardSidebar" id="wizard_sidebar">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">0</property>
-
- <child>
- <object class="GtkLabel" id="wizard_intro_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Introduction</property>
- <property name="margin-start">25</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-step-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkLabel" id="wizard_source_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Source Selection</property>
- <property name="margin-start">25</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-step-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkLabel" id="wizard_preparation_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Preparation</property>
- <property name="margin-start">25</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-step-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkLabel" id="wizard_setup_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Setup</property>
- <property name="margin-start">25</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-step-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkLabel" id="wizard_review_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Review</property>
- <property name="margin-start">25</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-step-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">10</property>
- </packing>
- </child>
</object>
</child>
diff --git a/data/ui/wizard-sidebar.ui b/data/ui/wizard-sidebar.ui
new file mode 100644
index 0000000..89fa685
--- /dev/null
+++ b/data/ui/wizard-sidebar.ui
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+
+ <template class="BoxesWizardSidebar" parent="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <object class="GtkLabel" id="intro_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Introduction</property>
+ <property name="margin-start">25</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-step-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="source_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Source Selection</property>
+ <property name="margin-start">25</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-step-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="preparation_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Preparation</property>
+ <property name="margin-start">25</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-step-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="setup_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Setup</property>
+ <property name="margin-start">25</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-step-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="review_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Review</property>
+ <property name="margin-start">25</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-step-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">10</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 2108512..15eef87 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -141,6 +141,7 @@ gnome_boxes_SOURCES = \
libvirt-system-importer.vala \
libvirt-system-vm-importer.vala \
vnc-display.vala \
+ wizard-sidebar.vala \
wizard-source.vala \
wizard-toolbar.vala \
wizard.vala \
diff --git a/src/sidebar.vala b/src/sidebar.vala
index 8b38266..ccfbcd1 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -13,23 +13,11 @@ private class Boxes.Sidebar: Gtk.Revealer, Boxes.UI {
public UIState ui_state { get; protected set; }
[GtkChild]
- private Gtk.Notebook notebook;
- [GtkChild]
- private Gtk.Box wizard_vbox;
- [GtkChild]
- private Gtk.Label wizard_intro_label;
- [GtkChild]
- private Gtk.Label wizard_source_label;
- [GtkChild]
- private Gtk.Label wizard_preparation_label;
- [GtkChild]
- private Gtk.Label wizard_setup_label;
- [GtkChild]
- private Gtk.Label wizard_review_label;
-
+ public WizardSidebar wizard_sidebar;
[GtkChild]
public Gtk.Image screenshot;
[GtkChild]
+ private Gtk.Notebook notebook;
public Gtk.ListStore props_listmodel;
[GtkChild]
private Gtk.TreeModelFilter props_model_filter;
@@ -55,31 +43,6 @@ private class Boxes.Sidebar: Gtk.Revealer, Boxes.UI {
this.window = window;
}
- public void set_wizard_page (WizardPage wizard_page) {
- foreach (var label in wizard_vbox.get_children ())
- label.get_style_context ().remove_class ("boxes-wizard-current-page-label");
-
- Gtk.Label current_label = null;
- switch ((int) wizard_page) {
- case WizardPage.INTRODUCTION:
- current_label = wizard_intro_label;
- break;
- case WizardPage.SOURCE:
- current_label = wizard_source_label;
- break;
- case WizardPage.PREPARATION:
- current_label = wizard_preparation_label;
- break;
- case WizardPage.SETUP:
- current_label = wizard_setup_label;
- break;
- case WizardPage.REVIEW:
- current_label = wizard_review_label;
- break;
- }
- current_label.get_style_context ().add_class ("boxes-wizard-current-page-label");
- }
-
private void ui_state_changed () {
switch (ui_state) {
case UIState.WIZARD:
diff --git a/src/wizard-sidebar.vala b/src/wizard-sidebar.vala
new file mode 100644
index 0000000..ef62c9e
--- /dev/null
+++ b/src/wizard-sidebar.vala
@@ -0,0 +1,42 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+using Gdk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-sidebar.ui")]
+private class Boxes.WizardSidebar: Gtk.Box {
+ [GtkChild]
+ private Gtk.Label intro_label;
+ [GtkChild]
+ private Gtk.Label source_label;
+ [GtkChild]
+ private Gtk.Label preparation_label;
+ [GtkChild]
+ private Gtk.Label setup_label;
+ [GtkChild]
+ private Gtk.Label review_label;
+
+ public void set_page (WizardPage wizard_page) {
+ foreach (var label in get_children ())
+ label.get_style_context ().remove_class ("boxes-wizard-current-page-label");
+
+ Gtk.Label current_label = null;
+ switch ((int) wizard_page) {
+ case WizardPage.INTRODUCTION:
+ current_label = intro_label;
+ break;
+ case WizardPage.SOURCE:
+ current_label = source_label;
+ break;
+ case WizardPage.PREPARATION:
+ current_label = preparation_label;
+ break;
+ case WizardPage.SETUP:
+ current_label = setup_label;
+ break;
+ case WizardPage.REVIEW:
+ current_label = review_label;
+ break;
+ }
+ current_label.get_style_context ().add_class ("boxes-wizard-current-page-label");
+ }
+}
diff --git a/src/wizard.vala b/src/wizard.vala
index 731d8a3..3484f64 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -135,7 +135,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
return;
_page = value;
- window.sidebar.set_wizard_page (value);
+ window.sidebar.wizard_sidebar.set_page (value);
visible_child_name = page_names[value];
if (value == WizardPage.SOURCE)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]