From c8a59a6f92e79461622ebd6da058d29094d696ef Mon Sep 17 00:00:00 2001
From: Cosimo Cecchi <cosimoc@gnome.org>
Date: Tue, 17 May 2011 14:20:31 -0400
Subject: all: avoid boxed structs copying where possible

Use the GtkStyleContext accessors for boxed properties where possible,
to reduce allocations.

https://bugzilla.gnome.org/show_bug.cgi?id=650420
---
 gtk/gtkcombobox.c | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

(limited to 'gtk/gtkcombobox.c')

diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index dfd27d8b99..760e77f25b 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -1282,17 +1282,13 @@ gtk_combo_box_state_flags_changed (GtkWidget     *widget,
         {
           GtkStyleContext *context;
           GtkStateFlags state;
-          GdkRGBA *color;
+          GdkRGBA color;
 
           context  = gtk_widget_get_style_context (widget);
           state = gtk_widget_get_state_flags (widget);
+          gtk_style_context_get_background_color (context, state, &color);
 
-          gtk_style_context_get (context, state,
-                                 "background-color", &color,
-                                 NULL);
-
-          gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), color);
-          gdk_rgba_free (color);
+          gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), &color);
         }
     }
 
@@ -1374,17 +1370,14 @@ gtk_combo_box_style_updated (GtkWidget *widget)
   if (priv->tree_view && priv->cell_view)
     {
       GtkStyleContext *context;
-      GdkRGBA *color;
-
-      context = gtk_widget_get_style_context (widget);
-      gtk_style_context_get (context, 0,
-                             "background-color", &color,
-                             NULL);
+      GtkStateFlags state;
+      GdkRGBA color;
 
-      gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view),
-                                         color);
+      context  = gtk_widget_get_style_context (widget);
+      state = gtk_widget_get_state_flags (widget);
+      gtk_style_context_get_background_color (context, state, &color);
 
-      gdk_rgba_free (color);
+      gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), &color);
     }
 
   child = gtk_bin_get_child (GTK_BIN (combo_box));
@@ -3292,17 +3285,13 @@ gtk_combo_box_list_setup (GtkComboBox *combo_box)
     {
       GtkStyleContext *context;
       GtkStateFlags state;
-      GdkRGBA *color;
+      GdkRGBA color;
 
-      context = gtk_widget_get_style_context (widget);
+      context  = gtk_widget_get_style_context (widget);
       state = gtk_widget_get_state_flags (widget);
+      gtk_style_context_get_background_color (context, state, &color);
 
-      gtk_style_context_get (context, state,
-                             "background-color", &color,
-                             NULL);
-
-      gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), color);
-      gdk_rgba_free (color);
+      gtk_cell_view_set_background_rgba (GTK_CELL_VIEW (priv->cell_view), &color);
 
       priv->box = gtk_event_box_new ();
       gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->box),
-- 
cgit v1.2.1