[gimp/gtk3-port: 133/451] app: implement GtkWidget::style_updated() instead of style_set()



commit 54c403d3926d35b3eb92ac4eafaa1f9dcef862c6
Author: Michael Natterer <mitch gimp org>
Date:   Wed Dec 22 23:34:47 2010 +0100

    app: implement GtkWidget::style_updated() instead of style_set()

 app/display/gimpcanvas.c        |   10 ++++------
 app/display/gimpcursorview.c    |   18 ++++++++----------
 app/display/gimpimagewindow.c   |   10 ++++------
 app/display/gimpscalecombobox.c |   34 ++++++++++++++--------------------
 app/display/gimpstatusbar.c     |   22 +++++++++-------------
 5 files changed, 39 insertions(+), 55 deletions(-)
---
diff --git a/app/display/gimpcanvas.c b/app/display/gimpcanvas.c
index c0dd8b1..eb681f2 100644
--- a/app/display/gimpcanvas.c
+++ b/app/display/gimpcanvas.c
@@ -56,8 +56,7 @@ static void       gimp_canvas_get_property    (GObject         *object,
                                                GParamSpec      *pspec);
 
 static void       gimp_canvas_unrealize       (GtkWidget       *widget);
-static void       gimp_canvas_style_set       (GtkWidget       *widget,
-                                               GtkStyle        *prev_style);
+static void       gimp_canvas_style_updated   (GtkWidget       *widget);
 static gboolean   gimp_canvas_focus_in_event  (GtkWidget       *widget,
                                                GdkEventFocus   *event);
 static gboolean   gimp_canvas_focus_out_event (GtkWidget       *widget,
@@ -81,7 +80,7 @@ gimp_canvas_class_init (GimpCanvasClass *klass)
   object_class->get_property    = gimp_canvas_get_property;
 
   widget_class->unrealize       = gimp_canvas_unrealize;
-  widget_class->style_set       = gimp_canvas_style_set;
+  widget_class->style_updated   = gimp_canvas_style_updated;
   widget_class->focus_in_event  = gimp_canvas_focus_in_event;
   widget_class->focus_out_event = gimp_canvas_focus_out_event;
   widget_class->focus           = gimp_canvas_focus;
@@ -153,12 +152,11 @@ gimp_canvas_unrealize (GtkWidget *widget)
 }
 
 static void
-gimp_canvas_style_set (GtkWidget *widget,
-                       GtkStyle  *prev_style)
+gimp_canvas_style_updated (GtkWidget *widget)
 {
   GimpCanvas *canvas = GIMP_CANVAS (widget);
 
-  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
   g_clear_object (&canvas->layout);
 }
diff --git a/app/display/gimpcursorview.c b/app/display/gimpcursorview.c
index 6ec54da..caadb35 100644
--- a/app/display/gimpcursorview.c
+++ b/app/display/gimpcursorview.c
@@ -83,8 +83,8 @@ struct _GimpCursorViewPriv
   GimpContext      *context;
   GimpDisplayShell *shell;
   GimpImage        *image;
-  GimpUnit          unit;
 
+  GimpUnit          unit;
   guint             cursor_idle_id;
   GimpImage        *cursor_image;
   GimpUnit          cursor_unit;
@@ -105,8 +105,7 @@ static void       gimp_cursor_view_get_property          (GObject             *o
                                                           GValue              *value,
                                                           GParamSpec          *pspec);
 
-static void       gimp_cursor_view_style_set             (GtkWidget           *widget,
-                                                          GtkStyle            *prev_style);
+static void       gimp_cursor_view_style_updated         (GtkWidget           *widget);
 
 static void       gimp_cursor_view_set_aux_info          (GimpDocked          *docked,
                                                           GList               *aux_info);
@@ -153,11 +152,11 @@ gimp_cursor_view_class_init (GimpCursorViewClass* klass)
   GObjectClass   *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->dispose      = gimp_cursor_view_dispose;
-  object_class->get_property = gimp_cursor_view_get_property;
-  object_class->set_property = gimp_cursor_view_set_property;
+  object_class->dispose       = gimp_cursor_view_dispose;
+  object_class->get_property  = gimp_cursor_view_get_property;
+  object_class->set_property  = gimp_cursor_view_set_property;
 
