[libgd] Add gd_ensure_types



commit 51d7519c5c0c7228f4995655e184cd4b24deadce
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Thu Apr 18 00:01:42 2013 +0200

    Add gd_ensure_types
    
    Add gd-types-catalog.[ch] that contains gd_ensure_types() for
    ensuring all types are available to GtkBuilder.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=698139

 Makefile.am              |   5 +-
 libgd/gd-types-catalog.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++
 libgd/gd-types-catalog.h |  31 +++++++++++
 libgd/gd.h               |   2 +
 4 files changed, 175 insertions(+), 1 deletion(-)
---
diff --git a/Makefile.am b/Makefile.am
index a6f2533..0abb577 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,10 @@ endif
 libgd_la_LIBADD = $(LIBGD_LIBS) $(LIBM)
 libgd_la_LDFLAGS = -avoid-version
 libgd_la_SOURCES = libgd/gd.h
-nodist_libgd_la_SOURCES =
+nodist_libgd_la_SOURCES =                      \
+       libgd/gd-types-catalog.c                \
+       libgd/gd-types-catalog.h                \
+       $(NULL)
 
 if LIBGD_GTK_HACKS
 gtk_hacks_sources =                             \
diff --git a/libgd/gd-types-catalog.c b/libgd/gd-types-catalog.c
new file mode 100644
index 0000000..a5ea556
--- /dev/null
+++ b/libgd/gd-types-catalog.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This program 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 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 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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include "gd-types-catalog.h"
+
+#ifdef LIBGD__VIEW_COMMON
+# include <libgd/gd-main-view-generic.h>
+# include <libgd/gd-styled-text-renderer.h>
+# include <libgd/gd-toggle-pixbuf-renderer.h>
+# include <libgd/gd-two-lines-renderer.h>
+#endif
+
+#ifdef LIBGD_MAIN_ICON_VIEW
+# include <libgd/gd-main-icon-view.h>
+#endif
+
+#ifdef LIBGD_MAIN_LIST_VIEW
+# include <libgd/gd-main-list-view.h>
+#endif
+
+#ifdef LIBGD_MAIN_VIEW
+# include <libgd/gd-main-view.h>
+#endif
+
+#ifdef LIBGD_MAIN_TOOLBAR
+# include <libgd/gd-main-toolbar.h>
+#endif
+
+#ifdef LIBGD_HEADER_BAR
+# include <libgd/gd-header-bar.h>
+#endif
+
+#ifdef LIBGD__HEADER_BUTTON
+# include <libgd/gd-header-button.h>
+#endif
+
+#ifdef LIBGD_MARGIN_CONTAINER
+# include <libgd/gd-margin-container.h>
+#endif
+
+#ifdef LIBGD_TAGGED_ENTRY
+# include <libgd/gd-tagged-entry.h>
+#endif
+
+#ifdef LIBGD_NOTIFICATION
+# include <libgd/gd-notification.h>
+#endif
+
+#ifdef LIBGD_REVEALER
+# include <libgd/gd-revealer.h>
+#endif
+
+#ifdef LIBGD_STACK
+# include <libgd/gd-stack.h>
+# include <libgd/gd-stack-switcher.h>
+#endif
+
+/**
+ * gd_ensure_types:
+ *
+ * This functions must be called during initialization
+ * to make sure the widget types are available to GtkBuilder.
+ */
+void
+gd_ensure_types (void)
+{
+#ifdef LIBGD__VIEW_COMMON
+  g_type_ensure (GD_TYPE_MAIN_VIEW_GENERIC);
+  g_type_ensure (GD_TYPE_STYLED_TEXT_RENDERER);
+  g_type_ensure (GD_TYPE_TOGGLE_PIXBUF_RENDERER);
+  g_type_ensure (GD_TYPE_TWO_LINES_RENDERER);
+#endif
+
+#ifdef LIBGD_MAIN_ICON_VIEW
+  g_type_ensure (GD_TYPE_MAIN_ICON_VIEW);
+#endif
+
+#ifdef LIBGD_MAIN_LIST_VIEW
+  g_type_ensure (GD_TYPE_MAIN_LIST_VIEW);
+#endif
+
+#ifdef LIBGD_MAIN_VIEW
+  g_type_ensure (GD_TYPE_MAIN_VIEW);
+#endif
+
+#ifdef LIBGD_MAIN_TOOLBAR
+  g_type_ensure (GD_TYPE_MAIN_TOOLBAR);
+#endif
+
+#ifdef LIBGD_HEADER_BAR
+  g_type_ensure (GD_TYPE_HEADER_BAR);
+#endif
+
+#ifdef LIBGD__HEADER_BUTTON
+  g_type_ensure (GD_TYPE_HEADER_SIMPLE_BUTTON);
+  g_type_ensure (GD_TYPE_HEADER_MENU_BUTTON);
+  g_type_ensure (GD_TYPE_HEADER_TOGGLE_BUTTON);
+  g_type_ensure (GD_TYPE_HEADER_RADIO_BUTTON);
+#endif
+
+#ifdef LIBGD_MARGIN_CONTAINER
+  g_type_ensure (GD_TYPE_MARGIN_CONTAINER);
+#endif
+
+#ifdef LIBGD_TAGGED_ENTRY
+  g_type_ensure (GD_TYPE_TAGGED_ENTRY);
+#endif
+
+#ifdef LIBGD_NOTIFICATION
+  g_type_ensure (GD_TYPE_NOTIFICATION);
+#endif
+
+#ifdef LIBGD_REVEALER
+  g_type_ensure (GD_TYPE_REVEALER);
+#endif
+
+#ifdef LIBGD_STACK
+  g_type_ensure (GD_TYPE_STACK);
+  g_type_ensure (GD_TYPE_STACK_SWITCHER);
+#endif
+}
+
diff --git a/libgd/gd-types-catalog.h b/libgd/gd-types-catalog.h
new file mode 100644
index 0000000..fc99416
--- /dev/null
+++ b/libgd/gd-types-catalog.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012 Red Hat, Inc.
+ *
+ * This program 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 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 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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __GD_TYPES_CATALOG_H__
+#define __GD_TYPES_CATALOG_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+void gd_ensure_types (void);
+
+G_END_DECLS
+
+#endif /* __GD_TYPES_CATALOG_H__ */
diff --git a/libgd/gd.h b/libgd/gd.h
index 02c59d4..ae7bd16 100644
--- a/libgd/gd.h
+++ b/libgd/gd.h
@@ -28,6 +28,8 @@
 
 G_BEGIN_DECLS
 
+#include <libgd/gd-types-catalog.h>
+
 #ifdef LIBGD_GTK_HACKS
 # include <libgd/gd-icon-utils.h>
 # include <libgd/gd-entry-focus-hack.h>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]