cellrendererpixbuf: Always follow state
authorBenjamin Otte <otte@redhat.com>
Sat, 14 Mar 2015 14:41:34 +0000 (15:41 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 14 Mar 2015 14:46:13 +0000 (15:46 +0100)
Applications forget to set the follow-state property and then some
themes used a style where normal symbolic icons have the same color as
prelit or selected backgrounds and that suddenly made icons invisible
and who wants that?

https://bugzilla.gnome.org/show_bug.cgi?id=746201

gtk/gtkcellrendererpixbuf.c

index 54acb1a5b6bbaa8edfd4539b6a784cd58a3e54da..7151fc9827b6584c8bd454abeb452048057a560a 100644 (file)
@@ -111,6 +111,7 @@ gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf)
   priv->icon_helper = _gtk_icon_helper_new ();
   _gtk_icon_helper_set_force_scale_pixbuf (priv->icon_helper, TRUE);
   priv->icon_size = GTK_ICON_SIZE_MENU;
+  priv->follow_state = TRUE;
 }
 
 static void
@@ -237,6 +238,8 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
    * according to the #GtkCellRendererState.
    *
    * Since: 2.8
+   *
+   * Deprecated: 3.16: Cell renderers always follow state.
    */
   g_object_class_install_property (object_class,
                                   PROP_FOLLOW_STATE,
@@ -244,8 +247,8 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
                                                         P_("Follow State"),
                                                         P_("Whether the rendered pixbuf should be "
                                                            "colorized according to the state"),
-                                                        FALSE,
-                                                        GTK_PARAM_READWRITE));
+                                                        TRUE,
+                                                        GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
 
   /**
    * GtkCellRendererPixbuf:gicon:
@@ -516,7 +519,6 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer      *cell,
   GdkRectangle draw_rect;
   gboolean is_expander;
   gint xpad, ypad;
-  GtkStateFlags state;
   GtkIconHelper *icon_helper = NULL;
 
   gtk_cell_renderer_pixbuf_get_size (cell, widget, (GdkRectangle *) cell_area,
@@ -537,12 +539,6 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer      *cell,
   context = gtk_widget_get_style_context (widget);
   gtk_style_context_save (context);
 
-  state = gtk_cell_renderer_get_state (cell, widget, flags);
-
-  if (!priv->follow_state)
-    state &= ~(GTK_STATE_FLAG_FOCUSED | GTK_STATE_FLAG_PRELIGHT | GTK_STATE_FLAG_SELECTED);
-
-  gtk_style_context_set_state (context, state);
   gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE);
 
   g_object_get (cell, "is-expander", &is_expander, NULL);