Commit 7b665316 authored by Matthias Clasen's avatar Matthias Clasen

Hide GtkWindowGroup members

In the process of removing all sealed members from headers.
At the same time, add a gtkwindowprivate.h header and move
all internal functions from gtkwindow.h there.
parent a2dda0c2
...@@ -433,6 +433,7 @@ gtk_private_h_sources = \ ...@@ -433,6 +433,7 @@ gtk_private_h_sources = \
gtktreedatalist.h \ gtktreedatalist.h \
gtktreeprivate.h \ gtktreeprivate.h \
gtkwidgetprivate.h \ gtkwidgetprivate.h \
gtkwindowprivate.h \
$(gtk_clipboard_dnd_h_sources) \ $(gtk_clipboard_dnd_h_sources) \
$(gtk_appchooser_impl_h_sources) $(gtk_appchooser_impl_h_sources)
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include "gtkaccelmap.h" #include "gtkaccelmap.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
#include "gtkwindow.h" /* in lack of GtkAcceleratable */ #include "gtkwindowprivate.h"
#include "gtkintl.h" #include "gtkintl.h"
#include <glib/gstdio.h> #include <glib/gstdio.h>
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#include "gtkselection.h" #include "gtkselection.h"
#include "gtksettings.h" #include "gtksettings.h"
#include "gtkwidgetprivate.h" #include "gtkwidgetprivate.h"
#include "gtkwindow.h" #include "gtkwindowprivate.h"
#include "gtktooltip.h" #include "gtktooltip.h"
#include "gtkdebug.h" #include "gtkdebug.h"
#include "gtkmenu.h" #include "gtkmenu.h"
...@@ -1585,8 +1585,8 @@ gtk_main_do_event (GdkEvent *event) ...@@ -1585,8 +1585,8 @@ gtk_main_do_event (GdkEvent *event)
if (device) if (device)
grab_widget = gtk_window_group_get_current_device_grab (window_group, device); grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
if (!grab_widget && window_group->grabs) if (!grab_widget)
grab_widget = window_group->grabs->data; grab_widget = gtk_window_group_get_current_grab (window_group);
/* If the grab widget is an ancestor of the event widget /* If the grab widget is an ancestor of the event widget
* then we send the event to the original event widget. * then we send the event to the original event widget.
...@@ -1629,7 +1629,7 @@ gtk_main_do_event (GdkEvent *event) ...@@ -1629,7 +1629,7 @@ gtk_main_do_event (GdkEvent *event)
case GDK_DELETE: case GDK_DELETE:
g_object_ref (event_widget); g_object_ref (event_widget);
if ((!window_group->grabs || gtk_widget_get_toplevel (window_group->grabs->data) == event_widget) && if ((!gtk_window_group_get_current_grab (window_group) || gtk_widget_get_toplevel (gtk_window_group_get_current_grab (window_group)) == event_widget) &&
!gtk_widget_event (event_widget, event)) !gtk_widget_event (event_widget, event))
gtk_widget_destroy (event_widget); gtk_widget_destroy (event_widget);
g_object_unref (event_widget); g_object_unref (event_widget);
...@@ -1991,13 +1991,10 @@ gtk_grab_add (GtkWidget *widget) ...@@ -1991,13 +1991,10 @@ gtk_grab_add (GtkWidget *widget)
group = gtk_main_get_window_group (widget); group = gtk_main_get_window_group (widget);
if (group->grabs) old_grab_widget = gtk_window_group_get_current_grab (group);
old_grab_widget = (GtkWidget *)group->grabs->data;
else
old_grab_widget = NULL;
g_object_ref (widget); g_object_ref (widget);
group->grabs = g_slist_prepend (group->grabs, widget); _gtk_window_group_add_grab (group, widget);
gtk_grab_notify (group, NULL, old_grab_widget, widget, TRUE); gtk_grab_notify (group, NULL, old_grab_widget, widget, TRUE);
} }
...@@ -2018,9 +2015,7 @@ gtk_grab_get_current (void) ...@@ -2018,9 +2015,7 @@ gtk_grab_get_current (void)
group = gtk_main_get_window_group (NULL); group = gtk_main_get_window_group (NULL);
if (group->grabs) return gtk_window_group_get_current_grab (group);
return GTK_WIDGET (group->grabs->data);
return NULL;
} }
void void
...@@ -2036,12 +2031,8 @@ gtk_grab_remove (GtkWidget *widget) ...@@ -2036,12 +2031,8 @@ gtk_grab_remove (GtkWidget *widget)
_gtk_widget_set_has_grab (widget, FALSE); _gtk_widget_set_has_grab (widget, FALSE);
group = gtk_main_get_window_group (widget); group = gtk_main_get_window_group (widget);
group->grabs = g_slist_remove (group->grabs, widget); _gtk_window_group_remove_grab (group, widget);
new_grab_widget = gtk_window_group_get_current_grab (group);
if (group->grabs)
new_grab_widget = (GtkWidget *)group->grabs->data;
else
new_grab_widget = NULL;
gtk_grab_notify (group, NULL, widget, new_grab_widget, FALSE); gtk_grab_notify (group, NULL, widget, new_grab_widget, FALSE);
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "gtkplug.h" #include "gtkplug.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkplugprivate.h" #include "gtkplugprivate.h"
#include "gtkwindowprivate.h"
#include "gtkdebug.h" #include "gtkdebug.h"
#include "x11/gdkx.h" #include "x11/gdkx.h"
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkplugprivate.h" #include "gtkplugprivate.h"
#include "gtkwidgetprivate.h" #include "gtkwidgetprivate.h"
#include "gtkwindow.h" #include "gtkwindowprivate.h"
/** /**
* SECTION:gtkplug * SECTION:gtkplug
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "gtkmain.h" #include "gtkmain.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
#include "gtkwindow.h" #include "gtkwindowprivate.h"
#include "gtkplug.h" #include "gtkplug.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtksocket.h" #include "gtksocket.h"
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#include "gtkmain.h" #include "gtkmain.h"
#include "gtkmarshalers.h" #include "gtkmarshalers.h"
#include "gtksizerequest.h" #include "gtksizerequest.h"
#include "gtkwindow.h" #include "gtkwindowprivate.h"
#include "gtkplug.h" #include "gtkplug.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtksocketprivate.h" #include "gtksocketprivate.h"
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "gtksizegroup-private.h" #include "gtksizegroup-private.h"
#include "gtkwidget.h" #include "gtkwidget.h"
#include "gtkwidgetprivate.h" #include "gtkwidgetprivate.h"
#include "gtkwindow.h" #include "gtkwindowprivate.h"
#include "gtkbindings.h" #include "gtkbindings.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gdk/gdk.h" #include "gdk/gdk.h"
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
*/ */
#include "config.h" #include "config.h"
#include "gtkintl.h"
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
...@@ -32,11 +35,10 @@ ...@@ -32,11 +35,10 @@
#include "gdk/gdk.h" #include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h" #include "gdk/gdkkeysyms.h"
#include "gtkintl.h"
#include "gtkprivate.h" #include "gtkprivate.h"
#include "gtkrc.h" #include "gtkrc.h"
#include "gtkwindow.h" #include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtkbindings.h" #include "gtkbindings.h"
#include "gtkkeyhash.h" #include "gtkkeyhash.h"
#include "gtkmain.h" #include "gtkmain.h"
...@@ -95,7 +97,6 @@ ...@@ -95,7 +97,6 @@
*/ */
typedef struct _GtkDeviceGrabInfo GtkDeviceGrabInfo; typedef struct _GtkDeviceGrabInfo GtkDeviceGrabInfo;
typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate;
struct _GtkWindowPrivate struct _GtkWindowPrivate
{ {
...@@ -297,7 +298,6 @@ struct _GtkWindowGeometryInfo ...@@ -297,7 +298,6 @@ struct _GtkWindowGeometryInfo
GtkWindowLastGeometryInfo last; GtkWindowLastGeometryInfo last;
}; };
#define GTK_WINDOW_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_WINDOW_GROUP, GtkWindowGroupPrivate))
struct _GtkDeviceGrabInfo struct _GtkDeviceGrabInfo
{ {
...@@ -308,6 +308,7 @@ struct _GtkDeviceGrabInfo ...@@ -308,6 +308,7 @@ struct _GtkDeviceGrabInfo
struct _GtkWindowGroupPrivate struct _GtkWindowGroupPrivate
{ {
GSList *grabs;
GSList *device_grabs; GSList *device_grabs;
}; };
...@@ -8461,37 +8462,20 @@ gtk_window_has_toplevel_focus (GtkWindow *window) ...@@ -8461,37 +8462,20 @@ gtk_window_has_toplevel_focus (GtkWindow *window)
return window->priv->has_toplevel_focus; return window->priv->has_toplevel_focus;
} }
G_DEFINE_TYPE (GtkWindowGroup, gtk_window_group, G_TYPE_OBJECT)
static void static void
gtk_window_group_class_init (GtkWindowGroupClass *klass) gtk_window_group_init (GtkWindowGroup *group)
{ {
g_type_class_add_private (klass, sizeof (GtkWindowGroupPrivate)); group->priv = G_TYPE_INSTANCE_GET_PRIVATE (group,
GTK_TYPE_WINDOW_GROUP,
GtkWindowGroupPrivate);
} }
GType static void
gtk_window_group_get_type (void) gtk_window_group_class_init (GtkWindowGroupClass *klass)
{ {
static GType window_group_type = 0; g_type_class_add_private (klass, sizeof (GtkWindowGroupPrivate));
if (!window_group_type)
{
const GTypeInfo window_group_info =
{
sizeof (GtkWindowGroupClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_window_group_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkWindowGroup),
0, /* n_preallocs */
(GInstanceInitFunc) NULL,
};
window_group_type = g_type_register_static (G_TYPE_OBJECT, I_("GtkWindowGroup"),
&window_group_info, 0);
}
return window_group_type;
} }
/** /**
...@@ -8517,7 +8501,9 @@ window_group_cleanup_grabs (GtkWindowGroup *group, ...@@ -8517,7 +8501,9 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
GSList *tmp_list; GSList *tmp_list;
GSList *to_remove = NULL; GSList *to_remove = NULL;
tmp_list = group->grabs; priv = group->priv;
tmp_list = priv->grabs;
while (tmp_list) while (tmp_list)
{ {
if (gtk_widget_get_toplevel (tmp_list->data) == (GtkWidget*) window) if (gtk_widget_get_toplevel (tmp_list->data) == (GtkWidget*) window)
...@@ -8532,7 +8518,6 @@ window_group_cleanup_grabs (GtkWindowGroup *group, ...@@ -8532,7 +8518,6 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
to_remove = g_slist_delete_link (to_remove, to_remove); to_remove = g_slist_delete_link (to_remove, to_remove);
} }
priv = GTK_WINDOW_GROUP_GET_PRIVATE (group);
tmp_list = priv->device_grabs; tmp_list = priv->device_grabs;
while (tmp_list) while (tmp_list)
...@@ -8709,11 +8694,32 @@ gtk_window_group_get_current_grab (GtkWindowGroup *window_group) ...@@ -8709,11 +8694,32 @@ gtk_window_group_get_current_grab (GtkWindowGroup *window_group)
{ {
g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL); g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL);
if (window_group->grabs) if (window_group->priv->grabs)
return GTK_WIDGET (window_group->grabs->data); return GTK_WIDGET (window_group->priv->grabs->data);
return NULL; return NULL;
} }
void
_gtk_window_group_add_grab (GtkWindowGroup *window_group,
GtkWidget *widget)
{
GtkWindowGroupPrivate *priv;
priv = window_group->priv;
priv->grabs = g_slist_prepend (priv->grabs, widget);
}
void
_gtk_window_group_remove_grab (GtkWindowGroup *window_group,
GtkWidget *widget)
{
GtkWindowGroupPrivate *priv;
priv = window_group->priv;
priv->grabs = g_slist_remove (priv->grabs, widget);
}
void void
_gtk_window_group_add_device_grab (GtkWindowGroup *window_group, _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget, GtkWidget *widget,
...@@ -8723,7 +8729,7 @@ _gtk_window_group_add_device_grab (GtkWindowGroup *window_group, ...@@ -8723,7 +8729,7 @@ _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWindowGroupPrivate *priv; GtkWindowGroupPrivate *priv;
GtkDeviceGrabInfo *info; GtkDeviceGrabInfo *info;
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group); priv = window_group->priv;
info = g_slice_new0 (GtkDeviceGrabInfo); info = g_slice_new0 (GtkDeviceGrabInfo);
info->widget = widget; info->widget = widget;
...@@ -8743,7 +8749,7 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group, ...@@ -8743,7 +8749,7 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
GSList *list, *node = NULL; GSList *list, *node = NULL;
GdkDevice *other_device; GdkDevice *other_device;
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group); priv = window_group->priv;
other_device = gdk_device_get_associated_device (device); other_device = gdk_device_get_associated_device (device);
list = priv->device_grabs; list = priv->device_grabs;
...@@ -8794,7 +8800,7 @@ gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group, ...@@ -8794,7 +8800,7 @@ gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL); g_return_val_if_fail (GTK_IS_WINDOW_GROUP (window_group), NULL);
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL); g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group); priv = window_group->priv;
list = priv->device_grabs; list = priv->device_grabs;
other_device = gdk_device_get_associated_device (device); other_device = gdk_device_get_associated_device (device);
...@@ -8821,7 +8827,7 @@ _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group, ...@@ -8821,7 +8827,7 @@ _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
GdkDevice *other_device; GdkDevice *other_device;
GSList *list; GSList *list;
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group); priv = window_group->priv;
other_device = gdk_device_get_associated_device (device); other_device = gdk_device_get_associated_device (device);
list = priv->device_grabs; list = priv->device_grabs;
......
...@@ -53,6 +53,7 @@ typedef struct _GtkWindowClass GtkWindowClass; ...@@ -53,6 +53,7 @@ typedef struct _GtkWindowClass GtkWindowClass;
typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo; typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo;
typedef struct _GtkWindowGroup GtkWindowGroup; typedef struct _GtkWindowGroup GtkWindowGroup;
typedef struct _GtkWindowGroupClass GtkWindowGroupClass; typedef struct _GtkWindowGroupClass GtkWindowGroupClass;
typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate;
struct _GtkWindow struct _GtkWindow
{ {
...@@ -95,7 +96,7 @@ struct _GtkWindowGroup ...@@ -95,7 +96,7 @@ struct _GtkWindowGroup
{ {
GObject parent_instance; GObject parent_instance;
GSList *GSEAL (grabs); GtkWindowGroupPrivate *priv;
}; };
struct _GtkWindowGroupClass struct _GtkWindowGroupClass
...@@ -336,6 +337,7 @@ void gtk_window_group_remove_window (GtkWindowGroup *window_grou ...@@ -336,6 +337,7 @@ void gtk_window_group_remove_window (GtkWindowGroup *window_grou
GtkWindow *window); GtkWindow *window);
GList * gtk_window_group_list_windows (GtkWindowGroup *window_group); GList * gtk_window_group_list_windows (GtkWindowGroup *window_group);
GtkWidget * gtk_window_group_get_current_grab (GtkWindowGroup *window_group);
GtkWidget * gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group, GtkWidget * gtk_window_group_get_current_device_grab (GtkWindowGroup *window_group,
GdkDevice *device); GdkDevice *device);
...@@ -353,65 +355,6 @@ gboolean gtk_window_resize_grip_is_visible (GtkWindow *window); ...@@ -353,65 +355,6 @@ gboolean gtk_window_resize_grip_is_visible (GtkWindow *window);
gboolean gtk_window_get_resize_grip_area (GtkWindow *window, gboolean gtk_window_get_resize_grip_area (GtkWindow *window,
GdkRectangle *rect); GdkRectangle *rect);
/* --- internal functions --- */
void _gtk_window_internal_set_focus (GtkWindow *window,
GtkWidget *focus);
void gtk_window_remove_embedded_xid (GtkWindow *window,
GdkNativeWindow xid);
void gtk_window_add_embedded_xid (GtkWindow *window,
GdkNativeWindow xid);
void _gtk_window_reposition (GtkWindow *window,
gint x,
gint y);
void _gtk_window_constrain_size (GtkWindow *window,
gint width,
gint height,
gint *new_width,
gint *new_height);
GtkWidget *gtk_window_group_get_current_grab (GtkWindowGroup *window_group);
void _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device,
gboolean block_others);
void _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device);
gboolean _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device);
void _gtk_window_set_has_toplevel_focus (GtkWindow *window,
gboolean has_toplevel_focus);
void _gtk_window_unset_focus_and_default (GtkWindow *window,
GtkWidget *widget);
void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
void _gtk_window_set_is_toplevel (GtkWindow *window,
gboolean is_toplevel);
void _gtk_window_get_wmclass (GtkWindow *window,
gchar **wmclass_name,
gchar **wmclass_class);
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
guint keyval,
GdkModifierType modifiers,
gboolean is_mnemonic,
gpointer data);
void _gtk_window_keys_foreach (GtkWindow *window,
GtkWindowKeysForeachFunc func,
gpointer func_data);
/* --- internal (GtkAcceleratable) --- */
gboolean _gtk_window_query_nonaccels (GtkWindow *window,
guint accel_key,
GdkModifierType accel_mods);
G_END_DECLS G_END_DECLS
#endif /* __GTK_WINDOW_H__ */ #endif /* __GTK_WINDOW_H__ */
/* GTK - The GIMP Toolkit
* Copyright (C) 2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GTK_WINDOW_PRIVATE_H__
#define __GTK_WINDOW_PRIVATE_H__
#include "gtkwindow.h"
G_BEGIN_DECLS
void _gtk_window_internal_set_focus (GtkWindow *window,
GtkWidget *focus);
void gtk_window_remove_embedded_xid (GtkWindow *window,
GdkNativeWindow xid);
void gtk_window_add_embedded_xid (GtkWindow *window,
GdkNativeWindow xid);
void _gtk_window_reposition (GtkWindow *window,
gint x,
gint y);
void _gtk_window_constrain_size (GtkWindow *window,
gint width,
gint height,
gint *new_width,
gint *new_height);
void _gtk_window_group_add_grab (GtkWindowGroup *window_group,
GtkWidget *widget);
void _gtk_window_group_remove_grab (GtkWindowGroup *window_group,
GtkWidget *widget);
void _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device,
gboolean block_others);
void _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device);
gboolean _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
GtkWidget *widget,
GdkDevice *device);
void _gtk_window_set_has_toplevel_focus (GtkWindow *window,
gboolean has_toplevel_focus);
void _gtk_window_unset_focus_and_default (GtkWindow *window,
GtkWidget *widget);
void _gtk_window_set_is_active (GtkWindow *window,
gboolean is_active);
void _gtk_window_set_is_toplevel (GtkWindow *window,
gboolean is_toplevel);
void _gtk_window_get_wmclass (GtkWindow *window,
gchar **wmclass_name,
gchar **wmclass_class);
typedef void (*GtkWindowKeysForeachFunc) (GtkWindow *window,
guint keyval,
GdkModifierType modifiers,
gboolean is_mnemonic,
gpointer data);
void _gtk_window_keys_foreach (GtkWindow *window,
GtkWindowKeysForeachFunc func,
gpointer func_data);
/* --- internal (GtkAcceleratable) --- */
gboolean _gtk_window_query_nonaccels (GtkWindow *window,
guint accel_key,
GdkModifierType accel_mods);
G_END_DECLS
#endif /* __GTK_WINDOW_PRIVATE_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment