[gnome-boxes] properties-toolbar: Add name title entry
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] properties-toolbar: Add name title entry
- Date: Sat, 16 Aug 2014 16:28:05 +0000 (UTC)
commit b0c71c5ea77a4bf55bcc08eeaab5916d006e8033
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Mar 12 15:30:51 2014 +0100
properties-toolbar: Add name title entry
This allows to edit the machine's name in the title.
https://bugzilla.gnome.org/show_bug.cgi?id=692383
data/ui/properties-toolbar.ui | 13 +++++++++++++
src/machine.vala | 3 +++
src/properties-toolbar.vala | 30 ++++++++++++++++++++++++++++++
src/topbar.vala | 12 ------------
4 files changed, 46 insertions(+), 12 deletions(-)
---
diff --git a/data/ui/properties-toolbar.ui b/data/ui/properties-toolbar.ui
index 79a34f3..b16a6af 100644
--- a/data/ui/properties-toolbar.ui
+++ b/data/ui/properties-toolbar.ui
@@ -30,5 +30,18 @@
</child>
</object>
</child>
+
+ <child type="title">
+ <object class="BoxesEditableEntry" id="title_entry">
+ <property name="visible">True</property>
+ <property name="editable">True</property>
+ <property name="text-xalign">0.5</property>
+ <style>
+ <class name="title"/>
+ </style>
+
+ <signal name="editing_done" handler="on_title_entry_changed"/>
+ </object>
+ </child>
</template>
</interface>
diff --git a/src/machine.vala b/src/machine.vala
index 549bf05..6a90147 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -184,6 +184,9 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
set_screenshot_enable (true);
});
+ notify["name"].connect (() => {
+ status = this.name;
+ });
}
protected void load_screenshot () {
diff --git a/src/properties-toolbar.vala b/src/properties-toolbar.vala
index f8953a4..dced377 100644
--- a/src/properties-toolbar.vala
+++ b/src/properties-toolbar.vala
@@ -5,20 +5,50 @@ using Gtk;
private class Boxes.PropertiesToolbar: HeaderBar {
[GtkChild]
private Image back_image;
+ [GtkChild]
+ private EditableEntry title_entry;
private AppWindow window;
+ private CollectionItem item;
+ private ulong item_name_id;
+
construct {
back_image.icon_name = (get_direction () == TextDirection.RTL)? "go-previous-rtl-symbolic" :
"go-previous-symbolic";
+
+ // Work around for https://bugzilla.gnome.org/show_bug.cgi?id=734676
+ set_custom_title (title_entry);
}
public void setup_ui (AppWindow window) {
this.window = window;
+ window.notify["ui-state"].connect (ui_state_changed);
}
[GtkCallback]
private void on_back_clicked () {
window.set_state (window.previous_ui_state);
}
+
+ [GtkCallback]
+ private void on_title_entry_changed () {
+ window.current_item.name = title_entry.text;
+ }
+
+ private void ui_state_changed () {
+ if (item_name_id != 0) {
+ item.disconnect (item_name_id);
+ item_name_id = 0;
+ }
+
+ if (window.ui_state == UIState.PROPERTIES) {
+ item = window.current_item;
+
+ item_name_id = item.notify["name"].connect (() => {
+ title_entry.text = item.name;
+ });
+ title_entry.text = item.name;
+ }
+ }
}
diff --git a/src/topbar.vala b/src/topbar.vala
index 9b26013..9655ef9 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -28,8 +28,6 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
[GtkChild]
private PropertiesToolbar props_toolbar;
- private GLib.Binding props_name_bind;
-
private AppWindow window;
// Clicks the appropriate back button depending on the ui state.
@@ -74,13 +72,6 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
}
}
- public string properties_title {
- set {
- // Translators: The %s will be replaced with the name of the VM
- props_toolbar.title = _("%s - Properties").printf (window.current_item.name);
- }
- }
-
private TopbarPage _page;
public TopbarPage page {
get { return _page; }
@@ -132,9 +123,6 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
case UIState.PROPERTIES:
page = TopbarPage.PROPERTIES;
- props_name_bind = window.current_item.bind_property ("name",
- this, "properties-title",
- BindingFlags.SYNC_CREATE);
break;
case UIState.WIZARD:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]