[gnome-panel/gtk3] fish: Save Wanda a bit more



commit f56a0964159e4776c60f05cb47a96fc092bb5e02
Author: Vincent Untz <vuntz gnome org>
Date:   Mon Jan 31 17:53:15 2011 +0100

    fish: Save Wanda a bit more
    
    Use draw instead of expose-event.
    Use gtk_widget_set_size_request() on the drawing area, instead of
    connecting to the size-request signal that doesn't exist anymore.

 applets/fish/fish.c |   37 +++++++++++++------------------------
 1 files changed, 13 insertions(+), 24 deletions(-)
---
diff --git a/applets/fish/fish.c b/applets/fish/fish.c
index a4d02bf..d445318 100644
--- a/applets/fish/fish.c
+++ b/applets/fish/fish.c
@@ -114,7 +114,7 @@ typedef struct {
 
 
 static gboolean load_fish_image          (FishApplet *fish);
-static void     update_surface            (FishApplet *fish);
+static void     update_surface           (FishApplet *fish);
 static void     something_fishy_going_on (FishApplet *fish,
 					  const char *message);
 static void     display_fortune_dialog   (FishApplet *fish);
@@ -1528,6 +1528,10 @@ update_surface (FishApplet *fish)
 		}
 	}
 
+	gtk_widget_set_size_request (fish->drawing_area,
+				     fish->requisition.width,
+				     fish->requisition.height);
+
 	g_assert (width != -1 && height != -1);
 
 	if (width == 0 || height == 0)
@@ -1592,14 +1596,13 @@ update_surface (FishApplet *fish)
 }
 
 static gboolean
-fish_applet_expose_event (GtkWidget      *widget,
-			  GdkEventExpose *event,
-			  FishApplet     *fish)
+fish_applet_draw (GtkWidget  *widget,
+		  cairo_t    *cr,
+		  FishApplet *fish)
 {
-	GdkWindow    *window;
+	GdkWindow *window;
 	int width, height;
 	int src_x, src_y;
-        cairo_t *cr;
 
 	g_return_val_if_fail (fish->surface != NULL, FALSE);
 
@@ -1623,27 +1626,15 @@ fish_applet_expose_event (GtkWidget      *widget,
 	} else
 		src_x = ((width * fish->current_frame) / fish->n_frames);
 
-        cr = gdk_cairo_create (event->window);
-        gdk_cairo_region (cr, event->region);
-        cairo_clip (cr);
-
+        cairo_save (cr);
         cairo_set_source_surface (cr, fish->surface, -src_x, -src_y);
         cairo_paint (cr);
-
-        cairo_destroy (cr);
+        cairo_restore (cr);
 
         return FALSE;
 }
 
 static void
-fish_applet_size_request (GtkWidget      *widget,
-			  GtkRequisition *requisition,
-			  FishApplet     *fish)
-{
-	*requisition = fish->requisition;
-}
-
-static void
 fish_applet_size_allocate (GtkWidget     *widget,
 			   GtkAllocation *allocation,
 			   FishApplet    *fish)
@@ -1818,12 +1809,10 @@ setup_fish_widget (FishApplet *fish)
 			  G_CALLBACK (fish_applet_realize), fish);
 	g_signal_connect (fish->drawing_area, "unrealize",
 			  G_CALLBACK (fish_applet_unrealize), fish);
-	g_signal_connect (fish->drawing_area, "size-request",
-			  G_CALLBACK (fish_applet_size_request), fish);
 	g_signal_connect (fish->drawing_area, "size-allocate",
 			  G_CALLBACK (fish_applet_size_allocate), fish);
-	g_signal_connect (fish->drawing_area, "expose-event",
-			  G_CALLBACK (fish_applet_expose_event), fish);
+	g_signal_connect (fish->drawing_area, "draw",
+			  G_CALLBACK (fish_applet_draw), fish);
 
 	gtk_widget_add_events (widget, GDK_ENTER_NOTIFY_MASK | 
 				       GDK_LEAVE_NOTIFY_MASK |



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