[gimp/gtk3-port: 92/247] app: port to GtkWidget::draw()



commit 20bf38e133982108f8b85c5049954d0dd140f280
Author: Michael Natterer <mitch gimp org>
Date:   Wed Oct 20 19:25:37 2010 +0200

    app: port to GtkWidget::draw()

 app/widgets/gimptagpopup.c |   66 ++++++++++++++++++-------------------------
 1 files changed, 28 insertions(+), 38 deletions(-)
---
diff --git a/app/widgets/gimptagpopup.c b/app/widgets/gimptagpopup.c
index 888e876..f042fb2 100644
--- a/app/widgets/gimptagpopup.c
+++ b/app/widgets/gimptagpopup.c
@@ -76,11 +76,11 @@ static void     gimp_tag_popup_get_property            (GObject        *object,
                                                         GValue         *value,
                                                         GParamSpec     *pspec);
 
-static gboolean gimp_tag_popup_border_expose           (GtkWidget      *widget,
-                                                        GdkEventExpose *event,
+static gboolean gimp_tag_popup_border_draw             (GtkWidget      *widget,
+                                                        cairo_t        *cr,
                                                         GimpTagPopup   *popup);
-static gboolean gimp_tag_popup_list_expose             (GtkWidget      *widget,
-                                                        GdkEventExpose *event,
+static gboolean gimp_tag_popup_list_draw               (GtkWidget      *widget,
+                                                        cairo_t        *cr,
                                                         GimpTagPopup   *popup);
 static gboolean gimp_tag_popup_border_event            (GtkWidget      *widget,
                                                         GdkEvent       *event);
@@ -178,14 +178,14 @@ gimp_tag_popup_init (GimpTagPopup *popup)
   gtk_container_add (GTK_CONTAINER (popup->alignment), popup->tag_area);
   gtk_widget_show (popup->tag_area);
 
-  g_signal_connect (popup->alignment, "expose-event",
-                    G_CALLBACK (gimp_tag_popup_border_expose),
+  g_signal_connect (popup->alignment, "draw",
+                    G_CALLBACK (gimp_tag_popup_border_draw),
                     popup);
   g_signal_connect (popup, "event",
                     G_CALLBACK (gimp_tag_popup_border_event),
                     NULL);
-  g_signal_connect (popup->tag_area, "expose-event",
-                    G_CALLBACK (gimp_tag_popup_list_expose),
+  g_signal_connect (popup->tag_area, "draw",
+                    G_CALLBACK (gimp_tag_popup_list_draw),
                     popup);
   g_signal_connect (popup->tag_area, "event",
                     G_CALLBACK (gimp_tag_popup_list_event),
@@ -560,11 +560,10 @@ gimp_tag_popup_layout_tags (GimpTagPopup *popup,
 }
 
 static gboolean
-gimp_tag_popup_border_expose (GtkWidget      *widget,
-                              GdkEventExpose *event,
-                              GimpTagPopup   *popup)
+gimp_tag_popup_border_draw (GtkWidget    *widget,
+                            cairo_t      *cr,
+                            GimpTagPopup *popup)
 {
-  GdkWindow    *window = gtk_widget_get_window (widget);
   GtkStyle     *style  = gtk_widget_get_style (widget);
   GdkRectangle  border;
   GdkRectangle  upper;
@@ -572,36 +571,36 @@ gimp_tag_popup_border_expose (GtkWidget      *widget,
   gint          arrow_space;
   gint          arrow_size;
 
-  if (event->window != gtk_widget_get_window (widget))
+  if (! gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
     return FALSE;
 
   get_arrows_visible_area (popup, &border, &upper, &lower, &arrow_space);
 
   arrow_size = 0.7 * arrow_space;
 
-  gtk_paint_box (style, window,
+  gtk_paint_box (style, cr,
                  GTK_STATE_NORMAL,
                  GTK_SHADOW_OUT,
-                 &event->area, widget, "menu",
+                 widget, "menu",
                  0, 0, -1, -1);
 
   if (popup->arrows_visible)
     {
       /*  upper arrow  */
 
-      gtk_paint_box (style, window,
+      gtk_paint_box (style, cr,
                      popup->upper_arrow_state,
                      GTK_SHADOW_OUT,
-                     &event->area, widget, "menu",
+                     widget, "menu",
                      upper.x,
                      upper.y,
                      upper.width,
                      upper.height);
 
-      gtk_paint_arrow (style, window,
+      gtk_paint_arrow (style, cr,
                        popup->upper_arrow_state,
                        GTK_SHADOW_OUT,
-                       &event->area, widget, "menu_scroll_arrow_up",
+                       widget, "menu_scroll_arrow_up",
                        GTK_ARROW_UP,
                        TRUE,
                        upper.x + (upper.width - arrow_size) / 2,
@@ -610,19 +609,19 @@ gimp_tag_popup_border_expose (GtkWidget      *widget,
 
       /*  lower arrow  */
 
-      gtk_paint_box (style, window,
+      gtk_paint_box (style, cr,
                      popup->lower_arrow_state,
                      GTK_SHADOW_OUT,
-                     &event->area, widget, "menu",
+                     widget, "menu",
                      lower.x,
                      lower.y,
                      lower.width,
                      lower.height);
 
-      gtk_paint_arrow (style, window,
+      gtk_paint_arrow (style, cr,
                        popup->lower_arrow_state,
                        GTK_SHADOW_OUT,
-                       &event->area, widget, "menu_scroll_arrow_down",
+                       widget, "menu_scroll_arrow_down",
                        GTK_ARROW_DOWN,
                        TRUE,
                        lower.x + (lower.width - arrow_size) / 2,
@@ -731,22 +730,15 @@ gimp_tag_popup_border_event (GtkWidget *widget,
 }
 
 static gboolean
-gimp_tag_popup_list_expose (GtkWidget      *widget,
-                            GdkEventExpose *event,
-                            GimpTagPopup   *popup)
+gimp_tag_popup_list_draw (GtkWidget    *widget,
+                          cairo_t      *cr,
+                          GimpTagPopup *popup)
 {
-  GdkWindow      *window = gtk_widget_get_window (widget);
-  GtkStyle       *style  = gtk_widget_get_style (widget);
-  cairo_t        *cr;
+  GtkStyle       *style = gtk_widget_get_style (widget);
   PangoAttribute *attribute;
   PangoAttrList  *attributes;
   gint            i;
 
-  cr = gdk_cairo_create (event->window);
-
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   cairo_set_line_width (cr, 1.0);
   cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
 
@@ -828,9 +820,9 @@ gimp_tag_popup_list_expose (GtkWidget      *widget,
           tag_data->state != GTK_STATE_INSENSITIVE &&
           ! popup->single_select_disabled)
         {
-          gtk_paint_focus (style, window,
+          gtk_paint_focus (style, cr,
                            tag_data->state,
-                           &event->area, widget, NULL,
+                           widget, NULL,
                            tag_data->bounds.x,
                            tag_data->bounds.y - popup->scroll_y,
                            tag_data->bounds.width,
@@ -838,8 +830,6 @@ gimp_tag_popup_list_expose (GtkWidget      *widget,
         }
     }
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 



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