[gimp] libgimpwidgets: implement GtkWidget::state_flags_changed()



commit 1264285cff2a504916e1de205cb3b3e414438272
Author: Michael Natterer <mitch gimp org>
Date:   Tue Dec 21 00:07:03 2010 +0100

    libgimpwidgets: implement GtkWidget::state_flags_changed()
    
    instead of GtkWidget::state_changed()

 libgimpwidgets/gimpcolorarea.c   |  129 +++++++++++++++++++-------------------
 libgimpwidgets/gimpcolorbutton.c |   93 ++++++++++++++--------------
 libgimpwidgets/gimpcolorscale.c  |   81 ++++++++++++------------
 3 files changed, 153 insertions(+), 150 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorarea.c b/libgimpwidgets/gimpcolorarea.c
index 95b7180..940b191 100644
--- a/libgimpwidgets/gimpcolorarea.c
+++ b/libgimpwidgets/gimpcolorarea.c
@@ -79,52 +79,52 @@ struct _GimpColorAreaPrivate
                                      GimpColorAreaPrivate)
 
 
-static void      gimp_color_area_dispose       (GObject            *object);
-static void      gimp_color_area_finalize      (GObject            *object);
-static void      gimp_color_area_get_property  (GObject            *object,
-                                                guint               property_id,
-                                                GValue             *value,
-                                                GParamSpec         *pspec);
-static void      gimp_color_area_set_property  (GObject            *object,
-                                                guint               property_id,
-                                                const GValue       *value,
-                                                GParamSpec         *pspec);
-
-static void      gimp_color_area_size_allocate (GtkWidget          *widget,
-                                                GtkAllocation      *allocation);
-static void      gimp_color_area_state_changed (GtkWidget          *widget,
-                                                GtkStateType        previous_state);
-static gboolean  gimp_color_area_draw          (GtkWidget          *widget,
-                                                cairo_t            *cr);
-static void      gimp_color_area_render_buf    (GtkWidget          *widget,
-                                                gboolean            insensitive,
-                                                GimpColorAreaType   type,
-                                                guchar             *buf,
-                                                guint               width,
-                                                guint               height,
-                                                guint               rowstride,
-                                                GimpRGB            *color);
-static void      gimp_color_area_render        (GimpColorArea      *area);
-
-static void  gimp_color_area_drag_begin         (GtkWidget        *widget,
-                                                 GdkDragContext   *context);
-static void  gimp_color_area_drag_end           (GtkWidget        *widget,
-                                                 GdkDragContext   *context);
-static void  gimp_color_area_drag_data_received (GtkWidget        *widget,
-                                                 GdkDragContext   *context,
-                                                 gint              x,
-                                                 gint              y,
-                                                 GtkSelectionData *selection_data,
-                                                 guint             info,
-                                                 guint             time);
-static void  gimp_color_area_drag_data_get      (GtkWidget        *widget,
-                                                 GdkDragContext   *context,
-                                                 GtkSelectionData *selection_data,
-                                                 guint             info,
-                                                 guint             time);
-
-static void  gimp_color_area_create_transform   (GimpColorArea    *area);
-static void  gimp_color_area_destroy_transform  (GimpColorArea    *area);
+static void      gimp_color_area_dispose             (GObject           *object);
+static void      gimp_color_area_finalize            (GObject           *object);
+static void      gimp_color_area_get_property        (GObject           *object,
+                                                      guint              property_id,
+                                                      GValue            *value,
+                                                      GParamSpec        *pspec);
+static void      gimp_color_area_set_property        (GObject           *object,
+                                                      guint              property_id,
+                                                      const GValue      *value,
+                                                      GParamSpec        *pspec);
+
+static void      gimp_color_area_size_allocate       (GtkWidget         *widget,
+                                                      GtkAllocation     *allocation);
+static void      gimp_color_area_state_flags_changed (GtkWidget         *widget,
+                                                      GtkStateFlags      previous_state);
+static gboolean  gimp_color_area_draw                (GtkWidget         *widget,
+                                                      cairo_t           *cr);
+static void      gimp_color_area_render_buf          (GtkWidget         *widget,
+                                                      gboolean           insensitive,
+                                                      GimpColorAreaType  type,
+                                                      guchar            *buf,
+                                                      guint              width,
+                                                      guint              height,
+                                                      guint              rowstride,
+                                                      GimpRGB           *color);
+static void      gimp_color_area_render              (GimpColorArea     *area);
+
+static void      gimp_color_area_drag_begin          (GtkWidget         *widget,
+                                                      GdkDragContext    *context);
+static void      gimp_color_area_drag_end            (GtkWidget         *widget,
+                                                      GdkDragContext    *context);
+static void      gimp_color_area_drag_data_received  (GtkWidget         *widget,
+                                                      GdkDragContext    *context,
+                                                      gint               x,
+                                                      gint               y,
+                                                      GtkSelectionData  *selection_data,
+                                                      guint              info,
+                                                      guint              time);
+static void      gimp_color_area_drag_data_get       (GtkWidget         *widget,
+                                                      GdkDragContext    *context,
+                                                      GtkSelectionData  *selection_data,
+                                                      guint              info,
+                                                      guint              time);
+
+static void      gimp_color_area_create_transform    (GimpColorArea     *area);
+static void      gimp_color_area_destroy_transform   (GimpColorArea     *area);
 
 
 G_DEFINE_TYPE (GimpColorArea, gimp_color_area, GTK_TYPE_DRAWING_AREA)
