Add GTK4 viewer outline
This does nothing since the widget isn't implemented, but it's setup to use GTK4 paradigms.
Testing Done:
Compile and run `gplugin-gtk4-viewer` with the various options, and some temporary debug prints.
Reviewed at https://reviews.imfreedom.org/r/992/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/data/gplugin-gtk-viewer.gresource.xml Sat Oct 09 23:05:38 2021 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?> + <gresource prefix="/org/imfreedom/keep/gplugin/gplugin/viewer/"> + <file compressed="true">window.ui</file> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/data/window.ui Sat Oct 09 23:05:38 2021 -0500
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?> + <requires lib="gtk" version="4.0"/> + <requires lib="gplugin-gtk" version="0.35"/> + <template class="GPluginGtkViewerWindow" parent="GtkApplicationWindow"> + <property name="title" translatable="yes">GPlugin Viewer</property> + <property name="default-width">600</property> + <property name="default-height">400</property> + <object class="GtkScrolledWindow"> + <property name="hscrollbar_policy">never</property> + <object class="GtkListBox"> + <child type="placeholder"> + <object class="GtkLabel"> + <property name="label" translatable="yes">No plugins found</property> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer-window.c Sat Oct 09 23:05:38 2021 -0500
@@ -0,0 +1,54 @@
+ * Copyright 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program 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 General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +#include "gplugin-gtk-viewer-window.h" +struct _GPluginGtkViewerWindow { + GtkApplicationWindow parent; + GPluginGtkViewerWindow, + gplugin_gtk_viewer_window, + GTK_TYPE_APPLICATION_WINDOW) +/****************************************************************************** + *****************************************************************************/ +gplugin_gtk_viewer_window_class_init(GPluginGtkViewerWindowClass *klass) + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + gtk_widget_class_set_template_from_resource( + "/org/imfreedom/keep/gplugin/gplugin/viewer/window.ui"); + gtk_widget_class_add_binding_action( +gplugin_gtk_viewer_window_init(GPluginGtkViewerWindow *self) + gtk_widget_init_template(GTK_WIDGET(self)); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer-window.h Sat Oct 09 23:05:38 2021 -0500
@@ -0,0 +1,35 @@
+ * Copyright 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program 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 General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +#ifndef GPLUGIN_GTK_VIEWER_WINDOW_H +#define GPLUGIN_GTK_VIEWER_WINDOW_H +#define GPLUGIN_GTK_VIEWER_TYPE_WINDOW (gplugin_gtk_viewer_window_get_type()) + GPluginGtkViewerWindow, + gplugin_gtk_viewer_window, +#endif /* GPLUGIN_GTK_VIEWER_WINDOW_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Sat Oct 09 23:05:38 2021 -0500
@@ -0,0 +1,152 @@
+ * Copyright (C) 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com> + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This program 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 General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. +#include <gplugin-gtk.h> +#include "gplugin-gtk-viewer-window.h" +/****************************************************************************** + *****************************************************************************/ +static gboolean show_internal = FALSE; +/****************************************************************************** + *****************************************************************************/ +handle_local_options_cb( + G_GNUC_UNUSED GApplication *app, + G_GNUC_UNUSED gpointer data) + gboolean option = FALSE; + if(g_variant_dict_lookup(options, "version", "b", &option, NULL)) { + /* Handle --version and exit with success. */ + printf("gplugin-gtk-viewer %s\n", GPLUGIN_VERSION); +startup_cb(G_GNUC_UNUSED GApplication *app, G_GNUC_UNUSED gpointer data) + GPluginManager *manager = NULL; + const gchar *env_paths = NULL; + gplugin_init(GPLUGIN_CORE_FLAGS_NONE); + manager = gplugin_manager_get_default(); + env_paths = g_getenv("GPLUGIN_PLUGIN_PATH"); + if(env_paths != NULL) { + gchar **paths = g_strsplit(env_paths, G_SEARCHPATH_SEPARATOR_S, 0); + for(i = 0; paths[i] != NULL; i++) { + gplugin_manager_prepend_path(manager, paths[i]); + gplugin_manager_refresh(manager); +shutdown_cb(G_GNUC_UNUSED GApplication *app, G_GNUC_UNUSED gpointer data) +activate_cb(GApplication *app) + GtkWindow *window = NULL; + g_return_if_fail(GTK_IS_APPLICATION(app)); + window = gtk_application_get_active_window(GTK_APPLICATION(app)); + GPLUGIN_GTK_VIEWER_TYPE_WINDOW, + gtk_window_present(window); +/****************************************************************************** + *****************************************************************************/ +static GOptionEntry entries[] = { + "internal", 'i', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, + &show_internal, "Show internal plugins", NULL, + "version", 'V', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, + NULL, "Display the version and exit", NULL, + NULL, 0, 0, 0, NULL, NULL, NULL, +main(gint argc, gchar **argv) + GtkApplication *app = NULL; + /* Set up gettext translations. */ + bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + /* Prepare application and options. */ + app = gtk_application_new(NULL, G_APPLICATION_FLAGS_NONE); + g_application_add_main_option_entries(G_APPLICATION(app), entries); + g_application_add_option_group( + gplugin_get_option_group()); + g_signal_connect(app, "activate", G_CALLBACK(activate_cb), NULL); + "handle-local-options", + G_CALLBACK(handle_local_options_cb), + g_signal_connect(app, "startup", G_CALLBACK(startup_cb), NULL); + g_signal_connect(app, "shutdown", G_CALLBACK(shutdown_cb), NULL); + /* Run and get exit code. */ + ret = g_application_run(G_APPLICATION(app), argc, argv); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/meson.build Sat Oct 09 23:05:38 2021 -0500
@@ -0,0 +1,36 @@
+if not get_option('install-gplugin-gtk4-viewer') +summary('gplugin-gtk4-viewer', + 'You have disabled installation of gplugin-gtk4-viewer which is a ' + + 'very useful diagnostics tool.', +gplugin_gtk4_viewer_resources = gnome.compile_resources( + 'gplugin-gtk-viewer-resources', + 'data/gplugin-gtk-viewer.gresource.xml', + c_name: 'gplugin_gtk_viewer', +gplugin_gtk4_viewer = executable('gplugin-gtk4-viewer', + 'gplugin-gtk-viewer.c', + 'gplugin-gtk-viewer-window.c', + gplugin_gtk4_viewer_resources, + dependencies : [gplugin_dep, gplugin_gtk4_dep], + install : get_option('install-gplugin-gtk4-viewer') +if get_option('help2man') + gplugin_gtk_viewer_man = custom_target('gplugin-gtk4-viewer.1', + '--name=View installed plugins', '--section=1', + '--help-option=--help-all', '--no-info', + '--output', '@OUTPUT@', + output : 'gplugin-gtk4-viewer.1', + install : get_option('install-gplugin-gtk4-viewer'), + install_dir : get_option('mandir') / 'man1') --- a/meson.build Sat Oct 09 22:59:17 2021 -0500
+++ b/meson.build Sat Oct 09 23:05:38 2021 -0500
@@ -124,6 +124,7 @@
subdir('gplugin-gtk3-viewer')
+subdir('gplugin-gtk4-viewer') --- a/meson_options.txt Sat Oct 09 22:59:17 2021 -0500
+++ b/meson_options.txt Sat Oct 09 23:05:38 2021 -0500
@@ -37,7 +37,13 @@
'install-gplugin-gtk3-viewer',
type : 'boolean', value : true,
- description : 'Whether or not to install the gtk3 viewer application'
+ description : 'Whether or not to install the GTK3 viewer application' + 'install-gplugin-gtk4-viewer', + type : 'boolean', value : true, + description : 'Whether or not to install the GTK4 viewer application' --- a/po/POTFILES Sat Oct 09 22:59:17 2021 -0500
+++ b/po/POTFILES Sat Oct 09 23:05:38 2021 -0500
@@ -5,6 +5,9 @@
gplugin-gtk3/gplugin-gtk-plugin-info.c
gplugin-gtk3/gplugin-gtk-store.c
gplugin-gtk3/gplugin-gtk-view.c
+gplugin-gtk4-viewer/data/window.ui +gplugin-gtk4-viewer/gplugin-gtk-viewer-window.c +gplugin-gtk4-viewer/gplugin-gtk-viewer.c gplugin-query/gplugin-query.c
gplugin/gplugin-file-tree.c