summaryrefslogtreecommitdiff
path: root/plugins/gtk+
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-07-22 19:10:38 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-07-22 19:10:38 -0300
commit392a3d61992ef100235166baf2ba32cc200c92d7 (patch)
treed017f573871193641b679dccb79d5e764418f84a /plugins/gtk+
parent17bde66d00e631cb63c6965d058ac80f99e0ec62 (diff)
downloadglade-392a3d61992ef100235166baf2ba32cc200c92d7.tar.gz
Gtk plugin: add glade_gtk_get_params_without_use_header_bar()
Add common function to generate a param list without use-header-bar property
Diffstat (limited to 'plugins/gtk+')
-rw-r--r--plugins/gtk+/glade-gtk.c69
-rw-r--r--plugins/gtk+/glade-gtk.h11
-rw-r--r--plugins/gtk+/meson.build1
3 files changed, 80 insertions, 1 deletions
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
new file mode 100644
index 00000000..221dc343
--- /dev/null
+++ b/plugins/gtk+/glade-gtk.c
@@ -0,0 +1,69 @@
+/*
+ * glade-gtk.c - Utilities
+ *
+ * Copyright (C) 2020 Juan Pablo Ugarte
+ *
+ * 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.1 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 program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Authors:
+ * Juan Pablo Ugarte <juanpablougarte@gmail.com>
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+
+#include "glade-gtk.h"
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+GParameter *
+glade_gtk_get_params_without_use_header_bar (guint *n_parameters, GParameter *parameters)
+{
+ GParameter *new_params = g_new0 (GParameter, *n_parameters + 1);
+ gboolean use_header_bar_set = FALSE;
+ gint i;
+
+ /* Here we need to force use-header-bar to FALSE in the runtime because
+ * GtkAboutDialog set it to TRUE in its constructor which then triggers a
+ * warning when glade tries to add placeholders in the action area
+ */
+ for (i = 0; i < *n_parameters; i++)
+ {
+ new_params[i] = parameters[i];
+
+ if (!g_strcmp0 (new_params[i].name, "use-header-bar"))
+ {
+ /* force the value to 0 */
+ g_value_set_int (&new_params[i].value, 0);
+ use_header_bar_set = TRUE;
+ }
+ }
+
+ if (!use_header_bar_set)
+ {
+ GParameter *use_header = &new_params[*n_parameters];
+
+ *n_parameters = *n_parameters + 1;
+
+ /* append value if it was not part of the parameters */
+ use_header->name = "use-header-bar";
+ g_value_init (&use_header->value, G_TYPE_INT);
+ g_value_set_int (&use_header->value, 0);
+ }
+
+ return new_params;
+}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
diff --git a/plugins/gtk+/glade-gtk.h b/plugins/gtk+/glade-gtk.h
index b3796b06..d793cb2e 100644
--- a/plugins/gtk+/glade-gtk.h
+++ b/plugins/gtk+/glade-gtk.h
@@ -27,7 +27,7 @@
#include <glib/gi18n-lib.h>
-#include <gladeui/glade-widget-adaptor.h>
+#include <glib-object.h>
/* --------------------------------- Constants ------------------------------ */
@@ -43,4 +43,13 @@
#define GLADE_TAG_ATTRIBUTES "attributes"
#define GLADE_TAG_ATTRIBUTE "attribute"
+G_BEGIN_DECLS
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+GParameter *glade_gtk_get_params_without_use_header_bar (guint *n_parameters,
+ GParameter *parameters);
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+G_END_DECLS
+
#endif /* __GLADE_GTK_H__ */
diff --git a/plugins/gtk+/meson.build b/plugins/gtk+/meson.build
index f86dafeb..781a6b5c 100644
--- a/plugins/gtk+/meson.build
+++ b/plugins/gtk+/meson.build
@@ -28,6 +28,7 @@ sources = files(
'glade-font-chooser-editor.c',
'glade-font-chooser-widget-editor.c',
'glade-grid-editor.c',
+ 'glade-gtk.c',
'glade-gtk-about-dialog.c',
'glade-gtk-action-bar.c',
'glade-gtk-action.c',