From 60d3e3935272bcd5bab89abd0cd3d95c886a211c Mon Sep 17 00:00:00 2001 From: Emanuele Petriglia Date: Wed, 29 Apr 2020 15:37:41 +0200 Subject: [PATCH] Open xfce4-panel on close button (bug #16505) --- xfce4-panel-profiles/xfce4-panel-profiles.py | 22 +++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/xfce4-panel-profiles/xfce4-panel-profiles.py b/xfce4-panel-profiles/xfce4-panel-profiles.py index ce60bab..f2011cd 100644 --- a/xfce4-panel-profiles/xfce4-panel-profiles.py +++ b/xfce4-panel-profiles/xfce4-panel-profiles.py @@ -48,8 +48,12 @@ class XfcePanelProfiles: data_dir = "xfce4-panel-profiles" save_location = os.path.join(GLib.get_user_data_dir(), data_dir) - def __init__(self): - '''Initialize the Panel Profiles application.''' + def __init__(self, from_panel=False): + '''Initialize the Panel Profiles application. + + If 'from_panel' is set to 'True' the application launchs 'xfce4-panel + --preferences' when the user closes this application. + ''' self.builder = Gtk.Builder() self.builder.set_translation_domain('xfce4-panel-profiles') @@ -81,6 +85,8 @@ class XfcePanelProfiles: if not os.path.exists(self.save_location): os.makedirs(self.save_location) + self.from_panel = from_panel + self.window.show() def _copy(self, src, dst): @@ -306,6 +312,12 @@ class XfcePanelProfiles: def on_close_clicked(self, *args): '''Exit the application when the window is closed.''' + if self.from_panel: + path = GLib.find_program_in_path('xfce4-panel') + + if path != None: + GLib.spawn_command_line_async(path + ' --preferences') + Gtk.main_quit() def on_help_clicked(self, *args): @@ -382,6 +394,8 @@ class PanelConfirmDialog(Gtk.MessageDialog): box.show_all() if __name__ == "__main__": + from_panel = False + import sys session_bus = Gio.BusType.SESSION @@ -414,6 +428,8 @@ if __name__ == "__main__": print(repr(e)) exit(1) exit(0) + elif sys.argv[1] == '--from-panel': + from_panel = True else: print('Xfce Panel Profiles - Usage:') print(sys.argv[0] + ' : load graphical user interface.') @@ -422,5 +438,5 @@ if __name__ == "__main__": print('') exit(-1) - main = XfcePanelProfiles() + main = XfcePanelProfiles(from_panel) Gtk.main() -- 2.25.4