[gnome-tweak-tool/wip/pwood/app-chooser: 3/11] AppChooser: Don't show existing start-up apps



commit d242f6a568460f335281b9750e12a21ad20fe625
Author: Phillip Wood <phillip wood dunelm org uk>
Date:   Sun Apr 12 19:01:22 2015 +0100

    AppChooser: Don't show existing start-up apps
    
    Pass a set containing the existing start-up applications to the
    AppChooser dialog so it can avoid showing them.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=747983

 gtweak/tweaks/tweak_group_startup.py |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)
---
diff --git a/gtweak/tweaks/tweak_group_startup.py b/gtweak/tweaks/tweak_group_startup.py
index 7230124..ef74892 100644
--- a/gtweak/tweaks/tweak_group_startup.py
+++ b/gtweak/tweaks/tweak_group_startup.py
@@ -31,7 +31,7 @@ def _list_header_func(row, before, user_data):
         row.set_header (Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL))
 
 class _AppChooser(Gtk.Dialog):
-    def __init__(self, main_window, running_exes):
+    def __init__(self, main_window, running_exes, startup_apps):
         Gtk.Dialog.__init__(self, title=_("Applications"))
 
         self._running = {}
@@ -54,15 +54,16 @@ class _AppChooser(Gtk.Dialog):
 
         apps = Gio.app_info_get_all()
         for a in apps:
-            if a.should_show():
-                running = a.get_executable() in running_exes
-                w = self._build_widget(
+            if a.get_id() not in startup_apps:
+                if a.should_show():
+                    running = a.get_executable() in running_exes
+                    w = self._build_widget(
                         a,
                         _("running") if running else "")
-                if w:
-                    self._all[w] = a
-                    self._running[w] = running
-                    lb.add(w)
+                    if w:
+                        self._all[w] = a
+                        self._running[w] = running
+                        lb.add(w)
 
         sw = Gtk.ScrolledWindow()
         sw.props.hscrollbar_policy = Gtk.PolicyType.NEVER
@@ -197,6 +198,7 @@ class _StartupTweak(Gtk.ListBoxRow, Tweak):
         self.get_style_context().add_class('tweak-startup')
 
         self.btn = btn
+        self.app_id = df.get_id()
 
 class AddStartupTweak(Gtk.ListBoxRow, Tweak):
     def __init__(self, **options):
@@ -245,9 +247,12 @@ class AutostartListBoxTweakGroup(ListBoxTweakGroup):
 
     def _on_add_clicked(self, btn):
         Gio.Application.get_default().mark_busy()
+        startup_apps = set()
+        self.foreach(lambda row: startup_apps.add(row.app_id) if type(row) is _StartupTweak else None)
         a = _AppChooser(
                 self.main_window,
-                set(self._get_running_executables()))
+                set(self._get_running_executables()),
+                startup_apps)
         a.show_all()
         Gio.Application.get_default().unmark_busy()
         resp = a.run()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]