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



commit c921c5489ea0a6d03288a601408b66a9761297d4
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 15:11:34 2010 +0200

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

 app/widgets/gimppaletteview.c |   34 +++++++++++-----------------------
 1 files changed, 11 insertions(+), 23 deletions(-)
---
diff --git a/app/widgets/gimppaletteview.c b/app/widgets/gimppaletteview.c
index 6e6d856..f8df69c 100644
--- a/app/widgets/gimppaletteview.c
+++ b/app/widgets/gimppaletteview.c
@@ -47,8 +47,8 @@ enum
 };
 
 
-static gboolean gimp_palette_view_expose         (GtkWidget        *widget,
-                                                  GdkEventExpose   *eevent);
+static gboolean gimp_palette_view_draw           (GtkWidget        *widget,
+                                                  cairo_t          *cr);
 static gboolean gimp_palette_view_button_press   (GtkWidget        *widget,
                                                   GdkEventButton   *bevent);
 static gboolean gimp_palette_view_key_press      (GtkWidget        *widget,
@@ -141,7 +141,7 @@ gimp_palette_view_class_init (GimpPaletteViewClass *klass)
                   G_TYPE_POINTER,
                   GIMP_TYPE_RGB);
 
-  widget_class->expose_event       = gimp_palette_view_expose;
+  widget_class->draw               = gimp_palette_view_draw;
   widget_class->button_press_event = gimp_palette_view_button_press;
   widget_class->key_press_event    = gimp_palette_view_key_press;
   widget_class->focus              = gimp_palette_view_focus;
@@ -159,23 +159,19 @@ gimp_palette_view_init (GimpPaletteView *view)
 }
 
 static gboolean
-gimp_palette_view_expose (GtkWidget      *widget,
-                          GdkEventExpose *eevent)
+gimp_palette_view_draw (GtkWidget *widget,
+                        cairo_t   *cr)
 {
   GimpPaletteView *pal_view = GIMP_PALETTE_VIEW (widget);
   GimpView        *view     = GIMP_VIEW (widget);
 
-  if (! gtk_widget_is_drawable (widget))
-    return FALSE;
-
-  GTK_WIDGET_CLASS (parent_class)->expose_event (widget, eevent);
+  GTK_WIDGET_CLASS (parent_class)->draw (widget, cr);
 
   if (view->renderer->viewable && pal_view->selected)
     {
       GimpViewRendererPalette *renderer;
       GtkStyle                *style = gtk_widget_get_style (widget);
       GtkAllocation            allocation;
-      cairo_t                 *cr;
       gint                     row, col;
 
       renderer = GIMP_VIEW_RENDERER_PALETTE (view->renderer);
@@ -185,12 +181,6 @@ gimp_palette_view_expose (GtkWidget      *widget,
       row = pal_view->selected->position / renderer->columns;
       col = pal_view->selected->position % renderer->columns;
 
-      cr = gdk_cairo_create (gtk_widget_get_window (widget));
-      gdk_cairo_region (cr, eevent->region);
-      cairo_clip (cr);
-
-      cairo_translate (cr, allocation.x, allocation.y);
-
       cairo_rectangle (cr,
                        col * renderer->cell_width  + 0.5,
                        row * renderer->cell_height + 0.5,
@@ -206,8 +196,6 @@ gimp_palette_view_expose (GtkWidget      *widget,
           gdk_cairo_set_source_color (cr, &style->fg[GTK_STATE_NORMAL]);
           cairo_stroke (cr);
         }
-
-      cairo_destroy (cr);
     }
 
   return FALSE;
@@ -271,11 +259,11 @@ gimp_palette_view_key_press (GtkWidget   *widget,
   GimpPaletteView *view = GIMP_PALETTE_VIEW (widget);
 
   if (view->selected &&
-      (kevent->keyval == GDK_space    ||
-       kevent->keyval == GDK_KP_Space ||
-       kevent->keyval == GDK_Return   ||
-       kevent->keyval == GDK_KP_Enter ||
-       kevent->keyval == GDK_ISO_Enter))
+      (kevent->keyval == GDK_KEY_space    ||
+       kevent->keyval == GDK_KEY_KP_Space ||
+       kevent->keyval == GDK_KEY_Return   ||
+       kevent->keyval == GDK_KEY_KP_Enter ||
+       kevent->keyval == GDK_KEY_ISO_Enter))
     {
       g_signal_emit (view, view_signals[ENTRY_CLICKED], 0,
                      view->selected, kevent->state);



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