fix a typo.

2001-08-07  Havoc Pennington  <hp@pobox.com>

	* gtk/gtkfilesel.c (open_ref_dir): fix a typo.

	* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
	some fixage is needed here, but nothing simple. Owen understands
	it. ;-)

        * gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
	sizing and positioning.  Also, fix bug in compute_geometry_hints
	(width/height confusion for setting min size).
	(gtk_window_move): new function
	(gtk_window_resize): new function
	(gtk_window_get_size): new function
	(gtk_window_get_position): new function
	(gtk_window_parse_geometry): new function

 	* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
 	(gtk_widget_get_size_request): new function
 	(gtk_widget_get_usize): delete, that was a short-lived function
 	;-)
 	(gtk_widget_set_usize): deprecate
 	(gtk_widget_set_uposition): deprecate, make it a trivial
	gtk_window_move() wrapper
	(gtk_widget_class_init): remove x/y/width/height properties,
	add width_request height_request

        * demos/*: update to avoid deprecated functions

	* gtk/gtklayout.c: add x/y child properties

	* gtk/gtkfixed.c: add x/y child properties, and get rid of
	uses of "gint16"

	* tests/testgtk.c (create_window_sizing): lots of tweaks to window
	sizing test

	* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
	configure events on toplevel windows are always in root window
	coordinates, following ICCCM spec that all synthetic events
	are in root window coords already, while real events are
	in parent window coords. Previously the code assumed that
	coords of 0,0 were parent window coords, which was
	really broken.

 	* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
 	warning

 	* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
 	and GDK_HINT_USER_SIZE so we can set USSize and USPosition
 	hints in gtk_window_parse_geometry()

 	* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
 	new USER_POS USER_SIZE hints
This commit is contained in:
Havoc Pennington 2001-08-10 03:46:08 +00:00 committed by Havoc Pennington
parent 439cd9a3a5
commit f37a0627fc
35 changed files with 3052 additions and 824 deletions

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -1,3 +1,58 @@
2001-08-07 Havoc Pennington <hp@pobox.com>
* gtk/gtkfilesel.c (open_ref_dir): fix a typo.
* gtk/gtkplug.c (gtk_plug_init): remove setting of auto_shrink;
some fixage is needed here, but nothing simple. Owen understands
it. ;-)
* gtk/gtkwindow.h, gtk/gtkwindow.c: Rework code and API for window
sizing and positioning. Also, fix bug in compute_geometry_hints
(width/height confusion for setting min size).
(gtk_window_move): new function
(gtk_window_resize): new function
(gtk_window_get_size): new function
(gtk_window_get_position): new function
(gtk_window_parse_geometry): new function
* gtk/gtkwidget.c (gtk_widget_set_size_request): new function
(gtk_widget_get_size_request): new function
(gtk_widget_get_usize): delete, that was a short-lived function
;-)
(gtk_widget_set_usize): deprecate
(gtk_widget_set_uposition): deprecate, make it a trivial
gtk_window_move() wrapper
(gtk_widget_class_init): remove x/y/width/height properties,
add width_request height_request
* demos/*: update to avoid deprecated functions
* gtk/gtklayout.c: add x/y child properties
* gtk/gtkfixed.c: add x/y child properties, and get rid of
uses of "gint16"
* tests/testgtk.c (create_window_sizing): lots of tweaks to window
sizing test
* gdk/x11/gdkevents-x11.c (gdk_event_translate): Ensure that
configure events on toplevel windows are always in root window
coordinates, following ICCCM spec that all synthetic events
are in root window coords already, while real events are
in parent window coords. Previously the code assumed that
coords of 0,0 were parent window coords, which was
really broken.
* gtk/gtkcontainer.c (gtk_container_get_focus_chain): fix
warning
* gdk/gdkwindow.h (GdkWindowHints): add GDK_HINT_USER_POS
and GDK_HINT_USER_SIZE so we can set USSize and USPosition
hints in gtk_window_parse_geometry()
* gdk/x11/gdkwindow-x11.c (gdk_window_set_geometry_hints): support
new USER_POS USER_SIZE hints
2001-08-09 Matthias Clasen <matthiasc@waldgeist.poet.de>
* tests/prop-editor.c (properties_from_type): Use

View File

@ -78,7 +78,7 @@ do_colorsel (void)
da = gtk_drawing_area_new ();
/* set a minimum size */
gtk_widget_set_usize (da, 200, 200);
gtk_widget_set_size_request (da, 200, 200);
/* set the color */
gtk_widget_modify_bg (da, GTK_STATE_NORMAL, &color);

View File

@ -92,7 +92,7 @@ do_item_factory (void)
FALSE, FALSE, 0);
label = gtk_label_new ("Type\n<alt>\nto start");
gtk_widget_set_usize (label, 200, 200);
gtk_widget_set_size_request (label, 200, 200);
gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
gtk_box_pack_start (GTK_BOX (box1), label, TRUE, TRUE, 0);

View File

@ -686,7 +686,7 @@ create_tree (void)
gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
GTK_TREE_SELECTION_SINGLE);
gtk_widget_set_usize (tree_view, 200, -1);
gtk_widget_set_size_request (tree_view, 200, -1);
for (i=0; i < G_N_ELEMENTS (testgtk_demos); i++)
{

View File

@ -148,7 +148,7 @@ do_panes (void)
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME(frame), GTK_SHADOW_IN);
gtk_widget_set_usize (frame, 60, 60);
gtk_widget_set_size_request (frame, 60, 60);
gtk_paned_add1 (GTK_PANED (hpaned), frame);
button = gtk_button_new_with_mnemonic ("_Hi there");

View File

@ -246,7 +246,7 @@ do_pixbufs (void)
}
else
{
gtk_widget_set_usize (window, back_width, back_height);
gtk_widget_set_size_request (window, back_width, back_height);
frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height);

View File

@ -212,8 +212,9 @@ main (int argc, char **argv)
frame = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, back_width, back_height);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_set_usize (window, back_width, back_height);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_widget_set_size_request (window, back_width, back_height);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC (destroy_cb), NULL);

View File

