Use accessor functions instead of direct access

With the transition to GTK+ 3.0, direct access to struct members
will no longer be possible.
This bumps the required minimum version of GTK+ to 2.20.

https://bugzilla.gnome.org/show_bug.cgi?id=618258
This commit is contained in:
Florian Müllner 2010-05-10 17:48:53 +02:00
parent 75b52d36f2
commit 8c5bb8655d
6 changed files with 89 additions and 49 deletions

View File

@ -59,9 +59,11 @@ CLUTTER_MIN_VERSION=1.2.0
GOBJECT_INTROSPECTION_MIN_VERSION=0.6.9
GJS_MIN_VERSION=0.6
MUTTER_MIN_VERSION=2.29.1
GTK_MIN_VERSION=2.20.0
# Collect more than 20 libraries for a prize!
PKG_CHECK_MODULES(MUTTER_PLUGIN, gio-unix-2.0 gtk+-2.0 dbus-glib-1
PKG_CHECK_MODULES(MUTTER_PLUGIN, gio-unix-2.0 dbus-glib-1
gtk+-2.0 >= $GTK_MIN_VERSION
mutter-plugins >= $MUTTER_MIN_VERSION
gjs-gi-1.0 >= $GJS_MIN_VERSION
libgnome-menu $recorder_modules gconf-2.0

View File

@ -55,8 +55,12 @@ static void
shell_embedded_window_show (GtkWidget *widget)
{
ShellEmbeddedWindow *window = SHELL_EMBEDDED_WINDOW (widget);
GtkWidgetClass *widget_class;
GTK_WIDGET_SET_FLAGS (widget, GTK_VISIBLE);
/* Skip GtkWindow, but run the default GtkWidget handling which
* marks the widget visible */
widget_class = g_type_class_peek (GTK_TYPE_WIDGET);
widget_class->show (widget);
if (window->priv->actor)
{
@ -107,7 +111,7 @@ shell_embedded_window_realize (GtkWidget *widget)
* modifying the GDK hierarchy.
*/
XReparentWindow (GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (widget)),
GDK_WINDOW_XWINDOW (widget->window),
GDK_WINDOW_XWINDOW (gtk_widget_get_window (widget)),
stage_xwindow,
window->priv->position.x, window->priv->position.y);
}
@ -202,7 +206,8 @@ _shell_embedded_window_set_actor (ShellEmbeddedWindow *window,
window->priv->actor = actor;
if (GTK_WIDGET_VISIBLE (window) && CLUTTER_ACTOR_IS_REALIZED (actor))
if (gtk_widget_get_visible (GTK_WIDGET (window))
&& CLUTTER_ACTOR_IS_REALIZED (actor))
gtk_widget_map (GTK_WIDGET (window));
}
@ -222,8 +227,8 @@ _shell_embedded_window_allocate (ShellEmbeddedWindow *window,
window->priv->position.width = width;
window->priv->position.height = height;
if (GTK_WIDGET_REALIZED (window))
gdk_window_move_resize (GTK_WIDGET (window)->window,
if (gtk_widget_get_realized (GTK_WIDGET (window)))
gdk_window_move_resize (gtk_widget_get_window (GTK_WIDGET (window)),
x, y, width, height);
allocation.x = 0;
@ -239,7 +244,7 @@ _shell_embedded_window_realize (ShellEmbeddedWindow *window)
{
g_return_if_fail (SHELL_IS_EMBEDDED_WINDOW (window));
if (GTK_WIDGET_VISIBLE (window))
if (gtk_widget_get_visible (GTK_WIDGET (window)))
gtk_widget_map (GTK_WIDGET (window));
}

View File

@ -60,7 +60,7 @@ shell_gtk_embed_on_window_realize (GtkWidget *widget,
* screen.
*/
clutter_x11_texture_pixmap_set_window (CLUTTER_X11_TEXTURE_PIXMAP (embed),
GDK_WINDOW_XWINDOW (widget->window),
GDK_WINDOW_XWINDOW (gtk_widget_get_window (widget)),
FALSE);
}
@ -100,7 +100,7 @@ shell_gtk_embed_set_window (ShellGtkEmbed *embed,
g_signal_connect (embed->priv->window, "realize",
G_CALLBACK (shell_gtk_embed_on_window_realize), embed);
if (GTK_WIDGET_REALIZED (window))
if (gtk_widget_get_realized (GTK_WIDGET (window)))
shell_gtk_embed_on_window_realize (GTK_WIDGET (embed->priv->window), embed);
}
@ -155,7 +155,8 @@ shell_gtk_embed_get_preferred_width (ClutterActor *actor,
{
ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor);
if (embed->priv->window && GTK_WIDGET_VISIBLE (embed->priv->window))
if (embed->priv->window
&& gtk_widget_get_visible (GTK_WIDGET (embed->priv->window)))
{
GtkRequisition requisition;
gtk_widget_size_request (GTK_WIDGET (embed->priv->window), &requisition);
@ -174,7 +175,8 @@ shell_gtk_embed_get_preferred_height (ClutterActor *actor,
{
ShellGtkEmbed *embed = SHELL_GTK_EMBED (actor);
if (embed->priv->window && GTK_WIDGET_VISIBLE (embed->priv->window))
if (embed->priv->window
&& gtk_widget_get_visible (GTK_WIDGET (embed->priv->window)))
{
GtkRequisition requisition;
gtk_widget_size_request (GTK_WIDGET (embed->priv->window), &requisition);

View File

@ -268,7 +268,8 @@ shell_tray_manager_child_on_realize (GtkWidget *widget,
{
bg_pixmap = create_bg_pixmap (gtk_widget_get_colormap (widget),
&child->manager->priv->bg_color);
gdk_window_set_back_pixmap (widget->window, bg_pixmap, FALSE);
gdk_window_set_back_pixmap (gtk_widget_get_window (widget),
bg_pixmap, FALSE);
g_object_unref (bg_pixmap);
}
}

View File

@ -42,9 +42,12 @@ na_tray_child_realize (GtkWidget *widget)
{
NaTrayChild *child = NA_TRAY_CHILD (widget);
GdkVisual *visual = gtk_widget_get_visual (widget);
GdkWindow *window;
GTK_WIDGET_CLASS (na_tray_child_parent_class)->realize (widget);
window = gtk_widget_get_window (widget);
if (child->has_alpha)
{
/* We have real transparency with an ARGB visual and the Composite
@ -52,16 +55,16 @@ na_tray_child_realize (GtkWidget *widget)
/* Set a transparent background */
GdkColor transparent = { 0, 0, 0, 0 }; /* only pixel=0 matters */
gdk_window_set_background (widget->window, &transparent);
gdk_window_set_composited (widget->window, TRUE);
gdk_window_set_background (window, &transparent);
gdk_window_set_composited (window, TRUE);
child->parent_relative_bg = FALSE;
}
else if (visual == gdk_drawable_get_visual (GDK_DRAWABLE (gdk_window_get_parent (widget->window))))
else if (visual == gdk_drawable_get_visual (GDK_DRAWABLE (gdk_window_get_parent (window))))
{
/* Otherwise, if the visual matches the visual of the parent window, we
* can use a parent-relative background and fake transparency. */
gdk_window_set_back_pixmap (widget->window, NULL, TRUE);
gdk_window_set_back_pixmap (window, NULL, TRUE);
child->parent_relative_bg = TRUE;
}
@ -71,7 +74,7 @@ na_tray_child_realize (GtkWidget *widget)
child->parent_relative_bg = FALSE;
}
gdk_window_set_composited (widget->window, child->composited);
gdk_window_set_composited (window, child->composited);
gtk_widget_set_app_paintable (GTK_WIDGET (child),
child->parent_relative_bg || child->has_alpha);
@ -129,10 +132,16 @@ na_tray_child_size_allocate (GtkWidget *widget,
{
NaTrayChild *child = NA_TRAY_CHILD (widget);
gboolean moved = allocation->x != widget->allocation.x ||
allocation->y != widget->allocation.y;
gboolean resized = allocation->width != widget->allocation.width ||
allocation->height != widget->allocation.height;
GdkWindow *window;
GtkAllocation widget_allocation;
gboolean moved, resized;
gtk_widget_get_allocation (widget, &widget_allocation);
moved = allocation->x != widget_allocation.x ||
allocation->y != widget_allocation.y;
resized = allocation->width != widget_allocation.width ||
allocation->height != widget_allocation.height;
window = gtk_widget_get_window (widget);
/* When we are allocating the widget while mapped we need special handling
* for both real and fake transparency.
@ -144,21 +153,21 @@ na_tray_child_size_allocate (GtkWidget *widget,
* Fake transparency: if the widget moved, we need to force the contents to
* be redrawn with the new offset for the parent-relative background.
*/
if ((moved || resized) && GTK_WIDGET_MAPPED (widget))
if ((moved || resized) && gtk_widget_get_mapped (widget))
{
if (na_tray_child_has_alpha (child))
gdk_window_invalidate_rect (gdk_window_get_parent (widget->window),
&widget->allocation, FALSE);
gdk_window_invalidate_rect (gdk_window_get_parent (window),
&widget_allocation, FALSE);
}
GTK_WIDGET_CLASS (na_tray_child_parent_class)->size_allocate (widget,
allocation);
if ((moved || resized) && GTK_WIDGET_MAPPED (widget))
if ((moved || resized) && gtk_widget_get_mapped (widget))
{
if (na_tray_child_has_alpha (NA_TRAY_CHILD (widget)))
gdk_window_invalidate_rect (gdk_window_get_parent (widget->window),
&widget->allocation, FALSE);
gdk_window_invalidate_rect (gdk_window_get_parent (window),
&widget_allocation, FALSE);
else if (moved && child->parent_relative_bg)
na_tray_child_force_redraw (child);
}
@ -173,11 +182,12 @@ na_tray_child_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
NaTrayChild *child = NA_TRAY_CHILD (widget);
GdkWindow *window = gtk_widget_get_window (widget);
if (na_tray_child_has_alpha (child))
{
/* Clear to transparent */
cairo_t *cr = gdk_cairo_create (widget->window);
cairo_t *cr = gdk_cairo_create (window);
cairo_set_source_rgba (cr, 0, 0, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
gdk_cairo_region (cr, event->region);
@ -187,7 +197,7 @@ na_tray_child_expose_event (GtkWidget *widget,
else if (child->parent_relative_bg)
{
/* Clear to parent-relative pixmap */
gdk_window_clear_area (widget->window,
gdk_window_clear_area (window,
event->area.x, event->area.y,
event->area.width, event->area.height);
}
@ -372,11 +382,13 @@ void
na_tray_child_set_composited (NaTrayChild *child,
gboolean composited)
{
GdkWindow *window;
g_return_if_fail (NA_IS_TRAY_CHILD (child));
child->composited = composited;
if (GTK_WIDGET_REALIZED (child))
gdk_window_set_composited (GTK_WIDGET (child)->window, composited);
window = gtk_widget_get_window (GTK_WIDGET (child));
if (window)
gdk_window_set_composited (window, composited);
}
/* If we are faking transparency with a window-relative background, force a
@ -386,9 +398,10 @@ na_tray_child_set_composited (NaTrayChild *child,
void
na_tray_child_force_redraw (NaTrayChild *child)
{
GtkAllocation allocation;
GtkWidget *widget = GTK_WIDGET (child);
if (GTK_WIDGET_MAPPED (child) && child->parent_relative_bg)
if (gtk_widget_get_mapped (GTK_WIDGET (child)) && child->parent_relative_bg)
{
#if 1
/* Sending an ExposeEvent might cause redraw problems if the
@ -399,11 +412,11 @@ na_tray_child_force_redraw (NaTrayChild *child)
XEvent xev;
xev.xexpose.type = Expose;
xev.xexpose.window = GDK_WINDOW_XWINDOW (GTK_SOCKET (child)->plug_window);
xev.xexpose.window = GDK_WINDOW_XWINDOW (gtk_socket_get_plug_window (GTK_SOCKET (child)));
xev.xexpose.x = 0;
xev.xexpose.y = 0;
xev.xexpose.width = widget->allocation.width;
xev.xexpose.height = widget->allocation.height;
xev.xexpose.width = allocation.width;
xev.xexpose.height = allocation.height;
xev.xexpose.count = 0;
gdk_error_trap_push ();

View File

@ -296,7 +296,7 @@ na_tray_manager_handle_dock_request (NaTrayManager *manager,
gtk_socket_add_id (GTK_SOCKET (child), icon_window);
if (!GTK_SOCKET (child)->plug_window)
if (!gtk_socket_get_plug_window (GTK_SOCKET (child)))
{
/* Embedding failed, we won't get a plug-removed signal */
g_signal_emit (manager, manager_signals[TRAY_ICON_REMOVED], 0, child);
@ -537,6 +537,7 @@ na_tray_manager_unmanage (NaTrayManager *manager)
{
#ifdef GDK_WINDOWING_X11
GdkDisplay *display;
GdkWindow *window;
guint32 timestamp;
GtkWidget *invisible;
@ -544,16 +545,17 @@ na_tray_manager_unmanage (NaTrayManager *manager)
return;
invisible = manager->invisible;
window = gtk_widget_get_window (invisible);
g_assert (GTK_IS_INVISIBLE (invisible));
g_assert (GTK_WIDGET_REALIZED (invisible));
g_assert (GDK_IS_WINDOW (invisible->window));
g_assert (gtk_widget_get_realized (GTK_WIDGET (invisible)));
g_assert (GDK_IS_WINDOW (window));
display = gtk_widget_get_display (invisible);
if (gdk_selection_owner_get_for_display (display, manager->selection_atom) ==
invisible->window)
window)
{
timestamp = gdk_x11_get_server_time (invisible->window);
timestamp = gdk_x11_get_server_time (window);
gdk_selection_owner_set_for_display (display,
NULL,
manager->selection_atom,
@ -564,7 +566,7 @@ na_tray_manager_unmanage (NaTrayManager *manager)
//FIXME: we should also use gdk_remove_client_message_filter when it's
//available
// See bug #351254
gdk_window_remove_filter (invisible->window,
gdk_window_remove_filter (window,
na_tray_manager_window_filter, manager);
manager->invisible = NULL; /* prior to destroy for reentrancy paranoia */
@ -578,10 +580,16 @@ na_tray_manager_set_orientation_property (NaTrayManager *manager)
{
#ifdef GDK_WINDOWING_X11
GdkDisplay *display;
GdkWindow *window;
Atom orientation_atom;
gulong data[1];
if (!manager->invisible || !manager->invisible->window)
if (!manager->invisible)
return;
window = gtk_widget_get_window (GTK_WIDGET (manager->invisible));
if (!window)
return;
display = gtk_widget_get_display (manager->invisible);
@ -593,7 +601,7 @@ na_tray_manager_set_orientation_property (NaTrayManager *manager)
SYSTEM_TRAY_ORIENTATION_VERT;
XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XWINDOW (manager->invisible->window),
GDK_WINDOW_XWINDOW (window),
orientation_atom,
XA_CARDINAL, 32,
PropModeReplace,
@ -606,11 +614,17 @@ na_tray_manager_set_visual_property (NaTrayManager *manager)
{
#ifdef GDK_WINDOWING_X11
GdkDisplay *display;
GdkWindow *window;
Visual *xvisual;
Atom visual_atom;
gulong data[1];
if (!manager->invisible || !manager->invisible->window)
if (!manager->invisible)
return;
window = gtk_widget_get_window (GTK_WIDGET (manager->invisible));
if (!window)
return;
/* The visual property is a hint to the tray icons as to what visual they
@ -645,7 +659,7 @@ na_tray_manager_set_visual_property (NaTrayManager *manager)
data[0] = XVisualIDFromVisual (xvisual);
XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
GDK_WINDOW_XWINDOW (manager->invisible->window),
GDK_WINDOW_XWINDOW (window),
visual_atom,
XA_VISUALID, 32,
PropModeReplace,
@ -660,6 +674,7 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
GdkScreen *screen)
{
GdkDisplay *display;
GdkWindow *window;
Screen *xscreen;
GtkWidget *invisible;
char *selection_atom_name;
@ -683,6 +698,8 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
invisible = gtk_invisible_new_for_screen (screen);
gtk_widget_realize (invisible);
window = gtk_widget_get_window (GTK_WIDGET (invisible));
gtk_widget_add_events (invisible,
GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);
@ -698,11 +715,11 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
na_tray_manager_set_orientation_property (manager);
na_tray_manager_set_visual_property (manager);
timestamp = gdk_x11_get_server_time (invisible->window);
timestamp = gdk_x11_get_server_time (window);
/* Check if we could set the selection owner successfully */
if (gdk_selection_owner_set_for_display (display,
invisible->window,
window,
manager->selection_atom,
timestamp,
TRUE))
@ -720,7 +737,7 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
xev.data.l[0] = timestamp;
xev.data.l[1] = gdk_x11_atom_to_xatom_for_display (display,
manager->selection_atom);
xev.data.l[2] = GDK_WINDOW_XWINDOW (invisible->window);
xev.data.l[2] = GDK_WINDOW_XWINDOW (window);
xev.data.l[3] = 0; /* manager specific data */
xev.data.l[4] = 0; /* manager specific data */
@ -743,7 +760,7 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
manager);
#endif
/* This is for SYSTEM_TRAY_REQUEST_DOCK and SelectionClear */
gdk_window_add_filter (invisible->window,
gdk_window_add_filter (window,
na_tray_manager_window_filter, manager);
/* This is for SYSTEM_TRAY_BEGIN_MESSAGE and SYSTEM_TRAY_CANCEL_MESSAGE */
gdk_display_add_client_message_filter (display, opcode_atom,