--- a/gplugin-gtk/gplugin-gtk-view.c Thu Nov 07 20:39:14 2019 -0600
+++ b/gplugin-gtk/gplugin-gtk-view.c Thu Nov 07 21:20:25 2019 -0600
@@ -18,6 +18,8 @@
#include <gplugin-gtk/gplugin-gtk-view.h>
#include <gplugin-gtk/gplugin-gtk-store.h>
+#include <gplugin/gplugin.h> * SECTION:gplugin-gtk-view
* @Title: Gtk+ View for gplugins
@@ -59,7 +61,76 @@
static GParamSpec *properties[N_PROPERTIES] = {NULL,};
/******************************************************************************
+ *****************************************************************************/ +gplugin_gtk_view_plugin_toggled_cb(GtkCellRendererToggle *rend, + GPluginGtkView *view = GPLUGIN_GTK_VIEW(data); + GPluginPlugin *plugin = NULL; + GPluginPluginState state; + GtkTreeModel *model = NULL; + GtkTreePath *tree_path = NULL; + gboolean loaded = FALSE; + tree_path = gtk_tree_path_new_from_string(path); + model = gtk_tree_view_get_model(GTK_TREE_VIEW(view)); + gtk_tree_model_get_iter(model, &iter, tree_path); + gtk_tree_path_free(tree_path); + GPLUGIN_GTK_STORE_PLUGIN_COLUMN, &plugin, + if(!GPLUGIN_IS_PLUGIN(plugin)) { + state = gplugin_plugin_get_state(plugin); + if(state == GPLUGIN_PLUGIN_STATE_LOADED) { + gboolean unloaded = gplugin_manager_unload_plugin(plugin, &error); + g_warning("Failed to unload plugin: %s", error->message); + /* if unload failed, unloaded is set to false, which mean the plugin is + * still loaded. So we set loaded to the negated value of unloaded. + loaded = gplugin_manager_load_plugin(plugin, &error); + g_warning("Failed to load plugin: %s", error->message); + GPLUGIN_GTK_STORE_LOADED_COLUMN, loaded, +/****************************************************************************** + * GObject Implementation *****************************************************************************/
G_DEFINE_TYPE(GPluginGtkView, gplugin_gtk_view, GTK_TYPE_TREE_VIEW);
@@ -119,6 +190,8 @@
rend = gtk_cell_renderer_toggle_new();
gtk_tree_view_column_pack_start(col, rend, FALSE);
+ g_signal_connect(G_OBJECT(rend), "toggled", + G_CALLBACK(gplugin_gtk_view_plugin_toggled_cb), view); gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
gtk_tree_view_column_add_attribute(col, rend, "active",