-  widget_class->style_set    = gimp_cursor_view_style_set;
+  widget_class->style_updated = gimp_cursor_view_style_updated;
 
   g_object_class_install_property (object_class, PROP_SAMPLE_MERGED,
                                    g_param_spec_boolean ("sample-merged",
@@ -517,13 +516,12 @@ gimp_cursor_view_set_label_italic (GtkWidget *label,
 }
 
 static void
-gimp_cursor_view_style_set (GtkWidget *widget,
-                            GtkStyle  *prev_style)
+gimp_cursor_view_style_updated (GtkWidget *widget)
 {
   GimpCursorView *view = GIMP_CURSOR_VIEW (widget);
   gint            content_spacing;
 
-  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
   gtk_widget_style_get (GTK_WIDGET (view),
                         "content-spacing", &content_spacing,
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 44b3492..44096da 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -179,8 +179,7 @@ static gboolean  gimp_image_window_configure_event     (GtkWidget           *wid
                                                         GdkEventConfigure   *event);
 static gboolean  gimp_image_window_window_state_event  (GtkWidget           *widget,
                                                         GdkEventWindowState *event);
-static void      gimp_image_window_style_set           (GtkWidget           *widget,
-                                                        GtkStyle            *prev_style);
+static void      gimp_image_window_style_updated       (GtkWidget           *widget);
 
 static void      gimp_image_window_monitor_changed     (GimpWindow          *window,
                                                         GdkScreen           *screen,
@@ -302,7 +301,7 @@ gimp_image_window_class_init (GimpImageWindowClass *klass)
   widget_class->delete_event       = gimp_image_window_delete_event;
   widget_class->configure_event    = gimp_image_window_configure_event;
   widget_class->window_state_event = gimp_image_window_window_state_event;
-  widget_class->style_set          = gimp_image_window_style_set;
+  widget_class->style_updated      = gimp_image_window_style_updated;
 
   window_class->monitor_changed    = gimp_image_window_monitor_changed;
 
@@ -763,8 +762,7 @@ gimp_image_window_window_state_event (GtkWidget           *widget,
 }
 
 static void
-gimp_image_window_style_set (GtkWidget *widget,
-                             GtkStyle  *prev_style)
+gimp_image_window_style_updated (GtkWidget *widget)
 {
   GimpImageWindow        *window        = GIMP_IMAGE_WINDOW (widget);
   GimpImageWindowPrivate *private       = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
@@ -774,7 +772,7 @@ gimp_image_window_style_set (GtkWidget *widget,
   GdkGeometry             geometry      = { 0, };
   GdkWindowHints          geometry_mask = 0;
 
-  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
   if (! shell)
     return;
diff --git a/app/display/gimpscalecombobox.c b/app/display/gimpscalecombobox.c
index 53f8925..79f7e2c 100644
--- a/app/display/gimpscalecombobox.c
+++ b/app/display/gimpscalecombobox.c
@@ -56,8 +56,7 @@ enum
 static void      gimp_scale_combo_box_constructed     (GObject           *object);
 static void      gimp_scale_combo_box_finalize        (GObject           *object);
 
-static void      gimp_scale_combo_box_style_set       (GtkWidget         *widget,
-                                                       GtkStyle          *prev_style);
+static void      gimp_scale_combo_box_style_updated   (GtkWidget         *widget);
 
 static void      gimp_scale_combo_box_changed         (GimpScaleComboBox *combo_box);
 static void      gimp_scale_combo_box_entry_activate  (GtkWidget         *entry,
@@ -95,12 +94,12 @@ gimp_scale_combo_box_class_init (GimpScaleComboBoxClass *klass)
                   gimp_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  object_class->constructed = gimp_scale_combo_box_constructed;
-  object_class->finalize    = gimp_scale_combo_box_finalize;
+  object_class->constructed   = gimp_scale_combo_box_constructed;
+  object_class->finalize      = gimp_scale_combo_box_finalize;
 
-  widget_class->style_set   = gimp_scale_combo_box_style_set;
+  widget_class->style_updated = gimp_scale_combo_box_style_updated;
 
-  klass->entry_activated    = NULL;
+  klass->entry_activated      = NULL;
 
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_double ("label-scale",
@@ -210,35 +209,30 @@ gimp_scale_combo_box_finalize (GObject *object)
 }
 
 static void
-gimp_scale_combo_box_style_set (GtkWidget *widget,
-                                GtkStyle  *prev_style)
+gimp_scale_combo_box_style_updated (GtkWidget *widget)
 {
   GtkWidget            *entry;
-  GtkRcStyle           *rc_style;
   PangoContext         *context;
   PangoFontDescription *font_desc;
   gint                  font_size;
   gdouble               label_scale;
 
-  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
   gtk_widget_style_get (widget, "label-scale", &label_scale, NULL);
 
   entry = gtk_bin_get_child (GTK_BIN (widget));
 
-  rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (entry));
-
-  if (rc_style->font_desc)
-    pango_font_description_free (rc_style->font_desc);
-
-  context = gtk_widget_get_pango_context (widget);
+  context = gtk_widget_get_pango_context (entry);
   font_desc = pango_context_get_font_description (context);
-  rc_style->font_desc = pango_font_description_copy (font_desc);
+  font_desc = pango_font_description_copy (font_desc);
+
+  font_size = pango_font_description_get_size (font_desc);
+  pango_font_description_set_size (font_desc, scale * font_size);
 
-  font_size = pango_font_description_get_size (rc_style->font_desc);
-  pango_font_description_set_size (rc_style->font_desc, label_scale * font_size);
+  gtk_widget_override_font (entry, font_desc);
 
-  gtk_widget_modify_style (GTK_WIDGET (entry), rc_style);
+  pango_font_description_free (font_desc);
 }
 
 static void
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index ee76629..5359bc1 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -79,11 +79,9 @@ static void     gimp_statusbar_finalize           (GObject           *object);
 
 static void     gimp_statusbar_screen_changed     (GtkWidget         *widget,
                                                    GdkScreen         *previous);
-static void     gimp_statusbar_style_set          (GtkWidget         *widget,
-                                                   GtkStyle          *prev_style);
+static void     gimp_statusbar_style_updated      (GtkWidget         *widget);
 
-static void     gimp_statusbar_hbox_style_set     (GtkWidget         *widget,
-                                                   GtkStyle          *prev_style,
+static void     gimp_statusbar_hbox_style_updated (GtkWidget         *widget,
                                                    GimpStatusbar     *statusbar);
 
 static GimpProgress *
@@ -171,7 +169,7 @@ gimp_statusbar_class_init (GimpStatusbarClass *klass)
   object_class->finalize       = gimp_statusbar_finalize;
 
   widget_class->screen_changed = gimp_statusbar_screen_changed;
-  widget_class->style_set      = gimp_statusbar_style_set;
+  widget_class->style_updated  = gimp_statusbar_style_updated;
 }
 
 static void
@@ -223,8 +221,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
 
   gtk_container_remove (GTK_CONTAINER (hbox), statusbar->label);
 
-  g_signal_connect_after (hbox, "style-set",
-                          G_CALLBACK (gimp_statusbar_hbox_style_set),
+  g_signal_connect_after (hbox, "style-updated",
+                          G_CALLBACK (gimp_statusbar_hbox_style_updated),
                           statusbar);
 
   statusbar->cursor_label = gtk_label_new ("8888, 8888");
@@ -383,20 +381,18 @@ gimp_statusbar_screen_changed (GtkWidget *widget,
 }
 
 static void
-gimp_statusbar_style_set (GtkWidget *widget,
-                          GtkStyle  *prev_style)
+gimp_statusbar_style_updated (GtkWidget *widget)
 {
   GimpStatusbar *statusbar = GIMP_STATUSBAR (widget);
 
-  GTK_WIDGET_CLASS (parent_class)->style_set (widget, prev_style);
+  GTK_WIDGET_CLASS (parent_class)->style_updated (widget);
 
   g_clear_pointer (&statusbar->icon_hash, g_hash_table_unref);
 }
 
 static void
-gimp_statusbar_hbox_style_set (GtkWidget     *widget,
-                               GtkStyle      *prev_style,
-                               GimpStatusbar *statusbar)
+gimp_statusbar_hbox_style_updated (GtkWidget     *widget,
+                                   GimpStatusbar *statusbar)
 {
   GtkRequisition  requisition;
   GtkRequisition  child_requisition;


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