Settings manager pluguns reloading patch

Jasper Huijsmans jasper at moongroup.com
Tue Apr 1 09:27:50 CEST 2003


Hey Olivier,

What do you think? It seems to work for me. 

I could also add a reload button to the dialog, but I don't know if we
want to expose that detail to the user. It can be useful when installing
new modules.

	Jasper

Index: xfce-mcs-manager.c
===================================================================
RCS file:
/cvsroot/xfce/xfce-devel/xfce-mcs-manager/xfce-mcs-manager/xfce-mcs-man
ager.c,v retrieving revision 1.15
diff -u -r1.15 xfce-mcs-manager.c
--- xfce-mcs-manager.c	29 Mar 2003 20:18:55 -0000	1.15
+++ xfce-mcs-manager.c	1 Apr 2003 07:17:09 -0000
@@ -51,6 +51,7 @@
 #define SOEXT_LEN       (strlen (SOEXT))
 
 static GSList *plugin_list = NULL;
+static GSList *module_list = NULL;
 
 McsManager *manager;
 
@@ -123,6 +124,7 @@
                     plugin->plugin_name);
 #endif
             plugin_list = g_slist_append(plugin_list, plugin);
+	    module_list = g_slist_append(module_list, gm);
         }
     }
     else {
@@ -175,6 +177,29 @@
 }
 
 static void
+plugin_unload_all(void)
+{
+    g_slist_foreach(module_list, (GFunc)g_module_close, NULL);
+    g_slist_free(module_list);
+    module_list=NULL;
+
+    g_slist_foreach(plugin_list, (GFunc)g_free, NULL);
+    g_slist_free(plugin_list);
+    plugin_list=NULL;
+}
+
+void
+reload_plugins(void)
+{
+    gdk_x11_grab_server();
+    plugin_unload_all();
+
+    plugin_load_all();
+    gdk_x11_ungrab_server();
+    gdk_flush();
+}
+
+static void
 terminate_cb(void *data)
 {
     gboolean *terminated = data;
@@ -210,7 +235,7 @@
                 "Multi-Channel Manager Error:\nNo such plugin \"%s\"",
name);         gtk_dialog_run(GTK_DIALOG(dialog));
         gtk_widget_destroy(dialog);
-	    run_manager_dialog(plugin_list);
+	run_manager_dialog(plugin_list);
     }
 }
 
@@ -223,9 +248,16 @@
         return GDK_FILTER_CONTINUE;
 }
 
+static void
+sighandler(int sig)
+{
+    reload_plugins();
+}
+
 static int
 run_daemon(int argc, char **argv, gboolean daemon_mode)
 {
+    struct sigaction act;
     McsManagerCheck status;
     gboolean std_mgr = TRUE;
 
@@ -269,6 +301,10 @@
 
     plugin_load_all();
     gdk_flush();
+
+    act.sa_handler = sighandler;
+    act.sa_flags = 0;
+    sigaction(SIGHUP, &act, NULL);
 
     if(daemon_mode) {
 	    switch (fork()) {



More information about the Xfce4-dev mailing list