summaryrefslogtreecommitdiff
path: root/gtk/gtkprivate.c
diff options
context:
space:
mode:
authorTristan Van Berkom <tristanvb@openismus.com>2013-03-24 17:16:20 +0900
committerTristan Van Berkom <tristanvb@openismus.com>2013-04-08 21:19:27 +0900
commit4ec6d6006e36f3f51074750534a8ab20b51abb5b (patch)
treea8d778d3a7ec2024000b4b251a81ccb8a355a4fb /gtk/gtkprivate.c
parentc6ab5157358bc364eede018acc14de976add195c (diff)
downloadgtk+-4ec6d6006e36f3f51074750534a8ab20b51abb5b.tar.gz
Work around access to global resources without calling gtk_init()
Some utilities such as GIR and gtk-doc, initialize class vtables without initializing GTK+, with composite templates accessing resources this causes a hand full of unneeded warnings. The workaround for now is the use a private function _gtk_ensure_resources() which is both called while initializing GTK+, and at the beginning of gtk_widget_class_set_template_from_resource() (the private function ensures that the resource will only ever be registered GOnce).
Diffstat (limited to 'gtk/gtkprivate.c')
-rw-r--r--gtk/gtkprivate.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gtk/gtkprivate.c b/gtk/gtkprivate.c
index 70151f9bfe..3177d4761d 100644
--- a/gtk/gtkprivate.c
+++ b/gtk/gtkprivate.c
@@ -30,6 +30,7 @@
#include "gdk/gdk.h"
#include "gtkprivate.h"
+#include "gtkresources.h"
#if !defined G_OS_WIN32 && !(defined GDK_WINDOWING_QUARTZ && defined QUARTZ_RELOCATION)
@@ -251,3 +252,18 @@ _gtk_translate_keyboard_accel_state (GdkKeymap *keymap,
return retval;
}
+
+static gpointer
+register_resources (gpointer data)
+{
+ _gtk_register_resource ();
+ return NULL;
+}
+
+void
+_gtk_ensure_resources (void)
+{
+ static GOnce register_resources_once = G_ONCE_INIT;
+
+ g_once (&register_resources_once, register_resources, NULL);
+}