Commit 1fa6eeac authored by Philipp Hörist's avatar Philipp Hörist

StartChat: Add search text argument to action

- Remove usage of instance dict
parent 7310a2ce
Pipeline #3910 passed with stages
in 2 minutes and 52 seconds
......@@ -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
......
......@@ -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)
......
......@@ -71,6 +71,7 @@
<attribute name="label" translatable="yes">Start Chat</attribute>
<attribute name="action">app.start-chat</attribute>
<attribute name="accel">&lt;Primary&gt;N</attribute>
<attribute name="target"></attribute>
</item>
<item>
<attribute name="label" translatable="yes">Create Group Chat</attribute>
......
......@@ -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):
......
......@@ -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):
"""
......
......@@ -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)
......
......@@ -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):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment