[gnome-boxes/wip/wizard-n-props-in-dialog2: 2/2] tmp
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/wizard-n-props-in-dialog2: 2/2] tmp
- Date: Wed, 27 Aug 2014 16:24:32 +0000 (UTC)
commit f95fc06f61e8596caef4189653ed2af3e01f613c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Aug 15 19:16:35 2014 +0100
tmp
data/gnome-boxes.gresource.xml | 4 +-
data/ui/app-window.ui | 54 ------------
data/ui/properties-dialog.ui | 81 ++++++++++++++++++
data/ui/properties-sidebar.ui | 3 +-
data/ui/properties-toolbar.ui | 47 -----------
data/ui/topbar.ui | 23 -----
data/ui/wizard-dialog.ui | 157 +++++++++++++++++++++++++++++++++++
data/ui/wizard-toolbar.ui | 95 ---------------------
src/Makefile.am | 5 +-
src/app-window.vala | 38 ++-------
src/app.vala | 8 +-
src/libvirt-machine-properties.vala | 2 +-
src/machine.vala | 4 +-
src/properties-dialog.vala | 47 +++++++++++
src/properties-sidebar.vala | 2 +-
src/properties-toolbar.vala | 54 ------------
src/properties.vala | 21 +++--
src/sidebar.vala | 46 ----------
src/topbar.vala | 44 +---------
src/wizard-dialog.vala | 81 ++++++++++++++++++
src/wizard-toolbar.vala | 24 ------
src/wizard.vala | 42 ++++------
22 files changed, 419 insertions(+), 463 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 14ae7ea..2342a31 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-sidebar.ui</file>
- <file preprocess="xml-stripblanks">ui/properties-toolbar.ui</file>
+ <file preprocess="xml-stripblanks">ui/properties-dialog.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>
@@ -27,6 +27,6 @@
<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>
+ <file preprocess="xml-stripblanks">ui/wizard-dialog.ui</file>
</gresource>
</gresources>
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index ab82ab1..ed74372 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -18,16 +18,6 @@
| | |
| | |-> view = new Boxes.CollectionView ();
| | |
- | | |-> below_bin_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- | | | |
- | | | |-> sidebar = new Boxes.Sidebar ();
- | | | |
- | | | |-> content_bin = Gtk.Stack ();
- | | | |
- | | | |-> wizard = new Boxes.Wizard ();
- | | | |
- | | | |-> properties = new Boxes.Properties ();
- | | |
| | |-> empty_boxes = new Boxes.EmptyBoxes ();
| | |
| | |-> display_page = new Boxes.DisplayPage ();
@@ -101,50 +91,6 @@
</child>
<child>
- <object class="GtkBox" id="below_bin_hbox">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="halign">fill</property>
- <property name="valign">fill</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
- <property name="spacing">0</property>
-
- <child>
- <object class="BoxesSidebar" id="sidebar">
- <property name="visible">True</property>
- </object>
- </child>
-
- <child>
- <object class="GtkStack" id="content_bin">
- <property name="visible">True</property>
- <property name="homogeneous">True</property>
- <property name="transition-type">slide-left-right</property>
- <property name="transition-duration">400</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
-
- <child>
- <object class="BoxesWizard" id="wizard">
- <property name="visible">True</property>
- </object>
- </child>
-
- <child>
- <object class="BoxesProperties" id="properties">
- <property name="visible">True</property>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="name">below-bin-hbox</property>
- </packing>
- </child>
-
- <child>
<object class="BoxesDisplayPage" id="display_page">
<property name="visible">True</property>
</object>
diff --git a/data/ui/properties-dialog.ui b/data/ui/properties-dialog.ui
new file mode 100644
index 0000000..1ca058e
--- /dev/null
+++ b/data/ui/properties-dialog.ui
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+
+ <!-- Widget hierarchy:
+
+ Boxes.PropertiesDialog : Gtk.Dialog
+ |
+ |-> vbox (internal child)
+ |
+ |-> hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ |
+ |-> sidebar = new Boxes.PropertiesSidebar ();
+ |
+ |-> properties = new Boxes.Properties ();
+ |
+ |-> action_area (internal child) = new Gtk.ButtonBox ();
+ |
+ |-> close_button = new Gtk.Button ();
+ -->
+
+ <template class="BoxesPropertiesDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">0</property>
+ <property name="type_hint">dialog</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="use_header_bar">1</property>
+ <signal name="delete-event" handler="on_delete_event"/>
+
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <property name="visible">True</property>
+
+ <child>
+ <object class="GtkBox" id="hbox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="halign">fill</property>
+ <property name="valign">fill</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <object class="BoxesPropertiesSidebar" id="sidebar">
+ <property name="visible">True</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="BoxesProperties" id="properties">
+ <property name="visible">True</property>
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area">
+
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <property name="label" translatable="yes">_Close</property>
+ <signal name="clicked" handler="on_close_button_clicked"/>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+ </child>
+
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/data/ui/properties-sidebar.ui b/data/ui/properties-sidebar.ui
index 32aecb9..444d96f 100644
--- a/data/ui/properties-sidebar.ui
+++ b/data/ui/properties-sidebar.ui
@@ -5,7 +5,7 @@
<template class="BoxesPropertiesSidebar" parent="GtkBox">
<property name="visible">True</property>
<property name="orientation">vertical</property>
- <property name="spacing">10</property>
+ <property name="spacing">300</property>
<child>
<object class="GtkTreeView" id="tree_view">
@@ -57,7 +57,6 @@
<property name="margin-start">10</property>
<property name="margin-end">10</property>
<property name="margin-top">10</property>
- <property name="margin-bottom">30</property>
<child>
<object class="GtkImage" id="screenshot">
diff --git a/data/ui/topbar.ui b/data/ui/topbar.ui
index 7b70cff..058d809 100644
--- a/data/ui/topbar.ui
+++ b/data/ui/topbar.ui
@@ -28,29 +28,6 @@
</packing>
</child>
- <!-- Wizard -->
- <child>
- <object class="BoxesWizardToolbar" id="wizard_toolbar">
- <property name="visible">True</property>
- </object>
-
- <packing>
- <property name="name">wizard</property>
- </packing>
- </child>
-
- <!-- Properties -->
- <child>
- <object class="BoxesPropertiesToolbar" id="props_toolbar">
- <property name="visible">True</property>
- <property name="show-close-button">True</property>
- </object>
-
- <packing>
- <property name="name">properties</property>
- </packing>
- </child>
-
<!-- Display -->
<child>
<object class="BoxesDisplayToolbar" id="display_toolbar">
diff --git a/data/ui/wizard-dialog.ui b/data/ui/wizard-dialog.ui
new file mode 100644
index 0000000..035ca9e
--- /dev/null
+++ b/data/ui/wizard-dialog.ui
@@ -0,0 +1,157 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.9 -->
+
+ <!-- Widget hierarchy:
+
+ Boxes.WizardDialog : Gtk.Dialog
+ |
+ |-> vbox (internal child)
+ |
+ |-> hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ |
+ |-> sidebar = new Boxes.WizardSidebar ();
+ |
+ |-> wizard = new Boxes.Wizard ();
+ |
+ |-> action_area (internal child) = new Gtk.ButtonBox ();
+ |
+ |-> cancel_btn = new Gtk.Button ();
+ |-> create_btn = new Gtk.Button ();
+ |-> continue_btn = new Gtk.Button ();
+ |-> back_btn = new Gtk.Button ();
+ -->
+
+ <template class="BoxesWizardDialog" parent="GtkDialog">
+ <property name="title" translatable="yes">Create a Box</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">0</property>
+ <property name="type_hint">dialog</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <property name="use_header_bar">1</property>
+ <signal name="key-press-event" after="yes" handler="on_key_pressed"/>
+ <signal name="delete-event" handler="on_delete_event"/>
+
+ <child internal-child="vbox">
+ <object class="GtkBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+
+ <child>
+ <object class="GtkBox" id="hbox">
+ <property name="visible">True</property>
+ <property name="orientation">horizontal</property>
+ <property name="halign">fill</property>
+ <property name="valign">fill</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="spacing">10</property>
+
+ <child>
+ <object class="BoxesWizardSidebar" id="sidebar">
+ <property name="visible">True</property>
+ </object>
+ </child>
+
+ <child>
+ <object class="BoxesWizard" id="wizard">
+ <property name="visible">True</property>
+ </object>
+ </child>
+
+ </object>
+ </child>
+
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area">
+ <property name="margin-bottom">5</property>
+ <property name="margin-end">5</property>
+
+ <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>
+ <signal name="clicked" handler="on_cancel_btn_clicked"/>
+ <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>
+ <signal name="clicked" handler="on_create_btn_clicked"/>
+ <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>
+ <signal name="clicked" handler="on_continue_btn_clicked"/>
+ <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>
+ <signal name="clicked" handler="on_back_btn_clicked"/>
+ <style>
+ <class name="text-button"/>
+ </style>
+ </object>
+
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+
+ </object>
+ </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>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index e43d96b..79da105 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -122,13 +122,12 @@ gnome_boxes_SOURCES = \
notificationbar.vala \
os-database.vala \
properties.vala \
+ properties-dialog.vala \
properties-sidebar.vala \
- properties-toolbar.vala \
remote-machine.vala \
searchbar.vala \
selectionbar.vala \
selection-toolbar.vala \
- sidebar.vala \
spice-display.vala \
topbar.vala \
ui.vala \
@@ -142,9 +141,9 @@ gnome_boxes_SOURCES = \
libvirt-system-importer.vala \
libvirt-system-vm-importer.vala \
vnc-display.vala \
+ wizard-dialog.vala \
wizard-sidebar.vala \
wizard-source.vala \
- wizard-toolbar.vala \
wizard.vala \
downloader.vala \
empty-boxes.vala \
diff --git a/src/app-window.vala b/src/app-window.vala
index bdaaf57..40e285f 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -36,6 +36,9 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
}
}
+ public WizardDialog wizard_dialog;
+ public PropertiesDialog props_dialog;
+
[GtkChild]
public Searchbar searchbar;
[GtkChild]
@@ -45,22 +48,12 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
[GtkChild]
public Selectionbar selectionbar;
[GtkChild]
- public Sidebar sidebar;
- [GtkChild]
- public Wizard wizard;
- [GtkChild]
- public Properties properties;
- [GtkChild]
public DisplayPage display_page;
[GtkChild]
public EmptyBoxes empty_boxes;
[GtkChild]
public Gtk.Stack below_bin;
[GtkChild]
- private Gtk.Stack content_bin;
- [GtkChild]
- private Gtk.Box below_bin_hbox;
- [GtkChild]
public CollectionView view;
public GLib.Settings settings;
@@ -106,15 +99,15 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
public void setup_ui () {
topbar.setup_ui (this);
- wizard.setup_ui (this);
display_page.setup_ui (this);
view.setup_ui (this);
selectionbar.setup_ui (this);
searchbar.setup_ui (this);
- sidebar.setup_ui (this);
- properties.setup_ui (this);
empty_boxes.setup_ui (this);
notificationbar.searchbar = searchbar;
+
+ wizard_dialog = new WizardDialog (this);
+ props_dialog = new PropertiesDialog (this);
}
private void save_window_geometry () {
@@ -131,9 +124,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[] { sidebar, topbar, view, properties, wizard, empty_boxes }) {
+ foreach (var ui in new Boxes.UI[] { topbar, view, wizard_dialog, props_dialog, empty_boxes }) {
ui.set_state (ui_state);
}
@@ -165,18 +156,8 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
case UIState.CREDS:
case UIState.DISPLAY:
-
- break;
-
case UIState.WIZARD:
- below_bin.visible_child = below_bin_hbox;
- content_bin.visible_child = wizard;
-
- break;
-
case UIState.PROPERTIES:
- below_bin.visible_child = below_bin_hbox;
- content_bin.visible_child = properties;
break;
@@ -280,12 +261,9 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
(event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
topbar.click_back_button ();
return true;
- } else if (event.keyval == Gdk.Key.Right && // ALT + Right -> forward
- (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
- topbar.click_forward_button ();
- return true;
} else if (event.keyval == Gdk.Key.Escape) { // ESC -> cancel
topbar.click_cancel_button ();
+
}
return false;
diff --git a/src/app.vala b/src/app.vala
index 63575f8..983c806 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -232,11 +232,11 @@ private class Boxes.App: Gtk.Application {
if (file.query_exists ()) {
if (is_uri)
- main_window.wizard.open_with_uri (arg);
+ main_window.wizard_dialog.wizard.open_with_uri (arg);
else
- main_window.wizard.open_with_uri (file.get_uri ());
+ main_window.wizard_dialog.wizard.open_with_uri (file.get_uri ());
} else if (is_uri)
- main_window.wizard.open_with_uri (arg);
+ main_window.wizard_dialog.wizard.open_with_uri (arg);
else
open_name (arg);
});
@@ -274,7 +274,7 @@ private class Boxes.App: Gtk.Application {
foreach (var window in windows) {
window.notificationbar.cancel ();
- window.wizard.cleanup ();
+ window.wizard_dialog.wizard.cleanup ();
}
suspend_machines ();
}
diff --git a/src/libvirt-machine-properties.vala b/src/libvirt-machine-properties.vala
index b15c7d0..f9e4c6f 100644
--- a/src/libvirt-machine-properties.vala
+++ b/src/libvirt-machine-properties.vala
@@ -145,7 +145,7 @@ private class Boxes.LibvirtMachineProperties: GLib.Object, Boxes.IPropertiesProv
button.clicked.connect (() => {
var log = collect_logs ();
var dialog = new Gtk.Dialog.with_buttons (_("Troubleshooting log"),
- machine.window,
+ machine.window.props_dialog,
DialogFlags.DESTROY_WITH_PARENT,
_("_Save"), 100,
_("Copy to clipboard"), 101,
diff --git a/src/machine.vala b/src/machine.vala
index 6a90147..ca2773d 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -380,7 +380,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
orig_pixbuf = small_screenshot;
pixbuf = draw_vm (small_screenshot, SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT);
if (window.current_item == this)
- window.sidebar.props_sidebar.screenshot.set_from_pixbuf (pixbuf);
+ window.props_dialog.sidebar.screenshot.set_from_pixbuf (pixbuf);
if (save)
save_pixbuf_as_screenshot (small_screenshot);
@@ -541,7 +541,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
} else {
pixbuf = this.pixbuf;
}
- window.sidebar.props_sidebar.screenshot.set_from_pixbuf (pixbuf);
+ window.props_dialog.sidebar.screenshot.set_from_pixbuf (pixbuf);
break;
}
diff --git a/src/properties-dialog.vala b/src/properties-dialog.vala
new file mode 100644
index 0000000..fed5da6
--- /dev/null
+++ b/src/properties-dialog.vala
@@ -0,0 +1,47 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/properties-dialog.ui")]
+private class Boxes.PropertiesDialog: Gtk.Dialog, Boxes.UI {
+ public UIState previous_ui_state { get; protected set; }
+ public UIState ui_state { get; protected set; }
+
+ [GtkChild]
+ public PropertiesSidebar sidebar;
+ [GtkChild]
+ public Properties properties;
+
+ private unowned AppWindow app_window;
+
+ public PropertiesDialog (AppWindow app_window) {
+ this.app_window = app_window;
+
+ sidebar.setup_ui (app_window);
+ properties.setup_ui (app_window, this);
+
+ set_transient_for (app_window);
+
+ notify["ui-state"].connect (ui_state_changed);
+ }
+
+ private void ui_state_changed () {
+ properties.set_state (ui_state);
+ this.visible = (ui_state == UIState.PROPERTIES);
+ }
+
+ [GtkCallback]
+ private bool on_delete_event () {
+ revert_ui_state ();
+
+ return true;
+ }
+
+ [GtkCallback]
+ private void on_close_button_clicked () {
+ revert_ui_state ();
+ }
+
+ private void revert_ui_state () {
+ app_window.set_state (previous_ui_state);
+ }
+}
diff --git a/src/properties-sidebar.vala b/src/properties-sidebar.vala
index b98da6f..a2f8094 100644
--- a/src/properties-sidebar.vala
+++ b/src/properties-sidebar.vala
@@ -36,7 +36,7 @@ private class Boxes.PropertiesSidebar: Gtk.Box {
Gtk.TreeIter filter_iter, iter;
model_filter.get_iter (out filter_iter, path);
model_filter.convert_iter_to_child_iter (out iter, filter_iter);
- window.properties.page = (PropertiesPage) listmodel.get_path (iter).get_indices ()[0];
+ window.props_dialog.properties.page = (PropertiesPage) listmodel.get_path (iter).get_indices ()[0];
}
[GtkCallback]
diff --git a/src/properties.vala b/src/properties.vala
index 1eb5b40..dc44ef4 100644
--- a/src/properties.vala
+++ b/src/properties.vala
@@ -17,6 +17,7 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
public UIState ui_state { get; protected set; }
private AppWindow window;
+ private PropertiesSidebar sidebar;
private ulong stats_id;
private bool restore_fullscreen;
@@ -134,15 +135,14 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
}
private void populate () {
- window.sidebar.props_sidebar.listmodel.clear ();
+ sidebar.listmodel.clear ();
foreach (var page in get_children ())
remove (page);
var machine = window.current_item as Machine;
var libvirt_machine = window.current_item as LibvirtMachine;
- window.sidebar.props_sidebar.shutdown_button.sensitive = libvirt_machine != null &&
- libvirt_machine.is_running ();
+ sidebar.shutdown_button.sensitive = libvirt_machine != null && libvirt_machine.is_running ();
if (machine == null)
return;
@@ -156,11 +156,11 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
var current_page = page;
this.populate ();
var path = new Gtk.TreePath.from_indices (current_page);
- window.sidebar.props_sidebar.selection.select_path (path);
+ sidebar.selection.select_path (path);
page = current_page;
});
- list_append (window.sidebar.props_sidebar.listmodel, page.name, !page.empty);
+ list_append (sidebar.listmodel, page.name, !page.empty);
}
PropertiesPage current_page;
@@ -171,12 +171,13 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
current_page = PropertiesPage.LOGIN;
var path = new Gtk.TreePath.from_indices (current_page);
- window.sidebar.props_sidebar.selection.select_path (path);
+ sidebar.selection.select_path (path);
visible_child_name = page_names[current_page];
}
- public void setup_ui (AppWindow window) {
+ public void setup_ui (AppWindow window, PropertiesDialog dialog) {
this.window = window;
+ this.sidebar = dialog.sidebar;
transition_type = Gtk.StackTransitionType.SLIDE_UP_DOWN;
transition_duration = 400;
@@ -197,9 +198,9 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
if (window.current_item is LibvirtMachine) {
var libvirt_machine = window.current_item as LibvirtMachine;
stats_id = libvirt_machine.stats_updated.connect (() => {
- window.sidebar.props_sidebar.cpu_graph.points = libvirt_machine.cpu_stats;
- window.sidebar.props_sidebar.net_graph.points = libvirt_machine.net_stats;
- window.sidebar.props_sidebar.io_graph.points = libvirt_machine.io_stats;
+ sidebar.cpu_graph.points = libvirt_machine.cpu_stats;
+ sidebar.net_graph.points = libvirt_machine.net_stats;
+ sidebar.io_graph.points = libvirt_machine.io_stats;
});
}
diff --git a/src/topbar.vala b/src/topbar.vala
index 85e6527..f20156c 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -4,14 +4,12 @@ using Gtk;
public enum Boxes.TopbarPage {
COLLECTION,
SELECTION,
- WIZARD,
- PROPERTIES,
DISPLAY
}
[GtkTemplate (ui = "/org/gnome/Boxes/ui/topbar.ui")]
private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
- private const string[] page_names = { "collection", "selection", "wizard", "properties", "display" };
+ private const string[] page_names = { "collection", "selection", "display" };
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
@@ -22,44 +20,19 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
private SelectionToolbar selection_toolbar;
[GtkChild]
private DisplayToolbar display_toolbar;
- [GtkChild]
- public WizardToolbar wizard_toolbar;
-
- [GtkChild]
- private PropertiesToolbar props_toolbar;
private AppWindow window;
// Clicks the appropriate back button depending on the ui state.
public void click_back_button () {
- switch (window.ui_state) {
- case UIState.PROPERTIES:
- break;
- case UIState.CREDS:
+ if (window.ui_state == UIState.CREDS)
collection_toolbar.click_back_button ();
- break;
- case UIState.WIZARD:
- wizard_toolbar.click_back_button ();
- break;
- }
- }
-
- // Clicks the appropriate forward button dependent on the ui state.
- public void click_forward_button () {
- wizard_toolbar.click_forward_button ();
}
// Clicks the appropriate cancel button dependent on the ui state.
public void click_cancel_button () {
- switch (window.ui_state) {
- case UIState.COLLECTION:
- if (window.selection_mode)
- window.selection_mode = false;
- return;
- case UIState.WIZARD:
- wizard_toolbar.cancel_btn.clicked ();
- return;
- }
+ if (window.ui_state == UIState.COLLECTION && window.selection_mode)
+ window.selection_mode = false;
}
public void click_new_button () {
@@ -114,7 +87,6 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
collection_toolbar.setup_ui (window);
selection_toolbar.setup_ui (window);
display_toolbar.setup_ui (window);
- props_toolbar.setup_ui (window);
}
private void ui_state_changed () {
@@ -131,14 +103,6 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
page = TopbarPage.DISPLAY;
break;
- case UIState.PROPERTIES:
- page = TopbarPage.PROPERTIES;
- break;
-
- case UIState.WIZARD:
- page = TopbarPage.WIZARD;
- break;
-
default:
break;
}
diff --git a/src/wizard-dialog.vala b/src/wizard-dialog.vala
new file mode 100644
index 0000000..eaeb175
--- /dev/null
+++ b/src/wizard-dialog.vala
@@ -0,0 +1,81 @@
+// This file is part of GNOME Boxes. License: LGPLv2+
+using Gtk;
+
+[GtkTemplate (ui = "/org/gnome/Boxes/ui/wizard-dialog.ui")]
+private class Boxes.WizardDialog : Gtk.Dialog, Boxes.UI {
+ public UIState previous_ui_state { get; protected set; }
+ public UIState ui_state { get; protected set; }
+
+ [GtkChild]
+ public WizardSidebar sidebar;
+ [GtkChild]
+ public Wizard wizard;
+
+ [GtkChild]
+ public Button back_btn;
+ [GtkChild]
+ public Button continue_btn;
+ [GtkChild]
+ public Button create_btn;
+
+ public WizardDialog (AppWindow app_window) {
+ wizard.setup_ui (app_window, this);
+
+ set_transient_for (app_window);
+
+ notify["ui-state"].connect (ui_state_changed);
+ }
+
+ private void ui_state_changed () {
+ wizard.set_state (ui_state);
+
+ this.visible = (ui_state == UIState.WIZARD);
+ }
+
+ [GtkCallback]
+ public bool on_key_pressed (Widget widget, Gdk.EventKey event) {
+ var default_modifiers = Gtk.accelerator_get_default_mod_mask ();
+
+ if (event.keyval == Gdk.Key.Left && // ALT + Left -> back
+ (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
+ if (back_btn.sensitive)
+ back_btn.clicked ();
+ return true;
+ } else if (event.keyval == Gdk.Key.Right && // ALT + Right -> forward
+ (event.state & default_modifiers) == Gdk.ModifierType.MOD1_MASK) {
+ if (continue_btn.sensitive)
+ continue_btn.clicked ();
+ return true;
+ }
+
+ return false;
+ }
+
+ [GtkCallback]
+ private bool on_delete_event () {
+ wizard.cancel ();
+
+ return true;
+ }
+
+ [GtkCallback]
+ private void on_cancel_btn_clicked () {
+ wizard.cancel ();
+ }
+
+ [GtkCallback]
+ private void on_back_btn_clicked () {
+ wizard.cancel_prepare ();
+ wizard.page = wizard.page - 1;
+ }
+
+ [GtkCallback]
+ private void on_continue_btn_clicked () {
+ wizard.page = wizard.page + 1;
+ }
+
+ [GtkCallback]
+ private void on_create_btn_clicked () {
+ wizard.page = WizardPage.LAST;
+ }
+}
diff --git a/src/wizard.vala b/src/wizard.vala
index 082a2f0..ef06a12 100644
--- a/src/wizard.vala
+++ b/src/wizard.vala
@@ -19,7 +19,6 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
public UIState previous_ui_state { get; protected set; }
public UIState ui_state { get; protected set; }
- private Gtk.Button cancel_button;
private Gtk.Button back_button;
private Gtk.Button next_button;
private Gtk.Button continue_button;
@@ -60,7 +59,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
private WizardPage _page;
public WizardPage page {
get { return _page; }
- private set {
+ set {
back_button.sensitive = (value != WizardPage.INTRODUCTION);
var forwards = value > page;
@@ -135,7 +134,7 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
return;
_page = value;
- window.sidebar.wizard_sidebar.set_page (value);
+ window.wizard_dialog.sidebar.set_page (value);
visible_child_name = page_names[value];
if (value == WizardPage.SOURCE)
@@ -615,30 +614,12 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
prepare (progress);
}
- public void setup_ui (AppWindow window) {
+ public void setup_ui (AppWindow window, WizardDialog dialog) {
this.window = window;
- cancel_button = window.topbar.wizard_toolbar.cancel_btn;
- cancel_button.clicked.connect (() => {
- cleanup ();
- wizard_source.page = SourcePage.MAIN;
- window.set_state (UIState.COLLECTION);
- });
- back_button = window.topbar.wizard_toolbar.back_btn;
- back_button.clicked.connect (() => {
- if (prepare_cancellable != null)
- prepare_cancellable.cancel ();
-
- page = page - 1;
- });
- continue_button = window.topbar.wizard_toolbar.continue_btn;
- continue_button.clicked.connect (() => {
- page = page + 1;
- });
- create_button = window.topbar.wizard_toolbar.create_btn;
- create_button.clicked.connect (() => {
- page = WizardPage.LAST;
- });
+ back_button = dialog.back_btn;
+ continue_button = dialog.continue_btn;
+ create_button = dialog.create_btn;
wizard_source.setup_ui (window);
}
@@ -653,6 +634,17 @@ private class Boxes.Wizard: Gtk.Stack, Boxes.UI {
page = WizardPage.PREPARATION;
}
+ public void cancel () {
+ cleanup ();
+ wizard_source.page = SourcePage.MAIN;
+ window.set_state (UIState.COLLECTION);
+ }
+
+ public void cancel_prepare () {
+ if (prepare_cancellable != null)
+ prepare_cancellable.cancel ();
+ }
+
private void ui_state_changed () {
if (ui_state != UIState.WIZARD)
return;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]