[gtk+] iconview: don't use gtk_style_context_set_background()
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] iconview: don't use gtk_style_context_set_background()
- Date: Tue, 20 Nov 2012 18:42:27 +0000 (UTC)
commit da09447914c0919362533182261a2c862ac8de81
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Nov 20 12:28:14 2012 -0500
iconview: don't use gtk_style_context_set_background()
Render a background with gtk_render_background() during draw instead.
https://bugzilla.gnome.org/show_bug.cgi?id=688744
gtk/gtkiconview.c | 64 ++++++++--------------------------------------------
1 files changed, 10 insertions(+), 54 deletions(-)
---
diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c
index 7eb50ae..b7c8946 100644
--- a/gtk/gtkiconview.c
+++ b/gtk/gtkiconview.c
@@ -133,9 +133,6 @@ static void gtk_icon_view_get_property (GObject
static void gtk_icon_view_destroy (GtkWidget *widget);
static void gtk_icon_view_realize (GtkWidget *widget);
static void gtk_icon_view_unrealize (GtkWidget *widget);
-static void gtk_icon_view_style_updated (GtkWidget *widget);
-static void gtk_icon_view_state_flags_changed (GtkWidget *widget,
- GtkStateFlags previous_state);
static GtkSizeRequestMode gtk_icon_view_get_request_mode (GtkWidget *widget);
static void gtk_icon_view_get_preferred_width (GtkWidget *widget,
gint *minimum,
@@ -352,7 +349,6 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
widget_class->destroy = gtk_icon_view_destroy;
widget_class->realize = gtk_icon_view_realize;
widget_class->unrealize = gtk_icon_view_unrealize;
- widget_class->style_updated = gtk_icon_view_style_updated;
widget_class->get_request_mode = gtk_icon_view_get_request_mode;
widget_class->get_preferred_width = gtk_icon_view_get_preferred_width;
widget_class->get_preferred_height = gtk_icon_view_get_preferred_height;
@@ -373,7 +369,6 @@ gtk_icon_view_class_init (GtkIconViewClass *klass)
widget_class->drag_motion = gtk_icon_view_drag_motion;
widget_class->drag_drop = gtk_icon_view_drag_drop;
widget_class->drag_data_received = gtk_icon_view_drag_data_received;
- widget_class->state_flags_changed = gtk_icon_view_state_flags_changed;
container_class->remove = gtk_icon_view_remove;
container_class->forall = gtk_icon_view_forall;
@@ -974,6 +969,9 @@ gtk_icon_view_init (GtkIconView *icon_view)
icon_view->priv->row_contexts =
g_ptr_array_new_with_free_func ((GDestroyNotify)g_object_unref);
+
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (icon_view)),
+ GTK_STYLE_CLASS_VIEW);
}
/* GObject methods */
@@ -1251,7 +1249,6 @@ gtk_icon_view_realize (GtkWidget *widget)
GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
- GtkStyleContext *context;
gtk_widget_set_realized (widget, TRUE);
@@ -1294,15 +1291,6 @@ gtk_icon_view_realize (GtkWidget *widget)
icon_view->priv->bin_window = gdk_window_new (window,
&attributes, attributes_mask);
gdk_window_set_user_data (icon_view->priv->bin_window, widget);
-
- context = gtk_widget_get_style_context (widget);
-
- gtk_style_context_save (context);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
- gtk_style_context_set_background (context, icon_view->priv->bin_window);
- gtk_style_context_set_background (context, window);
- gtk_style_context_restore (context);
-
gdk_window_show (icon_view->priv->bin_window);
}
@@ -1320,44 +1308,6 @@ gtk_icon_view_unrealize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->unrealize (widget);
}
-static void
-_gtk_icon_view_update_background (GtkIconView *icon_view)
-{
- GtkWidget *widget = GTK_WIDGET (icon_view);
-
- if (gtk_widget_get_realized (widget))
- {
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (widget);
-
- gtk_style_context_save (context);
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW);
-
- gtk_style_context_set_background (context, gtk_widget_get_window (widget));
- gtk_style_context_set_background (context, icon_view->priv->bin_window);
-
- gtk_style_context_restore (context);
- }
-}
-
-static void
-gtk_icon_view_state_flags_changed (GtkWidget *widget,
- GtkStateFlags previous_state)
-{
- _gtk_icon_view_update_background (GTK_ICON_VIEW (widget));
- gtk_widget_queue_draw (widget);
-}
-
-static void
-gtk_icon_view_style_updated (GtkWidget *widget)
-{
- GTK_WIDGET_CLASS (gtk_icon_view_parent_class)->style_updated (widget);
-
- _gtk_icon_view_update_background (GTK_ICON_VIEW (widget));
- gtk_widget_queue_resize (widget);
-}
-
static gint
gtk_icon_view_get_n_items (GtkIconView *icon_view)
{
@@ -1823,9 +1773,16 @@ gtk_icon_view_draw (GtkWidget *widget,
gint dest_index;
GtkIconViewDropPosition dest_pos;
GtkIconViewItem *dest_item = NULL;
+ GtkStyleContext *context;
icon_view = GTK_ICON_VIEW (widget);
+ context = gtk_widget_get_style_context (widget);
+ gtk_render_background (context, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
if (!gtk_cairo_should_draw_window (cr, icon_view->priv->bin_window))
return FALSE;
@@ -3037,7 +2994,6 @@ gtk_icon_view_paint_item (GtkIconView *icon_view,
state = gtk_widget_get_state_flags (widget);
gtk_style_context_save (style_context);
- gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_VIEW);
gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_CELL);
state &= ~(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_PRELIGHT);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]