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



commit 8d72dc33574b589a098868a5b4c6c8c82dbbdc2c
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    |   14 +++++------
 app/display/gimpimagewindow.c   |   10 +++-----
 app/display/gimpscalecombobox.c |   46 ++++++++++++++++----------------------
 app/display/gimpstatusbar.c     |   12 ++++------
 5 files changed, 38 insertions(+), 54 deletions(-)
---
diff --git a/app/display/gimpcanvas.c b/app/display/gimpcanvas.c
index 84a8e1b..7bbcd09 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;
@@ -157,12 +156,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);
 
   if (canvas->layout)
     {
diff --git a/app/display/gimpcursorview.c b/app/display/gimpcursorview.c
index 832b5b4..7fef908 100644
--- a/app/display/gimpcursorview.c
+++ b/app/display/gimpcursorview.c
@@ -96,8 +96,7 @@ static void   gimp_cursor_view_get_property          (GObject             *objec
                                                       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);
@@ -146,10 +145,10 @@ gimp_cursor_view_class_init (GimpCursorViewClass* klass)
   GObjectClass   *object_class = G_OBJECT_CLASS (klass);
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
-  object_class->get_property = gimp_cursor_view_get_property;
-  object_class->set_property = gimp_cursor_view_set_property;
+  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",
@@ -485,13 +484,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 aee391d..fa450e1 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -151,8 +151,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 GList *   gimp_image_window_get_docks           (GimpDockContainer   *dock_container);
 static GimpUIManager *
                  gimp_image_window_dock_container_get_ui_manager
@@ -253,7 +252,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;
 
   g_object_class_install_property (object_class, PROP_GIMP,
                                    g_param_spec_object ("gimp",
@@ -651,8 +650,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);
@@ -662,7 +660,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 40ca369..25058b0 100644
--- a/app/display/gimpscalecombobox.c
+++ b/app/display/gimpscalecombobox.c
@@ -55,8 +55,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,
@@ -94,12 +93,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",
@@ -209,37 +208,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;
-  gint        font_size;
-  gdouble     scale;
+  GtkWidget            *entry;
+  PangoContext         *context;
+  PangoFontDescription *font_desc;
+  gint                  font_size;
+  gdouble               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", &scale, NULL);
 
   entry = gtk_bin_get_child (GTK_BIN (widget));
 
-  rc_style = gtk_widget_get_modifier_style (GTK_WIDGET (entry));
+  context = gtk_widget_get_pango_context (entry);
+  font_desc = pango_context_get_font_description (context);
+  font_desc = pango_font_description_copy (font_desc);
 
-  if (! rc_style->font_desc)
-    {
-      PangoContext         *context;
-      PangoFontDescription *font_desc;
-
-      context = gtk_widget_get_pango_context (widget);
-      font_desc = pango_context_get_font_description (context);
-
-      rc_style->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, 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 3143237..d41c1ee 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -73,8 +73,7 @@ static void     gimp_statusbar_progress_iface_init (GimpProgressInterface *iface
 static void     gimp_statusbar_dispose            (GObject           *object);
 static void     gimp_statusbar_finalize           (GObject           *object);
 
-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 *
@@ -188,8 +187,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");
@@ -310,9 +309,8 @@ gimp_statusbar_finalize (GObject *object)
 }
 
 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]