[Xfce4-commits] <xfce4-appfinder:master> Add option to disable the background service.

Nick Schermer noreply at xfce.org
Tue Feb 21 20:56:01 CET 2012


Updating branch refs/heads/master
         to 783b64a4c986a948adb7452d75279e302785baf4 (commit)
       from 5743612275c1b2828b11b3d665d2d787d193f782 (commit)

commit 783b64a4c986a948adb7452d75279e302785baf4
Author: Nick Schermer <nick at xfce.org>
Date:   Tue Feb 21 20:53:18 2012 +0100

    Add option to disable the background service.
    
    The process can consume quite some memory in daemon
    mode because of all the loaded pixbufs. So add an option
    to disable the background service for people who're not using
    the appfinder often and care about every bit of memory.

 src/appfinder-preferences.c     |    4 ++++
 src/appfinder-preferences.glade |   18 ++++++++++++++++++
 src/main.c                      |   23 ++++++++++++++++++++---
 3 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/src/appfinder-preferences.c b/src/appfinder-preferences.c
index 4baeee6..233aed1 100644
--- a/src/appfinder-preferences.c
+++ b/src/appfinder-preferences.c
@@ -119,6 +119,10 @@ xfce_appfinder_preferences_init (XfceAppfinderPreferences *preferences)
   xfconf_g_property_bind (preferences->channel, "/always-center", G_TYPE_BOOLEAN,
                           G_OBJECT (object), "active");
 
+  object = gtk_builder_get_object (GTK_BUILDER (preferences), "enable-service");
+  xfconf_g_property_bind (preferences->channel, "/enable-service", G_TYPE_BOOLEAN,
+                          G_OBJECT (object), "active");
+
   icons = gtk_builder_get_object (GTK_BUILDER (preferences), "icon-view");
   xfconf_g_property_bind (preferences->channel, "/icon-view", G_TYPE_BOOLEAN,
                           G_OBJECT (icons), "active");
diff --git a/src/appfinder-preferences.glade b/src/appfinder-preferences.glade
index 08a66de..cc23623 100644
--- a/src/appfinder-preferences.glade
+++ b/src/appfinder-preferences.glade
@@ -176,6 +176,24 @@
                                 <property name="position">1</property>
                               </packing>
                             </child>
+                            <child>
+                              <object class="GtkCheckButton" id="enable-service">
+                                <property name="label" translatable="yes">Keep running _instance in the background</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="tooltip_text" translatable="yes">Instead of quiting the application when the last window is closed, keep a running instance to speed up opening new windows. You might want to disable this to reduce memory usage.</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <property name="active">True</property>
+                              </object>
+                              <packing>
+                                <property name="expand">True</property>
+                                <property name="fill">True</property>
+                                <property name="position">2</property>
+                              </packing>
+                            </child>
                           </object>
                         </child>
                       </object>
diff --git a/src/main.c b/src/main.c
index d7b2e5d..3c2cdb8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -151,6 +151,8 @@ appfinder_refcount_debug_finalize (void)
 static void
 appfinder_window_destroyed (GtkWidget *window)
 {
+  XfconfChannel *channel;
+
   if (windows == NULL)
     return;
 
@@ -164,9 +166,24 @@ appfinder_window_destroyed (GtkWidget *window)
   /* remove from internal list */
   windows = g_slist_remove (windows, window);
 
-  /* leave if all windows are closed and we're not service owner */
-  if (windows == NULL && !service_owner)
-    gtk_main_quit ();
+  /* check if we're going to the background
+   * if the last window is closed */
+  if (windows == NULL)
+    {
+      if (!service_owner)
+        {
+          /* leave if we're not the daemon or started
+           * with --disable-server */
+          gtk_main_quit ();
+        }
+      else
+        {
+          /* leave if the user disable the service in the prefereces */
+          channel = xfconf_channel_get ("xfce4-appfinder");
+          if (!xfconf_channel_get_bool (channel, "/enable-service", TRUE))
+            gtk_main_quit ();
+        }
+    }
 }
 
 


More information about the Xfce4-commits mailing list