centering child dialogs on parent windows in gtk+ 2.0
- From: Michael Meeks <michael ximian com>
- To: Gtk Hackers <gtk-devel-list gnome org>
- Subject: centering child dialogs on parent windows in gtk+ 2.0
- Date: 22 Feb 2002 09:45:41 +0000
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.
Regards,
Michael.
--
mmeeks gnu org <><, Pseudo Engineer, itinerant idiot
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]