@@ -152,21 +152,21 @@ gimp_color_area_class_init (GimpColorAreaClass *klass)
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  object_class->dispose            = gimp_color_area_dispose;
-  object_class->finalize           = gimp_color_area_finalize;
-  object_class->get_property       = gimp_color_area_get_property;
-  object_class->set_property       = gimp_color_area_set_property;
+  object_class->dispose             = gimp_color_area_dispose;
+  object_class->finalize            = gimp_color_area_finalize;
+  object_class->get_property        = gimp_color_area_get_property;
+  object_class->set_property        = gimp_color_area_set_property;
 
-  widget_class->size_allocate      = gimp_color_area_size_allocate;
-  widget_class->state_changed      = gimp_color_area_state_changed;
-  widget_class->draw               = gimp_color_area_draw;
+  widget_class->size_allocate       = gimp_color_area_size_allocate;
+  widget_class->state_flags_changed = gimp_color_area_state_flags_changed;
+  widget_class->draw                = gimp_color_area_draw;
 
-  widget_class->drag_begin         = gimp_color_area_drag_begin;
-  widget_class->drag_end           = gimp_color_area_drag_end;
-  widget_class->drag_data_received = gimp_color_area_drag_data_received;
-  widget_class->drag_data_get      = gimp_color_area_drag_data_get;
+  widget_class->drag_begin          = gimp_color_area_drag_begin;
+  widget_class->drag_end            = gimp_color_area_drag_end;
+  widget_class->drag_data_received  = gimp_color_area_drag_data_received;
+  widget_class->drag_data_get       = gimp_color_area_drag_data_get;
 
-  klass->color_changed             = NULL;
+  klass->color_changed              = NULL;
 
   gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
 
@@ -364,17 +364,18 @@ gimp_color_area_size_allocate (GtkWidget     *widget,
 }
 
 static void
-gimp_color_area_state_changed (GtkWidget    *widget,
-                               GtkStateType  previous_state)
+gimp_color_area_state_flags_changed (GtkWidget     *widget,
+                                     GtkStateFlags  previous_state)
 {
-  if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE ||
-      previous_state == GTK_STATE_INSENSITIVE)
+  if ((gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_INSENSITIVE) !=
+      (previous_state & GTK_STATE_FLAG_INSENSITIVE))
     {
       GIMP_COLOR_AREA (widget)->needs_render = TRUE;
     }
 
