Philipp Hörist pushed to branch master at gajim / gajim
Commits: 7310a2ce by Philipp Hörist at 2019-07-09T20:42:33Z Remove unused code
- - - - - 1fa6eeac by Philipp Hörist at 2019-07-09T22:14:34Z StartChat: Add search text argument to action
- Remove usage of instance dict
- - - - -
7 changed files:
- gajim/app_actions.py - gajim/application.py - gajim/data/gui/application_menu.ui - gajim/gtk/start_chat.py - gajim/gtk/statusicon.py - gajim/message_window.py - gajim/remote_control.py
Changes:
===================================== gajim/app_actions.py ===================================== @@ -96,11 +96,17 @@ def on_quit(action, param): interface.roster.on_quit_request()
-def on_new_chat(action, param): - if 'start_chat' in app.interface.instances: - app.interface.instances['start_chat'].present() +def on_new_chat(_action, param): + search_text = param.get_string() + window = app.get_app_window(StartChatDialog) + if window is None: + window = StartChatDialog() else: - app.interface.instances['start_chat'] = StartChatDialog() + window.present() + + if search_text: + window.set_search_text(search_text) +
# Accounts Actions
@@ -376,12 +382,6 @@ def start_chat(_action, param): app.interface.new_chat_from_jid(account, jid)
-def join_groupchat(_action, param): - account, jid = param.get_strv() - room_jid = jid.split('?')[0] - app.interface.join_gc_minimal(account, room_jid) - - def on_browse_history(_action, param): jid, account = None, None if param is not None:
===================================== gajim/application.py ===================================== @@ -267,9 +267,9 @@ class GajimApplication(Gtk.Application): if len(accounts) == 1: app.interface.new_chat_from_jid(accounts[0], jid, message) else: - self.activate_action('start-chat') - start_chat_window = app.interface.instances['start_chat'] - start_chat_window.search_entry.set_text(jid) + self.activate_action('start-chat', GLib.Variant('s', '')) + start_chat = app.get_app_window('StartChatDialog') + start_chat.set_search_text(jid)
def do_shutdown(self, *args): Gtk.Application.do_shutdown(self) @@ -395,7 +395,6 @@ class GajimApplication(Gtk.Application): ('add-account', app_actions.on_add_account), ('join-groupchat', app_actions.on_join_gc), ('manage-proxies', app_actions.on_manage_proxies), - ('start-chat', app_actions.on_new_chat), ('bookmarks', app_actions.on_manage_bookmarks), ('history-manager', app_actions.on_history_manager), ('preferences', app_actions.on_preferences), @@ -411,6 +410,10 @@ class GajimApplication(Gtk.Application): ('show-next-pending-event', app_actions.show_next_pending_event), ]
+ act = Gio.SimpleAction.new('start-chat', GLib.VariantType.new('s')) + act.connect("activate", app_actions.on_new_chat) + self.add_action(act) + act = Gio.SimpleAction.new('accounts', GLib.VariantType.new('s')) act.connect("activate", app_actions.on_accounts) self.add_action(act)
===================================== gajim/data/gui/application_menu.ui ===================================== @@ -71,6 +71,7 @@ <attribute name="label" translatable="yes">Start Chat</attribute> <attribute name="action">app.start-chat</attribute> <attribute name="accel"><Primary>N</attribute> + <attribute name="target"></attribute> </item> <item> <attribute name="label" translatable="yes">Create Group Chat</attribute>
===================================== gajim/gtk/start_chat.py ===================================== @@ -87,6 +87,9 @@ class StartChatDialog(Gtk.ApplicationWindow): self.select_first_row() self.show_all()
+ def set_search_text(self, text): + self._ui.search_entry.set_text(text) + def add_contacts(self): show_account = len(self.accounts) > 1 for account in self.accounts: @@ -379,7 +382,6 @@ class StartChatDialog(Gtk.ApplicationWindow):
def _destroy(self, *args): self._destroyed = True - del app.interface.instances['start_chat']
class ContactRow(Gtk.Grid):
===================================== gajim/gtk/statusicon.py ===================================== @@ -22,6 +22,7 @@ import os
from gi.repository import Gtk +from gi.repository import GLib
from gajim import dialogs
@@ -170,7 +171,7 @@ class StatusIcon: SingleMessageWindow(account, action='send')
def on_new_chat(self, widget, account): - app.app.activate_action('start-chat') + app.app.activate_action('start-chat', GLib.Variant('s', ''))
def make_menu(self, event_button, event_time): """
===================================== gajim/message_window.py ===================================== @@ -199,9 +199,9 @@ class MessageWindow: # again. if destroy() is called from the StartChat Dialog, this # Window is not yet focused, because present() seems to be asynchron # at least on KDE, and takes time. - if 'start_chat' in app.interface.instances: - if app.interface.instances['start_chat'].ready_to_destroy: - app.interface.instances['start_chat'].destroy() + start_chat = app.get_app_window('StartChatDialog') + if start_chat is not None and start_chat.ready_to_destroy: + start_chat.destroy()
# window received focus, so if we had urgency REMOVE IT # NOTE: we do not have to read the message (it maybe in a bg tab)
===================================== gajim/remote_control.py ===================================== @@ -888,7 +888,7 @@ class GajimRemote(Server): if not account: # error is shown in gajim-remote check_arguments(..) return False - app.app.activate_action('start-chat') + app.app.activate_action('start-chat', GLib.Variant('s', '')) return True
def send_xml(self, xml, account):
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/f4225008e9209d75be37b65e01d1cfa1ce...