Merged in feature/gplugin-query-cleanups (pull request #79)
Feature/gplugin query cleanups
Approved-by: Richard Laager
Approved-by: Elliott Sales de Andrade
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-query/gplugin-query.c Sun Apr 19 08:59:19 2020 +0000
@@ -0,0 +1,368 @@
+ * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com> + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see <http://www.gnu.org/licenses/>. +/****************************************************************************** + *****************************************************************************/ +static gint verbosity = 0; +static gboolean show_internal = FALSE; +static gboolean output_paths = FALSE; +static gboolean exit_early = FALSE; +/****************************************************************************** + *****************************************************************************/ + G_GNUC_UNUSED const gchar *n, + G_GNUC_UNUSED const gchar *v, + G_GNUC_UNUSED gpointer d, + G_GNUC_UNUSED GError **e) + G_GNUC_UNUSED const gchar *n, + G_GNUC_UNUSED const gchar *v, + G_GNUC_UNUSED gpointer d, + G_GNUC_UNUSED GError **e) + G_GNUC_UNUSED const gchar *n, + G_GNUC_UNUSED const gchar *v, + G_GNUC_UNUSED gpointer d, + G_GNUC_UNUSED GError **e) + G_GNUC_UNUSED const gchar *n, + G_GNUC_UNUSED const gchar *v, + G_GNUC_UNUSED gpointer d, + G_GNUC_UNUSED GError **e) + printf("gplugin-query %s\n", GPLUGIN_VERSION); + G_GNUC_UNUSED const gchar *n, + G_GNUC_UNUSED const gchar *v, + G_GNUC_UNUSED gpointer d, + G_GNUC_UNUSED GError **e) +output_plugin(const gchar *id) + GSList *plugins = NULL, *l = NULL; + gboolean first = TRUE, header_output = FALSE; +#define MAIN_FORMAT_NEL " " FORMAT ": " +#define MAIN_FORMAT MAIN_FORMAT_NEL "%s\n" +#define STR_OR_EMPTY(str) ((str) ? (str) : "") + plugins = gplugin_manager_find_plugins(id); + printf("%s not found\n", id); + for(l = plugins; l; l = l->next) { + GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data); + GPluginPluginInfo *info = gplugin_plugin_get_info(plugin); + gboolean internal, loq; + gchar *license_id, *license_text, *license_url; + gchar *icon_name, *summary, *description, *category, *website; + gchar **authors, **dependencies; + internal = gplugin_plugin_info_get_internal(info); + if(!show_internal && internal) + "abi-version", &abi_version, + "license-id", &license_id, + "license-text", &license_text, + "license-url", &license_url, + "icon-name", &icon_name, + "description", &description, + "dependencies", &dependencies, + printf(MAIN_FORMAT, "name", STR_OR_EMPTY(name)); + printf(MAIN_FORMAT, "category", STR_OR_EMPTY(category)); + printf(MAIN_FORMAT, "version", STR_OR_EMPTY(version)); + printf(MAIN_FORMAT, "license", STR_OR_EMPTY(license_id)); + printf(MAIN_FORMAT, "license url", STR_OR_EMPTY(license_url)); + printf(MAIN_FORMAT, "summary", STR_OR_EMPTY(summary)); + printf(MAIN_FORMAT_NEL, "authors"); + for(i = 0; authors[i]; i++) { + printf("%s\n", STR_OR_EMPTY(authors[i])); + printf(MAIN_FORMAT, "website", STR_OR_EMPTY(website)); + STR_OR_EMPTY(gplugin_plugin_get_filename(plugin))); + GPluginLoader *loader = gplugin_plugin_get_loader(plugin); + printf(MAIN_FORMAT_NEL "%08x\n", "abi version", abi_version); + printf(MAIN_FORMAT, "internal", (internal) ? "yes" : "no"); + printf(MAIN_FORMAT, "load on query", (loq) ? "yes" : "no"); + printf(MAIN_FORMAT, "loader", G_OBJECT_TYPE_NAME(loader)); + g_object_unref(G_OBJECT(loader)); + printf(MAIN_FORMAT, "description", STR_OR_EMPTY(description)); + printf(MAIN_FORMAT_NEL, "dependencies"); + for(i = 0; dependencies[i]; i++) { + printf("%s\n", STR_OR_EMPTY(dependencies[i])); + g_strfreev(dependencies); + g_object_unref(G_OBJECT(info)); + g_slist_free_full(plugins, g_object_unref); +output_plugins(GList *plugins) + gboolean ret = TRUE, first = TRUE; + for(l = plugins; l; l = l->next) { + if(!output_plugin(l->data)) +/****************************************************************************** + *****************************************************************************/ +static GOptionEntry entries[] = { + "internal", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + internal_cb, N_("Show internal plugins"), + "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + verbosity_cb, N_("Increase verbosity"), + "full-verbose", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + full_verbosity_cb, N_("Increase verbosity to eleven"), + "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + version_cb, N_("Display the version and exit"), + "list", 'L', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, + list_cb, N_("Display all search paths and exit"), + NULL, 0, 0, 0, NULL, NULL, NULL, +main(gint argc, gchar **argv) + GOptionContext *ctx = NULL; + GOptionGroup *group = NULL; + ctx = g_option_context_new("PLUGIN-ID..."); + g_option_context_set_summary(ctx, _("Query installed plugins")); + g_option_context_set_translation_domain(ctx, GETTEXT_PACKAGE); + g_option_context_add_main_entries(ctx, entries, NULL); + group = gplugin_get_option_group(); + g_option_context_add_group(ctx, group); + g_option_context_parse(ctx, &argc, &argv, &error); + g_option_context_free(ctx); + fprintf(stderr, "%s\n", error->message); + for(path = gplugin_manager_get_paths(); path; path = path->next) { + printf("%s\n", (gchar *)path->data); + gplugin_manager_refresh(); + /* check if the user gave us atleast one plugin, and output them */ + GQueue *plugins = g_queue_new(); + for(i = 1; i < argc; i++) { + if(strlen(argv[i]) == 0) + g_queue_push_tail(plugins, argv[i]); + if(!output_plugins(plugins->head)) + GList *plugins = gplugin_manager_list_plugins(); + if(!output_plugins(plugins)) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-query/meson.build Sun Apr 19 08:59:19 2020 +0000
@@ -0,0 +1,17 @@
+gplugin_query = executable('gplugin-query', + dependencies : [gplugin_dep, GLIB, GOBJECT], +if get_option('help2man') + custom_target('gplugin-query.1', + '--name=Query installed plugins', '--section=1', + '--help-option=--help-all', '--no-info', + '--output', '@OUTPUT@', + output : 'gplugin-query.1', + install_dir : get_option('mandir') / 'man1') --- a/gplugin/gplugin-query.c Sat Apr 18 08:57:53 2020 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,364 +0,0 @@
- * Copyright (C) 2011-2020 Gary Kramlich <grim@reaperworld.com>
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
-/******************************************************************************
- *****************************************************************************/
-static gint verbosity = 0;
-static gboolean show_internal = FALSE;
-static gboolean output_paths = FALSE;
-static gboolean exit_early = FALSE;
-/******************************************************************************
- *****************************************************************************/
- G_GNUC_UNUSED const gchar *n,
- G_GNUC_UNUSED const gchar *v,
- G_GNUC_UNUSED gpointer d,
- G_GNUC_UNUSED GError **e)
- G_GNUC_UNUSED const gchar *n,
- G_GNUC_UNUSED const gchar *v,
- G_GNUC_UNUSED gpointer d,
- G_GNUC_UNUSED GError **e)
- G_GNUC_UNUSED const gchar *n,
- G_GNUC_UNUSED const gchar *v,
- G_GNUC_UNUSED gpointer d,
- G_GNUC_UNUSED GError **e)
- G_GNUC_UNUSED const gchar *n,
- G_GNUC_UNUSED const gchar *v,
- G_GNUC_UNUSED gpointer d,
- G_GNUC_UNUSED GError **e)
- printf("gplugin-query %s\n", GPLUGIN_VERSION);
- G_GNUC_UNUSED const gchar *n,
- G_GNUC_UNUSED const gchar *v,
- G_GNUC_UNUSED gpointer d,
- G_GNUC_UNUSED GError **e)
-output_plugin(const gchar *id)
- GSList *plugins = NULL, *l = NULL;
- gboolean first = TRUE, header_output = FALSE;
-#define MAIN_FORMAT_NEL " " FORMAT ": "
-#define MAIN_FORMAT MAIN_FORMAT_NEL "%s\n"
-#define STR_OR_EMPTY(str) ((str) ? (str) : "")
- plugins = gplugin_manager_find_plugins(id);
- printf("%s not found\n", id);
- for(l = plugins; l; l = l->next) {
- GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data);
- GPluginPluginInfo *info = gplugin_plugin_get_info(plugin);
- gboolean internal, loq;
- gchar *license_id, *license_text, *license_url;
- gchar *icon_name, *summary, *description, *category, *website;
- gchar **authors, **dependencies;
- internal = gplugin_plugin_info_get_internal(info);
- if(!show_internal && internal)
- "abi-version", &abi_version,
- "license-id", &license_id,
- "license-text", &license_text,
- "license-url", &license_url,
- "icon-name", &icon_name,
- "description", &description,
- "dependencies", &dependencies,
- printf(MAIN_FORMAT, "name", STR_OR_EMPTY(name));
- printf(MAIN_FORMAT, "category", STR_OR_EMPTY(category));
- printf(MAIN_FORMAT, "version", STR_OR_EMPTY(version));
- printf(MAIN_FORMAT, "license", STR_OR_EMPTY(license_id));
- printf(MAIN_FORMAT, "license url", STR_OR_EMPTY(license_url));
- printf(MAIN_FORMAT, "summary", STR_OR_EMPTY(summary));
- printf(MAIN_FORMAT_NEL, "authors");
- for(i = 0; authors[i]; i++) {
- printf("%s\n", STR_OR_EMPTY(authors[i]));
- printf(MAIN_FORMAT, "website", STR_OR_EMPTY(website));
- STR_OR_EMPTY(gplugin_plugin_get_filename(plugin)));
- GPluginLoader *loader = gplugin_plugin_get_loader(plugin);
- printf(MAIN_FORMAT_NEL "%08x\n", "abi version", abi_version);
- printf(MAIN_FORMAT, "internal", (internal) ? "yes" : "no");
- printf(MAIN_FORMAT, "load on query", (loq) ? "yes" : "no");
- printf(MAIN_FORMAT, "loader", G_OBJECT_TYPE_NAME(loader));
- g_object_unref(G_OBJECT(loader));
- printf(MAIN_FORMAT, "description", STR_OR_EMPTY(description));
- printf(MAIN_FORMAT_NEL, "dependencies");
- for(i = 0; dependencies[i]; i++) {
- printf("%s\n", STR_OR_EMPTY(dependencies[i]));
- g_strfreev(dependencies);
- g_object_unref(G_OBJECT(info));
- g_slist_free_full(plugins, g_object_unref);
-output_plugins(GList *plugins)
- gboolean ret = TRUE, first = TRUE;
- for(l = plugins; l; l = l->next) {
- if(!output_plugin(l->data))
-/******************************************************************************
- *****************************************************************************/
-static GOptionEntry entries[] = {
- "internal", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- internal_cb, N_("Show internal plugins"),
- "verbose", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- verbosity_cb, N_("Increase verbosity"),
- "full-verbose", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- full_verbosity_cb, N_("Increase verbosity to eleven"),
- "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- version_cb, N_("Display the version and exit"),
- "list", 'L', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- list_cb, N_("Display all search paths and exit"),
- NULL, 0, 0, 0, NULL, NULL, NULL,
-main(gint argc, gchar **argv)
- GOptionContext *ctx = NULL;
- GOptionGroup *group = NULL;
- ctx = g_option_context_new("PLUGIN-ID...");
- g_option_context_set_summary(ctx, _("Query installed plugins"));
- g_option_context_set_translation_domain(ctx, GETTEXT_PACKAGE);
- g_option_context_add_main_entries(ctx, entries, NULL);
- group = gplugin_get_option_group();
- g_option_context_add_group(ctx, group);
- g_option_context_parse(ctx, &argc, &argv, &error);
- g_option_context_free(ctx);
- fprintf(stderr, "%s\n", error->message);
- for(path = gplugin_manager_get_paths(); path; path = path->next) {
- printf("%s\n", (gchar *)path->data);
- gplugin_manager_refresh();
- /* check if the user gave us atleast one plugin, and output them */
- GQueue *plugins = g_queue_new();
- for(i = 1; i < argc; i++) {
- if(strlen(argv[i]) == 0)
- g_queue_push_tail(plugins, argv[i]);
- if(!output_plugins(plugins->head))
- GList *plugins = gplugin_manager_list_plugins();
- if(!output_plugins(plugins))
--- a/gplugin/meson.build Sat Apr 18 08:57:53 2020 +0000
+++ b/gplugin/meson.build Sun Apr 19 08:59:19 2020 +0000
@@ -188,26 +188,6 @@
###############################################################################
-# gplugin-query executable
-###############################################################################
-gplugin_query = executable('gplugin-query',
- dependencies : [gplugin_dep, GLIB, GOBJECT],
-if get_option('help2man')
- custom_target('gplugin-query.1',
- '--name=Query installed plugins', '--section=1',
- '--help-option=--help-all', '--no-info',
- '--output', '@OUTPUT@',
- output : 'gplugin-query.1',
- install_dir : get_option('mandir') / 'man1')
-###############################################################################
# loader-tests static library
###############################################################################
gplugin_loader_tests = static_library('gplugin-loader-tests',
--- a/meson.build Sat Apr 18 08:57:53 2020 +0000
+++ b/meson.build Sun Apr 19 08:59:19 2020 +0000
@@ -85,6 +85,7 @@
subdir('gplugin-gtk-viewer')