[gimp/gtk3-port: 142/226] app: check whether child widgets exist in GtkWidget::style_updated()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 142/226] app: check whether child widgets exist in GtkWidget::style_updated()
- Date: Wed, 11 Dec 2013 00:25:41 +0000 (UTC)
commit ef29c7f0bd43187fc1618c1a7d2e75f476f25d2f
Author: Michael Natterer <mitch gimp org>
Date: Wed Dec 29 15:22:09 2010 +0100
app: check whether child widgets exist in GtkWidget::style_updated()
because it is emitted repeatedly during widget construction, when not
everything is in place yet.
app/display/gimpscalecombobox.c | 32 ++++++++++--------
app/display/gimpstatusbar.c | 71 ++++++++++++++++++++++++---------------
2 files changed, 62 insertions(+), 41 deletions(-)
---
diff --git a/app/display/gimpscalecombobox.c b/app/display/gimpscalecombobox.c
index 25058b0..9627b68 100644
--- a/app/display/gimpscalecombobox.c
+++ b/app/display/gimpscalecombobox.c
@@ -210,28 +210,32 @@ gimp_scale_combo_box_finalize (GObject *object)
static void
gimp_scale_combo_box_style_updated (GtkWidget *widget)
{
- GtkWidget *entry;
- PangoContext *context;
- PangoFontDescription *font_desc;
- gint font_size;
- gdouble scale;
+ GtkWidget *entry;
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));
- context = gtk_widget_get_pango_context (entry);
- font_desc = pango_context_get_font_description (context);
- font_desc = pango_font_description_copy (font_desc);
+ if (entry)
+ {
+ PangoContext *context;
+ PangoFontDescription *font_desc;
+ gint font_size;
+ gdouble scale;
+
+ gtk_widget_style_get (widget, "label-scale", &scale, NULL);
- font_size = pango_font_description_get_size (font_desc);
- pango_font_description_set_size (font_desc, scale * font_size);
+ context = gtk_widget_get_pango_context (entry);
+ font_desc = pango_context_get_font_description (context);
+ font_desc = pango_font_description_copy (font_desc);
- gtk_widget_override_font (entry, font_desc);
+ font_size = pango_font_description_get_size (font_desc);
+ pango_font_description_set_size (font_desc, scale * font_size);
- pango_font_description_free (font_desc);
+ gtk_widget_override_font (entry, font_desc);
+
+ pango_font_description_free (font_desc);
+ }
}
static void
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index 48e297d..a396df2 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -323,33 +323,50 @@ gimp_statusbar_hbox_style_updated (GtkWidget *widget,
/* also consider the children which can be invisible */
- gtk_widget_get_preferred_size (statusbar->cursor_label,
- &child_requisition, NULL);
- width += child_requisition.width;
- height = MAX (height, child_requisition.height);
-
- gtk_widget_get_preferred_size (statusbar->unit_combo,
- &child_requisition, NULL);
- width += child_requisition.width;
- height = MAX (height, child_requisition.height);
-
- gtk_widget_get_preferred_size (statusbar->scale_combo,
- &child_requisition, NULL);
- width += child_requisition.width;
- height = MAX (height, child_requisition.height);
-
- gtk_widget_get_preferred_size (statusbar->progressbar,
- &child_requisition, NULL);
- height = MAX (height, child_requisition.height);
-
- gtk_widget_get_preferred_size (statusbar->label,
- &child_requisition, NULL);
- requisition->height = MAX (requisition->height,
- child_requisition.height);
-
- gtk_widget_get_preferred_size (statusbar->cancel_button,
- &child_requisition, NULL);
- height = MAX (height, child_requisition.height);
+ if (statusbar->cursor_label)
+ {
+ gtk_widget_get_preferred_size (statusbar->cursor_label,
+ &child_requisition, NULL);
+ width += child_requisition.width;
+ height = MAX (height, child_requisition.height);
+ }
+
+ if (statusbar->unit_combo)
+ {
+ gtk_widget_get_preferred_size (statusbar->unit_combo,
+ &child_requisition, NULL);
+ width += child_requisition.width;
+ height = MAX (height, child_requisition.height);
+ }
+
+ if (statusbar->scale_combo)
+ {
+ gtk_widget_get_preferred_size (statusbar->scale_combo,
+ &child_requisition, NULL);
+ width += child_requisition.width;
+ height = MAX (height, child_requisition.height);
+ }
+
+ if (statusbar->progressbar)
+ {
+ gtk_widget_get_preferred_size (statusbar->progressbar,
+ &child_requisition, NULL);
+ height = MAX (height, child_requisition.height);
+ }
+
+ if (statusbar->label)
+ {
+ gtk_widget_get_preferred_size (statusbar->label,
+ &child_requisition, NULL);
+ height = MAX (height, child_requisition.height);
+ }
+
+ if (statusbar->cancel_button)
+ {
+ gtk_widget_get_preferred_size (statusbar->cancel_button,
+ &child_requisition, NULL);
+ height = MAX (height, child_requisition.height);
+ }
width = MAX (requisition.width, width + 32);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]