diff --git a/ChangeLog b/ChangeLog index e115c44760..7182d932de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index e115c44760..7182d932de 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e115c44760..7182d932de 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e115c44760..7182d932de 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e115c44760..7182d932de 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e115c44760..7182d932de 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e115c44760..7182d932de 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,27 @@ +Sun Jan 18 09:57:00 1998 Owen Taylor + * gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c + gtkfixed.c gtkhandlebox.c gtkhscale.c gtkhscrollbar.c gtkitem.c + gtklist.c gtkmenushell.c gtkmisc.c gtknotebook.c gtkpaned.c + gtkpreview.c gtkprogressbar.c gtkruler.c gtktext.c gtktree.c + gtkviewport.c gtkvscale.c gtkvscrollbar.c gtkwidget.{c,h} + + Added gtk_widget_set_parent and gtk_widget_get_parent. All + widgets should use: + + gtk_widget_get_parent() instead of widget->parent->window. + + Any widget that wants to have children not in the parent window, + should use gtk_widget_set_parent () in their realize() and + add () routines. + + CList and Viewport widgets changed to do this. (Viewport + widget using code from gtk-fortier-980117-0.patch.) + +Sat Jan 17 23:56:02 1998 Owen Taylor + * gtk/gtkobject.c: + renamed g_string_equal => g_str_equal + renamed g_string_hash => g_str_hash + Sun Jan 18 03:57:52 1998 Tim Janik * gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations. diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c index f86275c19a..63cd1d21f0 100644 --- a/gtk/gtkbutton.c +++ b/gtk/gtkbutton.c @@ -366,7 +366,7 @@ gtk_button_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, button); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkclist.c b/gtk/gtkclist.c index 9e80fe7274..dc0ecfd75a 100644 --- a/gtk/gtkclist.c +++ b/gtk/gtkclist.c @@ -173,8 +173,6 @@ static void gtk_clist_foreach (GtkContainer * container, /* Buttons */ -static void gtk_clist_column_button_realize (GtkWidget * widget, - gpointer data); static void gtk_clist_column_button_clicked (GtkWidget * widget, gpointer data); @@ -428,11 +426,6 @@ gtk_clist_new (int columns, clist->column[i].button = gtk_button_new (); gtk_widget_set_parent (clist->column[i].button, GTK_WIDGET (clist)); - gtk_signal_connect_after (GTK_OBJECT (clist->column[i].button), - "realize", - (GtkSignalFunc) gtk_clist_column_button_realize, - (gpointer) clist); - gtk_signal_connect (GTK_OBJECT (clist->column[i].button), "clicked", (GtkSignalFunc) gtk_clist_column_button_clicked, @@ -1283,6 +1276,7 @@ gtk_clist_realize (GtkWidget * widget) GdkWindowAttr attributes; gint attributes_mask; GdkGCValues values; + gint i; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_CLIST (widget)); @@ -1308,7 +1302,7 @@ gtk_clist_realize (GtkWidget * widget) /* main window */ - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, clist); widget->style = gtk_style_attach (widget->style, widget->window); @@ -1322,6 +1316,10 @@ gtk_clist_realize (GtkWidget * widget) gtk_style_set_background (widget->style, clist->title_window, GTK_STATE_SELECTED); gdk_window_show (clist->title_window); + /* set things up so column buttons are drawn in title window */ + for (i = 0; i < clist->columns; i++) + gtk_widget_set_parent_window (clist->column[i].button, clist->title_window); + /* clist-window */ clist->clist_window = gdk_window_new (widget->window, &attributes, attributes_mask); gdk_window_set_user_data (clist->clist_window, clist); @@ -2351,21 +2349,6 @@ gtk_clist_foreach (GtkContainer * container, } /* BUTTONS */ -static void -gtk_clist_column_button_realize (GtkWidget * widget, - gpointer data) -{ - GtkCList *clist; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_CLIST (data)); - - clist = GTK_CLIST (data); - - if (widget->window && clist->title_window) - gdk_window_reparent (widget->window, clist->title_window, - widget->allocation.x, 0); -} static void gtk_clist_column_button_clicked (GtkWidget * widget, diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c index 8be0bc078b..1a59bfc6d3 100644 --- a/gtk/gtkdrawingarea.c +++ b/gtk/gtkdrawingarea.c @@ -110,7 +110,7 @@ gtk_drawing_area_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, darea); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 31f2ed2d5e..dca61fc1a4 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -585,7 +585,7 @@ gtk_entry_realize (GtkWidget *widget) GDK_KEY_PRESS_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, entry); attributes.x = widget->style->klass->xthickness + INNER_BORDER; diff --git a/gtk/gtkeventbox.c b/gtk/gtkeventbox.c index daec6c2266..ac9d8746da 100644 --- a/gtk/gtkeventbox.c +++ b/gtk/gtkeventbox.c @@ -112,7 +112,7 @@ gtk_event_box_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkfixed.c b/gtk/gtkfixed.c index 467b15b6a4..b17404795f 100644 --- a/gtk/gtkfixed.c +++ b/gtk/gtkfixed.c @@ -271,7 +271,7 @@ gtk_fixed_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c index 827203f4eb..344ed432c4 100644 --- a/gtk/gtkhandlebox.c +++ b/gtk/gtkhandlebox.c @@ -231,7 +231,7 @@ gtk_handle_box_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - hb->steady_window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + hb->steady_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (hb->steady_window, widget); attributes.x = 0; @@ -601,10 +601,13 @@ gtk_handle_box_motion (GtkWidget *widget, hb->is_onroot = TRUE; gdk_pointer_ungrab (GDK_CURRENT_TIME); - gtk_widget_show (hb->float_window); + + if (!GTK_WIDGET_REALIZED (hb->float_window)) + gtk_widget_realize (hb->float_window); + gtk_widget_set_uposition (hb->float_window, newx, newy); - gdk_window_reparent (widget->window, hb->float_window->window, 0, 0); + gtk_widget_show (hb->float_window); while (gdk_pointer_grab (widget->window, FALSE, @@ -628,10 +631,10 @@ gtk_handle_box_delete_float (GtkWidget *widget, { GtkHandleBox *hb; - g_return_if_fail (widget != NULL); - g_return_if_fail (event != NULL); - g_return_if_fail (data != NULL); - g_return_if_fail (GTK_IS_HANDLE_BOX (data)); + g_return_val_if_fail (widget != NULL, FALSE); + g_return_val_if_fail (event != NULL, FALSE); + g_return_val_if_fail (data != NULL, FALSE); + g_return_val_if_fail (GTK_IS_HANDLE_BOX (data), FALSE); hb = GTK_HANDLE_BOX (data); diff --git a/gtk/gtkhscale.c b/gtk/gtkhscale.c index 4771c2e1f6..3c1e42dbc1 100644 --- a/gtk/gtkhscale.c +++ b/gtk/gtkhscale.c @@ -138,7 +138,7 @@ gtk_hscale_realize (GtkWidget *widget) attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_hscale_pos_trough (GTK_HSCALE (widget), &x, &y, &w, &h); attributes.x = x; diff --git a/gtk/gtkhscrollbar.c b/gtk/gtkhscrollbar.c index dcc056c8ae..075b1344ff 100644 --- a/gtk/gtkhscrollbar.c +++ b/gtk/gtkhscrollbar.c @@ -147,7 +147,7 @@ gtk_hscrollbar_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); range->trough = widget->window; gdk_window_ref (range->trough); diff --git a/gtk/gtkitem.c b/gtk/gtkitem.c index ebf7a37561..0afa4e3efa 100644 --- a/gtk/gtkitem.c +++ b/gtk/gtkitem.c @@ -184,7 +184,7 @@ gtk_item_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtklist.c b/gtk/gtklist.c index fc5aea67f9..b93aca511c 100644 --- a/gtk/gtklist.c +++ b/gtk/gtklist.c @@ -578,7 +578,7 @@ gtk_list_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c index cf801afecd..cee765271b 100644 --- a/gtk/gtkmenushell.c +++ b/gtk/gtkmenushell.c @@ -298,7 +298,7 @@ gtk_menu_shell_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkmisc.c b/gtk/gtkmisc.c index 92ab64a49d..94cd489254 100644 --- a/gtk/gtkmisc.c +++ b/gtk/gtkmisc.c @@ -157,7 +157,7 @@ gtk_misc_realize (GtkWidget *widget) if (GTK_WIDGET_NO_WINDOW (widget)) { - widget->window = widget->parent->window; + widget->window = gtk_widget_get_parent_window (widget); widget->style = gtk_style_attach (widget->style, widget->window); } else @@ -173,7 +173,7 @@ gtk_misc_realize (GtkWidget *widget) attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 258d484f6c..d5e099c1f8 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -536,7 +536,7 @@ gtk_notebook_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, notebook); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c index e9a587e334..cd4d3949a2 100644 --- a/gtk/gtkpaned.c +++ b/gtk/gtkpaned.c @@ -168,12 +168,12 @@ gtk_paned_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR; - paned->handle = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + paned->handle = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (paned->handle, widget); gdk_window_show (paned->handle); gdk_window_raise (paned->handle); - widget->window = widget->parent->window; + widget->window = gtk_widget_get_parent_window (widget); widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, paned->handle, GTK_STATE_NORMAL); diff --git a/gtk/gtkpreview.c b/gtk/gtkpreview.c index 3080541e66..1f60d8624a 100644 --- a/gtk/gtkpreview.c +++ b/gtk/gtkpreview.c @@ -676,7 +676,7 @@ gtk_preview_realize (GtkWidget *widget) attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK; attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkprogressbar.c b/gtk/gtkprogressbar.c index ae15aa7b13..9bcd28f427 100644 --- a/gtk/gtkprogressbar.c +++ b/gtk/gtkprogressbar.c @@ -133,7 +133,7 @@ gtk_progress_bar_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, pbar); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkruler.c b/gtk/gtkruler.c index 849d5eadf1..dc5d841db0 100644 --- a/gtk/gtkruler.c +++ b/gtk/gtkruler.c @@ -176,7 +176,7 @@ gtk_ruler_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, ruler); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtktext.c b/gtk/gtktext.c index 44ac63ba63..23709ce721 100644 --- a/gtk/gtktext.c +++ b/gtk/gtktext.c @@ -643,7 +643,7 @@ gtk_text_realize (GtkWidget *widget) GDK_KEY_PRESS_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, text); attributes.x = (widget->style->klass->xthickness + TEXT_BORDER_ROOM); diff --git a/gtk/gtktree.c b/gtk/gtktree.c index c81e3d7744..c0f994398f 100644 --- a/gtk/gtktree.c +++ b/gtk/gtktree.c @@ -603,7 +603,7 @@ gtk_tree_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, widget); widget->style = gtk_style_attach (widget->style, widget->window); diff --git a/gtk/gtkviewport.c b/gtk/gtkviewport.c index b39ca31efa..dbb07c0024 100644 --- a/gtk/gtkviewport.c +++ b/gtk/gtkviewport.c @@ -31,6 +31,8 @@ static void gtk_viewport_draw (GtkWidget *widget, GdkRectangle *area); static gint gtk_viewport_expose (GtkWidget *widget, GdkEventExpose *event); +static void gtk_viewport_add (GtkContainer *container, + GtkWidget *widget); static void gtk_viewport_size_request (GtkWidget *widget, GtkRequisition *requisition); static void gtk_viewport_size_allocate (GtkWidget *widget, @@ -41,7 +43,6 @@ static void gtk_viewport_adjustment_changed (GtkAdjustment *adjustment, static void gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, gpointer data); - guint gtk_viewport_get_type () { @@ -84,6 +85,7 @@ gtk_viewport_class_init (GtkViewportClass *class) widget_class->size_request = gtk_viewport_size_request; widget_class->size_allocate = gtk_viewport_size_allocate; + container_class->add = gtk_viewport_add; container_class->need_resize = gtk_viewport_need_resize; } @@ -94,8 +96,8 @@ gtk_viewport_init (GtkViewport *viewport) GTK_WIDGET_SET_FLAGS (viewport, GTK_BASIC); viewport->shadow_type = GTK_SHADOW_IN; - viewport->main_window = NULL; viewport->view_window = NULL; + viewport->bin_window = NULL; viewport->hadjustment = NULL; viewport->vadjustment = NULL; } @@ -223,17 +225,15 @@ gtk_viewport_set_shadow_type (GtkViewport *viewport, static void gtk_viewport_map (GtkWidget *widget) { - GtkViewport *viewport; GtkBin *bin; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VIEWPORT (widget)); GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); - viewport = GTK_VIEWPORT (widget); bin = GTK_BIN (widget); - gdk_window_show (viewport->main_window); + gdk_window_show (widget->window); if (bin->child && GTK_WIDGET_VISIBLE (bin->child) && @@ -244,20 +244,18 @@ gtk_viewport_map (GtkWidget *widget) static void gtk_viewport_unmap (GtkWidget *widget) { - GtkViewport *viewport; - g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VIEWPORT (widget)); GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED); - viewport = GTK_VIEWPORT (widget); - gdk_window_hide (viewport->main_window); + gdk_window_hide (widget->window); } static void gtk_viewport_realize (GtkWidget *widget) { + GtkBin *bin; GtkViewport *viewport; GdkWindowAttr attributes; GtkRequisition *child_requisition; @@ -266,6 +264,7 @@ gtk_viewport_realize (GtkWidget *widget) g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VIEWPORT (widget)); + bin = GTK_BIN (widget); viewport = GTK_VIEWPORT (widget); GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); @@ -281,35 +280,38 @@ gtk_viewport_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - viewport->main_window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); - gdk_window_set_user_data (viewport->main_window, viewport); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), + &attributes, attributes_mask); + gdk_window_set_user_data (widget->window, viewport); attributes.x += widget->style->klass->xthickness; attributes.y += widget->style->klass->ythickness; attributes.width -= widget->style->klass->xthickness * 2; attributes.height -= widget->style->klass->ythickness * 2; - viewport->view_window = gdk_window_new (viewport->main_window, &attributes, attributes_mask); + viewport->view_window = gdk_window_new (widget->window, &attributes, attributes_mask); gdk_window_set_user_data (viewport->view_window, viewport); attributes.x = 0; attributes.y = 0; - if (GTK_BIN (viewport)->child) + viewport->bin_window = gdk_window_new (viewport->view_window, &attributes, attributes_mask); + gdk_window_set_user_data (viewport->bin_window, viewport); + + if (bin->child) { child_requisition = >K_WIDGET (GTK_BIN (viewport)->child)->requisition; attributes.width = child_requisition->width; attributes.height = child_requisition->height; + + gtk_widget_set_parent_window (bin->child, viewport->bin_window); } - widget->window = gdk_window_new (viewport->view_window, &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, viewport); - - widget->style = gtk_style_attach (widget->style, viewport->main_window); - gtk_style_set_background (widget->style, viewport->main_window, GTK_STATE_NORMAL); + widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); + gtk_style_set_background (widget->style, viewport->bin_window, GTK_STATE_NORMAL); - gdk_window_show (widget->window); + gdk_window_show (viewport->bin_window); gdk_window_show (viewport->view_window); } @@ -328,11 +330,11 @@ gtk_viewport_unrealize (GtkWidget *widget) gdk_window_destroy (widget->window); gdk_window_destroy (viewport->view_window); - gdk_window_destroy (viewport->main_window); + gdk_window_destroy (viewport->bin_window); widget->window = NULL; viewport->view_window = NULL; - viewport->main_window = NULL; + viewport->bin_window = NULL; } static void @@ -340,8 +342,6 @@ gtk_viewport_paint (GtkWidget *widget, GdkRectangle *area) { GtkViewport *viewport; - GtkStateType state; - gint x, y; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_VIEWPORT (widget)); @@ -351,14 +351,7 @@ gtk_viewport_paint (GtkWidget *widget, { viewport = GTK_VIEWPORT (widget); - state = widget->state; - if (!GTK_WIDGET_IS_SENSITIVE (widget)) - state = GTK_STATE_INSENSITIVE; - - x = GTK_CONTAINER (viewport)->border_width; - y = GTK_CONTAINER (viewport)->border_width; - - gtk_draw_shadow (widget->style, viewport->main_window, + gtk_draw_shadow (widget->style, widget->window, GTK_STATE_NORMAL, viewport->shadow_type, 0, 0, -1, -1); } @@ -413,7 +406,7 @@ gtk_viewport_expose (GtkWidget *widget, viewport = GTK_VIEWPORT (widget); bin = GTK_BIN (widget); - if (event->window == viewport->main_window) + if (event->window == widget->window) gtk_viewport_paint (widget, &event->area); child_event = *event; @@ -426,6 +419,36 @@ gtk_viewport_expose (GtkWidget *widget, return FALSE; } +static void +gtk_viewport_add (GtkContainer *container, + GtkWidget *widget) +{ + GtkBin *bin; + + g_return_if_fail (container != NULL); + g_return_if_fail (GTK_IS_VIEWPORT (container)); + g_return_if_fail (widget != NULL); + + bin = GTK_BIN (container); + + if (!bin->child) + { + gtk_widget_set_parent (widget, GTK_WIDGET (container)); + gtk_widget_set_parent_window (widget, GTK_VIEWPORT (container)->bin_window); + if (GTK_WIDGET_VISIBLE (widget->parent)) + { + if (GTK_WIDGET_MAPPED (widget->parent) && + !GTK_WIDGET_MAPPED (widget)) + gtk_widget_map (widget); + } + + bin->child = widget; + + if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (container)) + gtk_widget_queue_resize (widget); + } +} + static void gtk_viewport_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -481,7 +504,7 @@ gtk_viewport_size_allocate (GtkWidget *widget, if (GTK_WIDGET_REALIZED (widget)) { - gdk_window_move_resize (viewport->main_window, + gdk_window_move_resize (widget->window, allocation->x + GTK_CONTAINER (viewport)->border_width, allocation->y + GTK_CONTAINER (viewport)->border_width, allocation->width - GTK_CONTAINER (viewport)->border_width * 2, @@ -535,7 +558,7 @@ gtk_viewport_size_allocate (GtkWidget *widget, if (!GTK_WIDGET_REALIZED (widget)) gtk_widget_realize (widget); - gdk_window_resize (widget->window, + gdk_window_resize (viewport->bin_window, child_allocation.width, child_allocation.height); @@ -624,7 +647,7 @@ gtk_viewport_adjustment_value_changed (GtkAdjustment *adjustment, child_allocation.y = viewport->vadjustment->lower - viewport->vadjustment->value; if (GTK_WIDGET_REALIZED (viewport)) - gdk_window_move (GTK_WIDGET (viewport)->window, + gdk_window_move (viewport->bin_window, child_allocation.x, child_allocation.y); } diff --git a/gtk/gtkvscale.c b/gtk/gtkvscale.c index 20de97401b..292d3a7bcb 100644 --- a/gtk/gtkvscale.c +++ b/gtk/gtkvscale.c @@ -139,7 +139,7 @@ gtk_vscale_realize (GtkWidget *widget) attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_vscale_pos_trough (GTK_VSCALE (widget), &x, &y, &w, &h); attributes.x = x; diff --git a/gtk/gtkvscrollbar.c b/gtk/gtkvscrollbar.c index f83fef1e8b..47697e792b 100644 --- a/gtk/gtkvscrollbar.c +++ b/gtk/gtkvscrollbar.c @@ -146,7 +146,7 @@ gtk_vscrollbar_realize (GtkWidget *widget) GDK_LEAVE_NOTIFY_MASK); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask); + widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); range->trough = widget->window; gdk_window_ref (range->trough); diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index ced7b20834..be4cac893e 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -200,6 +200,7 @@ static const char *visual_key = "visual"; static const char *event_key = "event_mask"; static const char *resize_widgets_key = "resize_widgets"; static const char *extension_event_key = "extension_event_mode"; +static const char *parent_window_key = "parent_window"; static const char *redraw_handler_key = "redraw_handler_tag"; static const char *resize_handler_key = "resize_handler_tag"; static const char *shape_info_key = "shape_info"; @@ -1801,19 +1802,18 @@ static void gtk_widget_reparent_container_child(GtkWidget *widget, gpointer client_data) { - GtkWidget *new_parent = GTK_WIDGET (client_data); - g_return_if_fail (widget != NULL); g_return_if_fail (client_data != NULL); if (!GTK_WIDGET_NO_WINDOW (widget)) - gdk_window_reparent (widget->window, new_parent->window, 0, 0); + gdk_window_reparent (widget->window, + (GdkWindow *)client_data, 0, 0); else if (GTK_IS_CONTAINER (widget)) gtk_container_foreach (GTK_CONTAINER (widget), gtk_widget_reparent_container_child, - new_parent); + client_data); else - widget->window = new_parent->window; + widget->window = (GdkWindow *)client_data; } @@ -1841,12 +1841,12 @@ gtk_widget_reparent (GtkWidget *widget, if (GTK_IS_CONTAINER (widget)) gtk_container_foreach (GTK_CONTAINER(widget), gtk_widget_reparent_container_child, - new_parent); + gtk_widget_get_parent_window (widget)); else - widget->window = widget->parent->window; + widget->window = gtk_widget_get_parent_window (widget); } else - gdk_window_reparent (widget->window, widget->parent->window, 0, 0); + gdk_window_reparent (widget->window, gtk_widget_get_parent_window (widget), 0, 0); } else gtk_widget_unrealize (widget); @@ -2214,6 +2214,64 @@ gtk_widget_set_parent (GtkWidget *widget, } } +/************************************************************* + * gtk_widget_set_parent_window: + * Set a non default parent window for widget + * + * arguments: + * widget: + * parent_window + * + * results: + *************************************************************/ + +void +gtk_widget_set_parent_window (GtkWidget *widget, + GdkWindow *parent_window) +{ + GdkWindow *old_parent_window; + + g_return_if_fail (widget != NULL); + + old_parent_window = gtk_object_get_data (GTK_OBJECT (widget), + parent_window_key); + + if (parent_window != old_parent_window) + { + gtk_object_set_data (GTK_OBJECT (widget), parent_window_key, + parent_window); + if (old_parent_window) + gdk_window_unref (old_parent_window); + if (parent_window) + gdk_window_ref (parent_window); + } +} + +/************************************************************* + * gtk_widget_get_parent_window: + * Get widget's parent window + * + * arguments: + * widget: + * + * results: + * parent window + *************************************************************/ + +GdkWindow * +gtk_widget_get_parent_window (GtkWidget *widget) +{ + GdkWindow *parent_window; + + g_return_val_if_fail (widget != NULL, NULL); + + parent_window = gtk_object_get_data (GTK_OBJECT (widget), + parent_window_key); + + return (parent_window != NULL) ? parent_window : widget->parent->window; +} + + /***************************************** * gtk_widget_set_style: * @@ -3115,7 +3173,7 @@ gtk_real_widget_realize (GtkWidget *widget) GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); if(widget->parent) - widget->window = widget->parent->window; + widget->window = gtk_widget_get_parent_window (widget); widget->style = gtk_style_attach (widget->style, widget->window); } diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index f84e481539..13836c5e56 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -423,6 +423,9 @@ void gtk_widget_set_sensitive (GtkWidget *widget, gint sensitive); void gtk_widget_set_parent (GtkWidget *widget, GtkWidget *parent); +void gtk_widget_set_parent_window (GtkWidget *widget, + GdkWindow *parent_window); +GdkWindow *gtk_widget_get_parent_window (GtkWidget *widget); void gtk_widget_set_style (GtkWidget *widget, GtkStyle *style); void gtk_widget_set_uposition (GtkWidget *widget,