-  if (GTK_WIDGET_CLASS (parent_class)->state_changed)
-    GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state);
+  if (GTK_WIDGET_CLASS (parent_class)->state_flags_changed)
+    GTK_WIDGET_CLASS (parent_class)->state_flags_changed (widget,
+                                                          previous_state);
 }
 
 static gboolean
diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c
index d9cff53..f428264 100644
--- a/libgimpwidgets/gimpcolorbutton.c
+++ b/libgimpwidgets/gimpcolorbutton.c
@@ -106,39 +106,39 @@ struct _GimpColorButtonPrivate
                                                       GimpColorButtonPrivate)
 
 
-static void     gimp_color_button_class_init   (GimpColorButtonClass *klass);
-static void     gimp_color_button_init         (GimpColorButton      *button,
-                                                GimpColorButtonClass *klass);
-
-static void     gimp_color_button_finalize          (GObject         *object);
-static void     gimp_color_button_dispose           (GObject         *object);
-static void     gimp_color_button_get_property      (GObject         *object,
-                                                     guint            property_id,
-                                                     GValue          *value,
-                                                     GParamSpec      *pspec);
-static void     gimp_color_button_set_property      (GObject         *object,
-                                                     guint            property_id,
-                                                     const GValue    *value,
-                                                     GParamSpec      *pspec);
-
-static gboolean gimp_color_button_button_press      (GtkWidget       *widget,
-                                                     GdkEventButton  *bevent);
-static void     gimp_color_button_state_changed     (GtkWidget       *widget,
-                                                     GtkStateType     prev_state);
-static void     gimp_color_button_clicked           (GtkButton       *button);
-static GType    gimp_color_button_get_action_type   (GimpColorButton *button);
-
-static void     gimp_color_button_dialog_response   (GtkWidget       *dialog,
-                                                     gint             response_id,
-                                                     GimpColorButton *button);
-static void     gimp_color_button_use_color         (GtkAction       *action,
-                                                     GimpColorButton *button);
-static void     gimp_color_button_area_changed      (GtkWidget       *color_area,
-                                                     GimpColorButton *button);
-static void     gimp_color_button_selection_changed (GtkWidget       *selection,
-                                                     GimpColorButton *button);
-static void     gimp_color_button_help_func         (const gchar     *help_id,
-                                                     gpointer         help_data);
+static void     gimp_color_button_class_init     (GimpColorButtonClass *klass);
+static void     gimp_color_button_init           (GimpColorButton      *button,
+                                                  GimpColorButtonClass *klass);
+
+static void     gimp_color_button_finalize            (GObject         *object);
+static void     gimp_color_button_dispose             (GObject         *object);
+static void     gimp_color_button_get_property        (GObject         *object,
+                                                       guint            property_id,
+                                                       GValue          *value,
+                                                       GParamSpec      *pspec);
+static void     gimp_color_button_set_property        (GObject         *object,
+                                                       guint            property_id,
+                                                       const GValue    *value,
+                                                       GParamSpec      *pspec);
+
+static gboolean gimp_color_button_button_press        (GtkWidget       *widget,
+                                                       GdkEventButton  *bevent);
+static void     gimp_color_button_state_flags_changed (GtkWidget       *widget,
+                                                       GtkStateFlags    prev_state);
+static void     gimp_color_button_clicked             (GtkButton       *button);
+static GType    gimp_color_button_get_action_type     (GimpColorButton *button);
+
+static void     gimp_color_button_dialog_response     (GtkWidget       *dialog,
+                                                       gint             response_id,
+                                                       GimpColorButton *button);
+static void     gimp_color_button_use_color           (GtkAction       *action,
+                                                       GimpColorButton *button);
+static void     gimp_color_button_area_changed        (GtkWidget       *color_area,
+                                                       GimpColorButton *button);
+static void     gimp_color_button_selection_changed   (GtkWidget       *selection,
+                                                       GimpColorButton *button);
+static void     gimp_color_button_help_func           (const gchar     *help_id,
+                                                       gpointer         help_data);
 
 
 static const GtkActionEntry actions[] =
