From cc8927a5896121ffa8bcbc192b8a3b794a4d812f Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 28 Aug 2009 16:51:48 +0200 Subject: [PATCH] Add gtk_widget_set_window() New function as replacement for setting widget->window directly. Should only be used in GtkWidget::realize(). --- gtk/gtk.symbols | 1 + gtk/gtkwidget.c | 35 +++++++++++++++++++++++++++++++++-- gtk/gtkwidget.h | 5 ++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index bd13c9216c..5d5cbecf0c 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -5088,6 +5088,7 @@ gtk_widget_set_tooltip_markup gtk_widget_set_tooltip_text gtk_widget_set_tooltip_window gtk_widget_set_visible +gtk_widget_set_window gtk_widget_shape_combine_mask gtk_widget_input_shape_combine_mask gtk_widget_show diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 0f29020593..9ee2218e9c 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5737,8 +5737,8 @@ gtk_widget_is_drawable (GtkWidget *widget) { g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - return ((GTK_WIDGET_FLAGS (wid) & GTK_VISIBLE) != 0 && - (GTK_WIDGET_FLAGS (wid) & GTK_MAPPED) != 0); + return ((GTK_WIDGET_FLAGS (widget) & GTK_VISIBLE) != 0 && + (GTK_WIDGET_FLAGS (widget) & GTK_MAPPED) != 0); } /** @@ -10835,6 +10835,37 @@ gtk_widget_set_allocation (GtkWidget *widget, widget->allocation = *allocation; } +/** + * gtk_widget_set_window: + * @widget: a #GtkWidget + * @window: a #GdkWindow + * + * Sets a widget's window. This function should only be used in a + * widget's GtkWidget::realize() implementation. The %window passed is + * usually either new window created with gdk_window_new(), or the + * window of its parent widget as returned by + * gtk_widget_get_parent_window(). + * + * Widgets must indicate whether they will create their own #GdkWindow + * by calling gtk_widget_set_has_window(). This is usually done in the + * widget's init() function. + * + * Since: 2.18 + */ +void +gtk_widget_set_window (GtkWidget *widget, + GdkWindow *window) +{ + g_return_if_fail (GTK_IS_WIDGET (widget)); + g_return_if_fail (window == NULL || GDK_IS_WINDOW (window)); + + if (widget->window != window) + { + widget->window = window; + g_object_notify (G_OBJECT (widget), "window"); + } +} + /** * gtk_widget_get_window: * @widget: a #GtkWidget diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index eb972c9d42..d00beeb753 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -609,7 +609,10 @@ GdkWindow * gtk_widget_get_parent_window (GtkWidget *widget); void gtk_widget_set_child_visible (GtkWidget *widget, gboolean is_visible); gboolean gtk_widget_get_child_visible (GtkWidget *widget); -GdkWindow* gtk_widget_get_window (GtkWidget *widget); + +void gtk_widget_set_window (GtkWidget *widget, + GdkWindow *window); +GdkWindow * gtk_widget_get_window (GtkWidget *widget); void gtk_widget_get_allocation (GtkWidget *widget, GtkAllocation *allocation);