Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwurstsalat <mailtrash@posteo.de>2022-09-26 19:19:15 +0300
committerwurstsalat <mailtrash@posteo.de>2022-09-26 22:32:26 +0300
commit8474c016624fbe9086c3cb78b1a93d9b4baa63a9 (patch)
treeb0846f72bd7ad1adf4a26095ec441d0654a501e0
parent337fb835b3c82869526822106299d2c01ae8f355 (diff)
imprv: StartChat: Pass message body from XMPP URI
Fixes #11140
-rw-r--r--gajim/data/other/shortcuts.json2
-rw-r--r--gajim/gtk/application.py14
-rw-r--r--gajim/gtk/chat_list.py2
-rw-r--r--gajim/gtk/chat_page.py9
-rw-r--r--gajim/gtk/chat_stack.py2
-rw-r--r--gajim/gtk/const.py2
-rw-r--r--gajim/gtk/main.py9
-rw-r--r--gajim/gtk/start_chat.py17
-rw-r--r--gajim/gtk/status_icon.py2
-rw-r--r--gajim/gui_interface.py4
10 files changed, 40 insertions, 23 deletions
diff --git a/gajim/data/other/shortcuts.json b/gajim/data/other/shortcuts.json
index 22b135b45..b472ece52 100644
--- a/gajim/data/other/shortcuts.json
+++ b/gajim/data/other/shortcuts.json
@@ -5,7 +5,7 @@
"app.plugins": ["<Primary>E"],
"app.xml-console": ["<Primary><Shift>X"],
"app.file-transfer": ["<Primary>T"],
- "app.start-chat::": ["<Primary>N"],
+ "app.start-chat(['', ''])": ["<Primary>N"],
"app.create-groupchat::": ["<Primary>G"],
"win.change-nickname": ["<Primary><Shift>N"],
"win.change-subject": ["<Primary><Shift>S"],
diff --git a/gajim/gtk/application.py b/gajim/gtk/application.py
index 2405a84b4..a50e3d47f 100644
--- a/gajim/gtk/application.py
+++ b/gajim/gtk/application.py
@@ -305,7 +305,8 @@ class GajimApplication(Gtk.Application, CoreApplication):
'groupchat-join',
GLib.Variant('as', [accounts[0], jid]))
else:
- self.activate_action('start-chat', GLib.Variant('s', jid))
+ self.activate_action(
+ 'start-chat', GLib.Variant('as', [jid, '']))
elif cmd == 'roster':
self.activate_action('add-contact', GLib.Variant('s', jid))
@@ -338,7 +339,7 @@ class GajimApplication(Gtk.Application, CoreApplication):
options = command_line.get_options_dict()
remote_commands = [
- ('start-chat', GLib.Variant('s', '')),
+ ('start-chat', GLib.Variant('as', ['', ''])),
('show', None)
]
@@ -562,10 +563,11 @@ class GajimApplication(Gtk.Application, CoreApplication):
@staticmethod
def _on_new_chat_action(_action: Gio.SimpleAction,
param: GLib.Variant) -> None:
- window = open_window('StartChatDialog')
- search_text = param.get_string()
- if search_text:
- window.set_search_text(search_text)
+
+ jid, initial_message = param.get_strv()
+ open_window('StartChatDialog',
+ jid=jid or None,
+ initial_message=initial_message or None)
@staticmethod
def _on_profile_action(_action: Gio.SimpleAction,
diff --git a/gajim/gtk/chat_list.py b/gajim/gtk/chat_list.py
index a39d888a0..fe215fd16 100644
--- a/gajim/gtk/chat_list.py
+++ b/gajim/gtk/chat_list.py
@@ -337,7 +337,7 @@ class ChatList(Gtk.ListBox, EventHelper):
@staticmethod
def _on_start_chat_clicked(_button: Gtk.Button) -> None:
- app.app.activate_action('start-chat', GLib.Variant('s', ''))
+ app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
def set_filter(self, name: str) -> None:
self._current_filter = name
diff --git a/gajim/gtk/chat_page.py b/gajim/gtk/chat_page.py
index 0beba801c..0aaa274a5 100644
--- a/gajim/gtk/chat_page.py
+++ b/gajim/gtk/chat_page.py
@@ -16,6 +16,7 @@ from __future__ import annotations
from typing import Any
from typing import Literal
+from typing import Optional
from typing import TYPE_CHECKING
import logging
@@ -127,7 +128,7 @@ class ChatPage(Gtk.Box):
@staticmethod
def _on_start_chat_clicked(_button: Gtk.Button) -> None:
- app.app.activate_action('start-chat', GLib.Variant('s', ''))
+ app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
@staticmethod
def _on_button_release(paned: Gtk.Paned, event: Gdk.EventButton) -> None:
@@ -222,7 +223,8 @@ class ChatPage(Gtk.Box):
type_: str,
pinned: bool = False,
position: int = -1,
- select: bool = False) -> None:
+ select: bool = False,
+ message: Optional[str] = None) -> None:
client = app.get_client(account)
@@ -247,6 +249,9 @@ class ChatPage(Gtk.Box):
if select:
self._chat_list_stack.select_chat(account, jid)
self._chat_list_stack.store_open_chats(workspace_id)
+ if message is not None:
+ message_input = self._chat_stack.get_message_input()
+ message_input.insert_text(message)
def load_workspace_chats(self, workspace_id: str) -> None:
open_chats = app.settings.get_workspace_setting(workspace_id,
diff --git a/gajim/gtk/chat_stack.py b/gajim/gtk/chat_stack.py
index defa7d57d..13e328241 100644
--- a/gajim/gtk/chat_stack.py
+++ b/gajim/gtk/chat_stack.py
@@ -794,4 +794,4 @@ class ChatPlaceholderBox(Gtk.Box):
self.add(button)
def _on_start_chatting(self, _button: Gtk.Button) -> None:
- app.app.activate_action('start-chat', GLib.Variant('s', ''))
+ app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
diff --git a/gajim/gtk/const.py b/gajim/gtk/const.py
index 33800cdd1..d206dc643 100644
--- a/gajim/gtk/const.py
+++ b/gajim/gtk/const.py
@@ -181,7 +181,7 @@ APP_ACTIONS = [
('remove-history', 'a{sv}'),
('shortcuts', None),
('show', None),
- ('start-chat', 's'),
+ ('start-chat', 'as'),
('xml-console', None),
]
diff --git a/gajim/gtk/main.py b/gajim/gtk/main.py
index f23bac73e..7a615c9ad 100644
--- a/gajim/gtk/main.py
+++ b/gajim/gtk/main.py
@@ -712,18 +712,23 @@ class MainWindow(Gtk.ApplicationWindow, EventHelper):
jid: JID,
type_: str,
select: bool = False,
- workspace: str = 'default') -> None:
+ workspace: str = 'default',
+ message: Optional[str] = None
+ ) -> None:
+
if workspace == 'current':
workspace_id = self.get_active_workspace()
if workspace_id is None:
workspace_id = self._workspace_side_bar.get_first_workspace()
else:
workspace_id = self._workspace_side_bar.get_first_workspace()
+
self._chat_page.add_chat_for_workspace(workspace_id,
account,
jid,
type_,
- select=select)
+ select=select,
+ message=message)
def add_private_chat(self,
account: str,
diff --git a/gajim/gtk/start_chat.py b/gajim/gtk/start_chat.py
index 8362580ac..a160f8a19 100644
--- a/gajim/gtk/start_chat.py
+++ b/gajim/gtk/start_chat.py
@@ -68,7 +68,11 @@ class Search(IntEnum):
class StartChatDialog(Gtk.ApplicationWindow):
- def __init__(self, jid: Optional[str] = None) -> None:
+ def __init__(self,
+ jid: Optional[str] = None,
+ initial_message: Optional[str] = None
+ ) -> None:
+
Gtk.ApplicationWindow.__init__(self)
self.set_name('StartChatDialog')
self.set_application(app.app)
@@ -138,16 +142,15 @@ class StartChatDialog(Gtk.ApplicationWindow):
if rows:
self._load_contacts(rows)
+ self._initial_message: dict[str, Optional[str]] = {}
if jid is not None:
- self.set_search_text(jid)
+ self._initial_message[jid] = initial_message
+ self._ui.search_entry.set_text(jid)
self.select_first_row()
self._ui.connect_signals(self)
self.show_all()
- def set_search_text(self, text: str) -> None:
- self._ui.search_entry.set_text(text)
-
def remove_row(self, account: str, jid: str) -> None:
for row in cast(list[ContactRow], self._ui.listbox.get_children()):
if row.account == account and row.jid == jid:
@@ -362,12 +365,14 @@ class StartChatDialog(Gtk.ApplicationWindow):
self._disco_muc(row.account, jid, request_vcard=row.is_new)
else:
+ initial_message = self._initial_message.get(str(jid))
app.window.add_chat(
row.account,
jid,
'contact',
select=True,
- workspace='current')
+ workspace='current',
+ message=initial_message)
self.ready_to_destroy = True
self.destroy()
diff --git a/gajim/gtk/status_icon.py b/gajim/gtk/status_icon.py
index c05ead129..e55c823c0 100644
--- a/gajim/gtk/status_icon.py
+++ b/gajim/gtk/status_icon.py
@@ -179,7 +179,7 @@ class GtkMenuBackend(EventHelper):
@staticmethod
def _on_new_chat(_widget: Gtk.MenuItem) -> None:
- app.app.activate_action('start-chat', GLib.Variant('s', ''))
+ app.app.activate_action('start-chat', GLib.Variant('as', ['', '']))
@staticmethod
def _on_sounds_mute(widget: Gtk.CheckMenuItem) -> None:
diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py
index 0485a3579..a033d21c1 100644
--- a/gajim/gui_interface.py
+++ b/gajim/gui_interface.py
@@ -466,8 +466,8 @@ class Interface:
message_input.insert_text(message)
return
- # TODO: handle message arg in StartChat
- app.app.activate_action('start-chat', GLib.Variant('s', str(jid)))
+ app.app.activate_action(
+ 'start-chat', GLib.Variant('as', [str(jid), message or '']))
@staticmethod
def create_account(account: str,