summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTim Janik <timj@gtk.org>1999-02-20 19:00:53 +0000
committerTim Janik <timj@src.gnome.org>1999-02-20 19:00:53 +0000
commite0e893da8f9024334d59ad1ed1713fd70be05c22 (patch)
treea486827581410ab6c0e6ba742b8ecafae26af40c /gtk
parentaf1efabafb56997362a2999fbb5d4960b442e90d (diff)
downloadgtk+-e0e893da8f9024334d59ad1ed1713fd70be05c22.tar.gz
added ::modal argument. (gtk_window_hide): reset window->modal from the
Sat Feb 20 19:44:36 1999 Tim Janik <timj@gtk.org> * gtk/gtkwindow.c: added ::modal argument. (gtk_window_hide): reset window->modal from the current grab state (this is only relevant when grab_add/grab_remove is called on the window by bypassing gtk_window_set_modal). (gtk_window_remove_embedded_xid): (gtk_window_add_embedded_xid): don't use g_print() but g_message() within #ifdef G_ENABLE_DEBUG. when the hack got these functions added (ChangeLog doesn't know them)?
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkwindow.c49
-rw-r--r--gtk/gtkwindow.h14
2 files changed, 42 insertions, 21 deletions
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 3ce41b5e97..0423f77a42 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -39,6 +39,7 @@ enum {
ARG_AUTO_SHRINK,
ARG_ALLOW_SHRINK,
ARG_ALLOW_GROW,
+ ARG_MODAL,
ARG_WIN_POS
};
@@ -160,6 +161,7 @@ gtk_window_class_init (GtkWindowClass *klass)
gtk_object_add_arg_type ("GtkWindow::auto_shrink", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_AUTO_SHRINK);
gtk_object_add_arg_type ("GtkWindow::allow_shrink", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_SHRINK);
gtk_object_add_arg_type ("GtkWindow::allow_grow", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_ALLOW_GROW);
+ gtk_object_add_arg_type ("GtkWindow::modal", GTK_TYPE_BOOL, GTK_ARG_READWRITE, ARG_MODAL);
gtk_object_add_arg_type ("GtkWindow::window_position", GTK_TYPE_WINDOW_POSITION, GTK_ARG_READWRITE, ARG_WIN_POS);
window_signals[SET_FOCUS] =
@@ -258,6 +260,9 @@ gtk_window_set_arg (GtkObject *object,
window->allow_grow = (GTK_VALUE_BOOL (*arg) != FALSE);
gtk_window_set_hints (GTK_WIDGET (window), &GTK_WIDGET (window)->requisition);
break;
+ case ARG_MODAL:
+ gtk_window_set_modal (window, GTK_VALUE_BOOL (*arg));
+ break;
case ARG_WIN_POS:
gtk_window_set_position (window, GTK_VALUE_ENUM (*arg));
break;
@@ -292,6 +297,9 @@ gtk_window_get_arg (GtkObject *object,
case ARG_ALLOW_GROW:
GTK_VALUE_BOOL (*arg) = window->allow_grow;
break;
+ case ARG_MODAL:
+ GTK_VALUE_BOOL (*arg) = window->modal;
+ break;
case ARG_WIN_POS:
GTK_VALUE_ENUM (*arg) = window->position;
break;
@@ -470,18 +478,21 @@ gtk_window_activate_default (GtkWindow *window)
}
void
-gtk_window_set_modal (GtkWindow *window, gboolean modal)
+gtk_window_set_modal (GtkWindow *window,
+ gboolean modal)
{
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
+ modal = modal != FALSE;
+
/* If the widget was showed already, adjust it's grab state */
- if (GTK_WIDGET_VISIBLE(GTK_WIDGET(window)))
+ if (GTK_WIDGET_VISIBLE (window) && window->modal != modal)
{
- if (window->modal && !modal)
- gtk_grab_remove (GTK_WIDGET(window));
- else if (!window->modal && modal)
- gtk_grab_add (GTK_WIDGET(window));
+ if (modal)
+ gtk_grab_add (GTK_WIDGET (window));
+ else
+ gtk_grab_remove (GTK_WIDGET (window));
}
window->modal = modal;
@@ -494,8 +505,10 @@ gtk_window_add_embedded_xid (GtkWindow *window, guint xid)
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
-
- g_print ("add %#x\n", xid);
+
+#ifdef G_ENABLE_DEBUG
+ g_message ("add embedded xid %#x\n", xid);
+#endif
embedded_windows = gtk_object_get_data (GTK_OBJECT (window), "gtk-embedded");
if (embedded_windows)
@@ -519,8 +532,10 @@ gtk_window_remove_embedded_xid (GtkWindow *window, guint xid)
g_return_if_fail (window != NULL);
g_return_if_fail (GTK_IS_WINDOW (window));
- g_print ("remove %#x\n", xid);
-
+#ifdef G_ENABLE_DEBUG
+ g_message ("remove embedded xid %#x\n", xid);
+#endif
+
embedded_windows = gtk_object_get_data (GTK_OBJECT (window), "gtk-embedded");
if (embedded_windows)
gtk_object_remove_no_notify_by_id (GTK_OBJECT (window),
@@ -755,23 +770,27 @@ gtk_window_show (GtkWidget *widget)
gtk_container_check_resize (GTK_CONTAINER (widget));
gtk_widget_map (widget);
- if (GTK_WINDOW(widget)->modal)
- gtk_grab_add(widget);
-
+ if (GTK_WINDOW (widget)->modal)
+ gtk_grab_add (widget);
}
static void
gtk_window_hide (GtkWidget *widget)
{
+ GtkWindow *window;
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WINDOW (widget));
+ window = GTK_WINDOW (widget);
+
GTK_WIDGET_UNSET_FLAGS (widget, GTK_VISIBLE);
gtk_widget_unmap (widget);
- if (GTK_WINDOW(widget)->modal)
- gtk_grab_remove(widget);
+ window->modal = GTK_WIDGET_HAS_GRAB (window);
+ if (window->modal)
+ gtk_grab_remove (widget);
}
static void
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index fd307fae34..0a360ecac6 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -114,16 +114,18 @@ void gtk_window_set_geometry_hints (GtkWindow *window,
* 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);
+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);
+ gboolean modal);
-void gtk_window_remove_embedded_xid (GtkWindow *window, guint xid);
-void gtk_window_add_embedded_xid (GtkWindow *window, guint xid);
+void gtk_window_remove_embedded_xid (GtkWindow *window,
+ guint xid);
+void gtk_window_add_embedded_xid (GtkWindow *window,
+ guint xid);
#ifdef __cplusplus
}