Commit f67ae736 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor
Browse files

Add private function to get the aux info structure fo the widget.

Wed Mar 28 20:30:26 2001  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
	to get the aux info structure fo the widget.

	* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
	above function.

        [ Patch from  Havoc Pennington  <hp@redhat.com> ]

	* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
	to get the size of the window manager frame, basically the same
	code that gdk_window_get_root_origin() had
	(gdk_window_get_root_origin): use gdk_window_get_frame_extents()

	* gtk/gtkwindow.c (gtk_window_set_default_size): use
	gdk_window_resize() if the window is realized and resizeable

	* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
	typo so that setting gravity works

	* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
	allocation if auto_shrink is on, even if the default size
	has not changed.

	* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
	g_return_if_fail
parent f19af6f4
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
Wed Mar 28 20:30:26 2001 Owen Taylor <otaylor@redhat.com>
* gtk/gtkwidget.[ch] (_gtk_widget_get_aux_info): Add private function
to get the aux info structure fo the widget.
* gtk/gtklabel.c gtk/gtkscrolledwindow.c gtk/gtkwindow.c: Use
above function.
[ Patch from Havoc Pennington <hp@redhat.com> ]
* gdk/x11/gdkwindow-x11.c (gdk_window_get_frame_extents): function
to get the size of the window manager frame, basically the same
code that gdk_window_get_root_origin() had
(gdk_window_get_root_origin): use gdk_window_get_frame_extents()
* gtk/gtkwindow.c (gtk_window_set_default_size): use
gdk_window_resize() if the window is realized and resizeable
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): fix
typo so that setting gravity works
* gtk/gtkwindow.c (gtk_window_move_resize): don't ever use
allocation if auto_shrink is on, even if the default size
has not changed.
* gtk/gtkwidget.c (gtk_widget_render_icon): remove bogus
g_return_if_fail
Thu Mar 29 16:29:12 2001 Jonathan Blandford <jrb@webwynk.net>
* gtk/gtkliststore.c (gtk_list_store_iter_changed): Massive
......
......@@ -294,6 +294,8 @@ GtkWidget
@y:
@width:
@height:
@x_set:
@y_set:
<!-- ##### STRUCT GtkWidgetShapeInfo ##### -->
<para>
......
......@@ -416,6 +416,8 @@ gboolean gdk_window_get_deskrelative_origin (GdkWindow *window,
void gdk_window_get_root_origin (GdkWindow *window,
gint *x,
gint *y);
void gdk_window_get_frame_extents (GdkWindow *window,
GdkRectangle *rect);
GdkWindow* gdk_window_get_pointer (GdkWindow *window,
gint *x,
gint *y,
......
......@@ -1676,6 +1676,19 @@ gdk_window_get_geometry (GdkWindow *window,
}
}
/**
* gdk_window_get_origin:
* @window: a #GdkWindow
* @x: return location for X coordinate
* @y: return location for Y coordinate
*
* Obtains the position of a window in root window coordinates.
* (Compare with gdk_window_get_position() and
* gdk_window_get_geometry() which return the position of a window
* relative to its parent window.)
*
* Return value: not meaningful, ignore
**/
gint
gdk_window_get_origin (GdkWindow *window,
gint *x,
......@@ -1708,6 +1721,21 @@ gdk_window_get_origin (GdkWindow *window,
return return_val;
}
/**
* gdk_window_get_deskrelative_origin:
* @window: a #GdkWindow
* @x: return location for X coordinate
* @y: return location for Y coordinate
*
* This gets the origin of a #GdkWindow relative to
* an Enlightenment-window-manager desktop. As long as you don't
* assume that the user's desktop/workspace covers the entire
* root window (i.e. you don't assume that the desktop begins
* at root window coordinate 0,0) this function is not necessary.
* It's deprecated for that reason.
*
* Return value: not meaningful
**/
gboolean
gdk_window_get_deskrelative_origin (GdkWindow *window,
gint *x,
......@@ -1772,10 +1800,48 @@ gdk_window_get_deskrelative_origin (GdkWindow *window,
return return_val;
}
/**
* gdk_window_get_root_origin:
* @window: a #GdkWindow
* @x: return location for X position of window frame
* @y: return location for Y position of window frame
*
* Obtains the top-left corner of the window manager frame in root
* window coordinates.
*
**/
void
gdk_window_get_root_origin (GdkWindow *window,
gint *x,
gint *y)
{
GdkRectangle rect;
g_return_if_fail (GDK_IS_WINDOW (window));
gdk_window_get_frame_extents (window, &rect);
if (x)
*x = rect.x;
if (y)
*y = rect.y;
}
/**
* gdk_window_get_frame_extents:
* @window: a #GdkWindow
* @rect: rectangle to fill with bounding box of the window frame
*
* Obtains the bounding box of the window, including window manager
* titlebar/borders if any. The frame position is given in root window
* coordinates. To get the position of the window itself (rather than
* the frame) in root window coordinates, use gdk_window_get_origin().
*
**/
void
gdk_window_get_frame_extents (GdkWindow *window,
GdkRectangle *rect)
{
GdkWindowObject *private;
Window xwindow;
......@@ -1784,15 +1850,16 @@ gdk_window_get_root_origin (GdkWindow *window,
Window *children;
unsigned int nchildren;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
g_return_if_fail (rect != NULL);
private = (GdkWindowObject*) window;
if (x)
*x = 0;
if (y)
*y = 0;
rect->x = 0;
rect->y = 0;
rect->width = 1;
rect->height = 1;
if (GDK_WINDOW_DESTROYED (window))
return;
......@@ -1822,10 +1889,10 @@ gdk_window_get_root_origin (GdkWindow *window,
if (XGetGeometry (GDK_WINDOW_XDISPLAY (window), xwindow, &root, &wx, &wy, &ww, &wh, &wb, &wd))
{
if (x)
*x = wx;
if (y)
*y = wy;
rect->x = wx;
rect->y = wy;
rect->width = ww;
rect->height = wh;
}
}
}
......@@ -3442,7 +3509,6 @@ update_pos (gint new_root_x,
w += dx;
h += dy;
break;
}
w = MAX (w, 1);
......
......@@ -1013,7 +1013,7 @@ gtk_label_ensure_layout (GtkLabel *label,
gint width, height;
gint real_width;
aux_info = gtk_object_get_data (GTK_OBJECT (widget), "gtk-aux-info");
aux_info = _gtk_widget_get_aux_info (widget, FALSE);
if (aux_info && aux_info->width > 0)
{
pango_layout_set_width (label->layout, aux_info->width * PANGO_SCALE);
......
......@@ -666,20 +666,14 @@ gtk_scrolled_window_size_request (GtkWidget *widget,
if (bin->child && GTK_WIDGET_VISIBLE (bin->child))
{
static guint quark_aux_info = 0;
if (!quark_aux_info)
quark_aux_info = g_quark_from_static_string ("gtk-aux-info");
gtk_widget_size_request (bin->child, &child_requisition);
if (scrolled_window->hscrollbar_policy == GTK_POLICY_NEVER)
requisition->width += child_requisition.width;
else
{
GtkWidgetAuxInfo *aux_info;
GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (bin->child, FALSE);
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), quark_aux_info);
if (aux_info && aux_info->width > 0)
{
requisition->width += aux_info->width;
......@@ -693,9 +687,7 @@ gtk_scrolled_window_size_request (GtkWidget *widget,
requisition->height += child_requisition.height;
else
{
GtkWidgetAuxInfo *aux_info;
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), quark_aux_info);
GtkWidgetAuxInfo *aux_info = _gtk_widget_get_aux_info (bin->child, FALSE);
if (aux_info && aux_info->height > 0)
{
requisition->height += aux_info->height;
......
......@@ -198,6 +198,8 @@ static gboolean gtk_widget_real_activate_mnemonic (GtkWidget *widget,
static GtkWidgetAuxInfo* gtk_widget_aux_info_new (void);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static void gtk_widget_do_uposition (GtkWidget *widget);
static gpointer parent_class = NULL;
static guint widget_signals[LAST_SIGNAL] = { 0 };
......@@ -837,6 +839,7 @@ gtk_widget_set_arg (GtkObject *object,
guint arg_id)
{
GtkWidget *widget;
GtkWidgetAuxInfo *aux_info;
widget = GTK_WIDGET (object);
......@@ -851,10 +854,26 @@ gtk_widget_set_arg (GtkObject *object,
gtk_container_add (GTK_CONTAINER (GTK_VALUE_OBJECT (*arg)), widget);
break;
case ARG_X:
gtk_widget_set_uposition (widget, GTK_VALUE_INT (*arg), -2);
aux_info = _gtk_widget_get_aux_info (widget, TRUE);
if (GTK_VALUE_INT (*arg) == -1)
aux_info->x_set = FALSE;
else
{
aux_info->x_set = TRUE;
aux_info->x = GTK_VALUE_INT (*arg);
}
gtk_widget_do_uposition (widget);
break;
case ARG_Y:
gtk_widget_set_uposition (widget, -2, GTK_VALUE_INT (*arg));
aux_info = _gtk_widget_get_aux_info (widget, TRUE);
if (GTK_VALUE_INT (*arg) == -1)
aux_info->y_set = FALSE;
else
{
aux_info->y_set = TRUE;
aux_info->y = GTK_VALUE_INT (*arg);
}
gtk_widget_do_uposition (widget);
break;
case ARG_WIDTH:
gtk_widget_set_usize (widget, GTK_VALUE_INT (*arg), -2);
......@@ -960,28 +979,28 @@ gtk_widget_get_arg (GtkObject *object,
GTK_VALUE_OBJECT (*arg) = (GtkObject*) widget->parent;
break;
case ARG_X:
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info || !aux_info->x_set)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_INT (*arg) = aux_info->x;
break;
case ARG_Y:
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info || !aux_info->y_set)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_INT (*arg) = aux_info->y;
break;
case ARG_WIDTH:
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info)
GTK_VALUE_INT (*arg) = -1;
else
GTK_VALUE_INT (*arg) = aux_info->width;
break;
case ARG_HEIGHT:
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info)
GTK_VALUE_INT (*arg) = -1;
else
......@@ -1970,7 +1989,7 @@ gtk_widget_get_child_requisition (GtkWidget *widget,
*requisition = widget->requisition;
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (aux_info)
{
if (aux_info->width > 0)
......@@ -2001,7 +2020,7 @@ gtk_widget_size_allocate (GtkWidget *widget,
g_return_if_fail (GTK_IS_WIDGET (widget));
real_allocation = *allocation;
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (aux_info)
{
......@@ -3930,11 +3949,26 @@ gtk_widget_get_parent_window (GtkWidget *widget)
return (parent_window != NULL) ? parent_window : widget->parent->window;
}
/* Update the position from aux_info. Used from gtk_widget_set_uposition
* and gtk_widget_set_arg().
*/
static void
gtk_widget_do_uposition (GtkWidget *widget)
{
GtkWidgetAuxInfo *aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (GTK_IS_WINDOW (widget) && aux_info->x_set && aux_info->y_set)
gtk_window_reposition (GTK_WINDOW (widget), aux_info->x, aux_info->y);
if (GTK_WIDGET_VISIBLE (widget) && widget->parent)
gtk_widget_size_allocate (widget, &widget->allocation);
}
/**
* gtk_widget_set_uposition:
* @widget: a #GtkWidget
* @x: x position
* @y: y position
* @x: x position; -1 to unset x; -2 to leave x unchanged
* @y: y position; -1 to unset y; -2 to leave y unchanged
*
*
* Sets the position of a widget. The funny "u" in the name comes from
......@@ -3946,7 +3980,12 @@ gtk_widget_get_parent_window (GtkWidget *widget)
* window; most window managers will do the centering on your behalf
* if you call gtk_window_set_transient_for(), and it's really not
* possible to get the centering to work correctly in all cases from
* application code.
* application code. But if you insist, use gtk_window_set_position()
* to set #GTK_WIN_POS_CENTER_ON_PARENT, don't do the centering
* manually.
*
* Note that although x and y can be individually unset, the position
* is not honoured unless both x and y are set.
**/
void
gtk_widget_set_uposition (GtkWidget *widget,
......@@ -3958,25 +3997,33 @@ gtk_widget_set_uposition (GtkWidget *widget,
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
{
aux_info = gtk_widget_aux_info_new ();
gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_aux_info, aux_info);
}
aux_info =_gtk_widget_get_aux_info (widget, TRUE);
/* keep this in sync with gtk_window_compute_reposition() */
/* keep this in sync with gtk_window_set_location() */
if (x > -2)
aux_info->x = x;
{
if (x == -1)
aux_info->x_set = FALSE;
else
{
aux_info->x_set = TRUE;
aux_info->x = x;
}
}
if (y > -2)
aux_info->y = y;
if (GTK_IS_WINDOW (widget) && (aux_info->x != -1) && (aux_info->y != -1))
gtk_window_reposition (GTK_WINDOW (widget), x, y);
if (GTK_WIDGET_VISIBLE (widget) && widget->parent)
gtk_widget_size_allocate (widget, &widget->allocation);
{
if (y == -1)
aux_info->y_set = FALSE;
else
{
aux_info->y_set = TRUE;
aux_info->y = y;
}
}
gtk_widget_do_uposition (widget);
}
/**
......@@ -4014,12 +4061,7 @@ gtk_widget_set_usize (GtkWidget *widget,
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
if (!aux_info)
{
aux_info = gtk_widget_aux_info_new ();
gtk_object_set_data_by_id (GTK_OBJECT (widget), quark_aux_info, aux_info);
}
aux_info =_gtk_widget_get_aux_info (widget, TRUE);
if (width > -2)
aux_info->width = width;
......@@ -4742,7 +4784,7 @@ gtk_widget_finalize (GObject *object)
if (widget->name)
g_free (widget->name);
aux_info = gtk_object_get_data_by_id (GTK_OBJECT (widget), quark_aux_info);
aux_info =_gtk_widget_get_aux_info (widget, FALSE);