diff options
author | Owen Taylor <otaylor@gtk.org> | 1998-12-07 06:37:27 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1998-12-07 06:37:27 +0000 |
commit | 621beb8aaf93c8cfe234723d7001e114ac5a8345 (patch) | |
tree | 40c4267ff9db1dbbe02c70bb1dee962c2e8a20a8 | |
parent | fd7bdf03e002ecd5686ecab534b6254d83ea20ba (diff) | |
download | gtk+-621beb8aaf93c8cfe234723d7001e114ac5a8345.tar.gz |
New functions gtk_window_set_transient_for() - set up a "transient for"
Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org>
* gtk/gtkwindow.c: New functions
gtk_window_set_transient_for() - set up a "transient for" relationship.
gtk_window_set_default_size() - set the initial size of a window
distinct from its minimum size.
gtk_window_set_geometry_hints() - Allow the user to set
minimum, maximum sizes, aspect rations, and gridded geometry,
possibly all with respect to a subwidget of the window.
These interfaces are still a wee bit experimental.
* gdk/gdk.c: Added gdk_window_set_transient_for(),
gdk_window_set_geometry_hints(), and gdk_window_set_role().
* gdk/gdktypes.h: Added new types for find-grained specification
of WM hints.
* gtk/testgtk.c: Various changes to tests to test the
above new functions.
* gtk/gtkfontsel.c: Squash a few 'const' warnings.
* gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored
call to gtk_style_set_background() to prevent egregious
flashing to black.
-rw-r--r-- | ChangeLog | 28 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 28 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 28 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 28 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 28 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 28 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 28 | ||||
-rw-r--r-- | gdk/gdk.h | 14 | ||||
-rw-r--r-- | gdk/gdktypes.h | 24 | ||||
-rw-r--r-- | gdk/gdkwindow.c | 113 | ||||
-rw-r--r-- | gdk/x11/gdkwindow-x11.c | 113 | ||||
-rw-r--r-- | gtk/gtkfontsel.c | 5 | ||||
-rw-r--r-- | gtk/gtktogglebutton.c | 4 | ||||
-rw-r--r-- | gtk/gtkwindow.c | 389 | ||||
-rw-r--r-- | gtk/gtkwindow.h | 22 | ||||
-rw-r--r-- | gtk/testgtk.c | 36 | ||||
-rw-r--r-- | tests/testgtk.c | 36 |
17 files changed, 887 insertions, 65 deletions
@@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 81e3e72c5a..b8e20eb55a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 81e3e72c5a..b8e20eb55a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 81e3e72c5a..b8e20eb55a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 81e3e72c5a..b8e20eb55a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 81e3e72c5a..b8e20eb55a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 81e3e72c5a..b8e20eb55a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,29 @@ +Mon Dec 7 01:29:27 1998 Owen Taylor <otaylor@gtk.org> + + * gtk/gtkwindow.c: New functions + gtk_window_set_transient_for() - set up a "transient for" relationship. + gtk_window_set_default_size() - set the initial size of a window + distinct from its minimum size. + gtk_window_set_geometry_hints() - Allow the user to set + minimum, maximum sizes, aspect rations, and gridded geometry, + possibly all with respect to a subwidget of the window. + These interfaces are still a wee bit experimental. + + * gdk/gdk.c: Added gdk_window_set_transient_for(), + gdk_window_set_geometry_hints(), and gdk_window_set_role(). + + * gdk/gdktypes.h: Added new types for find-grained specification + of WM hints. + + * gtk/testgtk.c: Various changes to tests to test the + above new functions. + + * gtk/gtkfontsel.c: Squash a few 'const' warnings. + + * gtk/gtktogglebutton.c (gtk_toggle_button_realize): Restored + call to gtk_style_set_background() to prevent egregious + flashing to black. + Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> * gtk/gtksignal.c (gtk_handlers_run): when marshalling connect_object @@ -7,7 +33,7 @@ Mon Dec 7 03:52:01 1998 Tim Janik <timj@gtk.org> Mon Dec 7 03:08:39 1998 Tim Janik <timj@gtk.org> * gtk/gtktypeutils.h: - * gtk/gtktypeutils.c: reverted marius change to expose the type systems + * gtk/gtktypeutils.c: reverted Marius's change to expose the type systems internal type info data to the user. if such functionality is required we should provide wrapping accessors, ala gtk_signal_query(). also the GtkTypeInfo structures are dynamically allocated memory portions, so @@ -277,8 +277,18 @@ void gdk_window_set_hints (GdkWindow *window, gint max_width, gint max_height, gint flags); -void gdk_window_set_title (GdkWindow *window, - const gchar *title); +void gdk_window_set_geometry_hints (GdkWindow *window, + GdkGeometry *geometry, + GdkWindowHints flags); +void gdk_set_sm_client_id (const gchar *id); + + +void gdk_window_set_title (GdkWindow *window, + const gchar *title); +void gdk_window_set_role (GdkWindow *window, + const gchar *role); +void gdk_window_set_transient_for (GdkWindow *window, + GdkWindow *leader); void gdk_window_set_background (GdkWindow *window, GdkColor *color); void gdk_window_set_back_pixmap (GdkWindow *window, diff --git a/gdk/gdktypes.h b/gdk/gdktypes.h index 26527b45f8..bb38385b84 100644 --- a/gdk/gdktypes.h +++ b/gdk/gdktypes.h @@ -50,6 +50,7 @@ typedef struct _GdkWindow GdkWindow; typedef struct _GdkWindow GdkPixmap; typedef struct _GdkWindow GdkBitmap; typedef struct _GdkWindow GdkDrawable; +typedef struct _GdkGeometry GdkGeometry; typedef struct _GdkImage GdkImage; typedef struct _GdkGCValues GdkGCValues; typedef struct _GdkGC GdkGC; @@ -207,9 +208,12 @@ typedef enum */ typedef enum { - GDK_HINT_POS = 1 << 0, - GDK_HINT_MIN_SIZE = 1 << 1, - GDK_HINT_MAX_SIZE = 1 << 2 + GDK_HINT_POS = 1 << 0, + GDK_HINT_MIN_SIZE = 1 << 1, + GDK_HINT_MAX_SIZE = 1 << 2, + GDK_HINT_BASE_SIZE = 1 << 3, + GDK_HINT_ASPECT = 1 << 4, + GDK_HINT_RESIZE_INC = 1 << 5 } GdkWindowHints; /* GC function types. @@ -773,6 +777,20 @@ struct _GdkWindow gpointer user_data; }; +struct _GdkGeometry { + gint min_width; + gint min_height; + gint max_width; + gint max_height; + gint base_width; + gint base_height; + gint width_inc; + gint height_inc; + gdouble min_aspect; + gdouble max_aspect; + /* GdkGravity gravity; */ +}; + struct _GdkImage { GdkImageType type; diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index c8a42595ed..efbd713144 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -1012,6 +1012,82 @@ gdk_window_set_hints (GdkWindow *window, XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); } +void +gdk_window_set_geometry_hints (GdkWindow *window, + GdkGeometry *geometry, + GdkWindowHints geom_mask) +{ + GdkWindowPrivate *private; + XSizeHints size_hints; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + if (private->destroyed) + return; + + size_hints.flags = 0; + + if (geom_mask & GDK_HINT_POS) + size_hints.flags |= PPosition; + + if (geom_mask & GDK_HINT_MIN_SIZE) + { + size_hints.flags |= PMinSize; + size_hints.min_width = geometry->min_width; + size_hints.min_height = geometry->min_height; + } + + if (geom_mask & GDK_HINT_MAX_SIZE) + { + size_hints.flags |= PMaxSize; + size_hints.max_width = geometry->max_width; + size_hints.max_height = geometry->max_height; + } + + if (geom_mask & GDK_HINT_BASE_SIZE) + { + size_hints.flags |= PBaseSize; + size_hints.base_width = geometry->base_width; + size_hints.base_height = geometry->base_height; + } + + if (geom_mask & GDK_HINT_RESIZE_INC) + { + size_hints.flags |= PResizeInc; + size_hints.width_inc = geometry->width_inc; + size_hints.height_inc = geometry->height_inc; + } + + if (geom_mask & GDK_HINT_ASPECT) + { + size_hints.flags |= PAspect; + if (geometry->min_aspect <= 1) + { + size_hints.min_aspect.x = G_MAXINT * geometry->min_aspect; + size_hints.min_aspect.y = G_MAXINT; + } + else + { + size_hints.min_aspect.x = G_MAXINT; + size_hints.min_aspect.y = G_MAXINT / geometry->min_aspect;; + } + if (geometry->max_aspect <= 1) + { + size_hints.max_aspect.x = G_MAXINT * geometry->max_aspect; + size_hints.max_aspect.y = G_MAXINT; + } + else + { + size_hints.max_aspect.x = G_MAXINT; + size_hints.max_aspect.y = G_MAXINT / geometry->max_aspect;; + } + } + + if (geom_mask) + XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); +} + void gdk_window_set_title (GdkWindow *window, const gchar *title) @@ -1026,6 +1102,42 @@ gdk_window_set_title (GdkWindow *window, title, title, NULL, 0, NULL, NULL, NULL); } +void +gdk_window_set_role (GdkWindow *window, + const gchar *role) +{ + GdkWindowPrivate *private; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + + if (role) + XChangeProperty (private->xdisplay, private->xwindow, + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, + 8, PropModeReplace, role, strlen(role)); + else + XDeleteProperty (private->xdisplay, private->xwindow, + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); +} + +void +gdk_window_set_transient_for (GdkWindow *window, + GdkWindow *parent) +{ + GdkWindowPrivate *private; + GdkWindowPrivate *parent_private; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + parent_private = (GdkWindowPrivate*) parent; + + if (!private->destroyed && !parent_private->destroyed) + XSetTransientForHint (private->xdisplay, + private->xwindow, parent_private->xwindow); +} + void gdk_window_set_background (GdkWindow *window, GdkColor *color) @@ -2350,3 +2462,4 @@ gdk_drawable_set_data (GdkDrawable *drawable, { g_dataset_set_data_full (drawable, key, data, destroy_func); } + diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index c8a42595ed..efbd713144 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -1012,6 +1012,82 @@ gdk_window_set_hints (GdkWindow *window, XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); } +void +gdk_window_set_geometry_hints (GdkWindow *window, + GdkGeometry *geometry, + GdkWindowHints geom_mask) +{ + GdkWindowPrivate *private; + XSizeHints size_hints; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + if (private->destroyed) + return; + + size_hints.flags = 0; + + if (geom_mask & GDK_HINT_POS) + size_hints.flags |= PPosition; + + if (geom_mask & GDK_HINT_MIN_SIZE) + { + size_hints.flags |= PMinSize; + size_hints.min_width = geometry->min_width; + size_hints.min_height = geometry->min_height; + } + + if (geom_mask & GDK_HINT_MAX_SIZE) + { + size_hints.flags |= PMaxSize; + size_hints.max_width = geometry->max_width; + size_hints.max_height = geometry->max_height; + } + + if (geom_mask & GDK_HINT_BASE_SIZE) + { + size_hints.flags |= PBaseSize; + size_hints.base_width = geometry->base_width; + size_hints.base_height = geometry->base_height; + } + + if (geom_mask & GDK_HINT_RESIZE_INC) + { + size_hints.flags |= PResizeInc; + size_hints.width_inc = geometry->width_inc; + size_hints.height_inc = geometry->height_inc; + } + + if (geom_mask & GDK_HINT_ASPECT) + { + size_hints.flags |= PAspect; + if (geometry->min_aspect <= 1) + { + size_hints.min_aspect.x = G_MAXINT * geometry->min_aspect; + size_hints.min_aspect.y = G_MAXINT; + } + else + { + size_hints.min_aspect.x = G_MAXINT; + size_hints.min_aspect.y = G_MAXINT / geometry->min_aspect;; + } + if (geometry->max_aspect <= 1) + { + size_hints.max_aspect.x = G_MAXINT * geometry->max_aspect; + size_hints.max_aspect.y = G_MAXINT; + } + else + { + size_hints.max_aspect.x = G_MAXINT; + size_hints.max_aspect.y = G_MAXINT / geometry->max_aspect;; + } + } + + if (geom_mask) + XSetWMNormalHints (private->xdisplay, private->xwindow, &size_hints); +} + void gdk_window_set_title (GdkWindow *window, const gchar *title) @@ -1026,6 +1102,42 @@ gdk_window_set_title (GdkWindow *window, title, title, NULL, 0, NULL, NULL, NULL); } +void +gdk_window_set_role (GdkWindow *window, + const gchar *role) +{ + GdkWindowPrivate *private; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + + if (role) + XChangeProperty (private->xdisplay, private->xwindow, + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE), XA_STRING, + 8, PropModeReplace, role, strlen(role)); + else + XDeleteProperty (private->xdisplay, private->xwindow, + gdk_atom_intern ("WM_WINDOW_ROLE", FALSE)); +} + +void +gdk_window_set_transient_for (GdkWindow *window, + GdkWindow *parent) +{ + GdkWindowPrivate *private; + GdkWindowPrivate *parent_private; + + g_return_if_fail (window != NULL); + + private = (GdkWindowPrivate*) window; + parent_private = (GdkWindowPrivate*) parent; + + if (!private->destroyed && !parent_private->destroyed) + XSetTransientForHint (private->xdisplay, + private->xwindow, parent_private->xwindow); +} + void gdk_window_set_background (GdkWindow *window, GdkColor *color) @@ -2350,3 +2462,4 @@ gdk_drawable_set_data (GdkDrawable *drawable, { g_dataset_set_data_full (drawable, key, data, destroy_func); } + diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index 7c193d3538..92eab52ad2 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -441,7 +441,7 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gchar buffer[128]; gchar *size; gint size_to_match; - gchar *row_text[3]; + const gchar *row_text[3]; gchar *property, *text; gboolean inserted; @@ -1316,7 +1316,8 @@ gtk_font_selection_show_available_sizes (GtkFontSelection *fontsel) { FontInfo *font; FontStyle *styles, *style; - guint16 *standard_sizes, *bitmapped_sizes, bitmap_size; + const guint16 *standard_sizes; + guint16 *bitmapped_sizes, bitmap_size; gint nstandard_sizes, nbitmapped_sizes; gchar buffer[16], *size; gfloat bitmap_size_float; diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c index cccbc49e8d..8b6fd6a881 100644 --- a/gtk/gtktogglebutton.c +++ b/gtk/gtktogglebutton.c @@ -538,7 +538,11 @@ gtk_toggle_button_realize (GtkWidget *widget) gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (widget->window, toggle_button); } + widget->style = gtk_style_attach (widget->style, widget->window); + + if (!toggle_button->draw_indicator) + gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); } static void diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index c46f17c246..31039943ca 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -42,6 +42,16 @@ enum { ARG_WIN_POS }; +typedef struct { + GdkGeometry geometry; + GdkWindowHints mask; + GtkWidget *widget; + gint width; + gint height; + gint last_width; + gint last_height; +} GtkWindowGeometryInfo; + static void gtk_window_class_init (GtkWindowClass *klass); static void gtk_window_init (GtkWindow *window); static void gtk_window_set_arg (GtkObject *object, @@ -95,6 +105,15 @@ static gint gtk_window_expose (GtkWidget *widget, GdkEventExpose *event); static void gtk_window_style_set (GtkWidget *widget, GtkStyle *previous_style); +static void gtk_window_unset_transient_for (GtkWindow *window); +static void gtk_window_transient_parent_realized (GtkWidget *parent, + GtkWidget *window); +static void gtk_window_transient_parent_unrealized (GtkWidget *parent, + GtkWidget *window); + +static GtkWindowGeometryInfo* gtk_window_get_geometry_info (GtkWindow *window, + gboolean create); +static void gtk_window_geometry_destroy (GtkWindowGeometryInfo *info); static GtkBinClass *parent_class = NULL; static guint window_signals[LAST_SIGNAL] = { 0 }; @@ -539,13 +558,176 @@ gtk_window_shutdown (GtkObject *object) } static void +gtk_window_transient_parent_realized (GtkWidget *parent, + GtkWidget *window) +{ + if (GTK_WIDGET_REALIZED (window)) + gdk_window_set_transient_for (parent->window, window->window); +} + +static void +gtk_window_transient_parent_unrealized (GtkWidget *parent, + GtkWidget *window) +{ + if (GTK_WIDGET_REALIZED (window)) + gdk_property_delete (window->window, + gdk_atom_intern ("WM_TRANSIENT_FOR", FALSE)); +} + +static void +gtk_window_unset_transient_for (GtkWindow *window) +{ + if (window->transient_parent) + { + gtk_signal_disconnect_by_func (GTK_OBJECT (window->transient_parent), + GTK_SIGNAL_FUNC (gtk_window_transient_parent_realized), + window); + gtk_signal_disconnect_by_func (GTK_OBJECT (window->transient_parent), + GTK_SIGNAL_FUNC (gtk_window_transient_parent_unrealized), + window); + gtk_signal_disconnect_by_func (GTK_OBJECT (window->transient_parent), + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &window->transient_parent); + + window->transient_parent = NULL; + } +} + +void +gtk_window_set_transient_for (GtkWindow *window, + GtkWindow *parent) +{ + g_return_if_fail (window != 0); + + if (window->transient_parent) + { + gtk_window_unset_transient_for (window); + + if (GTK_WIDGET_REALIZED (window) && + GTK_WIDGET_REALIZED (window->transient_parent) && + (!parent || !GTK_WIDGET_REALIZED (parent))) + gtk_window_transient_parent_unrealized (GTK_WIDGET (window->transient_parent), + GTK_WIDGET (window)); + } + + window->transient_parent = parent; + + if (parent) + { + gtk_signal_connect (GTK_OBJECT (parent), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &window->transient_parent); + gtk_signal_connect (GTK_OBJECT (parent), "realize", + GTK_SIGNAL_FUNC (gtk_window_transient_parent_realized), + window); + gtk_signal_connect (GTK_OBJECT (parent), "unrealize", + GTK_SIGNAL_FUNC (gtk_window_transient_parent_unrealized), + window); + + if (GTK_WIDGET_REALIZED (window) && + GTK_WIDGET_REALIZED (parent)) + gtk_window_transient_parent_realized (GTK_WIDGET (parent), + GTK_WIDGET (window)); + } +} + +static void +gtk_window_geometry_destroy (GtkWindowGeometryInfo *info) +{ + if (info->widget) + gtk_signal_disconnect_by_func (GTK_OBJECT (info->widget), + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &info->widget); + g_free (info); +} + +static GtkWindowGeometryInfo * +gtk_window_get_geometry_info (GtkWindow *window, gboolean create) +{ + GtkWindowGeometryInfo *info; + + info = gtk_object_get_data (GTK_OBJECT (window), "gtk-window-geometry"); + + if (!info && create) + { + info = g_new (GtkWindowGeometryInfo, 1); + + info->width = - 1; + info->height = -1; + info->last_width = -1; + info->last_height = -1; + info->widget = NULL; + info->mask = 0; + + gtk_object_set_data_full (GTK_OBJECT (window), + + "gtk-window-geometry", + info, + (GtkDestroyNotify) gtk_window_geometry_destroy); + } + + return info; +} + +void +gtk_window_set_geometry_hints (GtkWindow *window, + GtkWidget *geometry_widget, + GdkGeometry *geometry, + GdkWindowHints geom_mask) +{ + GtkWindowGeometryInfo *info; + + g_return_if_fail (window != NULL); + + info = gtk_window_get_geometry_info (window, TRUE); + + if (info->widget) + gtk_signal_disconnect_by_func (GTK_OBJECT (info->widget), + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &info->widget); + + info->widget = geometry_widget; + if (info->widget) + gtk_signal_connect (GTK_OBJECT (geometry_widget), "destroy", + GTK_SIGNAL_FUNC (gtk_widget_destroyed), + &info->widget); + + if (geometry) + info->geometry = *geometry; + + info->mask = geom_mask; +} + +void +gtk_window_set_default_size (GtkWindow *window, + gint width, + gint height) +{ + GtkWindowGeometryInfo *info; + + g_return_if_fail (window != NULL); + + info = gtk_window_get_geometry_info (window, TRUE); + + info->width = width; + info->height = height; +} + +static void gtk_window_destroy (GtkObject *object) { + GtkWindow *window; + g_return_if_fail (object != NULL); g_return_if_fail (GTK_IS_WINDOW (object)); + window = GTK_WINDOW (object); + gtk_container_unregister_toplevel (GTK_CONTAINER (object)); + if (window->transient_parent) + gtk_window_unset_transient_for (window); + GTK_OBJECT_CLASS (parent_class)->destroy (object); } @@ -682,6 +864,11 @@ gtk_window_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); gtk_window_paint (widget, NULL); + + if (window->transient_parent && + GTK_WIDGET_REALIZED (window->transient_parent)) + gdk_window_set_transient_for (widget->window, + GTK_WIDGET (window->transient_parent)->window); } static void @@ -1093,9 +1280,12 @@ static void gtk_window_move_resize (GtkWindow *window) { GtkWidget *widget; + GtkWindowGeometryInfo *info; GtkContainer *container; gint x, y; gint width, height; + gint new_width, new_height; + gint min_width, min_height; gint screen_width; gint screen_height; gboolean needed_resize; @@ -1107,14 +1297,76 @@ gtk_window_move_resize (GtkWindow *window) widget = GTK_WIDGET (window); container = GTK_CONTAINER (widget); + info = gtk_window_get_geometry_info (window, FALSE); + /* Remember old size, to know if we have to reset hints */ - width = widget->requisition.width; - height = widget->requisition.height; + if (info && (info->last_width > 0)) + width = info->last_width; + else + width = widget->requisition.width; + + if (info && (info->last_height > 0)) + height = info->last_height; + else + height = widget->requisition.height; + gtk_widget_size_request (widget, &widget->requisition); - size_changed = ((width != widget->requisition.width) || - (height != widget->requisition.height)); - + /* Figure out the new desired size */ + + size_changed = FALSE; + + if (info && info->width > 0) + { + size_changed = size_changed || (width != info->width); + info->last_width = width; + new_width = info->width; + } + else + { + size_changed = size_changed || (width != widget->requisition.width); + new_width = widget->requisition.width; + } + + if (info && info->height > 0) + { + size_changed = size_changed || (height != info->height); + info->last_height = height; + new_height = info->height; + } + else + { + size_changed = size_changed || (height != widget->requisition.height); + new_height = widget->requisition.height; + } + + /* Figure out the new minimum size */ + + if (info && (info->mask & (GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE))) + { + if (info->mask && GDK_HINT_MIN_SIZE) + { + min_width = info->geometry.min_width; + min_height = info->geometry.min_height; + } + else + { + min_width = info->geometry.base_width; + min_height = info->geometry.base_height; + } + + if (info->widget) + { + min_width += widget->requisition.width - info->widget->requisition.width; + min_height += widget->requisition.height - info->widget->requisition.height; + } + } + else + { + min_width = widget->requisition.width; + min_height = widget->requisition.height; + } + if (size_changed) { gboolean saved_use_upos; @@ -1126,35 +1378,33 @@ gtk_window_move_resize (GtkWindow *window) x = -1; y = -1; - width = widget->requisition.width; - height = widget->requisition.height; if (window->use_uposition) switch (window->position) { case GTK_WIN_POS_CENTER: - x = (gdk_screen_width () - width) / 2; - y = (gdk_screen_height () - height) / 2; + x = (gdk_screen_width () - new_width) / 2; + y = (gdk_screen_height () - new_height) / 2; gtk_widget_set_uposition (widget, x, y); break; case GTK_WIN_POS_MOUSE: gdk_window_get_pointer (NULL, &x, &y, NULL); - x -= width / 2; - y -= height / 2; + x -= new_width / 2; + y -= new_height / 2; screen_width = gdk_screen_width (); screen_height = gdk_screen_height (); if (x < 0) x = 0; - else if (x > (screen_width - width)) - x = screen_width - width; + else if (x > (screen_width - new_width)) + x = screen_width - new_width; if (y < 0) y = 0; - else if (y > (screen_height - height)) - y = screen_height - height; + else if (y > (screen_height - new_height)) + y = screen_height - new_height; gtk_widget_set_uposition (widget, x, y); break; @@ -1165,11 +1415,10 @@ gtk_window_move_resize (GtkWindow *window) needed_resize = container->need_resize; container->need_resize = FALSE; - if ((widget->requisition.width == 0) || - (widget->requisition.height == 0)) + if ((new_width == 0) || (new_height == 0)) { - widget->requisition.width = 200; - widget->requisition.height = 200; + new_width = 200; + new_height = 200; } if (!GTK_WIDGET_REALIZED (window)) @@ -1178,8 +1427,8 @@ gtk_window_move_resize (GtkWindow *window) allocation.x = 0; allocation.y = 0; - allocation.width = widget->requisition.width; - allocation.height = widget->requisition.height; + allocation.width = new_width; + allocation.height = new_height; gtk_widget_size_allocate (widget, &allocation); @@ -1194,20 +1443,27 @@ gtk_window_move_resize (GtkWindow *window) if (size_changed && (((window->auto_shrink && - ((width != widget->requisition.width) || - (height != widget->requisition.height)))) || - ((width < widget->requisition.width) || - (height < widget->requisition.height)))) + ((width != new_width) || + (height != new_height)))) || + ((width < min_width) || + (height < min_height)))) { window->resize_count += 1; + + if (!window->auto_shrink) + { + new_width = MAX(width, min_width); + new_height = MAX(height, min_height); + } + if ((x != -1) && (y != -1)) gdk_window_move_resize (widget->window, x, y, - widget->requisition.width, - widget->requisition.height); + new_width, + new_height); else gdk_window_resize (widget->window, - widget->requisition.width, - widget->requisition.height); + new_width, + new_height); } else if (needed_resize) { @@ -1219,8 +1475,8 @@ gtk_window_move_resize (GtkWindow *window) allocation.x = 0; allocation.y = 0; - allocation.width = widget->requisition.width; - allocation.height = widget->requisition.height; + allocation.width = new_width; + allocation.height = new_height; gtk_widget_size_allocate (widget, &allocation); } @@ -1269,8 +1525,12 @@ gtk_window_set_hints (GtkWidget *widget, { GtkWindow *window; GtkWidgetAuxInfo *aux_info; + GtkWindowGeometryInfo *geometry_info; + GdkGeometry new_geometry; gint flags; gint ux, uy; + gint extra_width = 0; + gint extra_height = 0; g_return_if_fail (widget != NULL); g_return_if_fail (GTK_IS_WINDOW (widget)); @@ -1280,7 +1540,22 @@ gtk_window_set_hints (GtkWidget *widget, { window = GTK_WINDOW (widget); - flags = 0; + geometry_info = gtk_window_get_geometry_info (GTK_WINDOW (widget), FALSE); + + if (geometry_info) + { + flags = geometry_info->mask; + new_geometry = geometry_info->geometry; + + if (geometry_info->widget) + { + extra_width = requisition->width - geometry_info->widget->requisition.width; + extra_height = requisition->height - geometry_info->widget->requisition.height; + } + } + else + flags = 0; + ux = 0; uy = 0; @@ -1291,17 +1566,49 @@ gtk_window_set_hints (GtkWidget *widget, uy = aux_info->y; flags |= GDK_HINT_POS; } + + if (flags & GDK_HINT_BASE_SIZE) + { + new_geometry.base_width += extra_width; + new_geometry.base_height += extra_height; + } + else if (!(flags & GDK_HINT_MIN_SIZE) && + (flags & GDK_HINT_RESIZE_INC) && + ((extra_width != 0) || (extra_height != 0))) + { + flags |= GDK_HINT_BASE_SIZE; + + new_geometry.base_width = extra_width; + new_geometry.base_height = extra_height; + } + + if (flags & GDK_HINT_MIN_SIZE) + { + new_geometry.min_width += extra_width; + new_geometry.min_height += extra_height; + } + else if (!window->allow_shrink) + { + flags |= GDK_HINT_MIN_SIZE; - if (!window->allow_shrink) - flags |= GDK_HINT_MIN_SIZE; - if (!window->allow_grow) - flags |= GDK_HINT_MAX_SIZE; + new_geometry.min_width = requisition->width; + new_geometry.min_height = requisition->height; + } + + if (flags & GDK_HINT_MAX_SIZE) + { + new_geometry.max_width += extra_width; + new_geometry.max_height += extra_height; + } + else if (!window->allow_grow) + { + flags |= GDK_HINT_MAX_SIZE; + + new_geometry.max_width = requisition->width; + new_geometry.max_height = requisition->height; + } - gdk_window_set_hints (widget->window, - ux, uy, - requisition->width, requisition->height, - requisition->width, requisition->height, - flags); + gdk_window_set_geometry_hints (widget->window, &new_geometry, flags); if (window->use_uposition && (flags & GDK_HINT_POS)) { diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index 0b78adb8c7..fd307fae34 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -52,6 +52,7 @@ struct _GtkWindow GtkWidget *focus_widget; GtkWidget *default_widget; + GtkWindow *transient_parent; gushort resize_count; guint allow_shrink : 1; @@ -59,6 +60,13 @@ struct _GtkWindow 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; }; @@ -96,6 +104,20 @@ void gtk_window_set_position (GtkWindow *window, gint gtk_window_activate_focus (GtkWindow *window); gint gtk_window_activate_default (GtkWindow *window); +void gtk_window_set_transient_for (GtkWindow *window, + GtkWindow *parent); +void gtk_window_set_geometry_hints (GtkWindow *window, + GtkWidget *geometry_widget, + GdkGeometry *geometry, + GdkWindowHints geom_mask); +/* 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. + */ +void gtk_window_set_default_size (GtkWindow *window, + gint width, + gint height); + /* If window is set modal, input will be grabbed when show and released when hide */ void gtk_window_set_modal (GtkWindow *window, gboolean modal); diff --git a/gtk/testgtk.c b/gtk/testgtk.c index 08e7edc599..f2f22dcad1 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -2375,7 +2375,7 @@ cmw_destroy_cb(GtkWidget *widget) } static void -cmw_color (GtkWidget *widget) +cmw_color (GtkWidget *widget, GtkWidget *parent) { GtkWidget *csd; @@ -2383,6 +2383,9 @@ cmw_color (GtkWidget *widget) /* Set as modal */ gtk_window_set_modal (GTK_WINDOW(csd),TRUE); + + /* And mark it as a transient dialog */ + gtk_window_set_transient_for (GTK_WINDOW (csd), GTK_WINDOW (parent)); gtk_signal_connect (GTK_OBJECT(csd), "destroy", GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); @@ -2400,7 +2403,7 @@ cmw_color (GtkWidget *widget) } static void -cmw_file (GtkWidget *widget) +cmw_file (GtkWidget *widget, GtkWidget *parent) { GtkWidget *fs; @@ -2409,6 +2412,9 @@ cmw_file (GtkWidget *widget) /* Set as modal */ gtk_window_set_modal (GTK_WINDOW(fs),TRUE); + /* And mark it as a transient dialog */ + gtk_window_set_transient_for (GTK_WINDOW (fs), GTK_WINDOW (parent)); + gtk_signal_connect (GTK_OBJECT(fs), "destroy", GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); @@ -2471,9 +2477,9 @@ create_modal_window (void) GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL); gtk_signal_connect (GTK_OBJECT (btnColor), "clicked", - GTK_SIGNAL_FUNC (cmw_color),NULL); + GTK_SIGNAL_FUNC (cmw_color),window); gtk_signal_connect (GTK_OBJECT (btnFile), "clicked", - GTK_SIGNAL_FUNC (cmw_file),NULL); + GTK_SIGNAL_FUNC (cmw_file),window); /* Show widgets */ gtk_widget_show_all (window); @@ -2558,6 +2564,7 @@ create_scrolled_windows (void) gtk_widget_grab_default (button); gtk_widget_show (button); + gtk_window_set_default_size (GTK_WINDOW (window), 300, 300); } if (!GTK_WIDGET_VISIBLE (window)) @@ -7548,6 +7555,8 @@ create_scroll_test (void) GtkWidget *scrollbar; GtkWidget *button; GtkAdjustment *adj; + GdkGeometry geometry; + GdkWindowHints geometry_mask; if (!window) { @@ -7599,6 +7608,22 @@ create_scroll_test (void) GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); gtk_widget_show (button); + + /* Set up gridded geometry */ + + geometry_mask = GDK_HINT_MIN_SIZE | + GDK_HINT_BASE_SIZE | + GDK_HINT_RESIZE_INC; + + geometry.min_width = 20; + geometry.min_height = 20; + geometry.base_width = 0; + geometry.base_height = 0; + geometry.width_inc = 10; + geometry.height_inc = 10; + + gtk_window_set_geometry_hints (GTK_WINDOW (window), + drawing_area, &geometry, geometry_mask); } if (!GTK_WIDGET_VISIBLE (window)) @@ -8109,7 +8134,8 @@ void create_layout (void) { sprintf(buf, "Button %d, %d", i, j); if ((i + j) % 2) - button = gtk_button_new_with_label (buf); + // button = gtk_button_new_with_label (buf); + button = gtk_combo_new(); else button = gtk_label_new (buf); diff --git a/tests/testgtk.c b/tests/testgtk.c index 08e7edc599..f2f22dcad1 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -2375,7 +2375,7 @@ cmw_destroy_cb(GtkWidget *widget) } static void -cmw_color (GtkWidget *widget) +cmw_color (GtkWidget *widget, GtkWidget *parent) { GtkWidget *csd; @@ -2383,6 +2383,9 @@ cmw_color (GtkWidget *widget) /* Set as modal */ gtk_window_set_modal (GTK_WINDOW(csd),TRUE); + + /* And mark it as a transient dialog */ + gtk_window_set_transient_for (GTK_WINDOW (csd), GTK_WINDOW (parent)); gtk_signal_connect (GTK_OBJECT(csd), "destroy", GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); @@ -2400,7 +2403,7 @@ cmw_color (GtkWidget *widget) } static void -cmw_file (GtkWidget *widget) +cmw_file (GtkWidget *widget, GtkWidget *parent) { GtkWidget *fs; @@ -2409,6 +2412,9 @@ cmw_file (GtkWidget *widget) /* Set as modal */ gtk_window_set_modal (GTK_WINDOW(fs),TRUE); + /* And mark it as a transient dialog */ + gtk_window_set_transient_for (GTK_WINDOW (fs), GTK_WINDOW (parent)); + gtk_signal_connect (GTK_OBJECT(fs), "destroy", GTK_SIGNAL_FUNC(cmw_destroy_cb),NULL); @@ -2471,9 +2477,9 @@ create_modal_window (void) GTK_SIGNAL_FUNC (cmw_destroy_cb),NULL); gtk_signal_connect (GTK_OBJECT (btnColor), "clicked", - GTK_SIGNAL_FUNC (cmw_color),NULL); + GTK_SIGNAL_FUNC (cmw_color),window); gtk_signal_connect (GTK_OBJECT (btnFile), "clicked", - GTK_SIGNAL_FUNC (cmw_file),NULL); + GTK_SIGNAL_FUNC (cmw_file),window); /* Show widgets */ gtk_widget_show_all (window); @@ -2558,6 +2564,7 @@ create_scrolled_windows (void) gtk_widget_grab_default (button); gtk_widget_show (button); + gtk_window_set_default_size (GTK_WINDOW (window), 300, 300); } if (!GTK_WIDGET_VISIBLE (window)) @@ -7548,6 +7555,8 @@ create_scroll_test (void) GtkWidget *scrollbar; GtkWidget *button; GtkAdjustment *adj; + GdkGeometry geometry; + GdkWindowHints geometry_mask; if (!window) { @@ -7599,6 +7608,22 @@ create_scroll_test (void) GTK_SIGNAL_FUNC (gtk_widget_destroy), GTK_OBJECT (window)); gtk_widget_show (button); + + /* Set up gridded geometry */ + + geometry_mask = GDK_HINT_MIN_SIZE | + GDK_HINT_BASE_SIZE | + GDK_HINT_RESIZE_INC; + + geometry.min_width = 20; + geometry.min_height = 20; + geometry.base_width = 0; + geometry.base_height = 0; + geometry.width_inc = 10; + geometry.height_inc = 10; + + gtk_window_set_geometry_hints (GTK_WINDOW (window), + drawing_area, &geometry, geometry_mask); } if (!GTK_WIDGET_VISIBLE (window)) @@ -8109,7 +8134,8 @@ void create_layout (void) { sprintf(buf, "Button %d, %d", i, j); if ((i + j) % 2) - button = gtk_button_new_with_label (buf); + // button = gtk_button_new_with_label (buf); + button = gtk_combo_new(); else button = gtk_label_new (buf); |