[polari/wip/fmuellner/room-list: 23/23] joinDialog: Include room list in join dialog



commit 4aec23aacfd2310833320dbf19ea70c76d7f4f94
Author: Isabella Ribeiro <belinhacbr gmail com>
Date:   Wed Mar 23 21:54:00 2016 -0400

    joinDialog: Include room list in join dialog
    
    Currently users have to know exactly which rooms they want to join
    and type in the exact name (either in the join dialog or as parameter
    to the /join command). It is often more convenient to browse the list
    of existing rooms and pick from that instead, so include that list
    in the join dialog.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763200

 data/resources/join-room-dialog.ui |   79 ++++++++++++++++++++++-------------
 src/joinDialog.js                  |   38 ++++++++++++-----
 2 files changed, 77 insertions(+), 40 deletions(-)
---
diff --git a/data/resources/join-room-dialog.ui b/data/resources/join-room-dialog.ui
index d23f682..56791f8 100644
--- a/data/resources/join-room-dialog.ui
+++ b/data/resources/join-room-dialog.ui
@@ -52,16 +52,11 @@
             <child>
               <object class="GtkGrid">
                 <property name="visible">True</property>
-                <property name="margin">24</property>
-                <property name="row-spacing">6</property>
+                <property name="margin">30</property>
+                <property name="margin-bottom">24</property>
+                <property name="row-spacing">18</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>
-                </child>
-                <child>
                   <object class="GtkLabel">
                     <property name="visible">True</property>
                     <property name="halign">end</property>
@@ -104,31 +99,57 @@
                   </object>
                 </child>
                 <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</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">nameEntry</property>
-                  </object>
-                  <packing>
-                    <property name="left-attach">1</property>
-                    <property name="top-attach">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkEntry" id="nameEntry">
+                  <object class="GtkBox">
                     <property name="visible">True</property>
-                    <property name="hexpand">True</property>
-                    <property name="margin-top">24</property>
-                    <property name="activates-default">True</property>
-                    <property name="completion">nameCompletion</property>
+                    <property name="orientation">vertical</property>
+                    <property name="spacing">18</property>
+                    <child>
+                      <object class="GtkBox">
+                        <property name="visible">True</property>
+                        <property name="orientation">vertical</property>
+                        <style>
+                          <class name="linked"/>
+                          <class name="frame"/>
+                        </style>
+                        <child>
+                          <object class="GtkBox">
+                            <property name="visible">True</property>
+                            <style>
+                              <class name="polari-listbox-filterbar"/>
+                            </style>
+                            <child>
+                              <object class="GtkSearchEntry" id="nameEntry">
+                                <property name="visible">True</property>
+                                <property name="hexpand">True</property>
+                                <property name="margin">60</property>
+                                <property name="margin-top">6</property>
+                                <property name="margin-bottom">6</property>
+                                <property name="margin-end">22</property>
+                                <property name="placeholder-text" translatable="yes">Enter room name to 
add</property>
+                              </object>
+                            </child>
+                            <child>
+                              <object class="GtkSpinner" id="spinner">
+                                <property name="visible">True</property>
+                                <property name="margin-end">22</property>
+                              </object>
+                            </child>
+                          </object>
+                         </child>
+                        <child>
+                          <object class="Gjs_ServerRoomList" id="serverRoomList">
+                            <property name="visible">True</property>
+                            <property name="vexpand">True</property>
+                            <property name="hscrollbar-policy">never</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
                   </object>
                   <packing>
-                    <property name="left-attach">2</property>
+                    <property name="width">3</property>
+                    <property name="left-attach">0</property>
                     <property name="top-attach">1</property>
-                    <property name="width">2</property>
                   </packing>
                 </child>
               </object>
diff --git a/src/joinDialog.js b/src/joinDialog.js
index 8c7f2be..6660f75 100644
--- a/src/joinDialog.js
+++ b/src/joinDialog.js
@@ -4,6 +4,7 @@ const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
 const Tp = imports.gi.TelepathyGLib;
 const Tpl = imports.gi.TelepathyLogger;
+const GObject = imports.gi.GObject;
 
 const AccountsMonitor = imports.accountsMonitor;
 const Connections = imports.connections;
@@ -24,11 +25,13 @@ const JoinDialog = new Lang.Class({
                        'mainStack',
                        'connectionCombo',
                        'connectionButton',
-                       'nameEntry',
                        'nameCompletion',
                        'connectionStack',
                        'filterEntry',
                        'connectionsList',
+                       'serverRoomList',
+                       'nameEntry',
+                       'spinner',
                        'details',
                        'addButton',
                        'customToggle'],
@@ -112,6 +115,10 @@ const JoinDialog = new Lang.Class({
 
         this._nameEntry.connect('changed',
                                 Lang.bind(this, this._updateCanJoin));
+        this._serverRoomList.connect('notify::can-join',
+                                     Lang.bind(this, this._updateCanJoin));
+        this._serverRoomList.bind_property('loading', this._spinner, 'active',
+                                            GObject.BindingFlags.SYNC_CREATE);
     },
 
     _setupConnectionPage: function() {
@@ -191,6 +198,8 @@ const JoinDialog = new Lang.Class({
                     }
                 }
             }));
+
+       this._serverRoomList.setAccount(account);
     },
 
     _onAccountCreated: function(w, account) {
@@ -203,16 +212,21 @@ const JoinDialog = new Lang.Class({
         let selected = this._connectionCombo.get_active_text();
         let account = this._accounts[selected];
 
-        let room = this._nameEntry.get_text();
-        if (room[0] != '#')
-            room = '#' + room;
+        let toJoinRooms = this._serverRoomList.selectedRooms;
+        if (this._nameEntry.get_text_length() > 0)
+            toJoinRooms.push(this._nameEntry.get_text());
 
-        let app = Gio.Application.get_default();
-        let action = app.lookup_action('join-room');
-        action.activate(GLib.Variant.new('(ssu)',
-                                         [ account.get_object_path(),
-                                           room,
-                                           Utils.getTpEventTime() ]));
+        toJoinRooms.forEach(function(room) {
+            if (room[0] != '#')
+                room = '#' + room;
+
+            let app = Gio.Application.get_default();
+            let action = app.lookup_action('join-room');
+            action.activate(GLib.Variant.new('(ssu)',
+                                             [ account.get_object_path(),
+                                             room,
+                                             Utils.getTpEventTime() ]));
+        });
     },
 
     _updateConnectionCombo: function() {
@@ -237,9 +251,11 @@ const JoinDialog = new Lang.Class({
 
     _updateCanJoin: function() {
         let sensitive = false;
+
         if (this._page == DialogPage.MAIN)
             sensitive = this._connectionCombo.get_active() > -1  &&
-                        this._nameEntry.get_text_length() > 0;
+                        (this._nameEntry.get_text_length() > 0 ||
+                        this._serverRoomList.can_join);
 
         this._joinButton.sensitive = sensitive;
         this.set_default_response(sensitive ? Gtk.ResponseType.OK


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]