gplugin/gplugin

Merge develop into default for the release
v0.29.0
2019-11-07, Gary Kramlich
fc9c95c883ae
Merge develop into default for the release
--- a/ChangeLog Thu Oct 31 23:55:18 2019 -0500
+++ b/ChangeLog Thu Nov 07 23:09:51 2019 -0600
@@ -1,3 +1,11 @@
+0.29.0: 2019/11/07
+ * Synchronize GPluginGtkStore with the plugin manager, make the enabled
+ toggle button work in GPluginGtkView, and allow developers to decide
+ whether or not to show column headers in GPlugingGtkView. (PR #37)
+ (Gary Kramlich)
+ * Added error messages when the unload method of a plugin loader is called.
+ (PR #38) (Gary Kramlich)
+
0.28.2: 2019/10/31
General
* Fixed a broken include in gplugin-gtk-plugin-info.h which caused build
--- a/convey.yml Thu Oct 31 23:55:18 2019 -0500
+++ b/convey.yml Thu Nov 07 23:09:51 2019 -0600
@@ -21,6 +21,8 @@
- elementary-juno-amd64
- fedora-29-amd64
- fedora-30-amd64
+ - fedora-31-amd64
+ - fedora-rawhide-amd64
- mingw-w64-i686
- mingw-w64-x86_64
- opensuse-tumbleweed-amd64
@@ -142,6 +144,10 @@
environment: [DISTRO=fedora, VERSION=30]
stages:
- tasks: [import, build, export]
+ fedora-31-amd64:
+ environment: [DISTRO=fedora, VERSION=31]
+ stages:
+ - tasks: [import, build, export]
fedora-rawhide-amd64:
environment: [DISTRO=fedora, VERSION=rawhide]
stages:
--- a/gplugin-gtk/gplugin-gtk-plugin-info.c Thu Oct 31 23:55:18 2019 -0500
+++ b/gplugin-gtk/gplugin-gtk-plugin-info.c Thu Nov 07 23:09:51 2019 -0600
@@ -314,19 +314,11 @@
gplugin_gtk_plugin_info_set_plugin(GPluginGtkPluginInfo *info,
GPluginPlugin *plugin)
{
- 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)));
- } else {
- info->plugin = NULL;
+ 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 Thu Oct 31 23:55:18 2019 -0500
+++ b/gplugin-gtk/gplugin-gtk-store.c Thu Nov 07 23:09:51 2019 -0600
@@ -72,6 +72,7 @@
gplugin_gtk_store_add_plugin(GPluginGtkStore *store, GPluginPlugin *plugin) {
GtkTreeIter iter;
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,
-1);
@@ -109,11 +110,72 @@
gplugin_manager_free_plugin_list(plugins);
}
+static gboolean
+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;
+ gboolean ret = FALSE;
+
+ gtk_tree_model_get(
+ model, iter,
+ GPLUGIN_GTK_STORE_PLUGIN_COLUMN, &plugin_b,
+ -1
+ );
+
+ if(plugin_a == plugin_b) {
+ gboolean loaded = gplugin_plugin_get_state(plugin_a) == GPLUGIN_PLUGIN_STATE_LOADED;
+
+ gtk_list_store_set(
+ GTK_LIST_STORE(model), iter,
+ GPLUGIN_GTK_STORE_LOADED_COLUMN, loaded,
+ -1
+ );
+
+ /* tell gplugin_gtk_store_update_plugin_state that we're done */
+ ret = TRUE;
+ }
+
+ g_object_unref(G_OBJECT(plugin_b));
+
+ return ret;
+}
+
+static void
+gplugin_gtk_store_update_plugin_state(GPluginGtkStore *store,
+ GPluginPlugin *plugin)
+{
+ gtk_tree_model_foreach(
+ GTK_TREE_MODEL(store),
+ gplugin_gtk_store_update_plugin_state_cb,
+ plugin
+ );
+}
+
/******************************************************************************
- * GObject Stuff
+ * Callbacks
+ *****************************************************************************/
+static void
+gplugin_gtk_store_plugin_loaded_cb(GObject *manager, GPluginPlugin *plugin,
+ gpointer data)
+{
+ gplugin_gtk_store_update_plugin_state(GPLUGIN_GTK_STORE(data), plugin);
+}
+
+static void
+gplugin_gtk_store_plugin_unloaded_cb(GObject *manager, GPluginPlugin *plugin,
+ gpointer data)
+{
+ gplugin_gtk_store_update_plugin_state(GPLUGIN_GTK_STORE(data), plugin);
+}
+
+/******************************************************************************
+ * GObject Implementation
*****************************************************************************/
static void
gplugin_gtk_store_constructed(GObject *obj) {
+ GObject *manager = NULL;
GList *l, *ids = 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),
(const gchar *)l->data);
g_list_free(ids);
+
+ 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);
}
static void
--- a/gplugin-gtk/gplugin-gtk-view.c Thu Oct 31 23:55:18 2019 -0500
+++ b/gplugin-gtk/gplugin-gtk-view.c Thu Nov 07 23:09:51 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,65 @@
static GParamSpec *properties[N_PROPERTIES] = {NULL,};
/******************************************************************************
- * GObject Stuff
+ * Callbacks
+ *****************************************************************************/
+static void
+gplugin_gtk_view_plugin_toggled_cb(GtkCellRendererToggle *rend,
+ gchar *path,
+ gpointer data)
+{
+ GPluginGtkView *view = GPLUGIN_GTK_VIEW(data);
+ GPluginPlugin *plugin = NULL;
+ GPluginPluginState state;
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+ 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);
+
+ gtk_tree_model_get(
+ model,
+ &iter,
+ GPLUGIN_GTK_STORE_PLUGIN_COLUMN, &plugin,
+ -1
+ );
+
+ if(!GPLUGIN_IS_PLUGIN(plugin)) {
+ return;
+ }
+
+ state = gplugin_plugin_get_state(plugin);
+ if(state == GPLUGIN_PLUGIN_STATE_LOADED) {
+ GError *error = NULL;
+
+ gplugin_manager_unload_plugin(plugin, &error);
+
+ if(error != NULL) {
+ g_warning("Failed to unload plugin: %s", error->message);
+
+ g_error_free(error);
+ }
+ } else {
+ GError *error = NULL;
+
+ gplugin_manager_load_plugin(plugin, &error);
+
+ if(error != NULL) {
+ g_warning("Failed to load plugin: %s", error->message);
+
+ g_error_free(error);
+ }
+ }
+
+ 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 Thu Oct 31 23:55:18 2019 -0500
+++ b/gplugin/gplugin-manager.c Thu Nov 07 23:09:51 2019 -0600
@@ -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.
*/
--- a/lua/gplugin-lua-core.c Thu Oct 31 23:55:18 2019 -0500
+++ b/lua/gplugin-lua-core.c Thu Nov 07 23:09:51 2019 -0600
@@ -21,6 +21,8 @@
#include "gplugin-lua-loader.h"
#include "gplugin-lua-plugin.h"
+#include <glib/gi18n-lib.h>
+
G_MODULE_EXPORT GPluginPluginInfo *
gplugin_query(G_GNUC_UNUSED GError **error) {
@@ -61,8 +63,15 @@
G_MODULE_EXPORT gboolean
gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin,
- G_GNUC_UNUSED GError **error)
+ GError **error)
{
+ g_set_error_literal(
+ error,
+ GPLUGIN_DOMAIN,
+ 0,
+ _("The Lua loader can not be unloaded")
+ );
+
return FALSE;
}
--- a/meson.build Thu Oct 31 23:55:18 2019 -0500
+++ b/meson.build Thu Nov 07 23:09:51 2019 -0600
@@ -1,7 +1,7 @@
###############################################################################
# Project Info
###############################################################################
-project('gplugin', 'c', version : '0.28.2',
+project('gplugin', 'c', version : '0.29.0',
meson_version : '>=0.42.0',
default_options : ['c_std=c99'])
--- a/packaging/debian/changelog Thu Oct 31 23:55:18 2019 -0500
+++ b/packaging/debian/changelog Thu Nov 07 23:09:51 2019 -0600
@@ -1,8 +1,14 @@
-gplugin (0.28.2) UNRELEASED; urgency=medium
+gplugin (0.28.3) unstable; urgency=medium
+
+ * New upstream release, see official changelog
+
+ -- Gary Kramlich <grim@reaperworld.com> Thu, 07 Nov 2019 23:03:46 -0600
+
+gplugin (0.28.2) unstable; urgency=medium
* New upstream release, see official changelog
- -- Gary Kramlich <grim@reaperworld.com> Tue, 22 Jan 2019 23:02:37 -0600
+ -- Gary Kramlich <grim@reaperworld.com> Thu, 31 Oct 2019 23:02:44 -0600
gplugin (0.26) unstable; urgency=medium
--- a/python/gplugin-python-core.c Thu Oct 31 23:55:18 2019 -0500
+++ b/python/gplugin-python-core.c Thu Nov 07 23:09:51 2019 -0600
@@ -18,6 +18,8 @@
#include <gplugin.h>
#include <gplugin-native.h>
+#include <glib/gi18n-lib.h>
+
#include "gplugin-python-loader.h"
#include "gplugin-python-plugin.h"
@@ -60,8 +62,15 @@
G_MODULE_EXPORT gboolean
gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin,
- G_GNUC_UNUSED GError **error)
+ GError **error)
{
+ g_set_error_literal(
+ error,
+ GPLUGIN_DOMAIN,
+ 0,
+ _("The Python loader can not be unloaded")
+ );
+
return FALSE;
}
--- a/tcc/gplugin-tcc-core.c Thu Oct 31 23:55:18 2019 -0500
+++ b/tcc/gplugin-tcc-core.c Thu Nov 07 23:09:51 2019 -0600
@@ -18,6 +18,8 @@
#include <gplugin.h>
#include <gplugin-native.h>
+#include <glib/gi18n-lib.h>
+
#include "gplugin-tcc-loader.h"
#include "gplugin-tcc-plugin.h"
@@ -60,8 +62,15 @@
G_MODULE_EXPORT gboolean
gplugin_unload(G_GNUC_UNUSED GPluginNativePlugin *plugin,
- G_GNUC_UNUSED GError **error)
+ GError **error)
{
+ g_set_error_literal(
+ error,
+ GPLUGIN_DOMAIN,
+ 0,
+ _("The TCC loader can not be unloaded")
+ );
+
return FALSE;
}