[gnome-boxes/wip/less-dialogs: 4/4] Merge PropertiesWindow & WizardWindow
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/less-dialogs: 4/4] Merge PropertiesWindow & WizardWindow
- Date: Tue, 2 Dec 2014 18:02:01 +0000 (UTC)
commit 82cca44e4dee5f2d87dddf313524d14feb4621d9
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Dec 2 17:29:49 2014 +0000
Merge PropertiesWindow & WizardWindow
data/gnome-boxes.gresource.xml | 3 +-
data/ui/properties-window.ui | 50 ------------------
data/ui/props-n-wizard-window.ui | 105 ++++++++++++++++++++++++++++++++++++++
data/ui/wizard-window.ui | 51 ------------------
src/Makefile.am | 3 +-
src/app-window.vala | 11 ++---
src/app.vala | 8 ++--
src/properties-window.vala | 51 ------------------
src/properties.vala | 2 +-
src/props-n-wizard-window.vala | 96 ++++++++++++++++++++++++++++++++++
src/wizard-window.vala | 55 --------------------
src/wizard.vala | 16 +++---
12 files changed, 220 insertions(+), 231 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 48fcbe6..a56b8b9 100644
--- a/data/gnome-boxes.gresource.xml
+++ b/data/gnome-boxes.gresource.xml
@@ -14,7 +14,7 @@
<file preprocess="xml-stripblanks">ui/mini-graph.ui</file>
<file preprocess="xml-stripblanks">ui/notification.ui</file>
<file preprocess="xml-stripblanks">ui/properties-toolbar.ui</file>
- <file preprocess="xml-stripblanks">ui/properties-window.ui</file>
+ <file preprocess="xml-stripblanks">ui/props-n-wizard-window.ui</file>
<file preprocess="xml-stripblanks">ui/searchbar.ui</file>
<file preprocess="xml-stripblanks">ui/selectionbar.ui</file>
<file preprocess="xml-stripblanks">ui/selection-toolbar.ui</file>
@@ -26,7 +26,6 @@
<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>
- <file preprocess="xml-stripblanks">ui/wizard-window.ui</file>
<file preprocess="xml-stripblanks">ui/snapshot-list-row.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/props-n-wizard-window.ui b/data/ui/props-n-wizard-window.ui
new file mode 100644
index 0000000..e74a98a
--- /dev/null
+++ b/data/ui/props-n-wizard-window.ui
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+
+ <!-- Widget hierarchy:
+
+ Boxes.PropertiesWindow : Gtk.Window
+ |
+ |-> notification_overlay = new Gtk.Overlay ();
+ | |
+ | |-> notificationbar = Boxes.Notificationbar ();
+ | |
+ | |-> view = Gtk.Stack ();
+ | |
+ | |-> properties = new Boxes.Properties ();
+ | |
+ | |-> wizard = new Boxes.Wizard ();
+ |
+ |-> topbar = new Gtk.Stack (); // as titlebar
+ |
+ |-> props_topbar = new Boxes.PropertiesToolbar ();
+ |
+ |-> wizard_topbar = new Boxes.WizardTopbar ();
+ -->
+
+ <template class="BoxesPropsNWizardWindow" parent="GtkWindow">
+ <property name="can_focus">False</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="type-hint">dialog</property>
+ <signal name="key-press-event" after="yes" handler="on_key_pressed"/>
+ <signal name="delete-event" handler="on_delete_event"/>
+
+ <child>
+ <object class="GtkOverlay" id="notification_overlay">
+ <property name="visible">True</property>
+
+ <child type="overlay">
+ <object class="BoxesNotificationbar" id="notificationbar">
+ <property name="visible">True</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="GtkStack" id="view">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left-right</property>
+ <property name="transition-duration">400</property>
+
+ <child>
+ <object class="BoxesProperties" id="properties">
+ <property name="visible">True</property>
+ </object>
+
+ <packing>
+ <property name="name">properties</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="BoxesWizard" id="wizard">
+ <property name="visible">True</property>
+ </object>
+
+ <packing>
+ <property name="name">wizard</property>
+ </packing>
+ </child>
+
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ <child type="titlebar">
+ <object class="GtkStack" id="topbar">
+ <property name="visible">True</property>
+ <property name="transition-type">slide-left-right</property>
+ <property name="transition-duration">400</property>
+
+ <child>
+ <object class="BoxesPropertiesToolbar" id="props_topbar">
+ <property name="visible">True</property>
+ </object>
+
+ <packing>
+ <property name="name">properties</property>
+ </packing>
+ </child>
+
+ <child>
+ <object class="BoxesWizardToolbar" id="wizard_topbar">
+ <property name="visible">True</property>
+ </object>
+
+ <packing>
+ <property name="name">wizard</property>
+ </packing>
+ </child>
+
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 6ddb52f..f18632b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -123,9 +123,9 @@ gnome_boxes_SOURCES = \
notificationbar.vala \
os-database.vala \
properties.vala \
- properties-window.vala \
properties-page-widget.vala \
properties-toolbar.vala \
+ props-n-wizard-window.vala \
remote-machine.vala \
searchbar.vala \
selectionbar.vala \
@@ -143,7 +143,6 @@ gnome_boxes_SOURCES = \
libvirt-system-importer.vala \
libvirt-system-vm-importer.vala \
vnc-display.vala \
- wizard-window.vala \
wizard-source.vala \
wizard-toolbar.vala \
wizard.vala \
diff --git a/src/app-window.vala b/src/app-window.vala
index 3249e29..d9cbcc5 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -64,17 +64,15 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
get {
switch (ui_state) {
case UIState.WIZARD:
- return wizard_window.notificationbar;
case UIState.PROPERTIES:
- return props_window.notificationbar;
+ return props_n_wizard_window.notificationbar;
default:
return _notificationbar;
}
}
}
- public WizardWindow wizard_window;
- public PropertiesWindow props_window;
+ public PropsNWizardWindow props_n_wizard_window;
[GtkChild]
public Searchbar searchbar;
@@ -144,8 +142,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
empty_boxes.setup_ui (this);
notificationbar.searchbar = searchbar;
- wizard_window = new WizardWindow (this);
- props_window = new PropertiesWindow (this);
+ props_n_wizard_window = new PropsNWizardWindow (this);
}
private void save_window_geometry () {
@@ -164,7 +161,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
private void ui_state_changed () {
// The order is important for some widgets here (e.g properties must change its state before wizard
so it can
// flush any deferred changes for wizard to pick-up when going back from properties to wizard
(review).
- foreach (var ui in new Boxes.UI[] { topbar, view, props_window, wizard_window, empty_boxes }) {
+ foreach (var ui in new Boxes.UI[] { topbar, view, props_n_wizard_window, empty_boxes }) {
ui.set_state (ui_state);
}
diff --git a/src/app.vala b/src/app.vala
index 1875fc2..651a6c5 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -234,11 +234,11 @@ private class Boxes.App: Gtk.Application {
if (file.query_exists ()) {
if (is_uri)
- main_window.wizard_window.wizard.open_with_uri (arg);
+ main_window.props_n_wizard_window.wizard.open_with_uri (arg);
else
- main_window.wizard_window.wizard.open_with_uri (file.get_uri ());
+ main_window.props_n_wizard_window.wizard.open_with_uri (file.get_uri ());
} else if (is_uri)
- main_window.wizard_window.wizard.open_with_uri (arg);
+ main_window.props_n_wizard_window.wizard.open_with_uri (arg);
else
open_name (arg);
});
@@ -276,7 +276,7 @@ private class Boxes.App: Gtk.Application {
foreach (var window in windows) {
window.notificationbar.cancel ();
- window.wizard_window.wizard.cleanup ();
+ window.props_n_wizard_window.wizard.cleanup ();
}
suspend_machines ();
}
diff --git a/src/properties.vala b/src/properties.vala
index 3ac4068..a6b9152 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -52,7 +52,7 @@ private class Boxes.Properties: Gtk.Notebook, Boxes.UI {
page = PropertiesPage.GENERAL;
}
- public void setup_ui (AppWindow window, PropertiesWindow dialog) {
+ public void setup_ui (AppWindow window, PropsNWizardWindow props_window) {
this.window = window;
show_all ();
diff --git a/src/props-n-wizard-window.vala b/src/props-n-wizard-window.vala
new file mode 100644
index 0000000..05bdd62
--- /dev/null
+++ b/src/props-n-wizard-window.vala
@@ -0,0 +1,96 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/props-n-wizard-window.ui")]
+private class Boxes.PropsNWizardWindow: Gtk.Window, Boxes.UI {
+ public UIState previous_ui_state { get; protected set; }
+ public UIState ui_state { get; protected set; }
+
+ [GtkChild]
+ public Gtk.Stack view;
+ [GtkChild]
+ public Properties properties;
+ [GtkChild]
+ public Wizard wizard;
+
+ [GtkChild]
+ public Gtk.Stack topbar;
+ [GtkChild]
+ public PropertiesToolbar props_topbar;
+ [GtkChild]
+ public WizardToolbar wizard_topbar;
+
+ [GtkChild]
+ public Notificationbar notificationbar;
+
+ private unowned AppWindow app_window;
+
+ public PropsNWizardWindow (AppWindow app_window) {
+ this.app_window = app_window;
+
+ properties.setup_ui (app_window, this);
+ wizard.setup_ui (app_window, this);
+
+ props_topbar.setup_ui (app_window);
+
+ set_transient_for (app_window);
+
+ notify["ui-state"].connect (ui_state_changed);
+ }
+
+ private void ui_state_changed () {
+ properties.set_state (ui_state);
+ wizard.set_state (ui_state);
+
+ if (ui_state == UIState.PROPERTIES || ui_state == UIState.WIZARD) {
+ props_topbar.back_button.visible = (previous_ui_state == UIState.WIZARD);
+ props_topbar.show_close_button = (previous_ui_state != UIState.WIZARD);
+
+ view.visible_child_name = (ui_state == UIState.PROPERTIES)? "properties" : "wizard";
+ topbar.visible_child_name = (ui_state == UIState.PROPERTIES)? "properties" : "wizard";
+
+ visible = true;
+ } else
+ visible = false;
+ }
+
+ [GtkCallback]
+ private bool on_key_pressed (Widget widget, Gdk.EventKey event) {
+ var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
+
+ if (ui_state == UIState.WIZARD) {
+ if (event.keyval == Gdk.Key.Left && // ALT + Left -> back
+ (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
+ wizard_topbar.click_back_button ();
+
+ return true;
+ } else if (event.keyval == Gdk.Key.Right && // ALT + Right -> forward
+ (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
+ wizard_topbar.click_forward_button ();
+
+ return true;
+ } else if (event.keyval == Gdk.Key.Escape) { // ESC -> cancel
+ wizard_topbar.cancel_btn.clicked ();
+
+ return true;
+ }
+ } else if (ui_state == UIState.PROPERTIES && // ESC -> back
+ event.keyval == Gdk.Key.Escape) {
+ props_topbar.back_button.clicked ();
+
+ return true;
+ }
+
+ return false;
+ }
+
+ [GtkCallback]
+ private bool on_delete_event () {
+ if (ui_state == UIState.WIZARD)
+ wizard.cancel ();
+ else
+ props_topbar.back_button.clicked ();
+
+ return true;
+ }
+}
diff --git a/src/wizard.vala b/src/wizard.vala
index e2d15ab..b14e35e 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -46,7 +46,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
private Gtk.Image installer_image;
private AppWindow window;
- private unowned WizardWindow wizard_window;
+ private WizardToolbar topbar;
private MediaManager media_manager;
@@ -136,7 +136,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
return;
_page = value;
- wizard_window.topbar.set_title_for_page (value);
+ topbar.set_title_for_page (value);
visible_child_name = page_names[value];
if (value == WizardPage.SOURCE)
@@ -601,23 +601,23 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
prepare (progress);
}
- public void setup_ui (AppWindow window, WizardWindow wizard_window) {
+ public void setup_ui (AppWindow window, PropsNWizardWindow wizard_window) {
this.window = window;
- this.wizard_window = wizard_window;
+ this.topbar = wizard_window.wizard_topbar;
- cancel_button = wizard_window.topbar.cancel_btn;
+ cancel_button = topbar.cancel_btn;
cancel_button.clicked.connect (cancel);
- back_button = wizard_window.topbar.back_btn;
+ back_button = topbar.back_btn;
back_button.clicked.connect (() => {
prepare_cancellable.cancel ();
page = page - 1;
});
- continue_button = wizard_window.topbar.continue_btn;
+ continue_button = topbar.continue_btn;
continue_button.clicked.connect (() => {
page = page + 1;
});
- create_button = wizard_window.topbar.create_btn;
+ create_button = topbar.create_btn;
create_button.clicked.connect (() => {
page = WizardPage.LAST;
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]