[gimp/gtk3-port: 35/246] app: port to GtkWidget::draw() and to the new GDK_KEY_foo key names



commit 33a7842d08f7542f316fcbcd5f97d6cf72997822
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 13:42:19 2010 +0200

    app: port to GtkWidget::draw() and to the new GDK_KEY_foo key names

 app/widgets/gimpcurveview.c |   45 +++++++++++++++++-------------------------
 1 files changed, 18 insertions(+), 27 deletions(-)
---
diff --git a/app/widgets/gimpcurveview.c b/app/widgets/gimpcurveview.c
index 3f5d4ff..3a749df 100644
--- a/app/widgets/gimpcurveview.c
+++ b/app/widgets/gimpcurveview.c
@@ -75,8 +75,8 @@ static void       gimp_curve_view_get_property    (GObject          *object,
 
 static void       gimp_curve_view_style_set       (GtkWidget        *widget,
                                                    GtkStyle         *prev_style);
-static gboolean   gimp_curve_view_expose          (GtkWidget        *widget,
-                                                   GdkEventExpose   *event);
+static gboolean   gimp_curve_view_draw            (GtkWidget        *widget,
+                                                   cairo_t          *cr);
 static gboolean   gimp_curve_view_button_press    (GtkWidget        *widget,
                                                    GdkEventButton   *bevent);
 static gboolean   gimp_curve_view_button_release  (GtkWidget        *widget,
@@ -119,7 +119,7 @@ gimp_curve_view_class_init (GimpCurveViewClass *klass)
   object_class->get_property         = gimp_curve_view_get_property;
 
   widget_class->style_set            = gimp_curve_view_style_set;
-  widget_class->expose_event         = gimp_curve_view_expose;
+  widget_class->draw                 = gimp_curve_view_draw;
   widget_class->button_press_event   = gimp_curve_view_button_press;
   widget_class->button_release_event = gimp_curve_view_button_release;
   widget_class->motion_notify_event  = gimp_curve_view_motion_notify;
@@ -184,11 +184,11 @@ gimp_curve_view_class_init (GimpCurveViewClass *klass)
 
   binding_set = gtk_binding_set_by_class (klass);
 
-  gtk_binding_entry_add_signal (binding_set, GDK_x, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK,
                                 "cut-clipboard", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK,
                                 "copy-clipboard", 0);
-  gtk_binding_entry_add_signal (binding_set, GDK_v, GDK_CONTROL_MASK,
+  gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK,
                                 "paste-clipboard", 0);
 }
 
@@ -449,14 +449,12 @@ gimp_curve_view_draw_curve (GimpCurveView *view,
 }
 
 static gboolean
-gimp_curve_view_expose (GtkWidget      *widget,
-                        GdkEventExpose *event)
+gimp_curve_view_draw (GtkWidget *widget,
+                      cairo_t   *cr)
 {
-  GimpCurveView *view   = GIMP_CURVE_VIEW (widget);
-  GdkWindow     *window = gtk_widget_get_window (widget);
-  GtkStyle      *style  = gtk_widget_get_style (widget);
+  GimpCurveView *view  = GIMP_CURVE_VIEW (widget);
+  GtkStyle      *style = gtk_widget_get_style (widget);
   GtkAllocation  allocation;
-  cairo_t       *cr;
   GList         *list;
   gint           border;
   gint           width;
@@ -464,7 +462,7 @@ gimp_curve_view_expose (GtkWidget      *widget,
   gdouble        x, y;
   gint           i;
 
-  GTK_WIDGET_CLASS (parent_class)->expose_event (widget, event);
+  GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
 
   if (! view->curve)
     return FALSE;
@@ -475,16 +473,11 @@ gimp_curve_view_expose (GtkWidget      *widget,
   width  = allocation.width  - 2 * border;
   height = allocation.height - 2 * border;
 
-  cr = gdk_cairo_create (gtk_widget_get_window (widget));
-
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   if (gtk_widget_has_focus (widget))
     {
-      gtk_paint_focus (style, window,
+      gtk_paint_focus (style, cr,
                        gtk_widget_get_state (widget),
-                       &event->area, widget, NULL,
+                       widget, NULL,
                        border - 2, border - 2,
                        width + 4, height + 4);
     }
@@ -660,8 +653,6 @@ gimp_curve_view_expose (GtkWidget      *widget,
       cairo_paint_with_alpha (cr, 0.6);
     }
 
-  cairo_destroy (cr);
-
   return FALSE;
 }
 
@@ -946,7 +937,7 @@ gimp_curve_view_key_press (GtkWidget   *widget,
 
       switch (kevent->keyval)
         {
-        case GDK_Left:
+        case GDK_KEY_Left:
           for (i = i - 1; i >= 0 && ! handled; i--)
             {
               gimp_curve_get_point (curve, i, &x, NULL);
@@ -960,7 +951,7 @@ gimp_curve_view_key_press (GtkWidget   *widget,
             }
           break;
 
-        case GDK_Right:
+        case GDK_KEY_Right:
           for (i = i + 1; i < curve->n_points && ! handled; i++)
             {
               gimp_curve_get_point (curve, i, &x, NULL);
@@ -974,7 +965,7 @@ gimp_curve_view_key_press (GtkWidget   *widget,
             }
           break;
 
-        case GDK_Up:
+        case GDK_KEY_Up:
           if (y < 1.0)
             {
               y = y + (kevent->state & GDK_SHIFT_MASK ?
@@ -986,7 +977,7 @@ gimp_curve_view_key_press (GtkWidget   *widget,
             }
           break;
 
-        case GDK_Down:
+        case GDK_KEY_Down:
           if (y > 0)
             {
               y = y - (kevent->state & GDK_SHIFT_MASK ?
@@ -998,7 +989,7 @@ gimp_curve_view_key_press (GtkWidget   *widget,
             }
           break;
 
-        case GDK_Delete:
+        case GDK_KEY_Delete:
           gimp_curve_delete_point (curve, i);
           break;
 



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