From b26ba9aa67136a93e03d9bbcb20bb937bcfcee88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Tue, 13 Feb 2018 19:18:40 +0100 Subject: [PATCH] Port show-next-pending-event from gajim-remote Delete some already ported methods --- gajim/app_actions.py | 10 ++++++++++ gajim/gajim.py | 17 ++++++++++++---- gajim/gajim_remote.py | 12 ----------- gajim/remote_control.py | 44 ----------------------------------------- 4 files changed, 23 insertions(+), 60 deletions(-) diff --git a/gajim/app_actions.py b/gajim/app_actions.py index 3bdfdc809..8d4f35a28 100644 --- a/gajim/app_actions.py +++ b/gajim/app_actions.py @@ -286,3 +286,13 @@ class AppActions(): win.present() else: app.interface.create_ipython_window() + + def show_next_pending_event(self, action, param): + """ + Show the window(s) with next pending event in tabbed/group chats + """ + if app.events.get_nb_events(): + account, jid, event = app.events.get_first_systray_event() + if not event: + return + app.interface.handle_event(account, jid, event.type_) diff --git a/gajim/gajim.py b/gajim/gajim.py index ff952d2b2..c94a4163b 100644 --- a/gajim/gajim.py +++ b/gajim/gajim.py @@ -96,7 +96,10 @@ class GajimApplication(Gtk.Application): _('Show all warnings')) self.add_main_option('ipython', ord('i'), GLib.OptionFlags.NONE, GLib.OptionArg.NONE, - _('open ipython shell')) + _('Open IPython shell')) + self.add_main_option('show-next-pending-event', 0, GLib.OptionFlags.NONE, + GLib.OptionArg.NONE, + _('Pops up a window with the next pending event')) self.connect('handle-local-options', self._handle_local_options) self.connect('command-line', self._handle_remote_options) @@ -291,9 +294,14 @@ class GajimApplication(Gtk.Application): # Parse all options that should be executed on a remote instance options = command_line.get_options_dict() - if options.contains('ipython'): - self.activate_action('ipython') - return 0 + remote_commands = ['ipython', + 'show-next-pending-event', + ] + + for cmd in remote_commands: + if options.contains(cmd): + self.activate_action(cmd) + return 0 uri = self._parse_uris(command_line) if uri is not None: @@ -415,6 +423,7 @@ class GajimApplication(Gtk.Application): ('about', action.on_about), ('faq', action.on_faq), ('ipython', action.toggle_ipython), + ('show-next-pending-event', action.show_next_pending_event), ] act = Gio.SimpleAction.new('add-contact', GLib.VariantType.new('s')) diff --git a/gajim/gajim_remote.py b/gajim/gajim_remote.py index 53bf9f905..bfde235e5 100644 --- a/gajim/gajim_remote.py +++ b/gajim/gajim_remote.py @@ -85,14 +85,6 @@ class GajimRemote: _('show help on command'), False) ] ], - 'toggle_roster_appearance': [ - _('Shows or hides the roster window'), - [] - ], - 'show_next_pending_event': [ - _('Pops up a window with the next pending event'), - [] - ], 'list_contacts': [ _('Lists all contacts in roster, one for each line'), [ @@ -257,10 +249,6 @@ class GajimRemote: _('Check if Gajim is running'), [] ], - 'toggle_ipython': [ - _('Shows or hides the ipython window'), - [] - ], } diff --git a/gajim/remote_control.py b/gajim/remote_control.py index de4d04979..9a87ebb9c 100644 --- a/gajim/remote_control.py +++ b/gajim/remote_control.py @@ -646,50 +646,6 @@ class SignalObject(dbus.service.Object): result.append(item) return result - @dbus.service.method(INTERFACE, in_signature='', out_signature='') - def toggle_roster_appearance(self): - """ - Show/hide the roster window - """ - win = app.interface.roster.window - if win.get_property('visible'): - GLib.idle_add(win.hide) - else: - win.present() - # preserve the 'steal focus preservation' - if self._is_first(): - win.window.present() - else: - win.window.present_with_time(int(time())) - - @dbus.service.method(INTERFACE, in_signature='', out_signature='') - def show_roster(self): - """ - Show the roster window - """ - win = app.interface.roster.window - win.present() - # preserve the 'steal focus preservation' - if self._is_first(): - win.window.present() - else: - win.window.present_with_time(int(time())) - - @dbus.service.method(INTERFACE, in_signature='', out_signature='') - def toggle_ipython(self): - """ - Show/hide the ipython window - """ - win = app.ipython_window - if win: - if win.window.is_visible(): - GLib.idle_add(win.hide) - else: - win.show_all() - win.present() - else: - app.interface.create_ipython_window() - @dbus.service.method(INTERFACE, in_signature='', out_signature='a{ss}') def prefs_list(self): prefs_dict = DBUS_DICT_SS()