Commit 4aec23aa authored by Isabella Ribeiro's avatar Isabella Ribeiro Committed by Florian Müllner
Browse files

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
parent e6760052
......@@ -52,15 +52,10 @@
<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>
......@@ -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>
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment