gplugin/gplugin

Move gplugin-gtk-viewer to it's own directory
develop
2018-10-01, Gary Kramlich
d16fed597df8
Parents 6d7e8fd31f49
Children 930e8096b9e4
Move gplugin-gtk-viewer to it's own directory
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk-viewer/data/gplugin-gtk-viewer.gresource.xml Mon Oct 01 21:11:06 2018 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/bitbucket/gplugin/gplugin/viewer/">
+ <file compressed="true">window.ui</file>
+ </gresource>
+</gresources>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk-viewer/data/window.ui Mon Oct 01 21:11:06 2018 -0500
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <requires lib="gplugin-gtk" version="0.28"/>
+ <template class="viewer" parent="GtkWindow">
+ <property name="can_focus">False</property>
+ <property name="border_width">12</property>
+ <property name="title" translatable="yes">GPlugin Viewer</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GPluginGtkView" id="view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection"/>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GPluginGtkPluginInfo" id="info">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child type="label">
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">__glade_unnamed_5</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk-viewer/gplugin-gtk-viewer.c Mon Oct 01 21:11:06 2018 -0500
@@ -0,0 +1,215 @@
+/*
+ * Copyright (C) 2011-2014 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/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include <gplugin/gplugin.h>
+#include <gplugin-gtk/gplugin-gtk.h>
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static gboolean show_internal = FALSE;
+static gboolean add_default_paths = TRUE, version_only = FALSE;
+static gchar **paths = NULL;
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static gboolean
+window_closed_cb(GPLUGIN_UNUSED GtkWidget *w,
+ GPLUGIN_UNUSED GdkEvent *e,
+ GPLUGIN_UNUSED gpointer d)
+{
+ gtk_main_quit();
+
+ return FALSE;
+}
+
+static void
+selection_changed_cb(GtkTreeSelection *sel, gpointer data) {
+ GPluginGtkPluginInfo *info = GPLUGIN_GTK_PLUGIN_INFO(data);
+ GPluginPlugin *plugin = NULL;
+ GtkTreeModel *model = NULL;
+ GtkTreeIter iter;
+
+ if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
+ gtk_tree_model_get(model, &iter,
+ GPLUGIN_GTK_STORE_PLUGIN_COLUMN, &plugin,
+ -1);
+ }
+
+ gplugin_gtk_plugin_info_set_plugin(info, plugin);
+}
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static gboolean
+internal_cb(GPLUGIN_UNUSED const gchar *n,
+ GPLUGIN_UNUSED const gchar *v,
+ GPLUGIN_UNUSED gpointer d,
+ GPLUGIN_UNUSED GError **e)
+{
+ show_internal = TRUE;
+
+ return TRUE;
+}
+
+static gboolean
+no_default_cb(GPLUGIN_UNUSED const gchar *n,
+ GPLUGIN_UNUSED const gchar *v,
+ GPLUGIN_UNUSED gpointer d,
+ GPLUGIN_UNUSED GError **e)
+{
+ add_default_paths = FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+version_cb(GPLUGIN_UNUSED const gchar *n,
+ GPLUGIN_UNUSED const gchar *v,
+ GPLUGIN_UNUSED gpointer d,
+ GPLUGIN_UNUSED GError **e)
+{
+ version_only = TRUE;
+
+ printf("gplugin-gtk-viewer %s\n", GPLUGIN_VERSION);
+
+ return TRUE;
+}
+
+static GtkWidget *
+create_window(void) {
+ GtkWidget *window = NULL, *grid = NULL, *sw = NULL;
+ GtkWidget *view = NULL, *info = NULL;
+ GtkTreeSelection *sel = NULL;
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW(window), "GPlugin Viewer");
+ gtk_container_set_border_width(GTK_CONTAINER(window), 12);
+ g_signal_connect(G_OBJECT(window), "delete-event",
+ G_CALLBACK(window_closed_cb), NULL);
+
+ grid = gtk_grid_new();
+ gtk_grid_set_row_homogeneous(GTK_GRID(grid), TRUE);
+ gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
+ gtk_container_add(GTK_CONTAINER(window), grid);
+
+ sw = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
+ GTK_SHADOW_IN);
+ gtk_grid_attach(GTK_GRID(grid), sw, 0, 0, 1, 1);
+
+ view = gplugin_gtk_view_new();
+ gplugin_gtk_view_set_show_internal(GPLUGIN_GTK_VIEW(view), show_internal);
+ gtk_container_add(GTK_CONTAINER(sw), view);
+
+ info = gplugin_gtk_plugin_info_new();
+ gtk_grid_attach(GTK_GRID(grid), info, 1, 0, 1, 1);
+
+ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
+ g_signal_connect(G_OBJECT(sel), "changed",
+ G_CALLBACK(selection_changed_cb), info);
+
+ return window;
+}
+
+/******************************************************************************
+ * Main Stuff
+ *****************************************************************************/
+static GOptionEntry entries[] = {
+ {
+ "internal", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ internal_cb, "Show internal plugins",
+ NULL,
+ }, {
+ "no-default-paths", 'D', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ no_default_cb, "Do not search the default plugin paths",
+ NULL,
+ }, {
+ "path", 'p', 0, G_OPTION_ARG_STRING_ARRAY,
+ &paths, "Additional paths to look for plugins",
+ "PATH",
+ }, {
+ "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ version_cb, "Display the version and exit",
+ NULL,
+ }, {
+ NULL, 0, 0, 0, NULL, NULL, NULL,
+ },
+};
+
+gint
+main(gint argc, gchar **argv) {
+ GError *error = NULL;
+ GOptionContext *ctx = NULL;
+ GtkWidget *window = NULL;
+
+ ctx = g_option_context_new("");
+ g_option_context_add_main_entries(ctx, entries, NULL);
+ g_option_context_add_group(ctx, gtk_get_option_group(TRUE));
+ g_option_context_parse(ctx, &argc, &argv, &error);
+ g_option_context_free(ctx);
+
+ if(error) {
+ fprintf(stderr, "%s\n", error->message);
+
+ g_error_free(error);
+
+ gplugin_uninit();
+
+ return EXIT_FAILURE;
+ }
+
+ if(version_only) {
+ return 0;
+ }
+
+ gtk_init(&argc, &argv);
+
+ gplugin_init();
+
+ if(add_default_paths)
+ gplugin_manager_add_default_paths();
+
+ if(paths) {
+ gint i;
+
+ for(i = 0; paths[i]; i++)
+ gplugin_manager_prepend_path(paths[i]);
+ }
+
+ gplugin_manager_refresh();
+
+ /* now create and show the window */
+ window = create_window();
+ gtk_widget_show_all(window);
+
+ gtk_main();
+
+ gplugin_uninit();
+
+ return 0;
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk-viewer/meson.build Mon Oct 01 21:11:06 2018 -0500
@@ -0,0 +1,27 @@
+if get_option('gtk3')
+
+gplugin_gtk_viewer_resources = gnome.compile_resources(
+ 'gplugin-gtk-viewer-resources',
+ 'data/gplugin-gtk-viewer.gresource.xml',
+ c_name: 'gplugin_gtk_viewer',
+ source_dir: 'data')
+
+gplugin_gtk_viewer = executable('gplugin-gtk-viewer',
+ 'gplugin-gtk-viewer.c',
+ dependencies : [gplugin_dep, gplugin_gtk_dep],
+ install : true
+)
+
+if get_option('help2man')
+ gplugin_gtk_viewer_man = custom_target('gplugin-gtk-viewer.1',
+ command : [help2man,
+ '--name=View installed plugins', '--section=1',
+ '--help-option=--help-all', '--no-info',
+ '--output', '@OUTPUT@',
+ gplugin_gtk_viewer],
+ output : 'gplugin-gtk-viewer.1',
+ install : true,
+ install_dir : join_paths(get_option('mandir'), 'man1'))
+endif
+
+endif
--- a/gplugin-gtk/gplugin-gtk-viewer.c Mon Oct 01 00:35:22 2018 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2011-2014 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/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <gtk/gtk.h>
-
-#include <gplugin/gplugin.h>
-#include <gplugin-gtk/gplugin-gtk.h>
-
-/******************************************************************************
- * Globals
- *****************************************************************************/
-static gboolean show_internal = FALSE;
-static gboolean add_default_paths = TRUE, version_only = FALSE;
-static gchar **paths = NULL;
-
-/******************************************************************************
- * Callbacks
- *****************************************************************************/
-static gboolean
-window_closed_cb(GPLUGIN_UNUSED GtkWidget *w,
- GPLUGIN_UNUSED GdkEvent *e,
- GPLUGIN_UNUSED gpointer d)
-{
- gtk_main_quit();
-
- return FALSE;
-}
-
-static void
-selection_changed_cb(GtkTreeSelection *sel, gpointer data) {
- GPluginGtkPluginInfo *info = GPLUGIN_GTK_PLUGIN_INFO(data);
- GPluginPlugin *plugin = NULL;
- GtkTreeModel *model = NULL;
- GtkTreeIter iter;
-
- if(gtk_tree_selection_get_selected(sel, &model, &iter)) {
- gtk_tree_model_get(model, &iter,
- GPLUGIN_GTK_STORE_PLUGIN_COLUMN, &plugin,
- -1);
- }
-
- gplugin_gtk_plugin_info_set_plugin(info, plugin);
-}
-
-/******************************************************************************
- * Helpers
- *****************************************************************************/
-static gboolean
-internal_cb(GPLUGIN_UNUSED const gchar *n,
- GPLUGIN_UNUSED const gchar *v,
- GPLUGIN_UNUSED gpointer d,
- GPLUGIN_UNUSED GError **e)
-{
- show_internal = TRUE;
-
- return TRUE;
-}
-
-static gboolean
-no_default_cb(GPLUGIN_UNUSED const gchar *n,
- GPLUGIN_UNUSED const gchar *v,
- GPLUGIN_UNUSED gpointer d,
- GPLUGIN_UNUSED GError **e)
-{
- add_default_paths = FALSE;
-
- return TRUE;
-}
-
-static gboolean
-version_cb(GPLUGIN_UNUSED const gchar *n,
- GPLUGIN_UNUSED const gchar *v,
- GPLUGIN_UNUSED gpointer d,
- GPLUGIN_UNUSED GError **e)
-{
- version_only = TRUE;
-
- printf("gplugin-gtk-viewer %s\n", GPLUGIN_VERSION);
-
- return TRUE;
-}
-
-static GtkWidget *
-create_window(void) {
- GtkWidget *window = NULL, *grid = NULL, *sw = NULL;
- GtkWidget *view = NULL, *info = NULL;
- GtkTreeSelection *sel = NULL;
-
- window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- gtk_window_set_title(GTK_WINDOW(window), "GPlugin Viewer");
- gtk_container_set_border_width(GTK_CONTAINER(window), 12);
- g_signal_connect(G_OBJECT(window), "delete-event",
- G_CALLBACK(window_closed_cb), NULL);
-
- grid = gtk_grid_new();
- gtk_grid_set_row_homogeneous(GTK_GRID(grid), TRUE);
- gtk_grid_set_column_spacing(GTK_GRID(grid), 12);
- gtk_container_add(GTK_CONTAINER(window), grid);
-
- sw = gtk_scrolled_window_new(NULL, NULL);
- gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
- GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
- gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
- GTK_SHADOW_IN);
- gtk_grid_attach(GTK_GRID(grid), sw, 0, 0, 1, 1);
-
- view = gplugin_gtk_view_new();
- gplugin_gtk_view_set_show_internal(GPLUGIN_GTK_VIEW(view), show_internal);
- gtk_container_add(GTK_CONTAINER(sw), view);
-
- info = gplugin_gtk_plugin_info_new();
- gtk_grid_attach(GTK_GRID(grid), info, 1, 0, 1, 1);
-
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
- g_signal_connect(G_OBJECT(sel), "changed",
- G_CALLBACK(selection_changed_cb), info);
-
- return window;
-}
-
-/******************************************************************************
- * Main Stuff
- *****************************************************************************/
-static GOptionEntry entries[] = {
- {
- "internal", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- internal_cb, "Show internal plugins",
- NULL,
- }, {
- "no-default-paths", 'D', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- no_default_cb, "Do not search the default plugin paths",
- NULL,
- }, {
- "path", 'p', 0, G_OPTION_ARG_STRING_ARRAY,
- &paths, "Additional paths to look for plugins",
- "PATH",
- }, {
- "version", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
- version_cb, "Display the version and exit",
- NULL,
- }, {
- NULL, 0, 0, 0, NULL, NULL, NULL,
- },
-};
-
-gint
-main(gint argc, gchar **argv) {
- GError *error = NULL;
- GOptionContext *ctx = NULL;
- GtkWidget *window = NULL;
-
- ctx = g_option_context_new("");
- g_option_context_add_main_entries(ctx, entries, NULL);
- g_option_context_add_group(ctx, gtk_get_option_group(TRUE));
- g_option_context_parse(ctx, &argc, &argv, &error);
- g_option_context_free(ctx);
-
- if(error) {
- fprintf(stderr, "%s\n", error->message);
-
- g_error_free(error);
-
- gplugin_uninit();
-
- return EXIT_FAILURE;
- }
-
- if(version_only) {
- return 0;
- }
-
- gtk_init(&argc, &argv);
-
- gplugin_init();
-
- if(add_default_paths)
- gplugin_manager_add_default_paths();
-
- if(paths) {
- gint i;
-
- for(i = 0; paths[i]; i++)
- gplugin_manager_prepend_path(paths[i]);
- }
-
- gplugin_manager_refresh();
-
- /* now create and show the window */
- window = create_window();
- gtk_widget_show_all(window);
-
- gtk_main();
-
- gplugin_uninit();
-
- return 0;
-}
-
--- a/gplugin-gtk/meson.build Mon Oct 01 00:35:22 2018 -0500
+++ b/gplugin-gtk/meson.build Mon Oct 01 21:11:06 2018 -0500
@@ -101,27 +101,6 @@
)
###############################################################################
-# Application Target
-###############################################################################
-gplugin_gtk_viewer = executable('gplugin-gtk-viewer',
- 'gplugin-gtk-viewer.c',
- dependencies : [gplugin_dep, gplugin_gtk_dep],
- install : true
-)
-
-if get_option('help2man')
- gplugin_gtk_viewer_man = custom_target('gplugin-gtk-viewer.1',
- command : [help2man,
- '--name=View installed plugins', '--section=1',
- '--help-option=--help-all', '--no-info',
- '--output', '@OUTPUT@',
- gplugin_gtk_viewer],
- output : 'gplugin-gtk-viewer.1',
- install : true,
- install_dir : join_paths(get_option('mandir'), 'man1'))
-endif
-
-###############################################################################
# GObject Introspection
###############################################################################
if get_option('gobject-introspection')
--- a/meson.build Mon Oct 01 00:35:22 2018 -0500
+++ b/meson.build Mon Oct 01 21:11:06 2018 -0500
@@ -112,6 +112,7 @@
###############################################################################
subdir('gplugin')
subdir('gplugin-gtk')
+subdir('gplugin-gtk-viewer')
subdir('packaging')
subdir('plugins')
subdir('po')