@@ -218,18 +218,18 @@ gimp_color_button_class_init (GimpColorButtonClass *klass)
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  object_class->finalize           = gimp_color_button_finalize;
-  object_class->dispose            = gimp_color_button_dispose;
-  object_class->get_property       = gimp_color_button_get_property;
-  object_class->set_property       = gimp_color_button_set_property;
+  object_class->finalize            = gimp_color_button_finalize;
+  object_class->dispose             = gimp_color_button_dispose;
+  object_class->get_property        = gimp_color_button_get_property;
+  object_class->set_property        = gimp_color_button_set_property;
 
-  widget_class->button_press_event = gimp_color_button_button_press;
-  widget_class->state_changed      = gimp_color_button_state_changed;
+  widget_class->button_press_event  = gimp_color_button_button_press;
+  widget_class->state_flags_changed = gimp_color_button_state_flags_changed;
 
-  button_class->clicked            = gimp_color_button_clicked;
+  button_class->clicked             = gimp_color_button_clicked;
 
-  klass->color_changed             = NULL;
-  klass->get_action_type           = gimp_color_button_get_action_type;
+  klass->color_changed              = NULL;
+  klass->get_action_type            = gimp_color_button_get_action_type;
 
   gimp_rgba_set (&color, 0.0, 0.0, 0.0, 1.0);
 
@@ -540,16 +540,17 @@ gimp_color_button_button_press (GtkWidget      *widget,
 }
 
 static void
-gimp_color_button_state_changed (GtkWidget    *widget,
-                                 GtkStateType  prev_state)
+gimp_color_button_state_flags_changed (GtkWidget     *widget,
+                                       GtkStateFlags  previous_state)
 {
   g_return_if_fail (GIMP_IS_COLOR_BUTTON (widget));
 
   if (! gtk_widget_is_sensitive (widget) && GIMP_COLOR_BUTTON (widget)->dialog)
     gtk_widget_hide (GIMP_COLOR_BUTTON (widget)->dialog);
 
-  if (GTK_WIDGET_CLASS (parent_class)->state_changed)
-    GTK_WIDGET_CLASS (parent_class)->state_changed (widget, prev_state);
+  if (GTK_WIDGET_CLASS (parent_class)->state_flags_changed)
+    GTK_WIDGET_CLASS (parent_class)->state_flags_changed (widget,
+                                                          previous_state);
 }
 
 static void
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index d7d14ec..6043b88 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -77,39 +77,39 @@ struct _GimpColorScalePrivate
                                      GimpColorScalePrivate)
 
 
