From 9dfadca46cb28d06f61fcc632cb2e941d8b1fd19 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 4 Feb 2010 16:43:54 +0100 Subject: [PATCH] Bug 608993 - Add gtk_widget_style_attach() As replacement for: widget->style = gtk_style_attach (widget->style, widget->window); --- gtk/gtk.symbols | 1 + gtk/gtkwidget.c | 26 ++++++++++++++++++++++++++ gtk/gtkwidget.h | 12 +++++++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index 00440e0466..e09d34a69c 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -5242,6 +5242,7 @@ gtk_widget_show_now gtk_widget_size_allocate gtk_widget_size_request gtk_widget_get_desired_size +gtk_widget_style_attach gtk_widget_style_get G_GNUC_NULL_TERMINATED gtk_widget_style_get_property gtk_widget_style_get_valist diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4e0da7c166..8e9ad8752e 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -6308,6 +6308,32 @@ gtk_widget_get_parent (GtkWidget *widget) * see docs/styles.txt *****************************************/ +/** + * gtk_widget_style_attach: + * @widget: a #GtkWidget + * + * This function attaches the widget's #GtkStyle to the widget's + * #GdkWindow. It is a replacement for + * + * + * widget->style = gtk_style_attach (widget->style, widget->window); + * + * + * and should only ever be called in a derived widget's "realize" + * implementation which does not chain up to its parent class' + * "realize" implementation, because one of the parent classes + * (finally #GtkWidget) would attach the style itself. + * + * Since: 2.20 + **/ +void +gtk_widget_style_attach (GtkWidget *widget) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + + widget->style = gtk_style_attach (widget->style, widget->window); +} + /** * gtk_widget_has_rc_style: * @widget: a #GtkWidget diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 6f4f8f81fa..ddb855013b 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -1069,11 +1069,13 @@ gboolean gtk_widget_hide_on_delete (GtkWidget *widget); /* Widget styles. */ -gboolean gtk_widget_has_rc_style (GtkWidget *widget); -void gtk_widget_set_style (GtkWidget *widget, - GtkStyle *style); -void gtk_widget_ensure_style (GtkWidget *widget); -GtkStyle* gtk_widget_get_style (GtkWidget *widget); +void gtk_widget_style_attach (GtkWidget *style); + +gboolean gtk_widget_has_rc_style (GtkWidget *widget); +void gtk_widget_set_style (GtkWidget *widget, + GtkStyle *style); +void gtk_widget_ensure_style (GtkWidget *widget); +GtkStyle * gtk_widget_get_style (GtkWidget *widget); void gtk_widget_modify_style (GtkWidget *widget, GtkRcStyle *style);