[glade3] * plugins/gtk+/glade-gtk.c, data/icons/Makefile.am, data/icons/fixed-bg.png, plugins/gtk+/fixed-bg



commit 4bf1e173e49965b7d3b415dfcae0f43467ae523a
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Thu Jan 13 02:25:02 2011 +0900

    	* plugins/gtk+/glade-gtk.c, data/icons/Makefile.am, data/icons/fixed-bg.png,
    	plugins/gtk+/fixed-bg.xpm: Now draw the GtkFixed/GtkLayout pattern in a "draw"
    	signal callback.

 ChangeLog                 |    4 ++
 data/icons/Makefile.am    |    2 +-
 data/icons/fixed-bg.png   |  Bin 0 -> 216 bytes
 plugins/gtk+/fixed-bg.xpm |   17 ---------
 plugins/gtk+/glade-gtk.c  |   82 +++++++++++++++++++++++----------------------
 5 files changed, 47 insertions(+), 58 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 40d6b55..488f970 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,10 @@
 	  read in by glade_signal_read from the xml (this happens because GTK+-3 removes some
 	  signals).
 
+	* plugins/gtk+/glade-gtk.c, data/icons/Makefile.am, data/icons/fixed-bg.png,
+	plugins/gtk+/fixed-bg.xpm: Now draw the GtkFixed/GtkLayout pattern in a "draw"
+	signal callback.
+
 2011-01-10  Tristan Van Berkom <tristanvb openismus com>
 
 	* gladeui/glade-signal-model.[ch]:
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 1390792..87139fa 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -17,7 +17,7 @@ update-icon-cache:
 
 
 pixmapsdir = $(pkgdatadir)/pixmaps
-pixmaps_DATA = selector.png devhelp.png plus.png atk.png drag-resize.png
+pixmaps_DATA = selector.png devhelp.png plus.png atk.png drag-resize.png fixed-bg.png
 
 
 EXTRA_DIST = $(pixmaps_DATA) glade-3.ico
diff --git a/data/icons/fixed-bg.png b/data/icons/fixed-bg.png
new file mode 100644
index 0000000..1f8c446
Binary files /dev/null and b/data/icons/fixed-bg.png differ
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 5677034..a4307c6 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -25,7 +25,6 @@
 #include <config.h>
 
 #include "glade-gtk.h"
-#include "fixed-bg.xpm"
 #include "glade-accels.h"
 #include "glade-attributes.h"
 #include "glade-column-types.h"
@@ -4645,36 +4644,6 @@ glade_gtk_entry_read_widget (GladeWidgetAdaptor * adaptor,
 }
 
 /* ----------------------------- GtkFixed/GtkLayout ------------------------------ */
-#if 0
-static void
-glade_gtk_fixed_layout_finalize (GdkPixmap * backing)
-{
-  g_object_unref (backing);
-}
-#endif
-
-static void
-glade_gtk_fixed_layout_realize (GtkWidget * widget)
-{
-#if _FIXME_FIXME_CAIRO_
-  GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (fixed_bg_xpm);
-  GdkPixmap *backing;
-
-  gdk_pixbuf_render_pixmap_and_mask (pixbuf, &backing, NULL, 1);
-
-  if (GTK_IS_LAYOUT (widget))
-    gdk_window_set_back_pixmap (gtk_layout_get_bin_window (GTK_LAYOUT (widget)),
-                                backing, FALSE);
-  else
-    gdk_window_set_back_pixmap (gtk_widget_get_window (widget), backing, FALSE);
-
-  /* For cleanup later
-   */
-  g_object_weak_ref (G_OBJECT (widget),
-                     (GWeakNotify) glade_gtk_fixed_layout_finalize, backing);
-#endif
-}
-
 static void
 glade_gtk_fixed_layout_sync_size_requests (GtkWidget * widget)
 {
@@ -4701,25 +4670,58 @@ glade_gtk_fixed_layout_sync_size_requests (GtkWidget * widget)
     }
 }
 
-void
-glade_gtk_fixed_layout_post_create (GladeWidgetAdaptor * adaptor,
-                                    GObject * object, GladeCreateReason reason)
+static cairo_pattern_t *
+get_fixed_layout_pattern (void)
 {
-  /* This is needed at least to set a backing pixmap. */
-  gtk_widget_set_has_window (GTK_WIDGET (object), FALSE);
+  static cairo_pattern_t *static_pattern = NULL;
 
-  /* For backing pixmap
-   */
-  g_signal_connect_after (object, "realize",
-                          G_CALLBACK (glade_gtk_fixed_layout_realize), 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)
+{
   /* 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



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