-static void     gimp_color_scale_dispose           (GObject          *object);
-static void     gimp_color_scale_finalize          (GObject          *object);
-static void     gimp_color_scale_get_property      (GObject          *object,
-                                                    guint             property_id,
-                                                    GValue           *value,
-                                                    GParamSpec       *pspec);
-static void     gimp_color_scale_set_property      (GObject          *object,
-                                                    guint             property_id,
-                                                    const GValue     *value,
-                                                    GParamSpec       *pspec);
-
-static void     gimp_color_scale_size_allocate     (GtkWidget        *widget,
-                                                    GtkAllocation    *allocation);
-static void     gimp_color_scale_state_changed     (GtkWidget        *widget,
-                                                    GtkStateType      previous_state);
-static gboolean gimp_color_scale_button_press      (GtkWidget        *widget,
-                                                    GdkEventButton   *event);
-static gboolean gimp_color_scale_button_release    (GtkWidget        *widget,
-                                                    GdkEventButton   *event);
-static gboolean gimp_color_scale_scroll            (GtkWidget        *widget,
-                                                    GdkEventScroll   *event);
-static gboolean gimp_color_scale_draw              (GtkWidget        *widget,
-                                                    cairo_t          *cr);
-
-static void     gimp_color_scale_render            (GimpColorScale   *scale);
-static void     gimp_color_scale_render_alpha      (GimpColorScale   *scale);
-static void     gimp_color_scale_render_stipple    (GimpColorScale   *scale);
-
-static void     gimp_color_scale_create_transform  (GimpColorScale   *scale);
-static void     gimp_color_scale_destroy_transform (GimpColorScale   *scale);
-static void     gimp_color_scale_notify_config     (GimpColorConfig  *config,
-                                                    const GParamSpec *pspec,
-                                                    GimpColorScale   *scale);
+static void     gimp_color_scale_dispose             (GObject          *object);
+static void     gimp_color_scale_finalize            (GObject          *object);
+static void     gimp_color_scale_get_property        (GObject          *object,
+                                                      guint             property_id,
+                                                      GValue           *value,
+                                                      GParamSpec       *pspec);
+static void     gimp_color_scale_set_property        (GObject          *object,
+                                                      guint             property_id,
+                                                      const GValue     *value,
+                                                      GParamSpec       *pspec);
+
+static void     gimp_color_scale_size_allocate       (GtkWidget        *widget,
+                                                      GtkAllocation    *allocation);
+static void     gimp_color_scale_state_flags_changed (GtkWidget        *widget,
+                                                      GtkStateFlags     previous_state);
+static gboolean gimp_color_scale_button_press        (GtkWidget        *widget,
+                                                      GdkEventButton   *event);
+static gboolean gimp_color_scale_button_release      (GtkWidget        *widget,
+                                                      GdkEventButton   *event);
+static gboolean gimp_color_scale_scroll              (GtkWidget        *widget,
+                                                      GdkEventScroll   *event);
+static gboolean gimp_color_scale_draw                (GtkWidget        *widget,
+                                                      cairo_t          *cr);
+
+static void     gimp_color_scale_render              (GimpColorScale   *scale);
+static void     gimp_color_scale_render_alpha        (GimpColorScale   *scale);
+static void     gimp_color_scale_render_stipple      (GimpColorScale   *scale);
+
+static void     gimp_color_scale_create_transform    (GimpColorScale   *scale);
+static void     gimp_color_scale_destroy_transform   (GimpColorScale   *scale);
+static void     gimp_color_scale_notify_config       (GimpColorConfig  *config,
+                                                      const GParamSpec *pspec,
+                                                      GimpColorScale   *scale);
 
 
 G_DEFINE_TYPE (GimpColorScale, gimp_color_scale, GTK_TYPE_SCALE)
@@ -132,7 +132,7 @@ gimp_color_scale_class_init (GimpColorScaleClass *klass)
   object_class->set_property         = gimp_color_scale_set_property;
 
   widget_class->size_allocate        = gimp_color_scale_size_allocate;
-  widget_class->state_changed        = gimp_color_scale_state_changed;
+  widget_class->state_flags_changed  = gimp_color_scale_state_flags_changed;
   widget_class->button_press_event   = gimp_color_scale_button_press;
   widget_class->button_release_event = gimp_color_scale_button_release;
   widget_class->scroll_event         = gimp_color_scale_scroll;
@@ -316,17 +316,18 @@ gimp_color_scale_size_allocate (GtkWidget     *widget,
 }
 
 static void
-gimp_color_scale_state_changed (GtkWidget    *widget,
-                                GtkStateType  previous_state)
+gimp_color_scale_state_flags_changed (GtkWidget     *widget,
+                                      GtkStateFlags  previous_state)
 {
-  if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE ||
-      previous_state == GTK_STATE_INSENSITIVE)
+  if ((gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_INSENSITIVE) !=
+      (previous_state & GTK_STATE_FLAG_INSENSITIVE))
     {
       GIMP_COLOR_SCALE (widget)->needs_render = TRUE;
     }
 
-  if (GTK_WIDGET_CLASS (parent_class)->state_changed)
-    GTK_WIDGET_CLASS (parent_class)->state_changed (widget, previous_state);
+  if (GTK_WIDGET_CLASS (parent_class)->state_flags_changed)
+    GTK_WIDGET_CLASS (parent_class)->state_flags_changed (widget,
+                                                          previous_state);
 }
 
 static gboolean


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