[Xfce4-commits] <xfce4-panel:devel> Add hidden property to run all plugins external.

Nick Schermer nick at xfce.org
Tue Aug 11 20:32:44 CEST 2009


Updating branch refs/heads/devel
         to fab9466550ad134e068ecde9e6bda72570c3229e (commit)
       from bd8aa20b56ed1643f49a453d0a9d63e8836f5aa1 (commit)

commit fab9466550ad134e068ecde9e6bda72570c3229e
Author: Nick Schermer <nick at xfce.org>
Date:   Sat May 30 20:38:39 2009 +0200

    Add hidden property to run all plugins external.
    
    Hidden boolean that will force all plugins to run external. You can
    set it with xfconf-query like this:
    xfconf-query -c xfce4-panel -p /force-all-external -t bool -n -s true
    
    or unset it with the following command:
    xfconf-query -c xfce4-panel -p /force-all-external -r

 panel/panel-application.c    |   10 +++++++---
 panel/panel-module-factory.c |   30 +++++++++++++++++++++---------
 panel/panel-module-factory.h |    2 ++
 panel/panel-module.c         |   10 +++++++---
 panel/panel-module.h         |    3 ++-
 5 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/panel/panel-application.c b/panel/panel-application.c
index a8ed897..a553a5d 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -181,12 +181,16 @@ panel_application_init (PanelApplication *application)
   application->drop_data_ready = FALSE;
   application->drop_occurred = FALSE;
 
-  /* get a factory reference so it never unloads */
-  application->factory = panel_module_factory_get ();
-
   /* get the xfconf channel */
   application->xfconf = xfconf_channel_new ("xfce4-panel");
 
+  /* check if we need to force all plugins to run external */
+  if (xfconf_channel_get_bool (application->xfconf, "/force-all-external", FALSE))
+    panel_module_factory_force_all_external ();
+
+  /* get a factory reference so it never unloads */
+  application->factory = panel_module_factory_get ();
+
   /* load setup */
   panel_application_load (application);
 
diff --git a/panel/panel-module-factory.c b/panel/panel-module-factory.c
index e5ad679..2be32aa 100644
--- a/panel/panel-module-factory.c
+++ b/panel/panel-module-factory.c
@@ -75,7 +75,8 @@ struct _PanelModuleFactory
 
 
 
-static guint factory_signals[LAST_SIGNAL];
+static guint    factory_signals[LAST_SIGNAL];
+static gboolean force_all_external = FALSE;
 
 
 
@@ -112,7 +113,7 @@ panel_module_factory_init (PanelModuleFactory *factory)
   factory->has_launcher = FALSE;
 
   /* create hash tables */
