[gnome-boxes/wip/wizard-n-props-in-dialog2: 231/233] Put properties in a modal dialog
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes/wip/wizard-n-props-in-dialog2: 231/233] Put properties in a modal dialog
- Date: Thu, 20 Nov 2014 18:03:33 +0000 (UTC)
commit a8fbc4ba17b2c50584b9dd1ba70943d338d6ded5
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Thu Aug 28 18:33:27 2014 +0100
Put properties in a modal dialog
With some UI transitions removed during the port away from clutter, its
better to have it in a dialog.
Known issues:
* This implies that now we can't change name of machine through title
anymore. Main reason is that there seems to be no way to set a custom
widget as title of a dialog but I don't think many will miss this
feature anyway, especially now that its a dialog.
* Page titles are missing in the sidebar when coming to properties from
wizard and hence the ability to switch pages.
https://bugzilla.gnome.org/show_bug.cgi?id=733367
data/gnome-boxes.gresource.xml | 2 +-
data/ui/app-window.ui | 46 -------------------------
data/ui/properties-dialog.ui | 74 ++++++++++++++++++++++++++++++++++++++++
src/Makefile.am | 1 +
src/app-window.vala | 18 ++--------
src/machine.vala | 4 +-
src/properties-dialog.vala | 64 ++++++++++++++++++++++++++++++++++
src/properties-sidebar.vala | 2 +-
src/properties.vala | 21 ++++++-----
src/snapshots-property.vala | 8 ++--
src/topbar.vala | 4 --
11 files changed, 161 insertions(+), 83 deletions(-)
---
diff --git a/data/gnome-boxes.gresource.xml b/data/gnome-boxes.gresource.xml
index 96c9a15..42197bf 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>
diff --git a/data/ui/app-window.ui b/data/ui/app-window.ui
index 6857c87..ed74372 100644
--- a/data/ui/app-window.ui
+++ b/data/ui/app-window.ui
@@ -18,14 +18,6 @@
| | |
| | |-> view = new Boxes.CollectionView ();
| | |
- | | |-> below_bin_hbox = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
- | | | |
- | | | |-> sidebar = new Boxes.Sidebar ();
- | | | |
- | | | |-> content_bin = Gtk.Stack ();
- | | | |
- | | | |-> properties = new Boxes.Properties ();
- | | |
| | |-> empty_boxes = new Boxes.EmptyBoxes ();
| | |
| | |-> display_page = new Boxes.DisplayPage ();
@@ -99,44 +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="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..f965ebf
--- /dev/null
+++ b/data/ui/properties-dialog.ui
@@ -0,0 +1,74 @@
+<?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 ();
+ |
+ |-> close_button (action child) = new Gtk.Button ();
+ -->
+
+ <template class="BoxesPropertiesDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="resizable">False</property>
+ <property name="modal">True</property>
+ <signal name="delete-event" handler="on_delete_event"/>
+
+ <child internal-child="vbox">
+ <object class="GtkBox">
+
+ <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>
+ </object>
+ </child>
+
+ <child type="action">
+ <object class="GtkButton" id="close_button">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="use-underline">True</property>
+ <property name="can-default">True</property>
+ <property name="has-default">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>
+ <action-widgets>
+ <action-widget response="ok" default="true">close_button</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 9cca2aa..e23746b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -123,6 +123,7 @@ gnome_boxes_SOURCES = \
notificationbar.vala \
os-database.vala \
properties.vala \
+ properties-dialog.vala \
properties-sidebar.vala \
properties-toolbar.vala \
remote-machine.vala \
diff --git a/src/app-window.vala b/src/app-window.vala
index dfc33ad..ef0804e 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -61,6 +61,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
}
public WizardDialog wizard_dialog;
+ public PropertiesDialog props_dialog;
[GtkChild]
public Searchbar searchbar;
@@ -71,20 +72,12 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
[GtkChild]
public Selectionbar selectionbar;
[GtkChild]
- public Sidebar sidebar;
- [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;
@@ -134,12 +127,11 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
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 () {
@@ -158,7 +150,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_dialog, empty_boxes })
{
+ foreach (var ui in new Boxes.UI[] { topbar, view, props_dialog, wizard_dialog, empty_boxes }) {
ui.set_state (ui_state);
}
@@ -192,11 +184,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
case UIState.CREDS:
case UIState.DISPLAY:
case UIState.WIZARD:
-
- break;
-
case UIState.PROPERTIES:
- below_bin.visible_child = below_bin_hbox;
break;
diff --git a/src/machine.vala b/src/machine.vala
index 1613940..ae6ddc6 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -427,7 +427,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);
@@ -587,7 +587,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..a5b3e5f
--- /dev/null
+++ b/src/properties-dialog.vala
@@ -0,0 +1,64 @@
+// 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;
+ [GtkChild]
+ public Gtk.Button close_button;
+
+ private unowned AppWindow app_window;
+
+ private GLib.Binding item_name_bind;
+
+ construct {
+ use_header_bar = 1;
+ }
+
+ 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);
+ item_name_bind = null;
+
+ if (ui_state != UIState.PROPERTIES) {
+ this.visible = false;
+
+ return;
+ }
+
+ item_name_bind = app_window.current_item.bind_property ("name", this, "title",
BindingFlags.SYNC_CREATE);
+ this.visible = true;
+ }
+
+ [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 6cee400..d830947 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;
@@ -133,15 +134,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;
@@ -155,11 +155,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;
@@ -170,12 +170,13 @@ private class Boxes.Properties: Gtk.Stack, Boxes.UI {
current_page = PropertiesPage.GENERAL;
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;
@@ -196,9 +197,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/snapshots-property.vala b/src/snapshots-property.vala
index 584d503..1511dc5 100644
--- a/src/snapshots-property.vala
+++ b/src/snapshots-property.vala
@@ -11,13 +11,13 @@ private class Boxes.SnapshotsProperty : Boxes.Property {
set {
if (value == null) {
snapshot_stack.visible_child = snapshot_box;
- machine.window.sidebar.sensitive = true;
- machine.window.topbar.props_toolbar.back_button.sensitive = true;
+ machine.window.props_dialog.sidebar.sensitive = true;
+ machine.window.props_dialog.close_button.sensitive = true;
} else {
activity_label.label = value;
snapshot_stack.visible_child = activity_box;
- machine.window.sidebar.sensitive = false;
- machine.window.topbar.props_toolbar.back_button.sensitive = false;
+ machine.window.props_dialog.sidebar.sensitive = false;
+ machine.window.props_dialog.close_button.sensitive = false;
}
}
}
diff --git a/src/topbar.vala b/src/topbar.vala
index 197be43..0604c86 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -106,10 +106,6 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
page = TopbarPage.DISPLAY;
break;
- case UIState.PROPERTIES:
- page = TopbarPage.PROPERTIES;
- break;
-
default:
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]