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

Commits:

10 changed files:

Changes:

  • gajim/data/other/shortcuts.json
    ... ... @@ -5,7 +5,7 @@
    5 5
         "app.plugins": ["<Primary>E"],
    
    6 6
         "app.xml-console": ["<Primary><Shift>X"],
    
    7 7
         "app.file-transfer": ["<Primary>T"],
    
    8
    -    "app.start-chat::": ["<Primary>N"],
    
    8
    +    "app.start-chat(['', ''])": ["<Primary>N"],
    
    9 9
         "app.create-groupchat::": ["<Primary>G"],
    
    10 10
         "win.change-nickname": ["<Primary><Shift>N"],
    
    11 11
         "win.change-subject": ["<Primary><Shift>S"],
    

  • gajim/gtk/application.py
    ... ... @@ -305,7 +305,8 @@ def _open_uris(self, uris: list[str]) -> None:
    305 305
                             'groupchat-join',
    
    306 306
                             GLib.Variant('as', [accounts[0], jid]))
    
    307 307
                     else:
    
    308
    -                    self.activate_action('start-chat', GLib.Variant('s', jid))
    
    308
    +                    self.activate_action(
    
    309
    +                        'start-chat', GLib.Variant('as', [jid, '']))
    
    309 310
     
    
    310 311
                 elif cmd == 'roster':
    
    311 312
                     self.activate_action('add-contact', GLib.Variant('s', jid))
    
    ... ... @@ -338,7 +339,7 @@ def _command_line(self,
    338 339
             options = command_line.get_options_dict()
    
    339 340
     
    
    340 341
             remote_commands = [
    
    341
    -            ('start-chat', GLib.Variant('s', '')),
    
    342
    +            ('start-chat', GLib.Variant('as', ['', ''])),
    
    342 343
                 ('show', None)
    
    343 344
             ]
    
    344 345
     
    
    ... ... @@ -562,10 +563,11 @@ def _on_quit_action(_action: Gio.SimpleAction,
    562 563
         @staticmethod
    
    563 564
         def _on_new_chat_action(_action: Gio.SimpleAction,
    
    564 565
                                 param: GLib.Variant) -> None:
    
    565
    -        window = open_window('StartChatDialog')
    
    566
    -        search_text = param.get_string()
    
    567
    -        if search_text:
    
    568
    -            window.set_search_text(search_text)
    
    566
    +
    
    567
    +        jid, initial_message = param.get_strv()
    
    568
    +        open_window('StartChatDialog',
    
    569
    +                    jid=jid or None,
    
    570
    +                    initial_message=initial_message or None)
    
    569 571
     
    
    570 572
         @staticmethod
    
    571 573
         def _on_profile_action(_action: Gio.SimpleAction,
    

  • gajim/gtk/chat_list.py
    ... ... @@ -337,7 +337,7 @@ def _set_placeholder(self) -> None:
    337 337
     
    
    338 338
         @staticmethod
    
    339 339
         def _on_start_chat_clicked(_button: Gtk.Button) -> None:
    
    340
    -        app.app.activate_action('start-chat', GLib.Variant('s', ''))
    
    340
    +        app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
    
    341 341
     
    
    342 342
         def set_filter(self, name: str) -> None:
    
    343 343
             self._current_filter = name
    

  • gajim/gtk/chat_page.py
    ... ... @@ -16,6 +16,7 @@
    16 16
     
    
    17 17
     from typing import Any
    
    18 18
     from typing import Literal
    
    19
    +from typing import Optional
    
    19 20
     from typing import TYPE_CHECKING
    
    20 21
     
    
    21 22
     import logging
    
    ... ... @@ -127,7 +128,7 @@ def get_chat_stack(self) -> ChatStack:
    127 128
     
    
    128 129
         @staticmethod
    
    129 130
         def _on_start_chat_clicked(_button: Gtk.Button) -> None:
    
    130
    -        app.app.activate_action('start-chat', GLib.Variant('s', ''))
    
    131
    +        app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
    
    131 132
     
    
    132 133
         @staticmethod
    
    133 134
         def _on_button_release(paned: Gtk.Paned, event: Gdk.EventButton) -> None:
    
    ... ... @@ -222,7 +223,8 @@ def add_chat_for_workspace(self,
    222 223
                                    type_: str,
    
    223 224
                                    pinned: bool = False,
    
    224 225
                                    position: int = -1,
    
    225
    -                               select: bool = False) -> None:
    
    226
    +                               select: bool = False,
    
    227
    +                               message: Optional[str] = None) -> None:
    
    226 228
     
    
    227 229
             client = app.get_client(account)
    
    228 230
     
    
    ... ... @@ -247,6 +249,9 @@ def add_chat_for_workspace(self,
    247 249
                 if select:
    
    248 250
                     self._chat_list_stack.select_chat(account, jid)
    
    249 251
                 self._chat_list_stack.store_open_chats(workspace_id)
    
    252
    +            if message is not None:
    
    253
    +                message_input = self._chat_stack.get_message_input()
    
    254
    +                message_input.insert_text(message)
    
    250 255
     
    
    251 256
         def load_workspace_chats(self, workspace_id: str) -> None:
    
    252 257
             open_chats = app.settings.get_workspace_setting(workspace_id,
    

  • gajim/gtk/chat_stack.py
    ... ... @@ -794,4 +794,4 @@ def __init__(self):
    794 794
             self.add(button)
    
    795 795
     
    
    796 796
         def _on_start_chatting(self, _button: Gtk.Button) -> None:
    
    797
    -        app.app.activate_action('start-chat', GLib.Variant('s', ''))
    797
    +        app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))

  • gajim/gtk/const.py
    ... ... @@ -181,7 +181,7 @@ def __str__(self):
    181 181
         ('remove-history', 'a{sv}'),
    
    182 182
         ('shortcuts', None),
    
    183 183
         ('show', None),
    
    184
    -    ('start-chat', 's'),
    
    184
    +    ('start-chat', 'as'),
    
    185 185
         ('xml-console', None),
    
    186 186
     ]
    
    187 187
     
    

  • gajim/gtk/main.py
    ... ... @@ -712,18 +712,23 @@ def add_chat(self,
    712 712
                      jid: JID,
    
    713 713
                      type_: str,
    
    714 714
                      select: bool = False,
    
    715
    -                 workspace: str = 'default') -> None:
    
    715
    +                 workspace: str = 'default',
    
    716
    +                 message: Optional[str] = None
    
    717
    +                 ) -> None:
    
    718
    +
    
    716 719
             if workspace == 'current':
    
    717 720
                 workspace_id = self.get_active_workspace()
    
    718 721
                 if workspace_id is None:
    
    719 722
                     workspace_id = self._workspace_side_bar.get_first_workspace()
    
    720 723
             else:
    
    721 724
                 workspace_id = self._workspace_side_bar.get_first_workspace()
    
    725
    +
    
    722 726
             self._chat_page.add_chat_for_workspace(workspace_id,
    
    723 727
                                                    account,
    
    724 728
                                                    jid,
    
    725 729
                                                    type_,
    
    726
    -                                               select=select)
    
    730
    +                                               select=select,
    
    731
    +                                               message=message)
    
    727 732
     
    
    728 733
         def add_private_chat(self,
    
    729 734
                              account: str,
    

  • gajim/gtk/start_chat.py
    ... ... @@ -68,7 +68,11 @@ class Search(IntEnum):
    68 68
     
    
    69 69
     
    
    70 70
     class StartChatDialog(Gtk.ApplicationWindow):
    
    71
    -    def __init__(self, jid: Optional[str] = None) -> None:
    
    71
    +    def __init__(self,
    
    72
    +                 jid: Optional[str] = None,
    
    73
    +                 initial_message: Optional[str] = None
    
    74
    +                 ) -> None:
    
    75
    +
    
    72 76
             Gtk.ApplicationWindow.__init__(self)
    
    73 77
             self.set_name('StartChatDialog')
    
    74 78
             self.set_application(app.app)
    
    ... ... @@ -138,16 +142,15 @@ def __init__(self, jid: Optional[str] = None) -> None:
    138 142
             if rows:
    
    139 143
                 self._load_contacts(rows)
    
    140 144
     
    
    145
    +        self._initial_message: dict[str, Optional[str]] = {}
    
    141 146
             if jid is not None:
    
    142
    -            self.set_search_text(jid)
    
    147
    +            self._initial_message[jid] = initial_message
    
    148
    +            self._ui.search_entry.set_text(jid)
    
    143 149
     
    
    144 150
             self.select_first_row()
    
    145 151
             self._ui.connect_signals(self)
    
    146 152
             self.show_all()
    
    147 153
     
    
    148
    -    def set_search_text(self, text: str) -> None:
    
    149
    -        self._ui.search_entry.set_text(text)
    
    150
    -
    
    151 154
         def remove_row(self, account: str, jid: str) -> None:
    
    152 155
             for row in cast(list[ContactRow], self._ui.listbox.get_children()):
    
    153 156
                 if row.account == account and row.jid == jid:
    
    ... ... @@ -362,12 +365,14 @@ def _start_new_chat(self, row: ContactRow) -> None:
    362 365
                 self._disco_muc(row.account, jid, request_vcard=row.is_new)
    
    363 366
     
    
    364 367
             else:
    
    368
    +            initial_message = self._initial_message.get(str(jid))
    
    365 369
                 app.window.add_chat(
    
    366 370
                     row.account,
    
    367 371
                     jid,
    
    368 372
                     'contact',
    
    369 373
                     select=True,
    
    370
    -                workspace='current')
    
    374
    +                workspace='current',
    
    375
    +                message=initial_message)
    
    371 376
                 self.ready_to_destroy = True
    
    372 377
                 self.destroy()
    
    373 378
     
    

  • gajim/gtk/status_icon.py
    ... ... @@ -179,7 +179,7 @@ def _on_account_state(self,
    179 179
     
    
    180 180
         @staticmethod
    
    181 181
         def _on_new_chat(_widget: Gtk.MenuItem) -> None:
    
    182
    -        app.app.activate_action('start-chat', GLib.Variant('s', ''))
    
    182
    +        app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
    
    183 183
     
    
    184 184
         @staticmethod
    
    185 185
         def _on_sounds_mute(widget: Gtk.CheckMenuItem) -> None:
    

  • gajim/gui_interface.py
    ... ... @@ -466,8 +466,8 @@ def start_chat_from_jid(account: str,
    466 466
                     message_input.insert_text(message)
    
    467 467
                 return
    
    468 468
     
    
    469
    -        # TODO: handle message arg in StartChat
    
    470
    -        app.app.activate_action('start-chat', GLib.Variant('s', str(jid)))
    
    469
    +        app.app.activate_action(
    
    470
    +            'start-chat', GLib.Variant('as', [str(jid), message or '']))
    
    471 471
     
    
    472 472
         @staticmethod
    
    473 473
         def create_account(account: str,