[polari] ui: Let GTK+ construct dialog headerbars
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] ui: Let GTK+ construct dialog headerbars
- Date: Wed, 10 Sep 2014 15:51:56 +0000 (UTC)
commit 2271d5b02d232048edb9c0f4a04056e7facb78e8
Author: Florian Müllner <fmuellner gnome org>
Date: Mon Jul 28 10:53:37 2014 +0200
ui: Let GTK+ construct dialog headerbars
This is now the recommended way to construct dialogs with headerbars,
and it's less code ...
data/resources/join-room-dialog.ui | 74 +++++++++++++++------------------
data/resources/message-user-dialog.ui | 46 ++++++++------------
src/joinDialog.js | 6 +--
src/mainWindow.js | 5 +-
4 files changed, 58 insertions(+), 73 deletions(-)
---
diff --git a/data/resources/join-room-dialog.ui b/data/resources/join-room-dialog.ui
index 194b78e..26d04e7 100644
--- a/data/resources/join-room-dialog.ui
+++ b/data/resources/join-room-dialog.ui
@@ -13,57 +13,49 @@
<property name="inline_completion">True</property>
</object>
<object class="GtkDialog" id="join_room_dialog">
+ <property name="title" translatable="yes">Join Chat Room</property>
<property name="can_focus">False</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="default_width">500</property>
<property name="use_header_bar">1</property>
- <child type="titlebar">
- <object class="GtkHeaderBar" id="titlebar">
- <property name="visible">True</property>
- <property name="title" translatable="yes">Join Chat Room</property>
- <child>
- <object class="GtkButton" id="back_button">
- <property name="visible">False</property>
- <property name="can_focus">True</property>
- <property name="valign">center</property>
- <style>
- <class name="image-button"/>
- </style>
- <child>
- <object class="GtkImage" id="back_icon">
- <property name="visible">True</property>
- <property name="icon_size">1</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- </child>
+ <child type="action">
+ <object class="GtkButton" id="back_button">
+ <property name="visible">False</property>
+ <property name="can_focus">True</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="image-button"/>
+ </style>
<child>
- <object class="GtkButton" id="confirm_button">
- <property name="label" translatable="yes">_Join</property>
+ <object class="GtkImage" id="back_icon">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
+ <property name="icon_size">1</property>
</object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
</child>
</object>
</child>
+ <child type="action">
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="confirm_button">
+ <property name="label" translatable="yes">_Join</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -252,7 +244,9 @@
</object>
</child>
<action-widgets>
- <action-widget response="-6">cancel_button</action-widget>
+ <action-widget response="cancel">cancel_button</action-widget>
+ <action-widget response="ok">confirm_button</action-widget>
+ <action-widget response="help">back_button</action-widget>
</action-widgets>
</object>
</interface>
diff --git a/data/resources/message-user-dialog.ui b/data/resources/message-user-dialog.ui
index 0b0fe4f..02cb565 100644
--- a/data/resources/message-user-dialog.ui
+++ b/data/resources/message-user-dialog.ui
@@ -19,33 +19,24 @@
<property name="modal">True</property>
<property name="type_hint">dialog</property>
<property name="use_header_bar">1</property>
- <child type="titlebar">
- <object class="GtkHeaderBar" id="titlebar">
+ <child type="action">
+ <object class="GtkButton" id="cancel_button">
+ <property name="label" translatable="yes">_Cancel</property>
<property name="visible">True</property>
- <property name="title" translatable="yes">Message User</property>
- <child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- </child>
- <child>
- <object class="GtkButton" id="message_button">
- <property name="label" translatable="yes">_Message</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="message_button">
+ <property name="label" translatable="yes">_Message</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="has_default">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_underline">True</property>
</object>
</child>
<child internal-child="vbox">
@@ -187,7 +178,8 @@
</object>
</child>
<action-widgets>
- <action-widget response="-6">cancel_button</action-widget>
+ <action-widget response="cancel">cancel_button</action-widget>
+ <action-widget response="confirm">message_button</action-widget>
</action-widgets>
</object>
</interface>
diff --git a/src/joinDialog.js b/src/joinDialog.js
index e6b9b2e..07887cc 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -63,8 +63,6 @@ const JoinDialog = new Lang.Class({
this.widget = builder.get_object('join_room_dialog');
- this._titlebar = builder.get_object('titlebar');
-
this._stack = builder.get_object('stack');
this._details = new Connections.ConnectionDetails(null);
@@ -219,8 +217,8 @@ const JoinDialog = new Lang.Class({
this._backButton.visible = !isMain;
this._cancelButton.visible = isMain;
- this._titlebar.title = isMain ? _("Join Chat Room")
- : _("Add Connection");
+ this.widget.title = isMain ? _("Join Chat Room")
+ : _("Add Connection");
this._confirmButton.label = isMain ? _("_Join")
: _("_Save");
this._stack.visible_child_name = isMain ? 'main' : 'connection';
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 699ef8d..37aef80 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -296,8 +296,9 @@ const MainWindow = new Lang.Class({
dialog.widget.transient_for = this.window;
dialog.widget.show();
dialog.widget.connect('response',
- function(widget) {
- widget.destroy();
+ function(widget, response) {
+ if (response != Gtk.ResponseType.HELP)
+ widget.destroy();
});
},
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]