grim/glibre

f3cc0c447749
Parents 22b2011af7f3
Children 43fd648ef584
Move the about window to it's own widget
--- a/meson.build Mon Sep 20 20:37:37 2021 -0500
+++ b/meson.build Mon Sep 20 21:19:53 2021 -0500
@@ -1,10 +1,10 @@
project('glibre', 'c', version : '0.0.3-dev')
-GLIB = dependency('glib-2.0', version : '>=2.40.0')
-GTK3 = dependency('gtk+-3.0', version : '>=3.18.0')
+GLIB = dependency('glib-2.0', version : '>=2.52.0')
+GTK3 = dependency('gtk+-3.0', version : '>=3.24.0')
add_project_arguments(
- '-DVERSION="@0@"'.format(meson.project_version()),
+ '-DGLIBRE_VERSION="@0@"'.format(meson.project_version()),
language : 'c',
)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/glibre-about-window.c Mon Sep 20 21:19:53 2021 -0500
@@ -0,0 +1,52 @@
+/*
+ * GlibRe - The glib regex tester
+ * Copyright (C) 2010-2021 Gary Kramlich <grim@reaperworld.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 "glibre-about-window.h"
+
+struct _GlibreAboutWindow {
+ GtkAboutDialog parent;
+};
+
+G_DEFINE_TYPE(GlibreAboutWindow, glibre_about_window, GTK_TYPE_ABOUT_DIALOG)
+
+/******************************************************************************
+ * GObject Implementation
+ *****************************************************************************/
+static void
+glibre_about_window_init(GlibreAboutWindow *window) {
+ gtk_widget_init_template(GTK_WIDGET(window));
+}
+
+static void
+glibre_about_window_class_init(GlibreAboutWindowClass *klass) {
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ gtk_widget_class_set_template_from_resource(widget_class,
+ "/org/imfreedom/keep/grim/glibre/about.ui");
+}
+
+/******************************************************************************
+ * Public API
+ *****************************************************************************/
+GtkWidget *
+glibre_about_window_new(void) {
+ return g_object_new(
+ GLIBRE_TYPE_ABOUT_WINDOW,
+ "version", GLIBRE_VERSION,
+ NULL);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/glibre-about-window.h Mon Sep 20 21:19:53 2021 -0500
@@ -0,0 +1,36 @@
+/*
+ * GlibRe - The glib regex tester
+ * Copyright (C) 2010-2021 Gary Kramlich <grim@reaperworld.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 GLIBRE_ABOUT_WINDOW_H
+#define GLIBRE_ABOUT_WINDOW_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GLIBRE_TYPE_ABOUT_WINDOW (glibre_about_window_get_type())
+G_DECLARE_FINAL_TYPE(GlibreAboutWindow, glibre_about_window, GLIBRE,
+ ABOUT_WINDOW, GtkAboutDialog)
+
+GtkWidget *glibre_about_window_new(void);
+
+G_END_DECLS
+
+#endif /* GLIBRE_ABOUT_WINDOW_H */
--- a/src/glibre.c Mon Sep 20 20:37:37 2021 -0500
+++ b/src/glibre.c Mon Sep 20 21:19:53 2021 -0500
@@ -19,6 +19,8 @@
#include <gdk/gdk.h>
#include <gtk/gtk.h>
+#include "glibre-about-window.h"
+
typedef struct {
GtkWidget *window;
@@ -605,34 +607,9 @@
static void
glibre_about_cb(GtkMenuItem *w, gpointer d) {
- const gchar *license = "\
-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.\n\
-\n\
-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.\n\
-\n\
-You should have received a copy of the GNU General Public License \
-along with this program. If not, see <http://www.gnu.org/licenses/>.";
- const gchar *authors[] = {
- "Gary Kramlich <grim@reaperworld.com",
- NULL,
- };
+ GtkWidget *about = glibre_about_window_new();
- gtk_show_about_dialog(NULL,
- "program-name", "glibre",
- "authors", authors,
- "copyright", "Copyright © 2010 Gary Kramlich <grim@reaperworld.com>",
- "license", license,
- "title", "About glibre",
- "version", VERSION,
- "website", "https://www.guifications.org/projects/glibre",
- "wrap-license", TRUE,
- NULL);
+ gtk_widget_show_all(about);
}
static void
--- a/src/meson.build Mon Sep 20 20:37:37 2021 -0500
+++ b/src/meson.build Mon Sep 20 21:19:53 2021 -0500
@@ -1,5 +1,16 @@
+gnome = import('gnome')
+
+glibre_resources = gnome.compile_resources(
+ 'glibre-resources',
+ 'resources/glibre.gresource.xml',
+ c_name: 'glibre',
+ source_dir: 'resources')
+
glibre = executable('glibre',
'glibre.c',
+ 'glibre-about-window.c',
+ 'glibre-about-window.h',
+ glibre_resources,
dependencies: [GLIB, GTK3],
install: true,
)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/resources/about.ui Mon Sep 20 21:19:53 2021 -0500
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.38.2
+
+Copyright (C) Copyright (C) 2010-2021
+
+This file is part of glibre.
+
+glibre 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.
+
+glibre 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 glibre. If not, see <http://www.gnu.org/licenses/>.
+
+Author: Gary Kramlich <grim@reaperworld.com>
+
+-->
+<interface domain="glibre">
+ <requires lib="gtk+" version="3.24"/>
+ <!-- interface-license-type gplv3 -->
+ <!-- interface-name glibre -->
+ <!-- interface-description A GLib Regex Testing Tool -->
+ <!-- interface-copyright Copyright (C) 2010-2021 -->
+ <!-- interface-authors Gary Kramlich <grim@reaperworld.com> -->
+ <template class="GlibreAboutWindow" parent="GtkAboutDialog">
+ <property name="can-focus">False</property>
+ <property name="type-hint">dialog</property>
+ <property name="program-name">Glibre</property>
+ <property name="copyright" translatable="yes">Copyright © 2010-2019 Gary Kramlich &lt;grim@reaperworld.com&gt;</property>
+ <property name="website">https://keep.imfreedom.org/grim/glibre</property>
+ <property name="website-label" translatable="yes">keep.imfreedom.org/grim/glibre</property>
+ <property name="license" translatable="yes">This program comes with absolutely no warranty.
+See the &lt;a href="https://www.gnu.org/licenses/gpl-3.0.html"&gt;GNU General Public License, version 3 or later&lt;/a&gt; for details.</property>
+ <property name="authors">Gary Kramlich &lt;grim@reaperworld.com&gt;</property>
+ <property name="logo-icon-name">edit-find-replace</property>
+ <property name="wrap-license">True</property>
+ <property name="license-type">gpl-3-0</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can-focus">False</property>
+ <signal name="delete-event" handler="gtk_widget_destroy" swapped="yes"/>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <property name="can-focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/resources/glibre.gresource.xml Mon Sep 20 21:19:53 2021 -0500
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<gresources>
+ <gresource prefix="org/imfreedom/keep/grim/glibre">
+ <file compressed="true">about.ui</file>
+ </gresource>
+</gresources>