Commit 11d37c50 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

gtkbutton.c gtkclist.c gtkdrawingarea.c gtkentry.c gtkeventbox.c

Sun Jan 18 09:57:00 1998  Owen Taylor  <owt1@cornell.edu>
* 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.)
parent 1e34b9ba
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
Sun Jan 18 09:57:00 1998 Owen Taylor <owt1@cornell.edu>
* 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 <owt1@cornell.edu>
* 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 <timj@psynet.net>
* gtk/gtkframe.c: gtk_*_get_arg() and gtk_*_set_arg() implementations.
......
......@@ -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);
......
......@@ -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,
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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 = &GTK_WIDGET (GTK_BIN (viewport)->child)->requisition;
attributes.width = child_requisition->width;
attributes.height = child_requisition->height;
}
widget->window = gdk_window_new (viewport->view_window, &attributes, attributes_mask);
gdk_window_set_user_data (widget->window, viewport);
gtk_widget_set_parent_window (bin->child, viewport->bin_window);
}
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;