-  factory->modules = g_hash_table_new_full (g_str_hash, g_str_equal, 
+  factory->modules = g_hash_table_new_full (g_str_hash, g_str_equal,
                                             g_free, g_object_unref);
 
   /* load all the modules */
@@ -193,7 +194,8 @@ panel_module_factory_load_modules (PanelModuleFactory *factory)
               /* create the full .desktop filename */
               filename = g_build_filename (path, name, NULL);
 
-              /* find the dot in the name (cannot fail since it pasted the .desktop suffix check) */
+              /* find the dot in the name, this cannot
+               * fail since it pasted the .desktop suffix check */
               p = strrchr (name, '.');
 
               /* get the new module internal name */
@@ -204,7 +206,9 @@ panel_module_factory_load_modules (PanelModuleFactory *factory)
                 goto already_loaded;
 
               /* try to load the module */
-              module = panel_module_new_from_desktop_file (filename, internal_name);
+              module = panel_module_new_from_desktop_file (filename,
+                                                           internal_name,
+                                                           force_all_external);
 
               if (G_LIKELY (module != NULL))
                 {
@@ -258,8 +262,8 @@ panel_module_factory_modules_cleanup (gpointer key,
   remove_from_table = !panel_module_is_valid (module);
 
   /* if we're going to remove this item, check if it's the launcher */
-  if (remove_from_table 
-      && exo_str_is_equal (LAUNCHER_PLUGIN_NAME, 
+  if (remove_from_table
+      && exo_str_is_equal (LAUNCHER_PLUGIN_NAME,
                            panel_module_get_name (module)))
     factory->has_launcher = FALSE;
 
@@ -302,6 +306,14 @@ panel_module_factory_get (void)
 
 
 
+void
+panel_module_factory_force_all_external (void)
+{
+  force_all_external = TRUE;
+}
+
+
+
 gboolean
 panel_module_factory_has_launcher (PanelModuleFactory *factory)
 {
@@ -350,18 +362,18 @@ GList *
 panel_module_factory_get_modules (PanelModuleFactory *factory)
 {
   panel_return_val_if_fail (PANEL_IS_MODULE_FACTORY (factory), NULL);
-  
+
   /* scan the resource directories again */
   panel_module_factory_load_modules (factory);
 
   /* make sure the hash table is clean */
-  g_hash_table_foreach_remove (factory->modules, 
+  g_hash_table_foreach_remove (factory->modules,
       panel_module_factory_modules_cleanup, factory);
 
 #if !GLIB_CHECK_VERSION (2,14,0)
   GList *value = NULL;
 
-  g_hash_table_foreach (factory->modules, 
+  g_hash_table_foreach (factory->modules,
       panel_module_factory_get_modules_foreach, &value);
 
   return value;
diff --git a/panel/panel-module-factory.h b/panel/panel-module-factory.h
index 21cc7dc..0b27f00 100644
--- a/panel/panel-module-factory.h
+++ b/panel/panel-module-factory.h
@@ -43,6 +43,8 @@ GType               panel_module_factory_get_type            (void) G_GNUC_CONST
 
 PanelModuleFactory *panel_module_factory_get                 (void);
 
+void                panel_module_factory_force_all_external  (void);
+
 gboolean            panel_module_factory_has_launcher        (PanelModuleFactory  *factory);
 
 void                panel_module_factory_emit_unique_changed (PanelModule         *module);
diff --git a/panel/panel-module.c b/panel/panel-module.c
index 8992a18..5a350ea 100644
--- a/panel/panel-module.c
+++ b/panel/panel-module.c
@@ -271,7 +271,8 @@ panel_module_plugin_destroyed (gpointer  user_data,
 
 PanelModule *
 panel_module_new_from_desktop_file (const gchar *filename,
-                                    const gchar *name)
+                                    const gchar *name,
+                                    gboolean     force_external)
 {
   PanelModule *module = NULL;
   XfceRc      *rc;
@@ -335,8 +336,11 @@ panel_module_new_from_desktop_file (const gchar *filename,
           /* whether the plugin is unique */
           module->is_unique = xfce_rc_read_bool_entry (rc, "X-XFCE-Unique", FALSE);
 
-          /* whether to run the plugin external */
-          module->run_in_wrapper = !xfce_rc_read_bool_entry (rc, "X-XFCE-Internal", FALSE);
+          /* whether to force the plugin to run external */
+          if (G_UNLIKELY (force_external))
+            module->run_in_wrapper = TRUE;
+          else
+            module->run_in_wrapper = !xfce_rc_read_bool_entry (rc, "X-XFCE-Internal", FALSE);
         }
       else if (xfce_rc_has_entry (rc, "X-XFCE-Exec"))
         {
diff --git a/panel/panel-module.h b/panel/panel-module.h
index 16b54f8..b42c7ef 100644
--- a/panel/panel-module.h
+++ b/panel/panel-module.h
@@ -41,7 +41,8 @@ typedef struct _PanelModule      PanelModule;
 GType        panel_module_get_type                 (void) G_GNUC_CONST;
 
 PanelModule *panel_module_new_from_desktop_file    (const gchar             *filename,
-                                                    const gchar             *name);
+                                                    const gchar             *name,
+                                                    gboolean                 force_external);
 
 GtkWidget   *panel_module_new_plugin               (PanelModule             *module,
                                                     GdkScreen               *screen,



More information about the Xfce4-commits mailing list