/* * callback function for a plugin */ static void curses_select_plugin(void *plugin) { /* prevent the selection when the list is empty */ if (plugin == NULL) return; /* print the message */ if (plugin_is_activated(plugin) == 0) INSTANT_USER_MSG("Activating %s plugin...\n", plugin); else INSTANT_USER_MSG("Deactivating %s plugin...\n", plugin); /* * pay attention on this ! * if the plugin init does not return, * we are blocked here. So it is encouraged * to write plugins which spawn a thread * and immediately return */ if (plugin_is_activated(plugin) == 1) plugin_fini(plugin); else plugin_init(plugin); /* refres the array for the list widget */ nplug = 0; plugin_list_walk(PLP_MIN, PLP_MAX, &curses_refresh_plug_array); /* refresh the list */ wdg_list_refresh(wdg_plugin); }
void curses_plugins_update(void) { DEBUG_MSG("curses_plugins_update"); CURSES_LOCK(pluginlist_mutex); /* refres the array for the list widget */ nplug = 0; plugin_list_walk(PLP_MIN, PLP_MAX, &curses_refresh_plug_array); /* refresh the list */ wdg_list_refresh(wdg_plugin); CURSES_UNLOCK(pluginlist_mutex); }
/* * create the array for the widget. * erase any previously alloc'd array */ static void curses_create_plug_array(void) { int res, i = 0; DEBUG_MSG("curses_create_plug_array"); /* free the array (if alloc'ed) */ while (wdg_plugin_elements && wdg_plugin_elements[i].desc != NULL) { SAFE_FREE(wdg_plugin_elements[i].desc); i++; } SAFE_FREE(wdg_plugin_elements); nplug = 0; /* go thru the list of plugins */ res = plugin_list_walk(PLP_MIN, PLP_MAX, &curses_wdg_plugin); if (res == -ENOTFOUND) { SAFE_CALLOC(wdg_plugin_elements, 1, sizeof(struct wdg_list)); wdg_plugin_elements->desc = "No plugin found !"; } }
/* * create the array for the widget. * erase any previously alloc'd array */ static void gtkui_create_plug_array(void) { GtkTreeIter iter; int res; static int blocked = 0; DEBUG_MSG("gtk_create_plug_array"); if(ls_plugins) gtk_list_store_clear(GTK_LIST_STORE (ls_plugins)); else ls_plugins = gtk_list_store_new (4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); /* go thru the list of plugins */ res = plugin_list_walk(PLP_MIN, PLP_MAX, >kui_add_plugin); if (res == -E_NOTFOUND) { blocked = g_signal_handlers_block_by_func (G_OBJECT (treeview), G_CALLBACK (gtkui_select_plugin), NULL); gtk_list_store_append (ls_plugins, &iter); gtk_list_store_set (ls_plugins, &iter, 0, " ", 1, "No Plugins Loaded", -1); } else if(blocked > 0) { g_signal_handlers_unblock_by_func (G_OBJECT (treeview), G_CALLBACK (gtkui_select_plugin), NULL); blocked = 0; } }