[polari/wip/fmuellner/connection-list: 16/22] connections: Use template for properties dialog
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/connection-list: 16/22] connections: Use template for properties dialog
- Date: Tue, 16 Feb 2016 13:28:42 +0000 (UTC)
commit b4bb05ff622fe5f08543f39caaa9bb09156aa0f2
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Feb 3 23:13:45 2016 +0100
connections: Use template for properties dialog
We are about to move some UI from connection details into the properties
dialog, so this seems like a good moment to start using GtkBuilder.
Also templates are great.
https://bugzilla.gnome.org/show_bug.cgi?id=761859
data/org.gnome.Polari.data.gresource.xml | 1 +
data/resources/connection-properties.ui | 43 ++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
src/connections.js | 21 +++------------
4 files changed, 49 insertions(+), 17 deletions(-)
---
diff --git a/data/org.gnome.Polari.data.gresource.xml b/data/org.gnome.Polari.data.gresource.xml
index 914812b..2b6537a 100644
--- a/data/org.gnome.Polari.data.gresource.xml
+++ b/data/org.gnome.Polari.data.gresource.xml
@@ -5,6 +5,7 @@
<file alias="gtk/help-overlay.ui" preprocess="xml-stripblanks">resources/help-overlay.ui</file>
<file alias="gtk/menus.ui" preprocess="xml-stripblanks">resources/menus.ui</file>
<file alias="ui/connection-details.ui"
preprocess="xml-stripblanks">resources/connection-details.ui</file>
+ <file alias="ui/connection-properties.ui"
preprocess="xml-stripblanks">resources/connection-properties.ui</file>
<file alias="ui/entry-area.ui" preprocess="xml-stripblanks">resources/entry-area.ui</file>
<file alias="ui/join-room-dialog.ui" preprocess="xml-stripblanks">resources/join-room-dialog.ui</file>
<file alias="ui/main-window.ui" preprocess="xml-stripblanks">resources/main-window.ui</file>
diff --git a/data/resources/connection-properties.ui b/data/resources/connection-properties.ui
new file mode 100644
index 0000000..dbffb9e
--- /dev/null
+++ b/data/resources/connection-properties.ui
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="Gjs_ConnectionProperties" parent="GtkDialog">
+ <property name="modal">True</property>
+ <property name="destroy-with-parent">True</property>
+ <property name="default-width">450</property>
+ <child type="action">
+ <object class="GtkButton" id="cancelButton">
+ <property name="label" translatable="yes">_Cancel</property>
+ <property name="visible">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="applyButton">
+ <property name="label" translatable="yes">_Apply</property>
+ <property name="visible">True</property>
+ <property name="can-default">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ <property name="sensitive" bind-source="details"
+ bind-property="can-confirm" bind-flags="sync-create"/>
+ </object>
+ </child>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="border-width">0</property>
+ <child>
+ <object class="Gjs_ConnectionDetails" id="details">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="cancel">cancelButton</action-widget>
+ <action-widget response="ok">applyButton</action-widget>
+ </action-widgets>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 83eb945..5324e01 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -2,6 +2,7 @@ data/appdata/org.gnome.Polari.appdata.xml.in
data/org.gnome.Polari.desktop.in
data/org.gnome.Polari.gschema.xml
[type: gettext/glade]data/resources/connection-details.ui
+[type: gettext/glade]data/resources/connection-properties.ui
[type: gettext/glade]data/resources/entry-area.ui
[type: gettext/glade]data/resources/help-overlay.ui
[type: gettext/glade]data/resources/join-room-dialog.ui
diff --git a/src/connections.js b/src/connections.js
index 7e574d5..e1efb02 100644
--- a/src/connections.js
+++ b/src/connections.js
@@ -230,35 +230,22 @@ const ConnectionDetails = new Lang.Class({
const ConnectionProperties = new Lang.Class({
Name: 'ConnectionProperties',
Extends: Gtk.Dialog,
+ Template: 'resource:///org/gnome/Polari/ui/connection-properties.ui',
+ InternalChildren: ['details'],
_init: function(account) {
/* Translators: %s is a connection name */
let title = _("“%s” Properties").format(account.display_name);
this.parent({ title: title,
- modal: true,
- destroy_with_parent: true,
- use_header_bar: 1,
- default_width: 450 });
+ use_header_bar: 1 });
- this.get_content_area().border_width = 0;
+ this._details.account = account;
this.connect('response', Lang.bind(this,
function(w, response) {
if (response == Gtk.ResponseType.OK)
this._details.save();
}));
-
- this.add_button(_("_Cancel"), Gtk.ResponseType.CANCEL);
-
- this._confirmButton = this.add_button(_("A_pply"), Gtk.ResponseType.OK);
- this._confirmButton.get_style_context().add_class('suggested-action');
-
- this._details = new ConnectionDetails();
- this._details.account = account;
- this._details.bind_property('can-confirm',
- this._confirmButton, 'sensitive',
- GObject.BindingFlags.SYNC_CREATE);
- this.get_content_area().add(this._details);
this.set_default_response(Gtk.ResponseType.OK);
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]