[gimp/gtk3-port: 84/229] app: port the colormap editor to GTK+ 3.0



commit f32704f19f44c44eb1d7892edeea72a38f8d1029
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 28 02:30:42 2010 +0200

    app: port the colormap editor to GTK+ 3.0

 app/widgets/gimpcolormapeditor.c |   28 ++++++++--------------------
 1 files changed, 8 insertions(+), 20 deletions(-)
---
diff --git a/app/widgets/gimpcolormapeditor.c b/app/widgets/gimpcolormapeditor.c
index 86bf480..ba498d9 100644
--- a/app/widgets/gimpcolormapeditor.c
+++ b/app/widgets/gimpcolormapeditor.c
@@ -74,8 +74,8 @@ static PangoLayout *
 
 static void   gimp_colormap_editor_update_entries  (GimpColormapEditor *editor);
 
-static gboolean gimp_colormap_preview_expose       (GtkWidget          *widget,
-                                                    GdkEventExpose     *event,
+static gboolean gimp_colormap_preview_draw         (GtkWidget          *widget,
+                                                    cairo_t            *cr,
                                                     GimpColormapEditor *editor);
 
 static void   gimp_colormap_editor_entry_clicked   (GimpPaletteView    *view,
@@ -150,7 +150,6 @@ gimp_colormap_editor_init (GimpColormapEditor *editor)
 {
   GtkWidget *frame;
   GtkWidget *table;
-  GtkObject *adj;
 
   frame = gtk_frame_new (NULL);
   gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
@@ -166,8 +165,8 @@ gimp_colormap_editor_init (GimpColormapEditor *editor)
   gtk_container_add (GTK_CONTAINER (frame), editor->view);
   gtk_widget_show (editor->view);
 
-  g_signal_connect (editor->view, "expose-event",
-                    G_CALLBACK (gimp_colormap_preview_expose),
+  g_signal_connect (editor->view, "draw",
+                    G_CALLBACK (gimp_colormap_preview_draw),
                     editor);
 
   g_signal_connect (editor->view, "entry-clicked",
@@ -193,9 +192,8 @@ gimp_colormap_editor_init (GimpColormapEditor *editor)
   gtk_box_pack_end (GTK_BOX (editor), table, FALSE, FALSE, 0);
   gtk_widget_show (table);
 
-  editor->index_spinbutton = gimp_spin_button_new (&adj,
+  editor->index_spinbutton = gimp_spin_button_new (&editor->index_adjustment,
                                                    0, 0, 0, 1, 10, 0, 1.0, 0);
-  editor->index_adjustment = GTK_ADJUSTMENT (adj);
   gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
                              _("Color index:"), 0.0, 0.5,
                              editor->index_spinbutton, 1, TRUE);
@@ -481,13 +479,12 @@ gimp_colormap_editor_create_layout (GtkWidget *widget)
 }
 
 static gboolean
-gimp_colormap_preview_expose (GtkWidget          *widget,
-                              GdkEventExpose     *event,
-                              GimpColormapEditor *editor)
+gimp_colormap_preview_draw (GtkWidget          *widget,
+                            cairo_t            *cr,
+                            GimpColormapEditor *editor)
 {
   GimpImageEditor *image_editor = GIMP_IMAGE_EDITOR (editor);
   GtkStyle        *style;
-  cairo_t         *cr;
   GtkAllocation    allocation;
   gint             width, height;
   gint             y;
@@ -496,18 +493,11 @@ gimp_colormap_preview_expose (GtkWidget          *widget,
       gimp_image_get_base_type (image_editor->image) == GIMP_INDEXED)
     return FALSE;
 
-  cr = gdk_cairo_create (event->window);
-  gdk_cairo_region (cr, event->region);
-  cairo_clip (cr);
-
   style = gtk_widget_get_style (widget);
   gdk_cairo_set_source_color (cr, &style->fg[gtk_widget_get_state (widget)]);
 
   gtk_widget_get_allocation (widget, &allocation);
 
-  if (! gtk_widget_get_has_window (widget))
-    cairo_translate (cr, allocation.x, allocation.y);
-
   if (! editor->layout)
     editor->layout = gimp_colormap_editor_create_layout (editor->view);
 
@@ -521,8 +511,6 @@ gimp_colormap_preview_expose (GtkWidget          *widget,
   cairo_move_to (cr, BORDER, MAX (y, 0));
   pango_cairo_show_layout (cr, editor->layout);
 
-  cairo_destroy (cr);
-
   return TRUE;
 }
 


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