Philipp Hörist pushed to branch master at gajim / gajim

Commits:

7 changed files:

Changes:

  • gajim/app_actions.py
    ... ... @@ -96,11 +96,17 @@ def on_quit(action, param):
    96 96
         interface.roster.on_quit_request()
    
    97 97
     
    
    98 98
     
    
    99
    -def on_new_chat(action, param):
    
    100
    -    if 'start_chat' in app.interface.instances:
    
    101
    -        app.interface.instances['start_chat'].present()
    
    99
    +def on_new_chat(_action, param):
    
    100
    +    search_text = param.get_string()
    
    101
    +    window = app.get_app_window(StartChatDialog)
    
    102
    +    if window is None:
    
    103
    +        window = StartChatDialog()
    
    102 104
         else:
    
    103
    -        app.interface.instances['start_chat'] = StartChatDialog()
    
    105
    +        window.present()
    
    106
    +
    
    107
    +    if search_text:
    
    108
    +        window.set_search_text(search_text)
    
    109
    +
    
    104 110
     
    
    105 111
     # Accounts Actions
    
    106 112
     
    
    ... ... @@ -376,12 +382,6 @@ def start_chat(_action, param):
    376 382
         app.interface.new_chat_from_jid(account, jid)
    
    377 383
     
    
    378 384
     
    
    379
    -def join_groupchat(_action, param):
    
    380
    -    account, jid = param.get_strv()
    
    381
    -    room_jid = jid.split('?')[0]
    
    382
    -    app.interface.join_gc_minimal(account, room_jid)
    
    383
    -
    
    384
    -
    
    385 385
     def on_browse_history(_action, param):
    
    386 386
         jid, account = None, None
    
    387 387
         if param is not None:
    

  • gajim/application.py
    ... ... @@ -267,9 +267,9 @@ class GajimApplication(Gtk.Application):
    267 267
                     if len(accounts) == 1:
    
    268 268
                         app.interface.new_chat_from_jid(accounts[0], jid, message)
    
    269 269
                     else:
    
    270
    -                    self.activate_action('start-chat')
    
    271
    -                    start_chat_window = app.interface.instances['start_chat']
    
    272
    -                    start_chat_window.search_entry.set_text(jid)
    
    270
    +                    self.activate_action('start-chat', GLib.Variant('s', ''))
    
    271
    +                    start_chat = app.get_app_window('StartChatDialog')
    
    272
    +                    start_chat.set_search_text(jid)
    
    273 273
     
    
    274 274
         def do_shutdown(self, *args):
    
    275 275
             Gtk.Application.do_shutdown(self)
    
    ... ... @@ -395,7 +395,6 @@ class GajimApplication(Gtk.Application):
    395 395
                 ('add-account', app_actions.on_add_account),
    
    396 396
                 ('join-groupchat', app_actions.on_join_gc),
    
    397 397
                 ('manage-proxies', app_actions.on_manage_proxies),
    
    398
    -            ('start-chat', app_actions.on_new_chat),
    
    399 398
                 ('bookmarks', app_actions.on_manage_bookmarks),
    
    400 399
                 ('history-manager', app_actions.on_history_manager),
    
    401 400
                 ('preferences', app_actions.on_preferences),
    
    ... ... @@ -411,6 +410,10 @@ class GajimApplication(Gtk.Application):
    411 410
                 ('show-next-pending-event', app_actions.show_next_pending_event),
    
    412 411
             ]
    
    413 412
     
    
    413
    +        act = Gio.SimpleAction.new('start-chat', GLib.VariantType.new('s'))
    
    414
    +        act.connect("activate", app_actions.on_new_chat)
    
    415
    +        self.add_action(act)
    
    416
    +
    
    414 417
             act = Gio.SimpleAction.new('accounts', GLib.VariantType.new('s'))
    
    415 418
             act.connect("activate", app_actions.on_accounts)
    
    416 419
             self.add_action(act)
    

  • gajim/data/gui/application_menu.ui
    ... ... @@ -71,6 +71,7 @@
    71 71
             <attribute name="label" translatable="yes">Start Chat</attribute>
    
    72 72
             <attribute name="action">app.start-chat</attribute>
    
    73 73
             <attribute name="accel">&lt;Primary&gt;N</attribute>
    
    74
    +        <attribute name="target"></attribute>
    
    74 75
           </item>
    
    75 76
           <item>
    
    76 77
             <attribute name="label" translatable="yes">Create Group Chat</attribute>
    

  • gajim/gtk/start_chat.py
    ... ... @@ -87,6 +87,9 @@ class StartChatDialog(Gtk.ApplicationWindow):
    87 87
             self.select_first_row()
    
    88 88
             self.show_all()
    
    89 89
     
    
    90
    +    def set_search_text(self, text):
    
    91
    +        self._ui.search_entry.set_text(text)
    
    92
    +
    
    90 93
         def add_contacts(self):
    
    91 94
             show_account = len(self.accounts) > 1
    
    92 95
             for account in self.accounts:
    
    ... ... @@ -379,7 +382,6 @@ class StartChatDialog(Gtk.ApplicationWindow):
    379 382
     
    
    380 383
         def _destroy(self, *args):
    
    381 384
             self._destroyed = True
    
    382
    -        del app.interface.instances['start_chat']
    
    383 385
     
    
    384 386
     
    
    385 387
     class ContactRow(Gtk.Grid):
    

  • gajim/gtk/statusicon.py
    ... ... @@ -22,6 +22,7 @@
    22 22
     import os
    
    23 23
     
    
    24 24
     from gi.repository import Gtk
    
    25
    +from gi.repository import GLib
    
    25 26
     
    
    26 27
     from gajim import dialogs
    
    27 28
     
    
    ... ... @@ -170,7 +171,7 @@ class StatusIcon:
    170 171
             SingleMessageWindow(account, action='send')
    
    171 172
     
    
    172 173
         def on_new_chat(self, widget, account):
    
    173
    -        app.app.activate_action('start-chat')
    
    174
    +        app.app.activate_action('start-chat', GLib.Variant('s', ''))
    
    174 175
     
    
    175 176
         def make_menu(self, event_button, event_time):
    
    176 177
             """
    

  • gajim/message_window.py
    ... ... @@ -199,9 +199,9 @@ class MessageWindow:
    199 199
             # again. if destroy() is called from the StartChat Dialog, this
    
    200 200
             # Window is not yet focused, because present() seems to be asynchron
    
    201 201
             # at least on KDE, and takes time.
    
    202
    -        if 'start_chat' in app.interface.instances:
    
    203
    -            if app.interface.instances['start_chat'].ready_to_destroy:
    
    204
    -                app.interface.instances['start_chat'].destroy()
    
    202
    +        start_chat = app.get_app_window('StartChatDialog')
    
    203
    +        if start_chat is not None and start_chat.ready_to_destroy:
    
    204
    +            start_chat.destroy()
    
    205 205
     
    
    206 206
             # window received focus, so if we had urgency REMOVE IT
    
    207 207
             # 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):
    888 888
             if not account:
    
    889 889
                 # error is shown in gajim-remote check_arguments(..)
    
    890 890
                 return False
    
    891
    -        app.app.activate_action('start-chat')
    
    891
    +        app.app.activate_action('start-chat', GLib.Variant('s', ''))
    
    892 892
             return True
    
    893 893
     
    
    894 894
         def send_xml(self, xml, account):