[gimp/gtk3-port: 72/247] app: port the splash to GTK+ 3.0



commit efb114730a0940b6e2c9eb59f0966f29d0f32772
Author: Michael Natterer <mitch gimp org>
Date:   Tue Oct 19 18:56:32 2010 +0200

    app: port the splash to GTK+ 3.0

 app/gui/splash.c |   56 ++++++++++++++++++++++-------------------------------
 1 files changed, 23 insertions(+), 33 deletions(-)
---
diff --git a/app/gui/splash.c b/app/gui/splash.c
index 8be54b8..9d16e80 100644
--- a/app/gui/splash.c
+++ b/app/gui/splash.c
@@ -24,6 +24,7 @@
 #include "libgimpbase/gimpbase.h"
 #include "libgimpmath/gimpmath.h"
 #include "libgimpcolor/gimpcolor.h"
+#include "libgimpwidgets/gimpwidgets.h"
 
 #include "gui-types.h"
 
@@ -66,14 +67,14 @@ static void        splash_position_layouts    (GimpSplash     *splash,
                                                const gchar    *text1,
                                                const gchar    *text2,
                                                GdkRectangle   *area);
-static gboolean    splash_area_expose         (GtkWidget      *widget,
-                                               GdkEventExpose *event,
+static gboolean    splash_area_draw           (GtkWidget      *widget,
+                                               cairo_t        *cr,
                                                GimpSplash     *splash);
 static void        splash_rectangle_union     (GdkRectangle   *dest,
                                                PangoRectangle *pango_rect,
                                                gint            offset_x,
                                                gint            offset_y);
-static gboolean    splash_average_text_area   (GimpSplash     *splash,
+static void        splash_average_text_area   (GimpSplash     *splash,
                                                GdkPixbuf      *pixbuf,
                                                GdkColor       *color);
 
@@ -170,27 +171,26 @@ splash_create (gboolean be_verbose)
 
   if (gdk_pixbuf_animation_is_static_image (pixbuf))
     {
-      GdkPixbuf *static_pixbuf = gdk_pixbuf_animation_get_static_image (pixbuf);
-      GdkPixmap *pixmap;
-      cairo_t   *cr;
+      GdkPixbuf       *static_pixbuf;
+      cairo_surface_t *surface;
+      cairo_pattern_t *pattern;
 
-      pixmap = gdk_pixmap_new (gtk_widget_get_window (splash->area),
-                               splash->width, splash->height, -1);
+      static_pixbuf = gdk_pixbuf_animation_get_static_image (pixbuf);
 
-      cr = gdk_cairo_create (pixmap);
-      gdk_cairo_set_source_pixbuf (cr, static_pixbuf, 0.0, 0.0);
-      cairo_paint (cr);
-      cairo_destroy (cr);
+      surface = gimp_cairo_surface_create_from_pixbuf (static_pixbuf);
 
-      gdk_window_set_back_pixmap (gtk_widget_get_window (splash->area),
-                                  pixmap, FALSE);
-      g_object_unref (pixmap);
+      pattern = cairo_pattern_create_for_surface (surface);
+      cairo_surface_destroy (surface);
+
+      gdk_window_set_background_pattern (gtk_widget_get_window (splash->area),
+                                         pattern);
+      cairo_pattern_destroy (pattern);
     }
 
   g_object_unref (pixbuf);
 
-  g_signal_connect_after (splash->area, "expose-event",
-			  G_CALLBACK (splash_area_expose),
+  g_signal_connect_after (splash->area, "draw",
+			  G_CALLBACK (splash_area_draw),
 			  splash);
 
   /*  add a progress bar  */
@@ -260,15 +260,10 @@ splash_update (const gchar *text1,
 /*  private functions  */
 
 static gboolean
-splash_area_expose (GtkWidget      *widget,
-                    GdkEventExpose *event,
-                    GimpSplash     *splash)
+splash_area_draw (GtkWidget  *widget,
+                  cairo_t    *cr,
+                  GimpSplash *splash)
 {
-  cairo_t *cr = gdk_cairo_create (event->window);
-
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   gdk_cairo_set_source_color (cr, &splash->color);
 
   cairo_move_to (cr, splash->upper_x, splash->upper_y);
@@ -277,8 +272,6 @@ splash_area_expose (GtkWidget      *widget,
   cairo_move_to (cr, splash->lower_x, splash->lower_y);
   pango_cairo_show_layout (cr, splash->lower);
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 
@@ -349,7 +342,7 @@ splash_rectangle_union (GdkRectangle   *dest,
 /* This function chooses a gray value for the text color, based on
  * the average luminance of the text area of the splash image.
  */
-static gboolean
+static void
 splash_average_text_area (GimpSplash *splash,
                           GdkPixbuf  *pixbuf,
                           GdkColor   *color)
@@ -362,8 +355,8 @@ splash_average_text_area (GimpSplash *splash,
   GdkRectangle  image     = { 0, 0, 0, 0 };
   GdkRectangle  area      = { 0, 0, 0, 0 };
 
-  g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), FALSE);
-  g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8, FALSE);
+  g_return_if_fail (GDK_IS_PIXBUF (pixbuf));
+  g_return_if_fail (gdk_pixbuf_get_bits_per_sample (pixbuf) == 8);
 
   image.width  = gdk_pixbuf_get_width (pixbuf);
   image.height = gdk_pixbuf_get_height (pixbuf);
@@ -408,9 +401,6 @@ splash_average_text_area (GimpSplash *splash,
     }
 
   color->red = color->green = color->blue = (luminance << 8 | luminance);
-
-  return gdk_colormap_alloc_color (gtk_widget_get_colormap (splash->area),
-                                   color, FALSE, TRUE);
 }
 
 static GdkPixbufAnimation *



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