[glade] Move GladeWidgetAdaptor code for GtkFixed/GtkLayout into it's own C file
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Move GladeWidgetAdaptor code for GtkFixed/GtkLayout into it's own C file
- Date: Fri, 3 May 2013 17:06:52 +0000 (UTC)
commit f8d2db9a3f3da3df31d991ae50d649004fb8b070
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Fri May 3 22:31:06 2013 +0900
Move GladeWidgetAdaptor code for GtkFixed/GtkLayout into it's own C file
plugins/gtk+/Makefile.am | 1 +
plugins/gtk+/glade-gtk-fixed-layout.c | 131 +++++++++++++++++++++++++++++++++
plugins/gtk+/glade-gtk.c | 108 ---------------------------
po/POTFILES.in | 1 +
4 files changed, 133 insertions(+), 108 deletions(-)
---
diff --git a/plugins/gtk+/Makefile.am b/plugins/gtk+/Makefile.am
index 233cbcc..6138ff2 100644
--- a/plugins/gtk+/Makefile.am
+++ b/plugins/gtk+/Makefile.am
@@ -38,6 +38,7 @@ libgladegtk_la_SOURCES = \
glade-gtk-container.c \
glade-gtk-entry.c \
glade-gtk-expander.c \
+ glade-gtk-fixed-layout.c \
glade-gtk-frame.c \
glade-gtk-grid.c \
glade-gtk-info-bar.c \
diff --git a/plugins/gtk+/glade-gtk-fixed-layout.c b/plugins/gtk+/glade-gtk-fixed-layout.c
new file mode 100644
index 0000000..4fc7d7c
--- /dev/null
+++ b/plugins/gtk+/glade-gtk-fixed-layout.c
@@ -0,0 +1,131 @@
+/*
+ * glade-gtk-fixed-layout.c - GladeWidgetAdaptor for GtkFixed and GtkLayout
+ *
+ * Copyright (C) 2013 Tristan Van Berkom
+ *
+ * Authors:
+ * Tristan Van Berkom <tristan van berkom gmail 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.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.
+ */
+
+#include <config.h>
+#include <glib/gi18n-lib.h>
+#include <gladeui/glade.h>
+
+static void
+glade_gtk_fixed_layout_sync_size_requests (GtkWidget * widget)
+{
+ GList *children, *l;
+
+ if ((children = gtk_container_get_children (GTK_CONTAINER (widget))) != NULL)
+ {
+ for (l = children; l; l = l->next)
+ {
+ GtkWidget *child = l->data;
+ GladeWidget *gchild = glade_widget_get_from_gobject (child);
+ gint width = -1, height = -1;
+
+ if (!gchild)
+ continue;
+
+ glade_widget_property_get (gchild, "width-request", &width);
+ glade_widget_property_get (gchild, "height-request", &height);
+
+ gtk_widget_set_size_request (child, width, height);
+
+ }
+ g_list_free (children);
+ }
+}
+
+static cairo_pattern_t *
+get_fixed_layout_pattern (void)
+{
+ static cairo_pattern_t *static_pattern = NULL;
+
+ if (!static_pattern)
+ {
+ gchar *path = g_build_filename (glade_app_get_pixmaps_dir (), "fixed-bg.png", NULL);
+ cairo_surface_t *surface =
+ cairo_image_surface_create_from_png (path);
+
+ if (surface)
+ {
+ static_pattern = cairo_pattern_create_for_surface (surface);
+ cairo_pattern_set_extend (static_pattern, CAIRO_EXTEND_REPEAT);
+ }
+ else
+ g_warning ("Failed to create surface for %s\n", path);
+
+ g_free (path);
+ }
+ return static_pattern;
+}
+
+static void
+glade_gtk_fixed_layout_draw (GtkWidget *widget, cairo_t *cr)
+{
+ GtkAllocation allocation;
+
+ gtk_widget_get_allocation (widget, &allocation);
+
+ cairo_save (cr);
+
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ cairo_set_source (cr, get_fixed_layout_pattern ());
+ cairo_fill (cr);
+
+ cairo_restore (cr);
+}
+
+void
+glade_gtk_fixed_layout_post_create (GladeWidgetAdaptor * adaptor,
+ GObject * object, GladeCreateReason reason)
+{
+ /* Set a minimun size so you can actually see it if you added to a box */
+ gtk_widget_set_size_request (GTK_WIDGET (object), 32, 32);
+
+ gtk_widget_set_has_window (GTK_WIDGET (object), TRUE);
+
+ /* Sync up size request at project load time */
+ if (reason == GLADE_CREATE_LOAD)
+ g_signal_connect_after (object, "realize",
+ G_CALLBACK
+ (glade_gtk_fixed_layout_sync_size_requests), NULL);
+
+ g_signal_connect (object, "draw",
+ G_CALLBACK (glade_gtk_fixed_layout_draw), NULL);
+}
+
+void
+glade_gtk_fixed_layout_add_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ g_return_if_fail (GTK_IS_CONTAINER (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
+}
+
+void
+glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor * adaptor,
+ GObject * object, GObject * child)
+{
+ g_return_if_fail (GTK_IS_CONTAINER (object));
+ g_return_if_fail (GTK_IS_WIDGET (child));
+
+ gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
+}
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index da59d2f..b9afb7e 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -85,114 +85,6 @@ glade_gtk_init (const gchar * name)
{
}
-/* -------------------------------- GtkEntry -------------------------------- */
-
-/* ----------------------------- GtkFixed/GtkLayout ------------------------------ */
-static void
-glade_gtk_fixed_layout_sync_size_requests (GtkWidget * widget)
-{
- GList *children, *l;
-
- if ((children = gtk_container_get_children (GTK_CONTAINER (widget))) != NULL)
- {
- for (l = children; l; l = l->next)
- {
- GtkWidget *child = l->data;
- GladeWidget *gchild = glade_widget_get_from_gobject (child);
- gint width = -1, height = -1;
-
- if (!gchild)
- continue;
-
- glade_widget_property_get (gchild, "width-request", &width);
- glade_widget_property_get (gchild, "height-request", &height);
-
- gtk_widget_set_size_request (child, width, height);
-
- }
- g_list_free (children);
- }
-}
-
-static cairo_pattern_t *
-get_fixed_layout_pattern (void)
-{
- static cairo_pattern_t *static_pattern = NULL;
-
- if (!static_pattern)
- {
- gchar *path = g_build_filename (glade_app_get_pixmaps_dir (), "fixed-bg.png", NULL);
- cairo_surface_t *surface =
- cairo_image_surface_create_from_png (path);
-
- if (surface)
- {
- static_pattern = cairo_pattern_create_for_surface (surface);
- cairo_pattern_set_extend (static_pattern, CAIRO_EXTEND_REPEAT);
- }
- else
- g_warning ("Failed to create surface for %s\n", path);
-
- g_free (path);
- }
- return static_pattern;
-}
-
-static void
-glade_gtk_fixed_layout_draw (GtkWidget *widget, cairo_t *cr)
-{
- GtkAllocation allocation;
-
- gtk_widget_get_allocation (widget, &allocation);
-
- cairo_save (cr);
-
- cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
- cairo_set_source (cr, get_fixed_layout_pattern ());
- cairo_fill (cr);
-
- cairo_restore (cr);
-}
-
-void
-glade_gtk_fixed_layout_post_create (GladeWidgetAdaptor * adaptor,
- GObject * object, GladeCreateReason reason)
-{
- /* Set a minimun size so you can actually see it if you added to a box */
- gtk_widget_set_size_request (GTK_WIDGET (object), 32, 32);
-
- gtk_widget_set_has_window (GTK_WIDGET (object), TRUE);
-
- /* Sync up size request at project load time */
- if (reason == GLADE_CREATE_LOAD)
- g_signal_connect_after (object, "realize",
- G_CALLBACK
- (glade_gtk_fixed_layout_sync_size_requests), NULL);
-
- g_signal_connect (object, "draw",
- G_CALLBACK (glade_gtk_fixed_layout_draw), NULL);
-}
-
-void
-glade_gtk_fixed_layout_add_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- g_return_if_fail (GTK_IS_CONTAINER (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- gtk_container_add (GTK_CONTAINER (object), GTK_WIDGET (child));
-}
-
-void
-glade_gtk_fixed_layout_remove_child (GladeWidgetAdaptor * adaptor,
- GObject * object, GObject * child)
-{
- g_return_if_fail (GTK_IS_CONTAINER (object));
- g_return_if_fail (GTK_IS_WIDGET (child));
-
- gtk_container_remove (GTK_CONTAINER (object), GTK_WIDGET (child));
-}
-
/* ----------------------------- GtkWindow ------------------------------ */
static void
glade_gtk_window_read_accel_groups (GladeWidget * widget, GladeXmlNode * node)
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 9c16536..c59ef0b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -66,6 +66,7 @@ plugins/gtk+/glade-gtk-box.c
plugins/gtk+/glade-gtk-container.c
plugins/gtk+/glade-gtk-entry.c
plugins/gtk+/glade-gtk-expander.c
+plugins/gtk+/glade-gtk-fixed-layout.c
plugins/gtk+/glade-gtk-frame.c
plugins/gtk+/glade-gtk-grid.c
plugins/gtk+/glade-gtk-notebook.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]