Philipp Hörist pushed to branch master at gajim / gajim
Commits:
23de7d53 by Philipp Hörist at 2017-12-26T21:55:19+01:00
Use higher level API to focus windows
set_active_tab() already calls present(), no need to call it afterwards
again
- - - - -
1b2ab928 by Philipp Hörist at 2017-12-26T21:55:19+01:00
Fix focus after destruction of StartChatDialog
On destroy() the window that was last focused gets the focus
again. if destroy() is called from the StartChat Dialog, the new
ChatControl is not yet focused, because present() seems to be asynchron,
at least on KDE, and takes time.
- - - - -
6 changed files:
- gajim/dialogs.py
- gajim/gui_interface.py
- gajim/message_window.py
- gajim/remote_control.py
- gajim/roster_window.py
- plugins/dbus_plugin/plugin.py
Changes:
=====================================
gajim/dialogs.py
=====================================
--- a/gajim/dialogs.py
+++ b/gajim/dialogs.py
@@ -2776,6 +2776,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
self.set_show_menubar(False)
self.set_title(_('Start new Conversation'))
self.set_default_size(-1, 400)
+ self.ready_to_destroy = False
self.builder = gtkgui_helpers.get_gtk_builder(
'start_chat_dialog.ui')
@@ -2891,7 +2892,7 @@ class StartChatDialog(Gtk.ApplicationWindow):
else:
app.interface.new_chat_from_jid(row.account, row.jid)
- self.destroy()
+ self.ready_to_destroy = True
def _on_search_changed(self, entry):
search_text = entry.get_text()
=====================================
gajim/gui_interface.py
=====================================
--- a/gajim/gui_interface.py
+++ b/gajim/gui_interface.py
@@ -1767,7 +1767,7 @@ class Interface:
self.roster.draw_contact(jid, account)
if w:
w.set_active_tab(ctrl)
- w.window.get_window().focus(Gtk.get_current_event_time())
+ w.window.present()
# Using isinstance here because we want to catch all derived types
if isinstance(ctrl, ChatControlBase):
tv = ctrl.conv_textview
@@ -2145,7 +2145,6 @@ class Interface:
# For JEP-0172
if added_to_roster:
ctrl.user_nick = app.nicks[account]
- GLib.idle_add(mw.window.grab_focus)
return ctrl
=====================================
gajim/message_window.py
=====================================
--- a/gajim/message_window.py
+++ b/gajim/message_window.py
@@ -204,6 +204,14 @@ class MessageWindow(object):
gtkgui_helpers.resize_window(self.window, width, height)
def _on_window_focus(self, widget, event):
+ # on destroy() the window that was last focused gets the focus
+ # 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()
+
# 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)
# to remove urgency hint so this functions does that
=====================================
gajim/remote_control.py
=====================================
--- a/gajim/remote_control.py
+++ b/gajim/remote_control.py
@@ -519,7 +519,7 @@ class SignalObject(dbus.service.Object):
win = app.interface.msg_win_mgr.get_window(jid,
connected_account).window
if win.get_property('visible'):
- win.window.focus(Gtk.get_current_event_time())
+ win.window.present()
return DBUS_BOOLEAN(True)
return DBUS_BOOLEAN(False)
@@ -658,9 +658,9 @@ class SignalObject(dbus.service.Object):
win.present()
# preserve the 'steal focus preservation'
if self._is_first():
- win.window.focus(Gtk.get_current_event_time())
+ win.window.present()
else:
- win.window.focus(int(time()))
+ win.window.present_with_time(int(time()))
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
def show_roster(self):
@@ -671,9 +671,9 @@ class SignalObject(dbus.service.Object):
win.present()
# preserve the 'steal focus preservation'
if self._is_first():
- win.window.focus(Gtk.get_current_event_time())
+ win.window.present()
else:
- win.window.focus(int(time()))
+ win.window.present_with_time(int(time()))
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
def toggle_ipython(self):
=====================================
gajim/roster_window.py
=====================================
--- a/gajim/roster_window.py
+++ b/gajim/roster_window.py
@@ -3131,7 +3131,6 @@ class RosterWindow:
if gc_control:
mw = app.interface.msg_win_mgr.get_window(jid, account)
mw.set_active_tab(gc_control)
- mw.window.get_window().focus(Gtk.get_current_event_time())
return
ctrl = app.interface.minimized_controls[account][jid]
mw = app.interface.msg_win_mgr.get_window(jid, account)
@@ -3145,7 +3144,6 @@ class RosterWindow:
ctrl.on_groupchat_maximize()
mw.new_tab(ctrl)
mw.set_active_tab(ctrl)
- mw.window.get_window().focus(Gtk.get_current_event_time())
self.remove_groupchat(jid, account)
def on_edit_account(self, widget, account):
=====================================
plugins/dbus_plugin/plugin.py
=====================================
--- a/plugins/dbus_plugin/plugin.py
+++ b/plugins/dbus_plugin/plugin.py
@@ -367,7 +367,7 @@ if dbus_support.supported:
win = gajim.interface.msg_win_mgr.get_window(jid,
connected_account).window
if win.get_property('visible'):
- win.window.focus()
+ win.window.present()
return DBUS_BOOLEAN(True)
return DBUS_BOOLEAN(False)
@@ -455,9 +455,9 @@ if dbus_support.supported:
win.present()
# preserve the 'steal focus preservation'
if self._is_first():
- win.window.focus()
+ win.window.present()
else:
- win.window.focus(long(time()))
+ win.window.present_with_time(long(time()))
@dbus.service.method(INTERFACE, in_signature='', out_signature='')
def toggle_ipython(self):
View it on GitLab:
https://dev.gajim.org/gajim/gajim/compare/fd7f30204413bbdf4b72b6fd8b2ab1b7602ed0d1...1b2ab928f0943fd046aafc7fbea7900d9c8cdf85
---
View it on GitLab:
https://dev.gajim.org/gajim/gajim/compare/fd7f30204413bbdf4b72b6fd8b2ab1b7602ed0d1...1b2ab928f0943fd046aafc7fbea7900d9c8cdf85
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits