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.
This commit is contained in:
Matthias Clasen 2010-12-17 20:41:16 -05:00
parent a2dda0c2bb
commit 7b665316cf
11 changed files with 157 additions and 125 deletions

View File

@ -433,6 +433,7 @@ gtk_private_h_sources = \
gtktreedatalist.h \
gtktreeprivate.h \
gtkwidgetprivate.h \
gtkwindowprivate.h \
$(gtk_clipboard_dnd_h_sources) \
$(gtk_appchooser_impl_h_sources)

View File

@ -22,7 +22,7 @@
#include "gtkaccelmap.h"
#include "gtkmarshalers.h"
#include "gtkwindow.h" /* in lack of GtkAcceleratable */
#include "gtkwindowprivate.h"
#include "gtkintl.h"
#include <glib/gstdio.h>

View File

@ -60,7 +60,7 @@
#include "gtkselection.h"
#include "gtksettings.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtktooltip.h"
#include "gtkdebug.h"
#include "gtkmenu.h"
@ -1585,8 +1585,8 @@ gtk_main_do_event (GdkEvent *event)
if (device)
grab_widget = gtk_window_group_get_current_device_grab (window_group, device);
if (!grab_widget && window_group->grabs)
grab_widget = window_group->grabs->data;
if (!grab_widget)
grab_widget = gtk_window_group_get_current_grab (window_group);
/* If the grab widget is an ancestor of the event widget
* then we send the event to the original event widget.
@ -1629,7 +1629,7 @@ gtk_main_do_event (GdkEvent *event)
case GDK_DELETE:
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_destroy (event_widget);
g_object_unref (event_widget);
@ -1988,16 +1988,13 @@ gtk_grab_add (GtkWidget *widget)
if (!gtk_widget_has_grab (widget) && gtk_widget_is_sensitive (widget))
{
_gtk_widget_set_has_grab (widget, TRUE);
group = gtk_main_get_window_group (widget);
if (group->grabs)
old_grab_widget = (GtkWidget *)group->grabs->data;
else
old_grab_widget = NULL;
old_grab_widget = gtk_window_group_get_current_grab (group);
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);
}
@ -2018,9 +2015,7 @@ gtk_grab_get_current (void)
group = gtk_main_get_window_group (NULL);
if (group->grabs)
return GTK_WIDGET (group->grabs->data);
return NULL;
return gtk_window_group_get_current_grab (group);
}
void
@ -2036,15 +2031,11 @@ gtk_grab_remove (GtkWidget *widget)
_gtk_widget_set_has_grab (widget, FALSE);
group = gtk_main_get_window_group (widget);
group->grabs = g_slist_remove (group->grabs, widget);
if (group->grabs)
new_grab_widget = (GtkWidget *)group->grabs->data;
else
new_grab_widget = NULL;
_gtk_window_group_remove_grab (group, widget);
new_grab_widget = gtk_window_group_get_current_grab (group);
gtk_grab_notify (group, NULL, widget, new_grab_widget, FALSE);
g_object_unref (widget);
}
}

View File

@ -45,6 +45,7 @@
#include "gtkplug.h"
#include "gtkprivate.h"
#include "gtkplugprivate.h"
#include "gtkwindowprivate.h"
#include "gtkdebug.h"
#include "x11/gdkx.h"

View File

@ -34,7 +34,7 @@
#include "gtkprivate.h"
#include "gtkplugprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
/**
* SECTION:gtkplug

View File

@ -31,7 +31,7 @@
#include "gdk/gdkkeysyms.h"
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtkplug.h"
#include "gtkprivate.h"
#include "gtksocket.h"

View File

@ -35,7 +35,7 @@
#include "gtkmain.h"
#include "gtkmarshalers.h"
#include "gtksizerequest.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtkplug.h"
#include "gtkprivate.h"
#include "gtksocketprivate.h"

View File

@ -41,7 +41,7 @@
#include "gtksizegroup-private.h"
#include "gtkwidget.h"
#include "gtkwidgetprivate.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtkbindings.h"
#include "gtkprivate.h"
#include "gdk/gdk.h"

View File

@ -25,6 +25,9 @@
*/
#include "config.h"
#include "gtkintl.h"
#include <string.h>
#include <stdlib.h>
#include <errno.h>
@ -32,11 +35,10 @@
#include "gdk/gdk.h"
#include "gdk/gdkkeysyms.h"
#include "gtkintl.h"
#include "gtkprivate.h"
#include "gtkrc.h"
#include "gtkwindow.h"
#include "gtkwindowprivate.h"
#include "gtkbindings.h"
#include "gtkkeyhash.h"
#include "gtkmain.h"
@ -95,7 +97,6 @@
*/
typedef struct _GtkDeviceGrabInfo GtkDeviceGrabInfo;
typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate;
struct _GtkWindowPrivate
{
@ -297,7 +298,6 @@ struct _GtkWindowGeometryInfo
GtkWindowLastGeometryInfo last;
};
#define GTK_WINDOW_GROUP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_WINDOW_GROUP, GtkWindowGroupPrivate))
struct _GtkDeviceGrabInfo
{
@ -308,6 +308,7 @@ struct _GtkDeviceGrabInfo
struct _GtkWindowGroupPrivate
{
GSList *grabs;
GSList *device_grabs;
};
@ -8461,39 +8462,22 @@ gtk_window_has_toplevel_focus (GtkWindow *window)
return window->priv->has_toplevel_focus;
}
G_DEFINE_TYPE (GtkWindowGroup, gtk_window_group, G_TYPE_OBJECT)
static void
gtk_window_group_init (GtkWindowGroup *group)
{
group->priv = G_TYPE_INSTANCE_GET_PRIVATE (group,
GTK_TYPE_WINDOW_GROUP,
GtkWindowGroupPrivate);
}
static void
gtk_window_group_class_init (GtkWindowGroupClass *klass)
{
g_type_class_add_private (klass, sizeof (GtkWindowGroupPrivate));
}
GType
gtk_window_group_get_type (void)
{
static GType window_group_type = 0;
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;
}
/**
* gtk_window_group_new:
*
@ -8510,14 +8494,16 @@ gtk_window_group_new (void)
static void
window_group_cleanup_grabs (GtkWindowGroup *group,
GtkWindow *window)
GtkWindow *window)
{
GtkWindowGroupPrivate *priv;
GtkDeviceGrabInfo *info;
GSList *tmp_list;
GSList *to_remove = NULL;
tmp_list = group->grabs;
priv = group->priv;
tmp_list = priv->grabs;
while (tmp_list)
{
if (gtk_widget_get_toplevel (tmp_list->data) == (GtkWidget*) window)
@ -8532,7 +8518,6 @@ window_group_cleanup_grabs (GtkWindowGroup *group,
to_remove = g_slist_delete_link (to_remove, to_remove);
}
priv = GTK_WINDOW_GROUP_GET_PRIVATE (group);
tmp_list = priv->device_grabs;
while (tmp_list)
@ -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);
if (window_group->grabs)
return GTK_WIDGET (window_group->grabs->data);
if (window_group->priv->grabs)
return GTK_WIDGET (window_group->priv->grabs->data);
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
_gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWidget *widget,
@ -8723,7 +8729,7 @@ _gtk_window_group_add_device_grab (GtkWindowGroup *window_group,
GtkWindowGroupPrivate *priv;
GtkDeviceGrabInfo *info;
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
priv = window_group->priv;
info = g_slice_new0 (GtkDeviceGrabInfo);
info->widget = widget;
@ -8743,7 +8749,7 @@ _gtk_window_group_remove_device_grab (GtkWindowGroup *window_group,
GSList *list, *node = NULL;
GdkDevice *other_device;
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
priv = window_group->priv;
other_device = gdk_device_get_associated_device (device);
list = priv->device_grabs;
@ -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 (GDK_IS_DEVICE (device), NULL);
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
priv = window_group->priv;
list = priv->device_grabs;
other_device = gdk_device_get_associated_device (device);
@ -8821,7 +8827,7 @@ _gtk_window_group_widget_is_blocked_for_device (GtkWindowGroup *window_group,
GdkDevice *other_device;
GSList *list;
priv = GTK_WINDOW_GROUP_GET_PRIVATE (window_group);
priv = window_group->priv;
other_device = gdk_device_get_associated_device (device);
list = priv->device_grabs;

View File

@ -53,6 +53,7 @@ typedef struct _GtkWindowClass GtkWindowClass;
typedef struct _GtkWindowGeometryInfo GtkWindowGeometryInfo;
typedef struct _GtkWindowGroup GtkWindowGroup;
typedef struct _GtkWindowGroupClass GtkWindowGroupClass;
typedef struct _GtkWindowGroupPrivate GtkWindowGroupPrivate;
struct _GtkWindow
{
@ -95,7 +96,7 @@ struct _GtkWindowGroup
{
GObject parent_instance;
GSList *GSEAL (grabs);
GtkWindowGroupPrivate *priv;
};
struct _GtkWindowGroupClass
@ -336,6 +337,7 @@ void gtk_window_group_remove_window (GtkWindowGroup *window_grou
GtkWindow *window);
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,
GdkDevice *device);
@ -353,65 +355,6 @@ gboolean gtk_window_resize_grip_is_visible (GtkWindow *window);
gboolean gtk_window_get_resize_grip_area (GtkWindow *window,
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
#endif /* __GTK_WINDOW_H__ */

90
gtk/gtkwindowprivate.h Normal file
View File

@ -0,0 +1,90 @@
/* 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__ */