]> Pileus Git - ~andy/gtk/commitdiff
all: avoid boxed structs copying where possible (and 2)
authorJavier Jardón <jjardon@gnome.org>
Tue, 31 May 2011 15:10:46 +0000 (17:10 +0200)
committerJavier Jardón <jjardon@gnome.org>
Tue, 31 May 2011 17:18:11 +0000 (19:18 +0200)
Use the GtkStyleContext accessors for boxed properties where possible,
to reduce allocations.

gtk/gtkcombobox.c
gtk/gtklabel.c
gtk/gtkwidget.c

index 760e77f25b1f345bf7f258ca034cf250aedf8944..b4f8211435892c02a319d556ed3c890fe68ede3a 100644 (file)
@@ -5252,7 +5252,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
   gint                   font_size, arrow_size;
   PangoContext          *context;
   PangoFontMetrics      *metrics;
-  PangoFontDescription  *font_desc;
+  const PangoFontDescription *font_desc;
   GtkWidget             *child;
   gint                   minimum_width = 0, natural_width = 0;
   gint                   child_min, child_nat;
@@ -5277,9 +5277,7 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
   state = gtk_widget_get_state_flags (widget);
 
   get_widget_padding (widget, &padding);
-  gtk_style_context_get (style_context, state,
-                         "font", &font_desc,
-                         NULL);
+  font_desc = gtk_style_context_get_font (style_context, state);
 
   context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
   metrics = pango_context_get_metrics (context, font_desc,
@@ -5287,7 +5285,6 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
   font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
                             pango_font_metrics_get_descent (metrics));
   pango_font_metrics_unref (metrics);
-  pango_font_description_free (font_desc);
 
   arrow_size = MAX (arrow_size, font_size) * arrow_scaling;
 
index 169117f2321f1da4ff6ccaa869af3c20e54ee42a..972c110a4b331a425920155b699b086a0c5933fa 100644 (file)
@@ -3200,19 +3200,16 @@ static PangoFontMetrics *
 get_font_metrics (PangoContext *context, GtkWidget *widget)
 {
   GtkStyleContext *style_context;
-  PangoFontDescription *font;
+  const PangoFontDescription *font;
   PangoFontMetrics *retval;
 
   style_context = gtk_widget_get_style_context (widget);
-  gtk_style_context_get (style_context, 0, "font", &font, NULL);
+  font = gtk_style_context_get_font (style_context, GTK_STATE_FLAG_NORMAL);
 
   retval = pango_context_get_metrics (context,
                                       font,
                                       pango_context_get_language (context));
 
-  if (font != NULL)
-    pango_font_description_free (font);
-
   return retval;
 }
 
index cece4de454202306b8bb7f25c724d897ad1a2fc7..c2c68ba913857a08cb01b77e5afe36e6f3226d2f 100644 (file)
@@ -9008,22 +9008,18 @@ static void
 update_pango_context (GtkWidget    *widget,
                      PangoContext *context)
 {
-  PangoFontDescription *font_desc;
+  const PangoFontDescription *font_desc;
   GtkStyleContext *style_context;
 
   style_context = gtk_widget_get_style_context (widget);
 
-  gtk_style_context_get (style_context,
-                        gtk_widget_get_state_flags (widget),
-                        "font", &font_desc,
-                        NULL);
+  font_desc = gtk_style_context_get_font (style_context,
+                                          gtk_widget_get_state_flags (widget));
 
   pango_context_set_font_description (context, font_desc);
   pango_context_set_base_dir (context,
                              gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
                              PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
-
-  pango_font_description_free (font_desc);
 }
 
 static void