@ -104,9 +104,9 @@ int main(int argc, char **argv)
gtk_container_add(GTK_CONTAINER(window), vbox);
drawing_area = gtk_drawing_area_new();
gtk_widget_set_usize(GTK_WIDGET(drawing_area),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
gtk_widget_set_size_request (GTK_WIDGET(drawing_area),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
gtk_signal_connect(GTK_OBJECT(drawing_area), "expose_event",
GTK_SIGNAL_FUNC(expose_cb), NULL);

View File

@ -142,9 +142,9 @@ main (int argc, char **argv)
gtk_container_add (GTK_CONTAINER (window), vbox);
drawing_area = gtk_drawing_area_new ();
gtk_widget_set_usize (GTK_WIDGET (drawing_area),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
gtk_widget_set_size_request (GTK_WIDGET (drawing_area),
gdk_pixbuf_get_width (pixbuf),
gdk_pixbuf_get_height (pixbuf));
gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event",
GTK_SIGNAL_FUNC (expose_cb), NULL);

View File

@ -393,7 +393,7 @@ new_testrgb_window (GdkPixbuf *pixbuf, gchar *title)
drawing_area = gtk_drawing_area_new ();
temp_box = gtk_hbox_new (FALSE, 0);
gtk_widget_set_usize (GTK_WIDGET(drawing_area), w, h);
gtk_widget_set_size_request (GTK_WIDGET(drawing_area), w, h);
gtk_box_pack_start (GTK_BOX (temp_box), drawing_area, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), temp_box, FALSE, FALSE, 0);

View File

@ -397,6 +397,22 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
using gdk_image_get() should really be ported to
gdk_pixbuf_get_from_drawable().
* gtk_widget_set_usize() has been renamed to
gtk_widget_set_size_request(), however the old name still exists
unless you define GTK_DISABLE_DEPRECATED.
* gtk_widget_set_uposition() is deprecated; use gtk_window_move(),
gtk_fixed_put(), or gtk_layout_put() instead.
* gtk_window_set_policy() is deprecated. To get the effect of
"allow_shrink", call gtk_widget_set_size_request(window, 0, 0). To
get the effect of "allow_grow", call
gtk_window_set_resizable(window, TRUE). You didn't want the effect
of auto_shrink, it made no sense. But maybe if you were using it you
want to use gtk_window_resize (window, 1, 1) to snap a window back
to its minimum size (the 1, 1 will be rounded up to the minimum
window size).
* The core GTK+ now takes care of handling mapping, unmapping and
realizing the child widgets of containers in
gtk_widget_set_parent(). In most cases, this allows container

View File

@ -87,6 +87,8 @@ Windows
@GDK_HINT_ASPECT:
@GDK_HINT_RESIZE_INC:
@GDK_HINT_WIN_GRAVITY:
@GDK_HINT_USER_POS:
@GDK_HINT_USER_SIZE:
<!-- ##### STRUCT GdkGeometry ##### -->
<para>

View File

@ -1004,6 +1004,36 @@ the #GtkAdjustment which sets the range of the scale.
@widget: the object which received the signal.
<!-- ##### ARG GtkWidget:height ##### -->
<para>
</para>
<!-- ##### ARG GtkWidget:width ##### -->
<para>
</para>
<!-- ##### ARG GtkWidget:x ##### -->
<para>
</para>
<!-- ##### ARG GtkWidget:y ##### -->
<para>
</para>
<!-- ##### ARG GtkWindow:auto-shrink ##### -->
<para>
If the window shrinks automatically when widgets within it shrink.
</para>
<!-- ##### FUNCTION gtk_arg_copy ##### -->
<para>
It will either copy data into an existing argument or allocate a new argument

View File

@ -495,7 +495,6 @@ This can later be composited together with other
#GtkRcStyle structures to form a #GtkStyle.
</para>
@parent_instance:
@name:
@bg_pixmap_name:
@font_desc:

View File

@ -1874,22 +1874,12 @@ a widget changes from un-anchored to anchored or vice-versa.
</para>
<!-- ##### ARG GtkWidget:x ##### -->
<!-- ##### ARG GtkWidget:width-request ##### -->
<para>
</para>
<!-- ##### ARG GtkWidget:y ##### -->
<para>
</para>
<!-- ##### ARG GtkWidget:width ##### -->
<para>
</para>
<!-- ##### ARG GtkWidget:height ##### -->
<!-- ##### ARG GtkWidget:height-request ##### -->
<para>
</para>

View File

@ -509,11 +509,6 @@ The type of the window.
The title of the window.
</para>
<!-- ##### ARG GtkWindow:auto-shrink ##### -->
<para>
If the window shrinks automatically when widgets within it shrink.
</para>
<!-- ##### ARG GtkWindow:allow-shrink ##### -->
<para>
If the window can be resized to a smaller size by the user.

121
docs/sizing-test.txt Normal file
View File

@ -0,0 +1,121 @@
This is a list of things to check when testing window size/pos functions.
===
gtk_widget_set_size_request():
- causes the widget to request the given size
- for toplevel windows, changes the default-requested size if
no default size is set and gtk_window_resize() has not been called
- passing -1 for either width or height reverts to "natural" request
in that dimension
- passing 0 is allowed, and results in requisition of 1x1
(0x0 is a permitted requisition, but equivalent to 1x1,
we use 1x1 for implementation convenience)
- causes notifies on width_request, height_request properties
gtk_window_resize():
- causes a configure request in all cases if the window is mapped,
unless the new size is the same as the old size
- overrides the default size on map if the window is unmapped
- allows size of 0, equivalent to 1
- clamped to geometry hints
gtk_window_set_default_size():
- has no effect after the window has been mapped the first time,
unless the window has been unrealized in which case it should
have an effect
- allows size of 0, equivalent to 1
- allows size of -1 to unset the default size
- clamped to geometry hints
- gtk_window_resize() overrides it
- causes notifies on default_width, default_height properties
gtk_window_get_default_size():
- returns the values last passed to set_default_size(), including
-1. If set_default_size() has not been called, returns -1.
gtk_window_move():
- always causes a configure request if the window is mapped,
unless the last configure request we sent was for the same
position being moved to
- position may be negative to move windows offscreen
- if GTK_WIN_POS_CENTER_ALWAYS (or other future position
constraints we may add) is in effect, the move
request is clamped to obey the constraints. thus
calling gtk_window_move() on a CENTER_ALWAYS window
may trigger the window to bounce back to center if it
wasn't there
- overrides all GTK_WIN_POS_ except CENTER_ALWAYS
gtk_window_get_size():
- obtains the client-side known size of widget->window,
as last received from a configure event
- prior to mapping, returns the default size we will request
- between realization and mapping, computes default size
rather than looking at widget->window up-to-date size,
so the size will be correct after force-realizing a window
gtk_window_get_position():
- obtains the point to be passed to gtk_window_move() in order
to keep the window in its current position
- round-trips to the server to get the position; this is suboptimal
from both a race condition and speed standpoint but required to get
window frame size
- if the window is unmapped, returns the default position we will
request
gtk_window_set_position():
- not the inverse of get_position(), sadly
- modifies the default positioning of the window
- if set to CENTER_ALWAYS and the window is mapped, results in a
configure request moving the window to the center, unless the
window was already centered
- ignored if gtk_window_move() called, with the exception
of CENTER_ALWAYS
gtk_window_parse_geometry():
- parses a standard X geometry string
- toggles on one or both of GDK_HINT_USER_SIZE, GDK_HINT_USER_POS
- "xprop" shows user size/position are set on the window
- calls gtk_window_set_default_size() to set the window size
- calls gtk_window_move() to set the window position
- calls gtk_window_set_gravity() to set the window gravity
gtk_window_reshow_with_initial_size():
- for use by GUI builders; unrealizes and re-shows the window,
using default size (and also position, but position
is reset on any hide anyway)
- window should be positioned and sized as it was on initial map,
barring odd window managers
gtk_window_set_geometry_hints():
- if a hint is set with this function, we do not override it
in other parts of the code
General behavior
===
- no infinite loops or nasty fighting-the-user flicker during
operations such as moving/resizing a window
Properties
===
GtkWindow::default_width, GtkWindow::default_height:
- default_width is -1 if unset, or >= 0 if
a default width is set
- default_height is -1 if unset, or >= 0 if
a default height is set
GtkWindow::allow_grow, GtkWindow::resizable:
- equivalent properties; changing one notifies on the other
- if FALSE, we set the min size to the max size in the geometry
hints.
- If the app programmer has called gtk_window_set_geometry_hints()
however and set min or max size, we don't replace the hint they
set.
GtkWidget::width_request, GtkWidget::height_request:
- if -1, default requisition of widget is used
- otherwise, override default requisition

View File

@ -82,7 +82,9 @@ typedef enum
GDK_HINT_BASE_SIZE = 1 << 3,
GDK_HINT_ASPECT = 1 << 4,
GDK_HINT_RESIZE_INC = 1 << 5,
GDK_HINT_WIN_GRAVITY = 1 << 6
GDK_HINT_WIN_GRAVITY = 1 << 6,
GDK_HINT_USER_POS = 1 << 7,
GDK_HINT_USER_SIZE = 1 << 8
} GdkWindowHints;

