Fix join groupchat dialog with multiple accounts
The dialog didnt show the account combobox when activated via CTRL + J from the Roster Also add a application action for join groupchat
This commit is contained in:
parent
129f72bf8e
commit
ce9af46fc3
5 changed files with 32 additions and 24 deletions
|
@ -120,16 +120,17 @@ def on_service_disco(action, param):
|
||||||
|
|
||||||
|
|
||||||
def on_join_gc(action, param):
|
def on_join_gc(action, param):
|
||||||
account = param.get_string()
|
account = None
|
||||||
invisible_show = app.SHOW_LIST.index('invisible')
|
if param is None:
|
||||||
if app.connections[account].connected == invisible_show:
|
if not app.get_connected_accounts():
|
||||||
app.interface.raise_dialog('join-while-invisible')
|
|
||||||
return
|
return
|
||||||
if 'join_gc' in interface.instances[account]:
|
|
||||||
interface.instances[account]['join_gc'].present()
|
|
||||||
else:
|
else:
|
||||||
interface.instances[account]['join_gc'] = \
|
account = param.get_string()
|
||||||
|
window = app.get_app_window(dialogs.JoinGroupchatWindow)
|
||||||
|
if window is None:
|
||||||
dialogs.JoinGroupchatWindow(account, None)
|
dialogs.JoinGroupchatWindow(account, None)
|
||||||
|
else:
|
||||||
|
window.present()
|
||||||
|
|
||||||
|
|
||||||
def on_add_contact(action, param):
|
def on_add_contact(action, param):
|
||||||
|
|
|
@ -303,6 +303,7 @@ class GajimApplication(Gtk.Application):
|
||||||
('quit', app_actions.on_quit),
|
('quit', app_actions.on_quit),
|
||||||
('accounts', app_actions.on_accounts),
|
('accounts', app_actions.on_accounts),
|
||||||
('add-account', app_actions.on_add_account),
|
('add-account', app_actions.on_add_account),
|
||||||
|
('join-groupchat', app_actions.on_join_gc),
|
||||||
('manage-proxies', app_actions.on_manage_proxies),
|
('manage-proxies', app_actions.on_manage_proxies),
|
||||||
('start-chat', app_actions.on_new_chat),
|
('start-chat', app_actions.on_new_chat),
|
||||||
('bookmarks', app_actions.on_manage_bookmarks),
|
('bookmarks', app_actions.on_manage_bookmarks),
|
||||||
|
|
|
@ -577,3 +577,9 @@ def prefers_app_menu():
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
return False
|
return False
|
||||||
return app.prefers_app_menu()
|
return app.prefers_app_menu()
|
||||||
|
|
||||||
|
def get_app_window(cls):
|
||||||
|
for win in app.get_windows():
|
||||||
|
if isinstance(win, cls):
|
||||||
|
return win
|
||||||
|
return None
|
||||||
|
|
|
@ -2351,10 +2351,10 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
|
||||||
else:
|
else:
|
||||||
for widget in extended_widgets:
|
for widget in extended_widgets:
|
||||||
getattr(self, widget).show()
|
getattr(self, widget).show()
|
||||||
self._fill_recent_and_servers(account)
|
|
||||||
|
|
||||||
if account is None:
|
if account is None:
|
||||||
connected_accounts = app.get_connected_accounts()
|
connected_accounts = app.get_connected_accounts()
|
||||||
|
account = connected_accounts[0]
|
||||||
for acc in connected_accounts:
|
for acc in connected_accounts:
|
||||||
self.account_combo.append_text(acc)
|
self.account_combo.append_text(acc)
|
||||||
else:
|
else:
|
||||||
|
@ -2378,8 +2378,6 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
# Select first account
|
# Select first account
|
||||||
self.account_combo.set_active(0)
|
self.account_combo.set_active(0)
|
||||||
if self.minimal_mode == 0:
|
|
||||||
self.recent_combo.set_active(0)
|
|
||||||
|
|
||||||
if self.password is not None:
|
if self.password is not None:
|
||||||
self.password_entry.set_text(self.password)
|
self.password_entry.set_text(self.password)
|
||||||
|
@ -2405,12 +2403,15 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
|
||||||
self.server_combo.get_child().set_text(server)
|
self.server_combo.get_child().set_text(server)
|
||||||
|
|
||||||
def _fill_recent_and_servers(self, account):
|
def _fill_recent_and_servers(self, account):
|
||||||
|
self.recent_combo.remove_all()
|
||||||
|
self.server_combo.remove_all()
|
||||||
recent = app.get_recent_groupchats(account)
|
recent = app.get_recent_groupchats(account)
|
||||||
servers = []
|
servers = []
|
||||||
for groupchat in recent:
|
for groupchat in recent:
|
||||||
text = '%s on %s@%s' % (groupchat.nickname,
|
text = '%s on %s@%s' % (groupchat.nickname,
|
||||||
groupchat.room,
|
groupchat.room,
|
||||||
groupchat.server)
|
groupchat.server)
|
||||||
|
|
||||||
self.recent_combo.append_text(text)
|
self.recent_combo.append_text(text)
|
||||||
servers.append(groupchat.server)
|
servers.append(groupchat.server)
|
||||||
|
|
||||||
|
@ -2435,7 +2436,11 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
def _on_account_combo_changed(self, combo):
|
def _on_account_combo_changed(self, combo):
|
||||||
account = combo.get_active_text()
|
account = combo.get_active_text()
|
||||||
|
self.account = account
|
||||||
self.nick_entry.set_text(app.nicks[account])
|
self.nick_entry.set_text(app.nicks[account])
|
||||||
|
if self.minimal_mode == 0:
|
||||||
|
self._fill_recent_and_servers(account)
|
||||||
|
self.recent_combo.set_active(0)
|
||||||
|
|
||||||
def _on_key_press_event(self, widget, event):
|
def _on_key_press_event(self, widget, event):
|
||||||
if event.keyval == Gdk.KEY_Escape:
|
if event.keyval == Gdk.KEY_Escape:
|
||||||
|
@ -2448,6 +2453,11 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
|
||||||
account = self.account_combo.get_active_text()
|
account = self.account_combo.get_active_text()
|
||||||
nickname = self.nick_entry.get_text()
|
nickname = self.nick_entry.get_text()
|
||||||
|
|
||||||
|
invisible_show = app.SHOW_LIST.index('invisible')
|
||||||
|
if app.connections[account].connected == invisible_show:
|
||||||
|
app.interface.raise_dialog('join-while-invisible')
|
||||||
|
return
|
||||||
|
|
||||||
if self.minimal_mode < 2:
|
if self.minimal_mode < 2:
|
||||||
if self.minimal_mode == 0:
|
if self.minimal_mode == 0:
|
||||||
server = self.server_combo.get_active_text()
|
server = self.server_combo.get_active_text()
|
||||||
|
@ -2526,7 +2536,6 @@ class JoinGroupchatWindow(Gtk.ApplicationWindow):
|
||||||
|
|
||||||
def _on_destroy(self, *args):
|
def _on_destroy(self, *args):
|
||||||
if self.minimal_mode == 0:
|
if self.minimal_mode == 0:
|
||||||
del app.interface.instances[self.account]['join_gc']
|
|
||||||
app.ged.remove_event_handler('agent-info-received', ged.GUI1,
|
app.ged.remove_event_handler('agent-info-received', ged.GUI1,
|
||||||
self._nec_agent_info_received)
|
self._nec_agent_info_received)
|
||||||
app.ged.remove_event_handler('agent-info-error-received', ged.GUI1,
|
app.ged.remove_event_handler('agent-info-error-received', ged.GUI1,
|
||||||
|
|
|
@ -3626,16 +3626,7 @@ class RosterWindow:
|
||||||
"""
|
"""
|
||||||
When the join gc menuitem is clicked, show the join gc window
|
When the join gc menuitem is clicked, show the join gc window
|
||||||
"""
|
"""
|
||||||
invisible_show = app.SHOW_LIST.index('invisible')
|
app.app.activate_action('join-groupchat')
|
||||||
if app.connections[account].connected == invisible_show:
|
|
||||||
dialogs.ErrorDialog(_('You cannot join a group chat while you are '
|
|
||||||
'invisible'))
|
|
||||||
return
|
|
||||||
if 'join_gc' in app.interface.instances[account]:
|
|
||||||
app.interface.instances[account]['join_gc'].present()
|
|
||||||
else:
|
|
||||||
app.interface.instances[account]['join_gc'] = \
|
|
||||||
dialogs.JoinGroupchatWindow(account, None)
|
|
||||||
|
|
||||||
def on_show_transports_action(self, action, param):
|
def on_show_transports_action(self, action, param):
|
||||||
app.config.set('show_transports_group', param.get_boolean())
|
app.config.set('show_transports_group', param.get_boolean())
|
||||||
|
|
Loading…
Add table
Reference in a new issue