Re: centering child dialogs on parent windows in gtk+ 2.0
- From: James Henstridge <james daa com au>
- To: Michael Meeks <michael ximian com>
- Cc: Gtk Hackers <gtk-devel-list gnome org>
- Subject: Re: centering child dialogs on parent windows in gtk+ 2.0
- Date: Fri, 22 Feb 2002 17:57:21 +0800
Michael Meeks wrote:
Hello,
I'm attempting to port this to Gtk+ 2.0, essentially it uses
set_uposition to center a child over it's parent when it's not a
transient, nor modal dialog:
static void
center_dialog_over_rect (GtkWindow *window, GdkRectangle rect)
{
fit_rect_on_screen (&rect);
gtk_widget_set_uposition (GTK_WIDGET (window),
rect.x + rect.width / 2
- GTK_WIDGET (window)->allocation.width / 2,
rect.y + rect.height / 2
- GTK_WIDGET (window)->allocation.height / 2);
}
static void
center_dialog_over_window (GtkWindow *window, GtkWindow *over)
{
GdkRectangle rect;
int x, y, w, h;
gdk_window_get_root_origin (GTK_WIDGET (over)->window, &x, &y);
gdk_window_get_size (GTK_WIDGET (over)->window, &w, &h);
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
center_dialog_over_rect (window, rect);
}
I tried something like:
GdkGeometry geometry = { 0 };
geometry.win_gravity = GDK_GRAVITY_CENTER;
gtk_window_set_geometry_hints (window,
GTK_WIDGET (over),
&geometry,
GDK_HINT_WIN_GRAVITY);
mainly because it had the text CENTER in it :-) this appeared to have
no effect whatsoever - is that sawfish brokenness, or is this totally
the wrong way to do it ? what is the right way ? advice much
appreciated.
I am pretty sure this isn't what you want to do. The widget argument to
set_geometry_hints() is really for use by things like terminals where
they want the window to resize so that some child widget's size is
quantised. I don't think that argument is used by the gravity hint.
Was there a problem with your old code?
James.
--
Email: james daa com au
WWW: http://www.daa.com.au/~james/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]