From 097c3fe625f3a63c9a1a5cb071085fb1c8db4bc2 Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Tue, 28 Oct 2003 15:43:43 +0000 Subject: [PATCH] Add getters corresponding to the is_active and has_toplevel_focus Tue Oct 28 10:34:24 2003 Owen Taylor * gtk/gtkwindow.[ch] (gtk_window_is_active, gtk_has_toplevel_focus): Add getters corresponding to the is_active and has_toplevel_focus properties. (#122531) --- ChangeLog | 11 +++++ ChangeLog.pre-2-10 | 11 +++++ ChangeLog.pre-2-4 | 11 +++++ ChangeLog.pre-2-6 | 11 +++++ ChangeLog.pre-2-8 | 11 +++++ docs/reference/gtk/gtk-sections.txt | 2 + gtk/gtkwindow.c | 70 ++++++++++++++++++++++++++++- gtk/gtkwindow.h | 5 +++ 8 files changed, 130 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 120c6cc7bf..405ec78612 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Tue Oct 28 10:34:24 2003 Owen Taylor + + * gtk/gtkwindow.[ch] (gtk_window_is_active, + gtk_has_toplevel_focus): Add getters corresponding to + the is_active and has_toplevel_focus properties. + (#122531) + +Tue Oct 28 10:18:55 2003 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_is_active): + 2003-10-28 Mark McLoughlin * gtk/gtkexpander.c: diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 120c6cc7bf..405ec78612 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,14 @@ +Tue Oct 28 10:34:24 2003 Owen Taylor + + * gtk/gtkwindow.[ch] (gtk_window_is_active, + gtk_has_toplevel_focus): Add getters corresponding to + the is_active and has_toplevel_focus properties. + (#122531) + +Tue Oct 28 10:18:55 2003 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_is_active): + 2003-10-28 Mark McLoughlin * gtk/gtkexpander.c: diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 120c6cc7bf..405ec78612 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,14 @@ +Tue Oct 28 10:34:24 2003 Owen Taylor + + * gtk/gtkwindow.[ch] (gtk_window_is_active, + gtk_has_toplevel_focus): Add getters corresponding to + the is_active and has_toplevel_focus properties. + (#122531) + +Tue Oct 28 10:18:55 2003 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_is_active): + 2003-10-28 Mark McLoughlin * gtk/gtkexpander.c: diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 120c6cc7bf..405ec78612 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,14 @@ +Tue Oct 28 10:34:24 2003 Owen Taylor + + * gtk/gtkwindow.[ch] (gtk_window_is_active, + gtk_has_toplevel_focus): Add getters corresponding to + the is_active and has_toplevel_focus properties. + (#122531) + +Tue Oct 28 10:18:55 2003 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_is_active): + 2003-10-28 Mark McLoughlin * gtk/gtkexpander.c: diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 120c6cc7bf..405ec78612 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,14 @@ +Tue Oct 28 10:34:24 2003 Owen Taylor + + * gtk/gtkwindow.[ch] (gtk_window_is_active, + gtk_has_toplevel_focus): Add getters corresponding to + the is_active and has_toplevel_focus properties. + (#122531) + +Tue Oct 28 10:18:55 2003 Owen Taylor + + * gtk/gtkwindow.c (gtk_window_is_active): + 2003-10-28 Mark McLoughlin * gtk/gtkexpander.c: diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 96b7d83e88..cf64afaf35 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -4335,6 +4335,8 @@ gtk_window_set_transient_for gtk_window_set_destroy_with_parent gtk_window_set_screen gtk_window_get_screen +gtk_window_is_active +gtk_window_has_toplevel_focus gtk_window_list_toplevels gtk_window_add_mnemonic gtk_window_remove_mnemonic diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 36f3bbd808..35f409f513 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -6340,11 +6340,77 @@ gtk_window_check_screen (GtkWindow *window) GdkScreen* gtk_window_get_screen (GtkWindow *window) { - g_return_val_if_fail (GTK_IS_WINDOW (window), NULL); + g_return_val_if_fail (GTK_IS_WINDOW (window), NULL); - return window->screen; + return window->screen; } +/** + * gtk_window_is_active: + * @window: a #GtkWindow + * + * Returns whether the window is part of the current active toplevel. + * (That is, the toplevel window receiving keystrokes.) + * The return value is %TRUE if the window is active toplevel + * itself, but also if it is, say, a #GtkPlug embedded in the active toplevel. + * You might use this function if you wanted to draw a widget + * differently in an active window from a widget in an inactive window. + * See gtk_window_has_toplevel_focus() + * + * Return value: %TRUE if the window part of the current active window. + * + * Since: 2.4 + **/ +gboolean +gtk_window_is_active (GtkWindow *window) +{ + g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); + + return window->is_active; +} + +/** + * gtk_window_has_toplevel_focus: + * @window: a #GtkWindow + * + * Returns whether the input focus is within this GtkWindow. + * For real toplevel windows, this is identical to gtk_window_is_active(), + * but for embedded windows, like #GtkPlug, the results will differ. + * + * Return value: %TRUE if the the input focus is within this GtkWindow + * + * Since: 2.4 + **/ +gboolean +gtk_window_has_toplevel_focus (GtkWindow *window) +{ + g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); + + return window->has_toplevel_focus; +} + +/** + * gtk_window_get_is_active: + * @window: a #GtkWindow + * + * Returns whether the window is part of the current active toplevel. + * The return value is %TRUE if the window is active toplevel + * itself, but also if it is a GtkPlug embedded in the active toplevel. + * You might use this function if you wanted to draw a widget + * differently in an active window from a widget in an inactive window. + * + * Return value: %TRUE if the window is the current active window. + * + * Since: 2.4 + **/ +static gboolean +gtk_window +_is_active (GtkWIndow *window) +{ + g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); + + return window->is_active; +} static void gtk_window_group_class_init (GtkWindowGroupClass *klass) diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h index c0d984cf2f..544aef2e5f 100644 --- a/gtk/gtkwindow.h +++ b/gtk/gtkwindow.h @@ -225,6 +225,11 @@ void gtk_window_set_screen (GtkWindow *window, GdkScreen *screen); GdkScreen* gtk_window_get_screen (GtkWindow *window); +gboolean gtk_window_is_active (GtkWindow *window); +gboolean gtk_window_has_toplevel_focus (GtkWindow *window); + + + /* gtk_window_set_has_frame () must be called before realizing the window_*/ void gtk_window_set_has_frame (GtkWindow *window, gboolean setting);