[gnome-boxes] wizard: Now a GtkStack rather than GtkNotebook
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] wizard: Now a GtkStack rather than GtkNotebook
- Date: Sun, 9 Mar 2014 19:03:34 +0000 (UTC)
commit f99155ed1a5f1bc9cdb90db73f74d24f4dfc7c87
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Mar 7 16:40:16 2014 +0000
wizard: Now a GtkStack rather than GtkNotebook
This is so that we can have nice sliding transitions mainly but GtkStack
is more appropriate here anyway.
data/ui/wizard.ui | 470 ++++++++++++++++++++++++++++++++---------------------
src/wizard.vala | 139 ++++++++--------
2 files changed, 354 insertions(+), 255 deletions(-)
---
diff --git a/data/ui/wizard.ui b/data/ui/wizard.ui
index 43ff3a1..69b03c3 100644
--- a/data/ui/wizard.ui
+++ b/data/ui/wizard.ui
@@ -1,140 +1,162 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.9 -->
- <template class="BoxesWizard" parent="GtkNotebook">
+ <template class="BoxesWizard" parent="GtkStack">
<property name="visible">True</property>
- <property name="show-tabs">False</property>
- <style>
- <class name="wizard"/>
- <class name="boxes-bg"/>
- </style>
+ <property name="transition-type">slide-left-right</property>
+ <property name="transition-duration">400</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
<!-- Introduction -->
<child>
- <object class="GtkBox" id="intro_hbox">
+ <object class="GtkBox" id="intro_box">
<property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">10</property>
- <property name="halign">center</property>
+ <style>
+ <class name="wizard"/>
+ <class name="boxes-bg"/>
+ </style>
<child>
- <object class="GtkImage" id="intro_image">
+ <object class="GtkBox" id="intro_hbox">
<property name="visible">True</property>
- <property name="resource">/org/gnome/Boxes/icons/boxes-create.png</property>
- </object>
- </child>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">10</property>
+ <property name="halign">center</property>
- <child>
- <object class="GtkLabel" id="intro_label">
- <property name="visible">True</property>
- <property name="wrap">True</property>
- <!-- Work around clutter size allocation issue (bz#677260) -->
- <property name="max-width-chars">40</property>
- <property name="use-markup">True</property>
- <property name="label" translatable="yes">Creating a Box will allow you to use another operating
system directly from your existing login.
+ <child>
+ <object class="GtkImage" id="intro_image">
+ <property name="visible">True</property>
+ <property name="resource">/org/gnome/Boxes/icons/boxes-create.png</property>
+ <property name="hexpand">True</property>
+ <property name="halign">end</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="intro_label">
+ <property name="visible">True</property>
+ <property name="wrap">True</property>
+ <!-- Work around clutter size allocation issue (bz#677260) -->
+ <property name="max-width-chars">40</property>
+ <property name="use-markup">True</property>
+ <property name="label" translatable="yes">Creating a Box will allow you to use another
operating system directly from your existing login.
You may connect to an existing machine <b><i>over the network</i></b> or create a
<b><i>virtual machine</i></b> that runs locally on your own.</property>
- <property name="use-markup">True</property>
- <style>
- <class name="boxes-wizard-label"/>
- </style>
+ <property name="use-markup">True</property>
+ <property name="hexpand">True</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-wizard-label"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</object>
+
+ <packing>
+ <property name="name">introduction</property>
+ </packing>
</child>
<!-- Source -->
<child>
- <object class="GtkBox" id="source_vbox">
+ <object class="GtkBox" id="source_box">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">30</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
+ <style>
+ <class name="wizard"/>
+ <class name="boxes-bg"/>
+ </style>
<child>
- <object class="GtkLabel" id="instruction_label">
+ <object class="GtkBox" id="source_vbox">
<property name="visible">True</property>
- <property name="label" translatable="yes">Insert operating system installation media or select a
source below</property>
- <property name="wrap">True</property>
- <property name="xalign">0.0</property>
- <style>
- <class name="boxes-wizard-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <property name="orientation">vertical</property>
+ <property name="spacing">30</property>
+ <property name="valign">center</property>
- <child>
- <object class="BoxesWizardSource" id="wizard_source">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
+ <child>
+ <object class="GtkLabel" id="instruction_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Insert operating system installation media or
select a source below</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0.0</property>
+ <style>
+ <class name="boxes-wizard-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
- <child>
- <object class="GtkLabel" id="trademark_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Any trademarks shown above are used merely for
identification of software products you have already obtained and are the property of their respective
owners.</property>
- <property name="wrap">True</property>
- <property name="max-width-chars">50</property>
- <style>
- <class name="boxes-logo-notice-label"/>
- </style>
+ <child>
+ <object class="BoxesWizardSource" id="wizard_source">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="trademark_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Any trademarks shown above are used merely for
identification of software products you have already obtained and are the property of their respective
owners.</property>
+ <property name="wrap">True</property>
+ <property name="max-width-chars">50</property>
+ <style>
+ <class name="boxes-logo-notice-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</object>
+
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">False</property>
</packing>
</child>
</object>
+
+ <packing>
+ <property name="name">source</property>
+ </packing>
</child>
<!-- Preparation -->
<child>
- <object class="GtkBox" id="prep_vbox">
+ <object class="GtkBox" id="prep_box">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">30</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
+ <style>
+ <class name="wizard"/>
+ <class name="boxes-bg"/>
+ </style>
<child>
- <object class="GtkLabel" id="preparing_label">
+ <object class="GtkBox" id="prep_vbox">
<property name="visible">True</property>
- <property name="label" translatable="yes">Preparing to create new box</property>
- <property name="wrap">True</property>
- <property name="xalign">0.0</property>
- <style>
- <class name="boxes-wizard-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkBox" id="prep_hbox">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">10</property>
- <property name="halign">center</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">30</property>
<property name="valign">center</property>
<child>
- <object class="GtkImage" id="installer_image">
+ <object class="GtkLabel" id="preparing_label">
<property name="visible">True</property>
- <property name="icon-name">media-optical</property>
- <property name="icon-size">0</property>
- <property name="pixel-size">128</property>
+ <property name="label" translatable="yes">Preparing to create new box</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0.0</property>
+
+ <style>
+ <class name="boxes-wizard-label"/>
+ </style>
</object>
<packing>
<property name="expand">False</property>
@@ -143,33 +165,19 @@ You may connect to an existing machine <b><i>over the network</i&
</child>
<child>
- <object class="GtkBox" id="prep_inner_vbox">
+ <object class="GtkBox" id="prep_hbox">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="orientation">horizontal</property>
<property name="spacing">10</property>
+ <property name="halign">center</property>
<property name="valign">center</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="prep_media_label">
- <property name="ellipsize">end</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-wizard-media-os-label"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
<child>
- <object class="GtkLabel" id="prep_status_label">
+ <object class="GtkImage" id="installer_image">
<property name="visible">True</property>
- <property name="halign">start</property>
- <style>
- <class name="boxes-wizard-label"/>
- </style>
+ <property name="icon-name">media-optical</property>
+ <property name="icon-size">0</property>
+ <property name="pixel-size">128</property>
</object>
<packing>
<property name="expand">False</property>
@@ -178,115 +186,165 @@ You may connect to an existing machine <b><i>over the network</i&
</child>
<child>
- <object class="GtkProgressBar" id="prep_progress">
+ <object class="GtkBox" id="prep_inner_vbox">
<property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">10</property>
+ <property name="valign">center</property>
+ <property name="homogeneous">True</property>
+ <child>
+ <object class="GtkLabel" id="prep_media_label">
+ <property name="ellipsize">end</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-wizard-media-os-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="prep_status_label">
+ <property name="visible">True</property>
+ <property name="halign">start</property>
+ <style>
+ <class name="boxes-wizard-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="GtkProgressBar" id="prep_progress">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
</child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
</child>
</object>
+
<packing>
<property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
</object>
+
+ <packing>
+ <property name="name">preparation</property>
+ </packing>
</child>
<!-- Setup -->
<child>
- <object class="GtkBox" id="setup_box">
+ <object class="GtkBox" id="setup_outerbox">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">0</property>
- <property name="valign">center</property>
- <property name="halign">center</property>
+ <style>
+ <class name="wizard"/>
+ <class name="boxes-bg"/>
+ </style>
+
+ <child>
+ <object class="GtkBox" id="setup_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">0</property>
+ <property name="valign">center</property>
+ </object>
+
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
</object>
+
+ <packing>
+ <property name="name">setup</property>
+ </packing>
</child>
<!-- Review -->
<child>
- <object class="GtkBox" id="review_box">
+ <object class="GtkBox" id="review_outerbox">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">0</property>
- <property name="valign">fill</property>
- <property name="halign">fill</property>
+ <style>
+ <class name="wizard"/>
+ <class name="boxes-bg"/>
+ </style>
<child>
- <!-- FIXME: We shouldn't need this box but for some weird unknown
- reason, toggling the visibility of the infobar itself doesn't
- exactly work. The bar remains visible even after setting
- visibility to 'false' but its only visible as a line. Likely
- some bug in clutter-gtk but I failed to reproduce it outside
- Boxes. :( -->
- <object class="GtkBox" id="nokvm_box">
+ <object class="GtkBox" id="review_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
+ <style>
+ <class name="wizard"/>
+ <class name="boxes-bg"/>
+ </style>
<child>
- <object class="GtkInfoBar" id="nokvm_infobar">
- <property name="halign">fill</property>
+ <!-- FIXME: We shouldn't need this box but for some weird unknown
+ reason, toggling the visibility of the infobar itself doesn't
+ exactly work. The bar remains visible even after setting
+ visibility to 'false' but its only visible as a line. Likely
+ some bug in clutter-gtk but I failed to reproduce it outside
+ Boxes. :( -->
+ <object class="GtkBox" id="nokvm_box">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
<property name="spacing">0</property>
- <property name="message-type">warning</property>
- <child internal-child="content_area">
- <object class="GtkContainer" id="nokvm_container">
- <child>
- <object class="GtkImage" id="nokvm_image">
- <property name="visible">True</property>
- <property name="icon-name">dialog-warning</property>
- <property name="icon-size">3</property>
- </object>
- </child>
+ <child>
+ <object class="GtkInfoBar" id="nokvm_infobar">
+ <property name="halign">fill</property>
+ <property name="spacing">0</property>
+ <property name="message-type">warning</property>
- <child>
- <object class="GtkLabel" id="nokvm_label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Virtualization extensions are unavailable
on your system. If your system is recent (post 2008), check your BIOS settings to enable them.</property>
- <property name="wrap">True</property>
- <property name="halign">start</property>
- <property name="hexpand">True</property>
+ <child internal-child="content_area">
+ <object class="GtkContainer" id="nokvm_container">
+ <child>
+ <object class="GtkImage" id="nokvm_image">
+ <property name="visible">True</property>
+ <property name="icon-name">dialog-warning</property>
+ <property name="icon-size">3</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkLabel" id="nokvm_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Virtualization extensions are
unavailable on your system. If your system is recent (post 2008), check your BIOS settings to enable
them.</property>
+ <property name="wrap">True</property>
+ <property name="halign">start</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
</child>
</object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
-
- <child>
- <object class="GtkBox" id="review_vbox">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">30</property>
- <property name="valign">center</property>
- <property name="halign">center</property>
-
- <child>
- <object class="GtkLabel" id="review_label">
- <property name="visible">True</property>
- <property name="xalign">0.0</property>
- <property name="wrap">True</property>
- <property name="width-chars">30</property>
- <style>
- <class name="boxes-wizard-label"/>
- </style>
- </object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
@@ -294,21 +352,55 @@ You may connect to an existing machine <b><i>over the network</i&
</child>
<child>
- <object class="BoxesWizardSummary" id="summary"/>
+ <object class="GtkBox" id="review_vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">30</property>
+ <property name="valign">center</property>
+ <property name="halign">center</property>
+
+ <child>
+ <object class="GtkLabel" id="review_label">
+ <property name="visible">True</property>
+ <property name="xalign">0.0</property>
+ <property name="wrap">True</property>
+ <property name="width-chars">30</property>
+ <style>
+ <class name="boxes-wizard-label"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="BoxesWizardSummary" id="summary"/>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+ </object>
+
<packing>
<property name="expand">True</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
</packing>
</child>
-
</object>
+
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
-
</object>
+
+ <packing>
+ <property name="name">review</property>
+ </packing>
</child>
</template>
diff --git a/src/wizard.vala b/src/wizard.vala
index e1ef513..48b42de 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -11,7 +11,9 @@ private enum Boxes.WizardPage {
}
[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard.ui")]
-private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
+private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
+ private const string[] page_names = { "introduction", "source", "preparation", "setup", "review" };
+
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
@@ -47,85 +49,89 @@ private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
protected Machine? machine { get; set; }
private LibvirtMachine? libvirt_machine { get { return (machine as LibvirtMachine); } }
- public override void switch_page (Gtk.Widget page_widget, uint page_num) {
- if (cancel_button == null) {
- // page is set to INTRODUCTION by GtkBuilder during construction (before even construct is
called) and
- // therefore none of the state we access below is available to us (nor it could be before this
object
- // exists).
- base.switch_page (page_widget, page_num);
-
- return;
- }
-
- back_button.sensitive = page_num != WizardPage.INTRODUCTION;
-
- var forwards = page_num > page;
-
- switch (page_num) {
- case WizardPage.INTRODUCTION:
- create_button.visible = false;
- continue_button.visible = true;
- next_button = continue_button;
- next_button.sensitive = true;
- next_button.grab_focus (); // FIXME: doesn't work?!
- break;
-
- case WizardPage.SOURCE:
- // reset page to notify deeply widgets states
- wizard_source.page = wizard_source.page;
- break;
- }
+ private WizardPage _page;
+ private WizardPage page {
+ get { return _page; }
+ set {
+ back_button.sensitive = value != WizardPage.INTRODUCTION;
+
+ var forwards = value > page;
+
+ switch (value) {
+ case WizardPage.INTRODUCTION:
+ create_button.visible = false;
+ continue_button.visible = true;
+ next_button = continue_button;
+ next_button.sensitive = true;
+ next_button.grab_focus (); // FIXME: doesn't work?!
+ break;
- if (forwards) {
- switch (page_num) {
case WizardPage.SOURCE:
- wizard_source.selected = null;
- wizard_source.page = SourcePage.MAIN;
+ // reset page to notify deeply widgets states
+ wizard_source.page = wizard_source.page;
break;
+ }
- case WizardPage.PREPARATION:
- if (!prepare ())
- return;
- break;
+ if (forwards) {
+ switch (value) {
+ case WizardPage.SOURCE:
+ wizard_source.selected = null;
+ wizard_source.page = SourcePage.MAIN;
+ break;
- case WizardPage.SETUP:
- if (!setup ())
- return;
- break;
+ case WizardPage.PREPARATION:
+ if (!prepare ())
+ return;
+ break;
- case WizardPage.REVIEW:
- continue_button.visible = false;
- create_button.visible = true;
- next_button = create_button;
- next_button.sensitive = false;
+ case WizardPage.SETUP:
+ if (!setup ())
+ return;
+ break;
- review.begin ((obj, result) => {
- next_button.sensitive = true;
- if (!review.end (result))
- page = page - 1;
- });
- break;
- }
- } else {
- switch (page) {
+ case WizardPage.REVIEW:
+ continue_button.visible = false;
+ create_button.visible = true;
+ next_button = create_button;
+ next_button.sensitive = false;
+
+ review.begin ((obj, result) => {
+ next_button.sensitive = true;
+ if (!review.end (result))
+ page = page - 1;
+ });
+ break;
+
+ case WizardPage.LAST:
+ create.begin ((obj, result) => {
+ if (create.end (result))
+ App.window.set_state (UIState.COLLECTION);
+ else
+ App.window.notificationbar.display_error (_("Box creation failed"));
+ });
+ return;
+ }
+ } else {
+ switch (page) {
case WizardPage.REVIEW:
create_button.visible = false;
continue_button.visible = true;
next_button = continue_button;
destroy_machine ();
break;
+ }
}
- }
- if (skip_page ((WizardPage) page_num))
- return;
+ if (skip_page (value))
+ return;
- base.switch_page (page_widget, page_num);
+ _page = value;
+ App.window.sidebar.set_wizard_page (value);
+ visible_child_name = page_names[value];
- App.window.sidebar.set_wizard_page ((WizardPage) page_num);
-
- if (page_num == WizardPage.SOURCE)
- wizard_source_update_next ();
+ if (value == WizardPage.SOURCE)
+ wizard_source_update_next ();
+ }
}
private void wizard_source_update_next () {
@@ -178,9 +184,8 @@ private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
page = WizardPage.PREPARATION;
});
- // Changing page to something other than INTRODUCTION here so that Gtk.Notebook doesn't ignore us
setting
- // it to INTRODUCTION later (also read the comment in switch_page method above).
- page = WizardPage.PREPARATION;
+ // FIXME: Why this won't work from .ui file?
+ transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT;
}
public void cleanup () {
@@ -547,6 +552,8 @@ private class Boxes.Wizard: Gtk.Notebook, Boxes.UI {
App.window.notificationbar.display_error (_("Box creation failed"));
});
});
+
+ page = WizardPage.INTRODUCTION;
}
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]