[gnome-boxes] wizard-source: Now a GtkStack rather than GtkNotebook
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] wizard-source: Now a GtkStack rather than GtkNotebook
- Date: Tue, 11 Mar 2014 13:57:19 +0000 (UTC)
commit febf1cb29b5b729cb88420d7e14040de683558e7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Mar 11 13:54:44 2014 +0000
wizard-source: Now a GtkStack rather than GtkNotebook
Same reason as for wizard and properites: We want transitions animated!
data/ui/wizard-source.ui | 19 +++++++++++++------
src/wizard-source.vala | 46 ++++++++++++++++++++++++++++------------------
2 files changed, 41 insertions(+), 24 deletions(-)
---
diff --git a/data/ui/wizard-source.ui b/data/ui/wizard-source.ui
index b42b9da..d1e675f 100644
--- a/data/ui/wizard-source.ui
+++ b/data/ui/wizard-source.ui
@@ -1,15 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.9 -->
- <template class="BoxesWizardSource" parent="GtkNotebook">
+ <template class="BoxesWizardSource" parent="GtkStack">
<property name="visible">True</property>
- <property name="show-tabs">False</property>
+ <property name="transition-type">slide-left-right</property>
+ <property name="transition-duration">400</property>
<property name="hexpand">True</property>
<property name="halign">center</property>
- <signal name="switch-page" handler="on_switch_page"/>
- <style>
- <class name="boxes-source-nb"/>
- </style>
<!-- main page -->
<child>
@@ -20,6 +17,7 @@
<property name="margin-top">15</property>
<property name="margin-bottom">15</property>
<style>
+ <class name="boxes-source-nb"/>
<class name="boxes-menu"/>
</style>
<child>
@@ -151,6 +149,10 @@
</object>
</child>
</object>
+
+ <packing>
+ <property name="name">main-page</property>
+ </packing>
</child>
<!-- URL page -->
@@ -162,6 +164,7 @@
<property name="margin-top">15</property>
<property name="margin-bottom">15</property>
<style>
+ <class name="boxes-source-nb"/>
<class name="boxes-menu"/>
</style>
<child>
@@ -270,6 +273,10 @@
</object>
</child>
</object>
+
+ <packing>
+ <property name="name">url-page</property>
+ </packing>
</child>
</template>
</interface>
diff --git a/src/wizard-source.vala b/src/wizard-source.vala
index c66e3b1..9eae31a 100644
--- a/src/wizard-source.vala
+++ b/src/wizard-source.vala
@@ -95,7 +95,9 @@ private class Boxes.WizardMediaEntry : Gtk.Button {
}
[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-source.ui")]
-private class Boxes.WizardSource: Gtk.Notebook {
+private class Boxes.WizardSource: Gtk.Stack {
+ private const string[] page_names = { "main-page", "url-page" };
+
public Gtk.Widget? selected { get; set; }
public string uri {
get { return url_entry.get_text (); }
@@ -130,6 +132,30 @@ private class Boxes.WizardSource: Gtk.Notebook {
public MediaManager media_manager;
+ private SourcePage _page;
+ public SourcePage page {
+ get { return _page; }
+ set {
+ _page = value;
+
+ visible_child_name = page_names[value];
+
+ if (selected != null)
+ selected.grab_focus ();
+ switch (value) {
+ case SourcePage.MAIN:
+ add_media_entries.begin ();
+ // FIXME: grab first element in the menu list
+ main_vbox.grab_focus ();
+ break;
+ case SourcePage.URL:
+ url_entry.changed ();
+ url_entry.grab_focus ();
+ break;
+ }
+ }
+ }
+
construct {
media_manager = MediaManager.get_instance ();
main_vbox.grab_focus ();
@@ -140,6 +166,7 @@ private class Boxes.WizardSource: Gtk.Notebook {
update_libvirt_sytem_entry_visibility.begin ();
add_media_entries.begin ();
+ transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT; // FIXME: Why this won't work from .ui
file?
}
[GtkCallback]
@@ -153,23 +180,6 @@ private class Boxes.WizardSource: Gtk.Notebook {
page = SourcePage.MAIN;
}
- [GtkCallback]
- private void on_switch_page (Gtk.Notebook self, Gtk.Widget page, uint page_num) {
- if (selected != null)
- selected.grab_focus ();
- switch (page_num) {
- case SourcePage.MAIN:
- add_media_entries.begin ();
- // FIXME: grab first element in the menu list
- main_vbox.grab_focus ();
- break;
- case SourcePage.URL:
- url_entry.changed ();
- url_entry.grab_focus ();
- break;
- }
- }
-
public void update_url_page(string title, string text, string icon_name) {
url_description_label.set_markup ("<b>" + title + "</b>\n\n" + text);
url_image.icon_name = icon_name;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]