View File

@ -1309,7 +1309,9 @@ gdk_event_translate (GdkEvent *event,
(window_private->extension_events != 0))
_gdk_input_configure_event (&xevent->xconfigure, window);
if (!window || GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD)
if (!window ||
GDK_WINDOW_TYPE (window) == GDK_WINDOW_CHILD ||
GDK_WINDOW_TYPE (window) == GDK_WINDOW_ROOT)
return_val = FALSE;
else
{
@ -1318,8 +1320,7 @@ gdk_event_translate (GdkEvent *event,
event->configure.width = xevent->xconfigure.width;
event->configure.height = xevent->xconfigure.height;
if (!xevent->xconfigure.x &&
!xevent->xconfigure.y &&
if (!xevent->xconfigure.send_event &&
!GDK_WINDOW_DESTROYED (window))
{
gint tx = 0;

View File

@ -1387,6 +1387,16 @@ gdk_window_set_geometry_hints (GdkWindow *window,
size_hints.x = 0;
size_hints.y = 0;
}
if (geom_mask & GDK_HINT_USER_POS)
{
size_hints.flags |= USPosition;
}
if (geom_mask & GDK_HINT_USER_SIZE)
{
size_hints.flags |= USSize;
}
if (geom_mask & GDK_HINT_MIN_SIZE)
{

View File

@ -25,7 +25,13 @@
*/
#include "gtkfixed.h"
#include "gtkintl.h"
enum {
CHILD_PROP_0,
CHILD_PROP_X,
CHILD_PROP_Y
};
static void gtk_fixed_class_init (GtkFixedClass *klass);
static void gtk_fixed_init (GtkFixed *fixed);
@ -44,6 +50,16 @@ static void gtk_fixed_forall (GtkContainer *container,
gpointer callback_data);
static GtkType gtk_fixed_child_type (GtkContainer *container);
static void gtk_fixed_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_fixed_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static GtkContainerClass *parent_class = NULL;
@ -94,6 +110,29 @@ gtk_fixed_class_init (GtkFixedClass *class)
container_class->remove = gtk_fixed_remove;
container_class->forall = gtk_fixed_forall;
container_class->child_type = gtk_fixed_child_type;
container_class->set_child_property = gtk_fixed_set_child_property;
container_class->get_child_property = gtk_fixed_get_child_property;
gtk_container_class_install_child_property (container_class,
CHILD_PROP_X,
g_param_spec_int ("x",
_("X position"),
_("X position of child widget"),
G_MININT,
G_MAXINT,
0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_Y,
g_param_spec_int ("y",
_("Y position"),
_("Y position of child widget"),
G_MININT,
G_MAXINT,
0,
G_PARAM_READWRITE));
}
static GtkType
@ -119,11 +158,32 @@ gtk_fixed_new (void)
return GTK_WIDGET (fixed);
}
static GtkFixedChild*
get_child (GtkFixed *fixed,
GtkWidget *widget)
{
GList *children;
children = fixed->children;
while (children)
{
GtkFixedChild *child;
child = children->data;
children = children->next;
if (child->widget == widget)
return child;
}
return NULL;
}
void
gtk_fixed_put (GtkFixed *fixed,
GtkWidget *widget,
gint16 x,
gint16 y)
gint x,
gint y)
{
GtkFixedChild *child_info;
@ -137,20 +197,121 @@ gtk_fixed_put (GtkFixed *fixed,
gtk_widget_set_parent (widget, GTK_WIDGET (fixed));
fixed->children = g_list_append (fixed->children, child_info);
fixed->children = g_list_append (fixed->children, child_info);
}
static void
gtk_fixed_move_internal (GtkFixed *fixed,
GtkWidget *widget,
gboolean change_x,
gint x,
gboolean change_y,
gint y)
{
GtkFixedChild *child;
g_return_if_fail (GTK_IS_FIXED (fixed));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (widget->parent == GTK_WIDGET (fixed));
child = get_child (fixed, widget);
g_assert (child);
gtk_widget_freeze_child_notify (widget);
if (change_x)
{
child->x = x;
gtk_widget_child_notify (widget, "x");
}
if (change_y)
{
child->y = y;
gtk_widget_child_notify (widget, "y");
}
gtk_widget_thaw_child_notify (widget);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (fixed))
gtk_widget_queue_resize (GTK_WIDGET (fixed));
}
void
gtk_fixed_move (GtkFixed *fixed,
GtkWidget *widget,
gint16 x,
gint16 y)
gint x,
gint y)
{
g_return_if_fail (GTK_IS_FIXED (fixed));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (widget->parent == GTK_WIDGET (fixed));
gtk_fixed_move_internal (fixed, widget, TRUE, x, TRUE, y);
}
static void
gtk_fixed_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
case CHILD_PROP_X:
gtk_fixed_move_internal (GTK_FIXED (container),
child,
TRUE, g_value_get_int (value),
FALSE, 0);
break;
case CHILD_PROP_Y:
gtk_fixed_move_internal (GTK_FIXED (container),
child,
FALSE, 0,
TRUE, g_value_get_int (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_fixed_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkFixedChild *fixed_child;
fixed_child = get_child (GTK_FIXED (container), child);
switch (property_id)
{
case CHILD_PROP_X:
g_value_set_int (value, fixed_child->x);
break;
case CHILD_PROP_Y:
g_value_set_int (value, fixed_child->y);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_fixed_map (GtkWidget *widget)
{
GtkFixed *fixed;
GtkFixedChild *child;
GList *children;
g_return_if_fail (GTK_IS_FIXED (fixed));
g_return_if_fail (widget != NULL);
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
fixed = GTK_FIXED (widget);
children = fixed->children;
while (children)
@ -158,17 +319,12 @@ gtk_fixed_move (GtkFixed *fixed,
child = children->data;
children = children->next;
if (child->widget == widget)
{
child->x = x;
child->y = y;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (fixed))
gtk_widget_queue_resize (GTK_WIDGET (fixed));
break;
}
if (GTK_WIDGET_VISIBLE (child->widget) &&
!GTK_WIDGET_MAPPED (child->widget))
gtk_widget_map (child->widget);
}
gdk_window_show (widget->window);
}
static void

View File

@ -64,8 +64,8 @@ struct _GtkFixedClass
struct _GtkFixedChild
{
GtkWidget *widget;
gint16 x;
gint16 y;
gint x;
gint y;
};
@ -73,12 +73,12 @@ GtkType gtk_fixed_get_type (void) G_GNUC_CONST;
GtkWidget* gtk_fixed_new (void);
void gtk_fixed_put (GtkFixed *fixed,
GtkWidget *widget,
gint16 x,
gint16 y);
gint x,
gint y);
void gtk_fixed_move (GtkFixed *fixed,
GtkWidget *widget,
gint16 x,
gint16 y);
gint x,
gint y);
#ifdef __cplusplus
}

View File

@ -51,44 +51,56 @@ enum {
PROP_HEIGHT
};
static void gtk_layout_class_init (GtkLayoutClass *class);
static void gtk_layout_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_layout_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_layout_init (GtkLayout *layout);
enum {
CHILD_PROP_0,
CHILD_PROP_X,
CHILD_PROP_Y
};
static void gtk_layout_finalize (GObject *object);
static void gtk_layout_realize (GtkWidget *widget);
static void gtk_layout_unrealize (GtkWidget *widget);
static void gtk_layout_map (GtkWidget *widget);
static void gtk_layout_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_layout_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_layout_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_layout_class_init (GtkLayoutClass *class);
static void gtk_layout_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_layout_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_layout_init (GtkLayout *layout);
static void gtk_layout_finalize (GObject *object);
static void gtk_layout_realize (GtkWidget *widget);
static void gtk_layout_unrealize (GtkWidget *widget);
static void gtk_layout_map (GtkWidget *widget);
static void gtk_layout_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_layout_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static gint gtk_layout_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_layout_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_layout_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_layout_set_adjustments (GtkLayout *layout,
GtkAdjustment *hadj,
GtkAdjustment *vadj);
static void gtk_layout_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_layout_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_layout_allocate_child (GtkLayout *layout,
GtkLayoutChild *child);
static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
GtkLayout *layout);
static void gtk_layout_remove (GtkContainer *container,
GtkWidget *widget);
static void gtk_layout_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callback_data);
static void gtk_layout_set_adjustments (GtkLayout *layout,
GtkAdjustment *hadj,
GtkAdjustment *vadj);
static void gtk_layout_allocate_child (GtkLayout *layout,
GtkLayoutChild *child);
static void gtk_layout_adjustment_changed (GtkAdjustment *adjustment,
GtkLayout *layout);
static GtkWidgetClass *parent_class = NULL;
@ -213,6 +225,26 @@ gtk_layout_set_vadjustment (GtkLayout *layout,
g_object_notify (G_OBJECT (layout), "vadjustment");
}
static GtkLayoutChild*
get_child (GtkLayout *layout,
GtkWidget *widget)
{
GList *children;
children = layout->children;
while (children)
{
GtkLayoutChild *child;
child = children->data;
children = children->next;
if (child->widget == widget)
return child;
}
return NULL;
}
void
gtk_layout_put (GtkLayout *layout,
@ -235,38 +267,59 @@ gtk_layout_put (GtkLayout *layout,
if (GTK_WIDGET_REALIZED (layout))
gtk_widget_set_parent_window (child->widget, layout->bin_window);
gtk_widget_set_parent (child_widget, GTK_WIDGET (layout));
}
static void
gtk_layout_move_internal (GtkLayout *layout,
GtkWidget *widget,
gboolean change_x,
gint x,
gboolean change_y,
gint y)
{
GtkLayoutChild *child;
g_return_if_fail (GTK_IS_LAYOUT (layout));
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (widget->parent == GTK_WIDGET (layout));
child = get_child (layout, widget);
g_assert (child);
gtk_widget_freeze_child_notify (widget);
if (change_x)
{
child->x = x;
gtk_widget_child_notify (widget, "x");
}
if (change_y)
{
child->y = y;
gtk_widget_child_notify (widget, "y");
}
gtk_widget_thaw_child_notify (widget);
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (layout))
gtk_widget_queue_resize (GTK_WIDGET (layout));
}
void
gtk_layout_move (GtkLayout *layout,
GtkWidget *child_widget,
gint x,
gint y)
{
GList *tmp_list;
GtkLayoutChild *child;
g_return_if_fail (GTK_IS_LAYOUT (layout));
g_return_if_fail (GTK_IS_WIDGET (child_widget));
g_return_if_fail (child_widget->parent == GTK_WIDGET (layout));
tmp_list = layout->children;
while (tmp_list)
{
child = tmp_list->data;
tmp_list = tmp_list->next;
if (child->widget == child_widget)
{
child->x = x;
child->y = y;
if (GTK_WIDGET_VISIBLE (child_widget) && GTK_WIDGET_VISIBLE (layout))
gtk_widget_queue_resize (child_widget);
return;
}
}
gtk_layout_move_internal (layout, child_widget, TRUE, x, TRUE, y);
}
static void
@ -413,6 +466,29 @@ gtk_layout_class_init (GtkLayoutClass *class)
gobject_class->get_property = gtk_layout_get_property;
gobject_class->finalize = gtk_layout_finalize;
container_class->set_child_property = gtk_layout_set_child_property;
container_class->get_child_property = gtk_layout_get_child_property;
gtk_container_class_install_child_property (container_class,
CHILD_PROP_X,
g_param_spec_int ("x",
_("X position"),
_("X position of child widget"),
G_MININT,
G_MAXINT,
0,
G_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_Y,
g_param_spec_int ("y",
_("Y position"),
_("Y position of child widget"),
G_MININT,
G_MAXINT,
0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HADJUSTMENT,
g_param_spec_object ("hadjustment",
@ -528,6 +604,57 @@ gtk_layout_set_property (GObject *object,
}
}
static void
gtk_layout_set_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
case CHILD_PROP_X:
gtk_layout_move_internal (GTK_LAYOUT (container),
child,
TRUE, g_value_get_int (value),
FALSE, 0);
break;
case CHILD_PROP_Y:
gtk_layout_move_internal (GTK_LAYOUT (container),
child,
FALSE, 0,
TRUE, g_value_get_int (value));
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_layout_get_child_property (GtkContainer *container,
GtkWidget *child,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkLayoutChild *layout_child;
layout_child = get_child (GTK_LAYOUT (container), child);
switch (property_id)
{
case CHILD_PROP_X:
g_value_set_int (value, layout_child->x);
break;
case CHILD_PROP_Y:
g_value_set_int (value, layout_child->y);
break;
default:
GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
break;
}
}
static void
gtk_layout_init (GtkLayout *layout)

View File

@ -156,7 +156,6 @@ gtk_plug_init (GtkPlug *plug)
window = GTK_WINDOW (plug);
window->type = GTK_WINDOW_TOPLEVEL;
window->auto_shrink = TRUE;
}
static void

View File

@ -121,10 +121,8 @@ enum {
PROP_0,
PROP_NAME,
PROP_PARENT,
PROP_X,
PROP_Y,
PROP_WIDTH,
PROP_HEIGHT,
PROP_WIDTH_REQUEST,
PROP_HEIGHT_REQUEST,
PROP_VISIBLE,
PROP_SENSITIVE,
PROP_APP_PAINTABLE,
@ -213,7 +211,6 @@ static gint gtk_widget_event_internal (GtkWidget *widget,
static gboolean gtk_widget_real_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling);
static void gtk_widget_aux_info_destroy (GtkWidgetAuxInfo *aux_info);
static void gtk_widget_do_uposition (GtkWidget *widget);
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
@ -400,38 +397,21 @@ gtk_widget_class_init (GtkWidgetClass *klass)
_("The parent widget of this widget. Must be a Container widget."),
GTK_TYPE_CONTAINER,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_X,
g_param_spec_int ("x",
_("x coordinate"),
_("The x coordinate of the top-left corner of the widget, or -1 if not set"),
-G_MAXINT,
G_MAXINT,
-1,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_Y,
g_param_spec_int ("y",
_("y coordinate"),
_("The y coordinate of the top-left corner of the widget, or -1 if not set"),
-G_MAXINT,
G_MAXINT,
-1,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_WIDTH,
g_param_spec_int ("width",
_("Width"),
_("The width of the widget, or -1 if unset."),
PROP_WIDTH_REQUEST,
g_param_spec_int ("width_request",
_("Width request"),
_("Override for width request of the widget, or -1 if natural request should be used."),
-1,
G_MAXINT,
-1,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class,
PROP_HEIGHT,
g_param_spec_int ("height",
_("Height"),
_("The height of the widget, or -1 if unset."),
PROP_HEIGHT_REQUEST,
g_param_spec_int ("height_request",
_("Height request"),
_("Override for height request of the widget, or -1 if natural request should be used."),
-1,
G_MAXINT,
-1,
@ -1078,7 +1058,6 @@ gtk_widget_set_property (GObject *object,
GParamSpec *pspec)
{
GtkWidget *widget;
GtkWidgetAuxInfo *aux_info;
widget = GTK_WIDGET (object);
@ -1092,32 +1071,10 @@ gtk_widget_set_property (GObject *object,
case PROP_PARENT:
gtk_container_add (GTK_CONTAINER (g_value_get_object (value)), widget);
break;
case PROP_X:
aux_info = _gtk_widget_get_aux_info (widget, TRUE);
if (g_value_get_int (value) == -1)
aux_info->x_set = FALSE;
else
{
aux_info->x_set = TRUE;
aux_info->x = g_value_get_int (value);
}
gtk_widget_do_uposition (widget);
break;
case PROP_Y:
aux_info = _gtk_widget_get_aux_info (widget, TRUE);
if (g_value_get_int (value) == -1)
aux_info->y_set = FALSE;
else
{
aux_info->y_set = TRUE;
aux_info->y = g_value_get_int (value);
}
gtk_widget_do_uposition (widget);
break;
case PROP_WIDTH:
case PROP_WIDTH_REQUEST:
gtk_widget_set_usize (widget, g_value_get_int (value), -2);
break;
case PROP_HEIGHT:
case PROP_HEIGHT_REQUEST:
gtk_widget_set_usize (widget, -2, g_value_get_int (value));
break;
case PROP_VISIBLE:
@ -1191,7 +1148,6 @@ gtk_widget_get_property (GObject *object,
switch (prop_id)
{
GtkWidgetAuxInfo *aux_info;
gint *eventp;
GdkExtensionMode *modep;
@ -1207,33 +1163,19 @@ gtk_widget_get_property (GObject *object,
else
g_value_set_object (value, NULL);
break;
case PROP_X:
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info || !aux_info->x_set)
g_value_set_int (value, -1);
else
g_value_set_int (value, aux_info->x);
case PROP_WIDTH_REQUEST:
{
int w;
gtk_widget_get_size_request (widget, &w, NULL);
g_value_set_int (value, w);
}
break;
case PROP_Y:
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info || !aux_info->y_set)
g_value_set_int (value, -1);
else
g_value_set_int (value, aux_info->y);
break;
case PROP_WIDTH:
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info)
g_value_set_int (value, -1);
else
g_value_set_int (value, aux_info->width);
break;
case PROP_HEIGHT:
aux_info =_gtk_widget_get_aux_info (widget, FALSE);
if (!aux_info)
g_value_set_int (value, -1);
else
g_value_set_int (value, aux_info->height);
case PROP_HEIGHT_REQUEST:
{
int h;
gtk_widget_get_size_request (widget, NULL, &h);
g_value_set_int (value, h);
}
break;
case PROP_VISIBLE:
g_value_set_boolean (value, (GTK_WIDGET_VISIBLE (widget) != FALSE));
@ -2247,10 +2189,20 @@ gtk_widget_draw (GtkWidget *widget,
* @widget: a #GtkWidget
* @requisition: a #GtkRequisition to be filled in
*
* This function is only used when implementing a #GtkContainer subclass.
* Obtains the preferred size of a widget. The container uses this
* information to arrange its child widgets and decide what size allocations
* to give them with gtk_widget_size_allocate().
* This function is typically used when implementing a #GtkContainer
* subclass. Obtains the preferred size of a widget. The container
* uses this information to arrange its child widgets and decide what
* size allocations to give them with gtk_widget_size_allocate().
*
* You can also call this function from an application, with some
* caveats. Most notably, getting a size request requires the widget
* to be associated with a screen, because font information may be
* needed. Multihead-aware applications should keep this in mind.
*
* Also remember that the size request is not necessarily the size
* a widget will actually be allocated.
*
* See also gtk_widget_get_child_requisition().
**/
void
gtk_widget_size_request (GtkWidget *widget,
@ -2282,6 +2234,19 @@ gtk_widget_size_request (GtkWidget *widget,
* @widget->requisition, unless someone has forced a particular
* geometry on the widget (e.g. with gtk_widget_set_usize()), in which
* case it returns that geometry instead of the widget's requisition.
*
* This function differs from gtk_widget_size_request() in that
* it retrieves the last size request value from widget->requisition,
* while gtk_widget_size_request() actually calls the "size_request" method
* on @widget to compute the size request and fill in widget->requisition,
* and only then returns widget->requisition.
*
* Because this function does not call the "size_request" method, it
* can only be used when you know that widget->requisition is
* up-to-date, that is, gtk_widget_size_request() has been called
* since the last time a resize was queued. In general, only container
* implementations have this information; applications should use
* gtk_widget_size_request().
**/
void
gtk_widget_get_child_requisition (GtkWidget *widget,
@ -4306,28 +4271,6 @@ gtk_widget_child_focus (GtkWidget *widget,
return return_val;
}
/* Update the position from aux_info. Used from gtk_widget_set_uposition
* and gtk_widget_set_property().
*/
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);
g_object_freeze_notify (G_OBJECT (widget));
if (aux_info->x_set)
g_object_notify (G_OBJECT (widget), "x");
if (aux_info->y_set)
g_object_notify (G_OBJECT (widget), "y");
g_object_thaw_notify (G_OBJECT (widget));
}
/**
* gtk_widget_set_uposition:
* @widget: a #GtkWidget
@ -4356,6 +4299,11 @@ gtk_widget_set_uposition (GtkWidget *widget,
gint x,
gint y)
{
/* FIXME this function is the only place that aux_info->x and
* aux_info->y are even used I believe, and this function is
* deprecated. Should be cleaned up.
*/
GtkWidgetAuxInfo *aux_info;
g_return_if_fail (GTK_IS_WIDGET (widget));
@ -4384,7 +4332,11 @@ gtk_widget_set_uposition (GtkWidget *widget,
}
}
gtk_widget_do_uposition (widget);
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);
}
/**
@ -4393,6 +4345,9 @@ gtk_widget_set_uposition (GtkWidget *widget,
* @width: minimum width, or -1 to unset
* @height: minimum height, or -1 to unset
*
* This function is deprecated; use gtk_widget_set_size_request()
* instead.
*
* Sets the minimum size of a widget; that is, the widget's size
* request will be @width by @height. You can use this function to
* force a widget to be either larger or smaller than it is. The
@ -4427,12 +4382,12 @@ gtk_widget_set_usize (GtkWidget *widget,
if (width > -2)
{
g_object_notify (G_OBJECT (widget), "width");
g_object_notify (G_OBJECT (widget), "width_request");
aux_info->width = width;
}
if (height > -2)
{
g_object_notify (G_OBJECT (widget), "height");
g_object_notify (G_OBJECT (widget), "height_request");
aux_info->height = height;
}
@ -4443,21 +4398,79 @@ gtk_widget_set_usize (GtkWidget *widget,
}
/**
* gtk_widget_get_usize:
* gtk_widget_set_size_request:
* @widget: a #GtkWidget
* @width: location to store the width, or %NULL
* @height: location to store the height, or %NULL
* @width: width @widget should request, or -1 to unset
* @height: height @widget should request, or -1 to unset
*
* Gets the size that has explicitely set for the widget to request,
* if any. A value of -1 stored in @width or @height indicates that
* that dimension has not been set explicitely and the natural
* requisition of the widget will be used intead. See
* gtk_widget_set_usize().
* Sets the minimum size of a widget; that is, the widget's size
* request will be @width by @height. You can use this function to
* force a widget to be either larger or smaller than it normally
* would be.
*
* In most cases, gtk_window_set_default_size() is a better choice for
* toplevel windows than this function; setting the default size will
* still allow users to shrink the window. Setting the size request
* will force them to leave the window at least as large as the size
* request. When dealing with window sizes,
* gtk_window_set_geometry_hints() can be a useful function as well.
*
* Note the inherent danger of setting any fixed size - themes,
* translations into other languages, different fonts, and user action
* can all change the appropriate size for a given widget. So, it's
* basically impossible to hardcode a size that will always be
* correct.
*
* The size request of a widget is the smallest size a widget can
* accept while still functioning well and drawing itself correctly.
* However in some strange cases a widget may be allocated less than
* its requested size, and in many cases a widget may be allocated more
* space than it requested.
*
* If the size request in a given direction is -1 (unset), then
* the "natural" size request of the widget will be used instead.
*
* Widgets can't actually be allocated a size less than 1 by 1, but
* you can pass 0,0 to this function to mean "as small as possible."
**/
void
gtk_widget_get_usize (GtkWidget *widget,
gint *width,
gint *height)
gtk_widget_set_size_request (GtkWidget *widget,
gint width,
gint height)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (width >= -1);
g_return_if_fail (height >= -1);
if (width == 0)
width = 1;
if (height == 0)
height = 1;
gtk_widget_set_usize (widget, width, height);
}
/**
* gtk_widget_get_size_request:
* @widget: a #GtkWidget
* @width: return location for width, or %NULL
* @height: return location for height, or %NULL
*
* Gets the size request that was explicitly set for the widget using
* gtk_widget_set_size_request(). A value of -1 stored in @width or
* @height indicates that that dimension has not been set explicitly
* and the natural requisition of the widget will be used intead. See
* gtk_widget_set_size_request(). To get the size a widget will
* actually use, call gtk_widget_size_request() instead of
* this function.
*
**/
void
gtk_widget_get_size_request (GtkWidget *widget,
gint *width,
gint *height)
{
GtkWidgetAuxInfo *aux_info;

View File

@ -562,6 +562,14 @@ GtkWidget *gtk_widget_get_parent (GtkWidget *widget);
GdkWindow *gtk_widget_get_parent_window (GtkWidget *widget);
gboolean gtk_widget_child_focus (GtkWidget *widget,
GtkDirectionType direction);
void gtk_widget_set_size_request (GtkWidget *widget,
gint width,
gint height);
void gtk_widget_get_size_request (GtkWidget *widget,
gint *width,
gint *height);
#ifndef GTK_DISABLE_DEPRECATED
void gtk_widget_set_uposition (GtkWidget *widget,
gint x,
gint y);
@ -571,6 +579,8 @@ void gtk_widget_set_usize (GtkWidget *widget,
void gtk_widget_get_usize (GtkWidget *widget,
gint *width,
gint *height);
#endif
void gtk_widget_set_events (GtkWidget *widget,
gint events);
void gtk_widget_add_events (GtkWidget *widget,

File diff suppressed because it is too large Load Diff

View File

@ -69,24 +69,23 @@ struct _GtkWindow
GdkWindow *frame;
GtkWindowGroup *group;
guint16 resize_count;
guint16 configure_request_count;
guint allow_shrink : 1;
guint allow_grow : 1;
guint configure_notify_received : 1;
/* The following flags are initially TRUE (before a window is mapped).
* They cause us to compute a configure request that involves
* default-only parameters. Once mapped, we set them to FALSE.
* Then we set them to TRUE again on unmap (for position)
* and on unrealize (for size).
*/
guint need_default_position : 1;
guint need_default_size : 1;
guint position : 3;
GtkWindowType type : 4;
guint has_user_ref_count : 1;
guint has_focus : 1;
guint allow_shrink : 1;
guint allow_grow : 1;
guint auto_shrink : 1;
guint handling_resize : 1;
guint position : 2;
/* The following flag is initially TRUE when a window is mapped.
* and will be set to FALSE after it is first positioned.
* It is also temporarily reset when the window's size changes.
*
* When TRUE, we move the window to the position the app set.
*/
guint use_uposition : 1;
guint modal : 1;
guint destroy_with_parent : 1;
@ -252,16 +251,33 @@ void gtk_window_set_policy (GtkWindow *window,
gint allow_grow,
gint auto_shrink);
#endif
/* The following differs from gtk_widget_set_usize, in that
* gtk_widget_set_usize() overrides the requisition, so sets a minimum
* size, while this only sets the size requested from the WM.
/* Set initial default size of the window (does not constrain user
* resize operations)
*/
void gtk_window_set_default_size (GtkWindow *window,
gint width,
gint height);
void gtk_window_get_default_size (GtkWindow *window,
gint *width,
gint *height);
void gtk_window_set_default_size (GtkWindow *window,
gint width,
gint height);
void gtk_window_get_default_size (GtkWindow *window,
gint *width,
gint *height);
void gtk_window_resize (GtkWindow *window,
gint width,
gint height);
void gtk_window_get_size (GtkWindow *window,
gint *width,
gint *height);
void gtk_window_move (GtkWindow *window,
gint x,
gint y);
void gtk_window_get_position (GtkWindow *window,
gint *x,
gint *y);
gboolean gtk_window_parse_geometry (GtkWindow *window,
const gchar *geometry);
/* Ignore this unless you are writing a GUI builder */
void gtk_window_reshow_with_initial_size (GtkWindow *window);
/* Window groups
*/

View File

@ -8109,16 +8109,10 @@ configure_event_callback (GtkWidget *widget,
gchar *msg;
gint x, y;
#if 0
/* FIXME */
gtk_window_get_location (GTK_WINDOW (widget), &x, &y);
#else
x = 0;
y = 0;
#endif
gtk_window_get_position (GTK_WINDOW (widget), &x, &y);
msg = g_strdup_printf ("event: %d,%d %d x %d\n"
"location: %d, %d",
"position: %d, %d",
event->x, event->y, event->width, event->height,
x, y);
@ -8152,9 +8146,17 @@ set_size_callback (GtkWidget *widget,
get_ints (data, &w, &h);
gtk_window_set_default_size (GTK_WINDOW (g_object_get_data (data, "target")), w, h);
gtk_window_resize (GTK_WINDOW (g_object_get_data (data, "target")), w, h);
}
static void
unset_default_size_callback (GtkWidget *widget,
gpointer data)
{
gtk_window_set_default_size (g_object_get_data (data, "target"),
-1, -1);
}
static void
set_default_size_callback (GtkWidget *widget,
gpointer data)
@ -8167,6 +8169,14 @@ set_default_size_callback (GtkWidget *widget,
w, h);
}
static void
unset_usize_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_set_size_request (g_object_get_data (data, "target"),
-1, -1);
}
static void
set_usize_callback (GtkWidget *widget,
gpointer data)
@ -8175,8 +8185,8 @@ set_usize_callback (GtkWidget *widget,
get_ints (data, &w, &h);
gtk_widget_set_usize (g_object_get_data (data, "target"),
w, h);
gtk_widget_set_size_request (g_object_get_data (data, "target"),
w, h);
}
static void
@ -8187,7 +8197,21 @@ set_location_callback (GtkWidget *widget,
get_ints (data, &x, &y);
gtk_widget_set_uposition (g_object_get_data (data, "target"), x, y);
gtk_window_move (g_object_get_data (data, "target"), x, y);
}
static void
move_to_position_callback (GtkWidget *widget,
gpointer data)
{
gint x, y;
GtkWindow *window;
window = g_object_get_data (data, "target");
gtk_window_get_position (window, &x, &y);
gtk_window_move (window, x, y);
}
static void
@ -8201,12 +8225,9 @@ set_geometry_callback (GtkWidget *entry,
text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
#if 0
/* FIXME */
if (!gtk_window_parse_geometry (target, text))
g_print ("Bad geometry string '%s'\n", text);
#endif
g_free (text);
}
@ -8242,12 +8263,232 @@ auto_shrink_callback (GtkWidget *widget,
static void
gravity_selected (GtkWidget *widget,
gpointer data)
gpointer data)
{
gtk_window_set_gravity (GTK_WINDOW (g_object_get_data (data, "target")),
gtk_option_menu_get_history (GTK_OPTION_MENU (widget)) + GDK_GRAVITY_NORTH_WEST);
}
static void
pos_selected (GtkWidget *widget,
gpointer data)
{
gtk_window_set_position (GTK_WINDOW (g_object_get_data (data, "target")),
gtk_option_menu_get_history (GTK_OPTION_MENU (widget)) + GTK_WIN_POS_NONE);
}
static void
move_gravity_window_to_current_position (GtkWidget *widget,
gpointer data)
{
gint x, y;
GtkWindow *window;
window = GTK_WINDOW (data);
gtk_window_get_position (window, &x, &y);
gtk_window_move (window, x, y);
}
static void
get_screen_corner (GtkWindow *window,
gint *x,
gint *y)
{
int w, h;
gtk_window_get_size (GTK_WINDOW (window), &w, &h);
switch (gtk_window_get_gravity (window))
{
case GDK_GRAVITY_SOUTH_EAST:
*x = gdk_screen_width () - w;
*y = gdk_screen_height () - h;
break;
case GDK_GRAVITY_NORTH_EAST:
*x = gdk_screen_width () - w;
*y = 0;
break;
case GDK_GRAVITY_SOUTH_WEST:
*x = 0;
*y = gdk_screen_height () - h;
break;
case GDK_GRAVITY_NORTH_WEST:
*x = 0;
*y = 0;
break;
case GDK_GRAVITY_SOUTH:
*x = (gdk_screen_width () - w) / 2;
*y = gdk_screen_height () - h;
break;
case GDK_GRAVITY_NORTH:
*x = (gdk_screen_width () - w) / 2;
*y = 0;
break;
case GDK_GRAVITY_WEST:
*x = 0;
*y = (gdk_screen_height () - h) / 2;
break;
case GDK_GRAVITY_EAST:
*x = gdk_screen_width () - w;
*y = (gdk_screen_height () - h) / 2;
break;
case GDK_GRAVITY_CENTER:
*x = (gdk_screen_width () - w) / 2;
*y = (gdk_screen_height () - h) / 2;
break;
case GDK_GRAVITY_STATIC:
/* pick some random numbers */
*x = 350;
*y = 350;
break;
default:
g_assert_not_reached ();
break;
}
}
static void
move_gravity_window_to_starting_position (GtkWidget *widget,
gpointer data)
{
gint x, y;
GtkWindow *window;
window = GTK_WINDOW (data);
get_screen_corner (window,
&x, &y);
gtk_window_move (window, x, y);
}
static GtkWidget*
make_gravity_window (GtkWidget *destroy_with,
GdkGravity gravity,
const gchar *title)
{
GtkWidget *window;
GtkWidget *button;
GtkWidget *vbox;
int x, y;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
vbox = gtk_vbox_new (FALSE, 0);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_window_set_title (GTK_WINDOW (window), title);
gtk_window_set_gravity (GTK_WINDOW (window), gravity);
gtk_signal_connect_object (GTK_OBJECT (destroy_with),
"destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroy),
GTK_OBJECT (window));
button = gtk_button_new_with_mnemonic ("_Move to current position");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (move_gravity_window_to_current_position),
window);
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_widget_show (button);
button = gtk_button_new_with_mnemonic ("Move to _starting position");
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (move_gravity_window_to_starting_position),
window);
gtk_container_add (GTK_CONTAINER (vbox), button);
gtk_widget_show (button);
/* Pretend this is the result of --geometry.
* DO NOT COPY THIS CODE unless you are setting --geometry results,
* and in that case you probably should just use gtk_window_parse_geometry().
* AGAIN, DO NOT SET GDK_HINT_USER_POS! It violates the ICCCM unless
* you are parsing --geometry or equivalent.
*/
gtk_window_set_geometry_hints (GTK_WINDOW (window),
NULL, NULL,
GDK_HINT_USER_POS);
gtk_window_set_default_size (GTK_WINDOW (window),
200, 200);
get_screen_corner (GTK_WINDOW (window), &x, &y);
gtk_window_move (GTK_WINDOW (window),
x, y);
return window;
}
static void
do_gravity_test (GtkWidget *widget,
gpointer data)
{
GtkWidget *destroy_with = data;
GtkWidget *window;
/* We put a window at each gravity point on the screen. */
window = make_gravity_window (destroy_with, GDK_GRAVITY_NORTH_WEST,
"NorthWest");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_SOUTH_EAST,
"SouthEast");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_NORTH_EAST,
"NorthEast");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_SOUTH_WEST,
"SouthWest");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_SOUTH,
"South");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_NORTH,
"North");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_WEST,
"West");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_EAST,
"East");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_CENTER,
"Center");
gtk_widget_show (window);
window = make_gravity_window (destroy_with, GDK_GRAVITY_STATIC,
"Static");
gtk_widget_show (window);
}
static GtkWidget*
window_controls (GtkWidget *window)
{
@ -8287,7 +8528,7 @@ window_controls (GtkWidget *window)
GTK_SIGNAL_FUNC (configure_event_callback),
label);
adj = (GtkAdjustment *) gtk_adjustment_new (10.0, -3.0, 800.0, 1.0,
adj = (GtkAdjustment *) gtk_adjustment_new (10.0, -2000.0, 2000.0, 1.0,
5.0, 0.0);
spin = gtk_spin_button_new (adj, 0, 0);
@ -8295,7 +8536,7 @@ window_controls (GtkWidget *window)
g_object_set_data (G_OBJECT (control_window), "spin1", spin);
adj = (GtkAdjustment *) gtk_adjustment_new (10.0, -3.0, 800.0, 1.0,
adj = (GtkAdjustment *) gtk_adjustment_new (10.0, -2000.0, 2000.0, 1.0,
5.0, 0.0);
spin = gtk_spin_button_new (adj, 0, 0);
@ -8309,15 +8550,29 @@ window_controls (GtkWidget *window)
gtk_signal_connect (GTK_OBJECT (entry), "changed",
GTK_SIGNAL_FUNC (set_geometry_callback),
control_window);
button = gtk_button_new_with_label ("Show gravity test windows");
gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (do_gravity_test),
control_window);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Reshow with initial size");
gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_window_reshow_with_initial_size),
GTK_OBJECT (window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Queue resize");
gtk_signal_connect_object (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (gtk_widget_queue_resize),
GTK_OBJECT (control_window));
GTK_OBJECT (window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Set size");
button = gtk_button_new_with_label ("Resize");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (set_size_callback),
@ -8331,20 +8586,41 @@ window_controls (GtkWidget *window)
GTK_OBJECT (control_window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Set usize");
button = gtk_button_new_with_label ("Unset default size");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (unset_default_size_callback),
GTK_OBJECT (control_window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Set size request");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (set_usize_callback),
GTK_OBJECT (control_window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Set location");
button = gtk_button_new_with_label ("Unset size request");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (unset_usize_callback),
GTK_OBJECT (control_window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Move");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (set_location_callback),
GTK_OBJECT (control_window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Move to current position");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (move_to_position_callback),
GTK_OBJECT (control_window));
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_check_button_new_with_label ("Allow shrink");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), FALSE);
gtk_signal_connect (GTK_OBJECT (button),
@ -8424,6 +8700,44 @@ window_controls (GtkWidget *window)
control_window);
gtk_box_pack_end (GTK_BOX (vbox), om, FALSE, FALSE, 0);
menu = gtk_menu_new ();
i = 0;
while (i < 5)
{
GtkWidget *mi;
static gchar *names[] = {
"GTK_WIN_POS_NONE",
"GTK_WIN_POS_CENTER",
"GTK_WIN_POS_MOUSE",
"GTK_WIN_POS_CENTER_ALWAYS",
"GTK_WIN_POS_CENTER_ON_PARENT",
NULL
};
g_assert (names[i]);
mi = gtk_menu_item_new_with_label (names[i]);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
++i;
}
gtk_widget_show_all (menu);
om = gtk_option_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu);
gtk_signal_connect (GTK_OBJECT (om),
"changed",
GTK_SIGNAL_FUNC (pos_selected),
control_window);
gtk_box_pack_end (GTK_BOX (vbox), om, FALSE, FALSE, 0);
gtk_widget_show_all (vbox);
@ -8434,27 +8748,36 @@ void
create_window_sizing (void)
{
static GtkWidget *window = NULL;
static GtkWidget *target_window = NULL;
if (!window)
if (!target_window)
{
GtkWidget *label;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
target_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label), "<span foreground=\"purple\"><big>Window being resized</big></span>\nBlah blah blah blah\nblah blah blah\nblah blah blah blah blah");
gtk_container_add (GTK_CONTAINER (window), label);
gtk_container_add (GTK_CONTAINER (target_window), label);
gtk_widget_show (label);
gtk_signal_connect (GTK_OBJECT (target_window), "destroy",
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&target_window);
window = window_controls (target_window);
gtk_signal_connect (GTK_OBJECT (window), "destroy",
GTK_SIGNAL_FUNC(gtk_widget_destroyed),
GTK_SIGNAL_FUNC (gtk_widget_destroyed),
&window);
gtk_window_set_title (GTK_WINDOW (window), "Window to size");
gtk_widget_show (window_controls (window));
gtk_window_set_title (GTK_WINDOW (target_window), "Window to size");
}
/* don't show target window by default, we want to allow testing
* of behavior on first show.
*/
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show (window);
else