--- a/gplugin-gtk/gplugin-gtk-plugin-info.c Fri Nov 08 04:55:27 2019 +0000
+++ b/gplugin-gtk/gplugin-gtk-plugin-info.c Fri Nov 08 04:55:47 2019 +0000
@@ -314,19 +314,11 @@
gplugin_gtk_plugin_info_set_plugin(GPluginGtkPluginInfo *info,
- GPluginPlugin *orig_plugin;
g_return_if_fail(GPLUGIN_GTK_IS_PLUGIN_INFO(info));
- orig_plugin = info->plugin;
- if(GPLUGIN_IS_PLUGIN(plugin)) {
- info->plugin = GPLUGIN_PLUGIN(g_object_ref(G_OBJECT(plugin)));
+ if(g_set_object(&info->plugin, plugin)) { + _gplugin_gtk_plugin_info_refresh(info, plugin); - g_object_unref(G_OBJECT(orig_plugin));
- _gplugin_gtk_plugin_info_refresh(info, plugin);
--- a/gplugin-gtk/gplugin-gtk-store.c Fri Nov 08 04:55:27 2019 +0000
+++ b/gplugin-gtk/gplugin-gtk-store.c Fri Nov 08 04:55:47 2019 +0000
@@ -72,6 +72,7 @@
gplugin_gtk_store_add_plugin(GPluginGtkStore *store, GPluginPlugin *plugin) {
GPluginPluginInfo *info = gplugin_plugin_get_info(plugin);
+ GPluginPluginState state = gplugin_plugin_get_state(plugin); GString *str = g_string_new("");
gchar *name = NULL, *summary = NULL;
@@ -90,7 +91,7 @@
gtk_list_store_append(GTK_LIST_STORE(store), &iter);
gtk_list_store_set(GTK_LIST_STORE(store), &iter,
- GPLUGIN_GTK_STORE_LOADED_COLUMN, FALSE,
+ GPLUGIN_GTK_STORE_LOADED_COLUMN, state == GPLUGIN_PLUGIN_STATE_LOADED, GPLUGIN_GTK_STORE_PLUGIN_COLUMN, g_object_ref(plugin),
GPLUGIN_GTK_STORE_MARKUP_COLUMN, str->str,
@@ -109,11 +110,72 @@
gplugin_manager_free_plugin_list(plugins);
+gplugin_gtk_store_update_plugin_state_cb(GtkTreeModel *model, GtkTreePath *path, + GtkTreeIter *iter, gpointer data) + GPluginPlugin *plugin_a = GPLUGIN_PLUGIN(data); + GPluginPlugin *plugin_b = NULL; + GPLUGIN_GTK_STORE_PLUGIN_COLUMN, &plugin_b, + if(plugin_a == plugin_b) { + gboolean loaded = gplugin_plugin_get_state(plugin_a) == GPLUGIN_PLUGIN_STATE_LOADED; + GTK_LIST_STORE(model), iter, + GPLUGIN_GTK_STORE_LOADED_COLUMN, loaded, + /* tell gplugin_gtk_store_update_plugin_state that we're done */ + g_object_unref(G_OBJECT(plugin_b)); +gplugin_gtk_store_update_plugin_state(GPluginGtkStore *store, + gtk_tree_model_foreach( + gplugin_gtk_store_update_plugin_state_cb, /******************************************************************************
+ *****************************************************************************/ +gplugin_gtk_store_plugin_loaded_cb(GObject *manager, GPluginPlugin *plugin, + gplugin_gtk_store_update_plugin_state(GPLUGIN_GTK_STORE(data), plugin); +gplugin_gtk_store_plugin_unloaded_cb(GObject *manager, GPluginPlugin *plugin, + gplugin_gtk_store_update_plugin_state(GPLUGIN_GTK_STORE(data), plugin); +/****************************************************************************** + * GObject Implementation *****************************************************************************/
gplugin_gtk_store_constructed(GObject *obj) {
+ GObject *manager = NULL; G_OBJECT_CLASS(gplugin_gtk_store_parent_class)->constructed(obj);
@@ -123,6 +185,12 @@
gplugin_gtk_store_add_plugin_by_id(GPLUGIN_GTK_STORE(obj),
+ manager = gplugin_manager_get_instance(); + g_signal_connect(manager, "loaded-plugin", + G_CALLBACK(gplugin_gtk_store_plugin_loaded_cb), obj); + g_signal_connect(manager, "unloaded-plugin", + G_CALLBACK(gplugin_gtk_store_plugin_unloaded_cb), obj); --- a/gplugin-gtk/gplugin-gtk-view.c Fri Nov 08 04:55:27 2019 +0000
+++ b/gplugin-gtk/gplugin-gtk-view.c Fri Nov 08 04:55:47 2019 +0000
@@ -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,65 @@
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; + 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) { + gplugin_manager_unload_plugin(plugin, &error); + g_warning("Failed to unload plugin: %s", error->message); + gplugin_manager_load_plugin(plugin, &error); + g_warning("Failed to load plugin: %s", error->message); + g_object_unref(G_OBJECT(plugin)); +/****************************************************************************** + * GObject Implementation *****************************************************************************/
G_DEFINE_TYPE(GPluginGtkView, gplugin_gtk_view, GTK_TYPE_TREE_VIEW);
@@ -112,10 +172,6 @@
GtkTreeViewColumn *col = NULL;
GtkCellRenderer *rend = NULL;
- gtk_widget_set_has_tooltip(GTK_WIDGET(view), TRUE);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view), FALSE);
/* create the first column */
col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, "Enabled");
@@ -123,6 +179,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",
--- a/gplugin/gplugin-manager.c Fri Nov 08 04:55:27 2019 +0000
+++ b/gplugin/gplugin-manager.c Fri Nov 08 04:55:47 2019 +0000
@@ -974,7 +974,6 @@
* GPluginManager::loaded-plugin:
* @manager: the #gpluginpluginmanager instance. treat as a #gobject.
* @plugin: the #gpluginplugin that's about to be loaded.
- * @error: return address for a #gerror.
* emitted after a plugin is loaded.
@@ -1034,7 +1033,6 @@
* GPluginManager::unloaded-plugin:
* @manager: the #gpluginpluginmanager instance. treat as a #gobject.
* @plugin: the #gpluginplugin that's about to be loaded.
- * @error: return address for a #gerror.
* emitted after a plugin is unloaded.