[polari] joinDialog: Support adding new connections from within the dialog
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] joinDialog: Support adding new connections from within the dialog
- Date: Wed, 8 Jan 2014 20:40:46 +0000 (UTC)
commit c83d5786e609e30c9e6da6cbd413b771ac1ea4b5
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Nov 20 23:28:29 2013 +0100
joinDialog: Support adding new connections from within the dialog
For IRC which does not have a real presence concept, setting up
server connections is a requirement for being able to join a room,
but not very interesting on its own; therefore it makes sense to
allow users to set up the required server connections when joining
a room if necessary, keeping the focus on the primary task rather
than requiring them to hunt down the connection editor first.
https://bugzilla.gnome.org/show_bug.cgi?id=711833
data/resources/join-room-dialog.ui | 351 ++++++++++++++++++++++--------------
src/joinDialog.js | 57 ++++++
2 files changed, 269 insertions(+), 139 deletions(-)
---
diff --git a/data/resources/join-room-dialog.ui b/data/resources/join-room-dialog.ui
index b455a0d..8944747 100644
--- a/data/resources/join-room-dialog.ui
+++ b/data/resources/join-room-dialog.ui
@@ -17,10 +17,27 @@
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
+ <property name="default_width">500</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>
</object>
</child>
<child internal-child="vbox">
@@ -41,167 +58,223 @@
</packing>
</child>
<child>
- <object class="GtkGrid" id="grid1">
+ <object class="GtkStack" id="stack">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_left">12</property>
- <property name="margin_right">12</property>
- <property name="margin_top">36</property>
- <property name="margin_bottom">0</property>
- <property name="row_spacing">12</property>
- <property name="column_spacing">12</property>
- <child>
- <object class="GtkLabel" id="margin">
- <property name="visible">True</property>
- <property name="width_request">24</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="password_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="visibility">False</property>
- <property name="activates_default">True</property>
- <property name="placeholder_text" translatable="yes">optional</property>
- <property name="input_purpose">password</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="name_entry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hexpand">True</property>
- <property name="margin_top">24</property>
- <property name="activates_default">True</property>
- <property name="completion">name_completion</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
+ <property name="transition_type">slide-left-right</property>
<child>
- <object class="GtkComboBoxText" id="connection_combo">
+ <object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="hexpand">True</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="connection_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">C_onnection</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">connection_combo</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="name_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="margin_top">24</property>
- <property name="label" translatable="yes">Room _Name</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">name_entry</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="password_label">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="label" translatable="yes">_Password</property>
- <property name="use_underline">True</property>
- <property name="mnemonic_widget">password_entry</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButtonBox" id="button_box1">
- <property name="visible">True</property>
- <property name="spacing">12</property>
- <property name="margin_top">24</property>
- <property name="vexpand">True</property>
- <property name="valign">end</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
+ <property name="margin_left">12</property>
+ <property name="margin_right">12</property>
+ <property name="margin_top">36</property>
+ <property name="margin_bottom">0</property>
+ <property name="row_spacing">12</property>
+ <property name="column_spacing">12</property>
<child>
- <object class="GtkButton" id="cancel_button">
- <property name="label" translatable="yes">_Cancel</property>
+ <object class="GtkLabel" id="margin">
+ <property name="visible">True</property>
+ <property name="width_request">24</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="password_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
+ <property name="hexpand">True</property>
+ <property name="visibility">False</property>
+ <property name="activates_default">True</property>
+ <property name="placeholder_text" translatable="yes">optional</property>
+ <property name="input_purpose">password</property>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
+ <property name="left_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="join_button">
- <property name="label" translatable="yes">_Join</property>
+ <object class="GtkEntry" id="name_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="margin_top">24</property>
+ <property name="activates_default">True</property>
+ <property name="completion">name_completion</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="width">2</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="add_connection_button">
<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>
+ <child>
+ <object class="GtkBox" id="box1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkImage" id="image1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="icon_name">list-add-symbolic</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Add Connection</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">add_connection_button</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">3</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="connection_combo">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="connection_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">C_onnection</property>
<property name="use_underline">True</property>
+ <property name="mnemonic_widget">connection_combo</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="name_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="margin_top">24</property>
+ <property name="label" translatable="yes">Room _Name</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">name_entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="password_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="label" translatable="yes">_Password</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">password_entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox" id="button_box1">
+ <property name="visible">True</property>
+ <property name="spacing">12</property>
+ <property name="margin_top">24</property>
+ <property name="vexpand">True</property>
+ <property name="valign">end</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</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>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="join_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>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">3</property>
+ <property name="height">1</property>
</packing>
</child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="top_attach">3</property>
- <property name="width">2</property>
- <property name="height">1</property>
+ <property name="name">main</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
diff --git a/src/joinDialog.js b/src/joinDialog.js
index 742f0b0..10a41f3 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -4,10 +4,16 @@ const Gtk = imports.gi.Gtk;
const Tpl = imports.gi.TelepathyLogger;
const AccountsMonitor = imports.accountsMonitor;
+const Connections = imports.connections;
const Lang = imports.lang;
const TP_CURRENT_TIME = GLib.MAXUINT32;
+const DialogPage = {
+ MAIN: 0,
+ CONNECTION: 1
+};
+
const JoinDialog = new Lang.Class({
Name: 'JoinDialog',
@@ -52,6 +58,38 @@ 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);
+ this._stack.add_named(this._details.widget, 'connection');
+
+ this._details.confirmButton.label = "_Save";
+ this._details.setCancelVisible(false);
+
+ this._details.connect('response', Lang.bind(this,
+ function() {
+ this._setPage(DialogPage.MAIN);
+ }));
+
+ this._connectionButton = builder.get_object('add_connection_button');
+ this._connectionButton.connect('clicked', Lang.bind(this,
+ function() {
+ this._setPage(DialogPage.CONNECTION);
+ }));
+ this._backButton = builder.get_object('back_button');
+ this._backButton.connect('clicked', Lang.bind(this,
+ function() {
+ this._setPage(DialogPage.MAIN);
+ }));
+
+ let backIcon = builder.get_object('back_icon');
+ if (backIcon.get_direction() == Gtk.TextDirection.RTL)
+ backIcon.icon_name = 'go-previous-rtl-symbolic';
+ else
+ backIcon.icon_name = 'go-previous-symbolic';
+
this._connectionCombo = builder.get_object('connection_combo');
this._connectionCombo.connect('changed',
Lang.bind(this, this._onAccountChanged));
@@ -66,6 +104,8 @@ const JoinDialog = new Lang.Class({
this._nameEntry = builder.get_object('name_entry');
this._nameEntry.connect('changed',
Lang.bind(this, this._updateCanConfirm));
+
+ this._setPage(DialogPage.MAIN);
},
_onAccountChanged: function() {
@@ -136,5 +176,22 @@ const JoinDialog = new Lang.Class({
let sensitive = this._connectionCombo.get_active() > -1 &&
this._nameEntry.get_text_length() > 0;
this._joinButton.sensitive = sensitive;
+ },
+
+ _setPage: function(page) {
+ let isMain = page == DialogPage.MAIN;
+
+ if (isMain) {
+ this._details.reset();
+
+ this._joinButton.grab_default();
+ } else {
+ this._details.confirmButton.grab_default();
+ }
+
+ this._backButton.visible = !isMain;
+ this._titlebar.title = isMain ? _("Join Chat Room")
+ : _("Add Connection");
+ this._stack.visible_child_name = isMain ? 'main' : 'connection';
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]