grim/gplugin

Initial work on some gtk4 widgets
draft gtk4
2021-08-02, Gary Kramlich
f67eceb97a96
Parents 159f625002cc
Children
Initial work on some gtk4 widgets
--- a/.hgignore Fri Jul 30 02:09:45 2021 -0500
+++ b/.hgignore Mon Aug 02 23:43:22 2021 -0500
@@ -17,3 +17,7 @@
^po\/.*\.pot$
^obj-x86_64-linux-gnu\/
^debian\/?$
+^subprojects\/.+\/
+^subprojects\/libsass\.wrap
+^subprojects\/sassc\.wrap
+
--- a/gplugin-gtk-viewer/gplugin-gtk-viewer.c Fri Jul 30 02:09:45 2021 -0500
+++ b/gplugin-gtk-viewer/gplugin-gtk-viewer.c Mon Aug 02 23:43:22 2021 -0500
@@ -15,8 +15,8 @@
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*/
-#include <stdio.h>
-#include <stdlib.h>
+#include <glib.h>
+#include <glib/gstdio.h>
#include <gtk/gtk.h>
@@ -44,26 +44,6 @@
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
*****************************************************************************/
@@ -100,57 +80,11 @@
{
version_only = TRUE;
- printf("gplugin-gtk-viewer %s\n", GPLUGIN_VERSION);
+ printf("gplugin-gtk4-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
*****************************************************************************/
@@ -192,7 +126,7 @@
g_option_context_free(ctx);
if(error) {
- fprintf(stderr, "%s\n", error->message);
+ g_fprintf(stderr, "%s\n", error->message);
g_error_free(error);
@@ -222,8 +156,8 @@
gplugin_manager_refresh();
/* now create and show the window */
- window = create_window();
- gtk_widget_show_all(window);
+ // window = create_window();
+ // gtk_widget_show_all(window);
gtk_main();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer-window.c Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011-2021 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
+ * <https://www.gnu.org/licenses/>.
+ */
+#include "gplugin-gtk-viewer-window.h"
+
+#include <gtk/gtk.h>
+
+struct _GPluginGtkViewerWindow {
+ GtkApplicationWindow parent;
+};
+
+G_DEFINE_TYPE(
+ GPluginGtkViewerWindow,
+ gplugin_gtk_viewer_window,
+ GTK_TYPE_APPLICATION_WINDOW)
+
+/******************************************************************************
+ * GObject Stuff
+ *****************************************************************************/
+static void
+gplugin_gtk_viewer_window_init(GPluginGtkViewerWindow *window)
+{
+ gtk_widget_init_template(GTK_WIDGET(window));
+}
+
+static void
+gplugin_gtk_viewer_window_class_init(GPluginGtkViewerWindowClass *klass)
+{
+ gtk_widget_class_set_template_from_resource(
+ GTK_WIDGET_CLASS(klass),
+ "/org/imfreedom/keep/gplugin/gplugin/viewer/window.ui");
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GtkWidget *
+gplugin_gtk_viewer_window_new(GApplication *application)
+{
+ /* clang-format off */
+ return GTK_WIDGET(g_object_new(
+ GPLUGIN_GTK_VIEWER_TYPE_WINDOW,
+ "application", application,
+ NULL));
+ /* clang-format on */
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer-window.h Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011-2021 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 <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_GTK_VIEWER_WINDOW_H
+#define GPLUGIN_GTK_VIEWER_WINDOW_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#define GPLUGIN_GTK_VIEWER_TYPE_WINDOW (gplugin_gtk_viewer_window_get_type())
+G_DECLARE_FINAL_TYPE(
+ GPluginGtkViewerWindow,
+ gplugin_gtk_viewer_window,
+ GPLUGIN_GTK_VIEWER,
+ WINDOW,
+ GtkApplicationWindow)
+
+G_BEGIN_DECLS
+
+GtkWidget *gplugin_gtk_viewer_window_new(GApplication *application);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_GTK_VIEWER_WINDOW_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/gplugin-gtk-viewer.c Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2011-2021 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 <https://www.gnu.org/licenses/>.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+
+#include <gplugin.h>
+#include <gplugin-gtk4.h>
+
+#include "gplugin-gtk-viewer-window.h"
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static gboolean show_internal = FALSE, version_only = FALSE;
+
+/******************************************************************************
+ * Helpers
+ *****************************************************************************/
+static gboolean
+internal_cb(
+ G_GNUC_UNUSED const gchar *n,
+ G_GNUC_UNUSED const gchar *v,
+ G_GNUC_UNUSED gpointer d,
+ G_GNUC_UNUSED GError **e)
+{
+ show_internal = TRUE;
+
+ return TRUE;
+}
+
+static gboolean
+version_cb(
+ G_GNUC_UNUSED const gchar *n,
+ G_GNUC_UNUSED const gchar *v,
+ G_GNUC_UNUSED gpointer d,
+ G_GNUC_UNUSED GError **e)
+{
+ version_only = TRUE;
+
+ printf("gplugin-gtk4-viewer %s\n", GPLUGIN_VERSION);
+
+ return TRUE;
+}
+
+/******************************************************************************
+ * Main Stuff
+ *****************************************************************************/
+static void
+gplugin_gtk_viewer_startup(GApplication *application, gpointer data)
+{
+ gplugin_init(GPLUGIN_CORE_FLAGS_NONE);
+}
+
+static void
+gplugin_gtk_viewer_shutdown(GApplication *application, gpointer data)
+{
+ gplugin_uninit();
+}
+
+static void
+gplugin_gtk_viewer_activate(GApplication *application, gpointer data)
+{
+ GtkWidget *window = NULL;
+ if(version_only) {
+ return;
+ }
+
+ window = gplugin_gtk_viewer_window_new(application);
+ gtk_widget_show(window);
+}
+
+/* clang-format off */
+static GOptionEntry entries[] = {
+ {
+ "internal", 'i', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
+ internal_cb, "Show internal plugins",
+ NULL,
+ }, {
+ "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,
+ },
+};
+/* clang-format on */
+
+gint
+main(gint argc, gchar **argv)
+{
+ GApplication *application = NULL;
+
+ application = G_APPLICATION(gtk_application_new(
+ "org.imfreedom.keep.gplugin.gplugin.gplugin-gtk4-viewer",
+ G_APPLICATION_NON_UNIQUE));
+
+ g_application_add_main_option_entries(application, entries);
+ g_application_add_option_group(application, gplugin_get_option_group());
+
+ g_signal_connect(
+ G_OBJECT(application),
+ "startup",
+ G_CALLBACK(gplugin_gtk_viewer_startup),
+ NULL);
+ g_signal_connect(
+ G_OBJECT(application),
+ "shutdown",
+ G_CALLBACK(gplugin_gtk_viewer_shutdown),
+ NULL);
+ g_signal_connect(
+ G_OBJECT(application),
+ "activate",
+ G_CALLBACK(gplugin_gtk_viewer_activate),
+ NULL);
+
+ return g_application_run(application, argc, argv);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/meson.build Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,25 @@
+if get_option('gtk4')
+
+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.',
+ section : 'Warnings')
+endif
+
+gplugin_gtk4_viewer_resources = gnome.compile_resources(
+ 'gplugin-gtk4-viewer-resources',
+ 'resources/gplugin-gtk-viewer.gresource.xml',
+ c_name: 'gplugin_gtk_viewer',
+ source_dir: 'resources')
+
+gplugin_gtk_viewer = executable('gplugin-gtk4-viewer',
+ 'gplugin-gtk-viewer.c',
+ 'gplugin-gtk-viewer-window.c',
+ 'gplugin-gtk-viewer-window.h',
+ gplugin_gtk4_viewer_resources,
+ dependencies : [gplugin_dep, gplugin_gtk4_dep],
+ install : get_option('install-gplugin-gtk4-viewer')
+)
+
+endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/resources/gplugin-gtk-viewer.gresource.xml Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/imfreedom/keep/gplugin/gplugin/viewer/">
+ <file compressed="true">window.ui</file>
+ </gresource>
+</gresources>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/resources/row.ui Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GPluginGtkViewerRow" parent="AdwActionRow">
+ </template>
+</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4-viewer/resources/window.ui Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface>
+ <template class="GPluginGtkViewerWindow" parent="GtkApplicationWindow">
+ <property name="title" translatable="yes">GPlugin Viewer</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="hscrollbar-policy">never</property>
+ <property name="min-content-height">200</property>
+ <property name="hexpand">0</property>
+ <property name="vexpand">1</property>
+ <child>
+ <object class="GPluginGtkList" id="list"/>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/gplugin-gtk-list.c Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011-2021 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
+ * <https://www.gnu.org/licenses/>.
+ */
+#include "gplugin-gtk-list.h"
+
+#include <gtk/gtk.h>
+
+struct _GPluginGtkList {
+ GtkListBox parent;
+};
+
+G_DEFINE_TYPE(
+ GPluginGtkList,
+ gplugin_gtk_list,
+ GTK_TYPE_LIST_BOX)
+
+/******************************************************************************
+ * GObject Stuff
+ *****************************************************************************/
+static void
+gplugin_gtk_list_init(GPluginGtkList *list)
+{
+ gtk_widget_init_template(GTK_WIDGET(list));
+}
+
+static void
+gplugin_gtk_list_class_init(GPluginGtkListClass *klass)
+{
+ gtk_widget_class_set_template_from_resource(
+ GTK_WIDGET_CLASS(klass),
+ "/org/imfreedom/keep/gplugin/gplugin/list.ui");
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GtkWidget *
+gplugin_gtk_list_new(void)
+{
+ /* clang-format off */
+ return GTK_WIDGET(g_object_new(
+ GPLUGIN_GTK_TYPE_LIST,
+ NULL));
+ /* clang-format on */
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/gplugin-gtk-list.h Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2011-2021 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 <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_GTK_LIST_H
+#define GPLUGIN_GTK_LIST_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#define GPLUGIN_GTK_TYPE_LIST (gplugin_gtk_list_get_type())
+G_DECLARE_FINAL_TYPE(
+ GPluginGtkList,
+ gplugin_gtk_list,
+ GPLUGIN_GTK,
+ LIST,
+ GtkListBox)
+
+G_BEGIN_DECLS
+
+GtkWidget *gplugin_gtk_list_new(void);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_GTK_LIST_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/gplugin-gtk-row.c Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2011-2021 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
+ * <https://www.gnu.org/licenses/>.
+ */
+#include "gplugin-gtk-row.h"
+
+#include <gtk/gtk.h>
+
+struct _GPluginGtkRow {
+ AdwActionRow parent;
+};
+
+G_DEFINE_TYPE(
+ GPluginGtkRow,
+ gplugin_gtk_row,
+ ADW_TYPE_ACTION_ROW)
+
+/******************************************************************************
+ * GObject Stuff
+ *****************************************************************************/
+static void
+gplugin_gtk_row_init(GPluginGtkRow *row)
+{
+ gtk_widget_init_template(GTK_WIDGET(row));
+}
+
+static void
+gplugin_gtk_row_class_init(GPluginGtkRowClass *klass)
+{
+ gtk_widget_class_set_template_from_resource(
+ GTK_WIDGET_CLASS(klass),
+ "/org/imfreedom/keep/gplugin/gplugin/row.ui");
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GtkWidget *
+gplugin_gtk_row_new(void)
+{
+ /* clang-format off */
+ return GTK_WIDGET(g_object_new(
+ GPLUGIN_GTK_TYPE_ROW,
+ NULL));
+ /* clang-format on */
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/gplugin-gtk-row.h Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2011-2021 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 <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef GPLUGIN_GTK_ROW_H
+#define GPLUGIN_GTK_ROW_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include <adwaita.h>
+
+#define GPLUGIN_GTK_TYPE_ROW (gplugin_gtk_row_get_type())
+G_DECLARE_FINAL_TYPE(
+ GPluginGtkRow,
+ gplugin_gtk_row,
+ GPLUGIN_GTK,
+ ROW,
+ AdwActionRow)
+
+G_BEGIN_DECLS
+
+GtkWidget *gplugin_gtk_row_new(void);
+
+G_END_DECLS
+
+#endif /* GPLUGIN_GTK_ROW_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/gplugin-gtk4.h.in Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2011-2021 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 <https://www.gnu.org/licenses/>.
+ */
+#ifndef GPLUGIN_GTK4_H
+#define GPLUGIN_GTK4_H
+
+#ifndef __GI_SCANNER__
+# ifdef GPLUGIN_GTK4_COMPILATION
+# error "gplugin-gtk4 source files should not include gplugin-gtk4.h"
+# endif /* GPLUGIN_GTK4_COMPILATION */
+#endif /* __GI_SCANNER__ */
+
+#ifndef GPLUGIN_GTK4_GLOBAL_HEADER_INSIDE
+# define GPLUGIN_GTK4_GLOBAL_HEADER_INSIDE
+#endif /* GPLUGIN_GTK4_GLOBAL_HEADER_INSIDE */
+
+@GPLUGIN_GTK4_H_INCLUDES@
+
+#undef GPLUGIN_GTK4_GLOBAL_HEADER_INSIDE
+
+#endif /* GPLUGIN_GTK4_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/meson.build Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,71 @@
+if get_option('gtk4')
+
+GTK4 = dependency('gtk4', version : '>=4.0.0')
+LIBADWAITA = dependency('libadwaita-1')
+
+GPLUGIN_GTK4_SOURCES = [
+ 'gplugin-gtk-list.c',
+ 'gplugin-gtk-row.c',
+]
+
+GPLUGIN_GTK4_HEADERS = [
+ 'gplugin-gtk-list.h',
+ 'gplugin-gtk-row.h',
+]
+
+GPLUGIN_GTK4_H_INCLUDES = ''
+foreach header : GPLUGIN_GTK_HEADERS
+ GPLUGIN_GTK4_H_INCLUDES = '@0@\n#include <gplugin-gtk4/@1@>'.format(
+ GPLUGIN_GTK4_H_INCLUDES,
+ header)
+endforeach
+
+conf = configuration_data()
+conf.set('GPLUGIN_GTK_H_INCLUDES', GPLUGIN_GTK_H_INCLUDES)
+gplugin_gtk_h = configure_file(
+ input : 'gplugin-gtk4.h.in',
+ output : 'gplugin-gtk4.h',
+ configuration : conf,
+ install : true,
+ install_dir : get_option('includedir') / 'gplugin-1.0')
+
+gplugin_gtk4_resources = gnome.compile_resources(
+ 'gplugin-gtk4-resources',
+ 'resources/gplugin-gtk.gresource.xml',
+ c_name: 'gplugin_gtk',
+ source_dir: 'resources')
+
+gplugin_gtk4 = library('gplugin-gtk4',
+ GPLUGIN_GTK4_SOURCES,
+ GPLUGIN_GTK4_HEADERS,
+ gplugin_gtk4_resources,
+ c_args : ['-DPLUGIN_GTK4_COMPILATION', '-DG_LOG_DOMAIN="GPluginGtk4"'],
+ include_directories : toplevel_inc,
+ dependencies : [gplugin_dep, GTK4, LIBADWAITA],
+ version : '@0@.@1@.@2@'.format(GPLUGIN_MAJOR_VERSION, GPLUGIN_MINOR_VERSION, GPLUGIN_MICRO_VERSION),
+ install : true,
+)
+
+gplugin_gtk4_inc = include_directories('.')
+gplugin_gtk4_dep = declare_dependency(
+ include_directories : [toplevel_inc, gplugin_gtk4_inc],
+ link_with : [gplugin, gplugin_gtk4],
+ dependencies : [GLIB, GOBJECT, GTK4, LIBADWAITA],
+)
+
+pkgconfig.generate(
+ gplugin_gtk4,
+ name : 'libgplugin-gtk4',
+ description : 'Gtk4 widgets for GPlugin',
+ filebase : 'gplugin-gtk4',
+ subdirs : 'gplugin-1.0',
+ libraries : [gplugin],
+ requires : [GLIB, GOBJECT, GTK4],
+)
+
+install_headers(
+ GPLUGIN_GTK4_HEADERS,
+ subdir : 'gplugin-1.0/gplugin-gtk4',
+)
+
+endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/resources/gplugin-gtk.gresource.xml Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/imfreedom/keep/gplugin/gplugin/viewer/">
+ <file compressed="true">row.ui</file>
+ </gresource>
+</gresources>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/resources/list.ui Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GPluginGtkList" parent="GtkListBox">
+ <property name="activate-on-single-click">false</property>
+ </template>
+</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin-gtk4/resources/row.ui Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GPluginGtkViewerRow" parent="AdwActionRow">
+ </template>
+</interface>
--- a/meson.build Fri Jul 30 02:09:45 2021 -0500
+++ b/meson.build Mon Aug 02 23:43:22 2021 -0500
@@ -16,6 +16,8 @@
parts = parts[0].split('.')
GPLUGIN_MAJOR_VERSION = parts[0]
+GPLUGIN_MINOR_VERSION = parts[1]
+GPLUGIN_MICRO_VERSION = parts[2]
version_conf = configuration_data()
version_conf.set('GPLUGIN_MAJOR_VERSION', GPLUGIN_MAJOR_VERSION)
@@ -86,6 +88,8 @@
subdir('gplugin')
subdir('gplugin-gtk')
subdir('gplugin-gtk-viewer')
+subdir('gplugin-gtk4')
+subdir('gplugin-gtk4-viewer')
subdir('gplugin-query')
subdir('packaging')
subdir('po')
@@ -116,6 +120,7 @@
summary({
'gtk-doc' : get_option('doc'),
'gtk3 widgets' : get_option('gtk3'),
+ 'gtk4 widgets' : get_option('gtk4'),
'man pages' : get_option('help2man'),
}, bool_yn : true, section : 'Miscellaneous')
--- a/meson_options.txt Fri Jul 30 02:09:45 2021 -0500
+++ b/meson_options.txt Mon Aug 02 23:43:22 2021 -0500
@@ -17,6 +17,12 @@
)
option(
+ 'gtk4',
+ type : 'boolean', value : true,
+ description : 'Whether or not to build the gtk4library'
+)
+
+option(
'help2man',
type : 'boolean', value : true,
description : 'Whether or not to build man pages from --help output'
@@ -29,6 +35,12 @@
)
option(
+ 'install-gplugin-gtk4-viewer',
+ type : 'boolean', value : true,
+ description : 'Whether or not to install the gtk4 viewer application'
+)
+
+option(
'install-gplugin-query',
type : 'boolean', value : true,
description : 'Whether or not to install the query application'
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/subprojects/libadwaita-1.wrap Mon Aug 02 23:43:22 2021 -0500
@@ -0,0 +1,7 @@
+[wrap-git]
+url = https://gitlab.gnome.org/GNOME/libadwaita.git
+revision = main
+
+[provide]
+dependency_names = libadwaita-1
+libadwaita-1 = libadwaita_dep