1 /* GAIL - The GNOME Accessibility Implementation Library
2 * Copyright 2001, 2002, 2003 Sun Microsystems Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #ifdef GDK_WINDOWING_X11
26 #include <gdk/x11/gdkx.h>
28 #include "gailwidget.h"
29 #include "gailnotebookpage.h"
30 #include "gail-private-macros.h"
32 extern GtkWidget *focus_widget;
34 static void gail_widget_class_init (GailWidgetClass *klass);
35 static void gail_widget_init (GailWidget *accessible);
36 static void gail_widget_connect_widget_destroyed (GtkAccessible *accessible);
37 static void gail_widget_destroyed (GtkWidget *widget,
38 GtkAccessible *accessible);
40 static G_CONST_RETURN gchar* gail_widget_get_description (AtkObject *accessible);
41 static AtkObject* gail_widget_get_parent (AtkObject *accessible);
42 static AtkStateSet* gail_widget_ref_state_set (AtkObject *accessible);
43 static AtkRelationSet* gail_widget_ref_relation_set (AtkObject *accessible);
44 static gint gail_widget_get_index_in_parent (AtkObject *accessible);
46 static void atk_component_interface_init (AtkComponentIface *iface);
48 static guint gail_widget_add_focus_handler
49 (AtkComponent *component,
50 AtkFocusHandler handler);
52 static void gail_widget_get_extents (AtkComponent *component,
57 AtkCoordType coord_type);
59 static void gail_widget_get_size (AtkComponent *component,
63 static AtkLayer gail_widget_get_layer (AtkComponent *component);
65 static gboolean gail_widget_grab_focus (AtkComponent *component);
68 static void gail_widget_remove_focus_handler
69 (AtkComponent *component,
72 static gboolean gail_widget_set_extents (AtkComponent *component,
77 AtkCoordType coord_type);
79 static gboolean gail_widget_set_position (AtkComponent *component,
82 AtkCoordType coord_type);
84 static gboolean gail_widget_set_size (AtkComponent *component,
88 static gint gail_widget_map_gtk (GtkWidget *widget);
89 static void gail_widget_real_notify_gtk (GObject *obj,
91 static void gail_widget_notify_gtk (GObject *obj,
93 static gboolean gail_widget_focus_gtk (GtkWidget *widget,
94 GdkEventFocus *event);
95 static gboolean gail_widget_real_focus_gtk (GtkWidget *widget,
96 GdkEventFocus *event);
97 static void gail_widget_size_allocate_gtk (GtkWidget *widget,
98 GtkAllocation *allocation);
100 static void gail_widget_focus_event (AtkObject *obj,
103 static void gail_widget_real_initialize (AtkObject *obj,
105 static GtkWidget* gail_widget_find_viewport (GtkWidget *widget);
106 static gboolean gail_widget_on_screen (GtkWidget *widget);
107 static gboolean gail_widget_all_parents_visible(GtkWidget *widget);
109 G_DEFINE_TYPE_WITH_CODE (GailWidget, gail_widget, GTK_TYPE_ACCESSIBLE,
110 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
113 gail_widget_class_init (GailWidgetClass *klass)
115 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
116 GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
118 klass->notify_gtk = gail_widget_real_notify_gtk;
119 klass->focus_gtk = gail_widget_real_focus_gtk;
121 accessible_class->connect_widget_destroyed = gail_widget_connect_widget_destroyed;
123 class->get_description = gail_widget_get_description;
124 class->get_parent = gail_widget_get_parent;
125 class->ref_relation_set = gail_widget_ref_relation_set;
126 class->ref_state_set = gail_widget_ref_state_set;
127 class->get_index_in_parent = gail_widget_get_index_in_parent;
128 class->initialize = gail_widget_real_initialize;
132 gail_widget_init (GailWidget *accessible)
137 * This function specifies the GtkWidget for which the GailWidget was created
138 * and specifies a handler to be called when the GtkWidget is destroyed.
141 gail_widget_real_initialize (AtkObject *obj,
144 GtkAccessible *accessible;
147 g_return_if_fail (GTK_IS_WIDGET (data));
149 widget = GTK_WIDGET (data);
151 accessible = GTK_ACCESSIBLE (obj);
152 accessible->widget = widget;
153 gtk_accessible_connect_widget_destroyed (accessible);
154 g_signal_connect_after (widget,
156 G_CALLBACK (gail_widget_focus_gtk),
158 g_signal_connect_after (widget,
160 G_CALLBACK (gail_widget_focus_gtk),
162 g_signal_connect (widget,
164 G_CALLBACK (gail_widget_notify_gtk),
166 g_signal_connect (widget,
168 G_CALLBACK (gail_widget_size_allocate_gtk),
170 atk_component_add_focus_handler (ATK_COMPONENT (accessible),
171 gail_widget_focus_event);
173 * Add signal handlers for GTK signals required to support property changes
175 g_signal_connect (widget,
177 G_CALLBACK (gail_widget_map_gtk),
179 g_signal_connect (widget,
181 G_CALLBACK (gail_widget_map_gtk),
183 g_object_set_data (G_OBJECT (obj), "atk-component-layer",
184 GINT_TO_POINTER (ATK_LAYER_WIDGET));
186 obj->role = ATK_ROLE_UNKNOWN;
190 gail_widget_new (GtkWidget *widget)
193 AtkObject *accessible;
195 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
197 object = g_object_new (GAIL_TYPE_WIDGET, NULL);
199 accessible = ATK_OBJECT (object);
200 atk_object_initialize (accessible, widget);
206 * This function specifies the function to be called when the widget
210 gail_widget_connect_widget_destroyed (GtkAccessible *accessible)
212 if (accessible->widget)
214 g_signal_connect_after (accessible->widget,
216 G_CALLBACK (gail_widget_destroyed),
222 * This function is called when the widget is destroyed.
223 * It sets the widget field in the GtkAccessible structure to NULL
224 * and emits a state-change signal for the state ATK_STATE_DEFUNCT
227 gail_widget_destroyed (GtkWidget *widget,
228 GtkAccessible *accessible)
230 accessible->widget = NULL;
231 atk_object_notify_state_change (ATK_OBJECT (accessible), ATK_STATE_DEFUNCT,
235 static G_CONST_RETURN gchar*
236 gail_widget_get_description (AtkObject *accessible)
238 if (accessible->description)
239 return accessible->description;
242 /* Get the tooltip from the widget */
243 GtkAccessible *obj = GTK_ACCESSIBLE (accessible);
245 gail_return_val_if_fail (obj, NULL);
247 if (obj->widget == NULL)
253 gail_return_val_if_fail (GTK_WIDGET (obj->widget), NULL);
255 return gtk_widget_get_tooltip_text (obj->widget);
260 gail_widget_get_parent (AtkObject *accessible)
264 parent = accessible->accessible_parent;
267 g_return_val_if_fail (ATK_IS_OBJECT (parent), NULL);
270 GtkWidget *widget, *parent_widget;
272 widget = GTK_ACCESSIBLE (accessible)->widget;
278 gail_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
280 parent_widget = widget->parent;
281 if (parent_widget == NULL)
285 * For a widget whose parent is a GtkNoteBook, we return the
286 * accessible object corresponding the GtkNotebookPage containing
287 * the widget as the accessible parent.
289 if (GTK_IS_NOTEBOOK (parent_widget))
293 GtkNotebook *notebook;
296 notebook = GTK_NOTEBOOK (parent_widget);
299 child = gtk_notebook_get_nth_page (notebook, page_num);
304 parent = gtk_widget_get_accessible (parent_widget);
305 parent = atk_object_ref_accessible_child (parent, page_num);
306 g_object_unref (parent);
313 parent = gtk_widget_get_accessible (parent_widget);
319 find_label (GtkWidget *widget)
323 GtkWidget *temp_widget;
325 labels = gtk_widget_list_mnemonic_labels (widget);
333 g_warning ("Widget (%s) has more than one label", G_OBJECT_TYPE_NAME (widget));
338 label = labels->data;
341 g_list_free (labels);
345 * Ignore a label within a button; bug #136602
347 if (label && GTK_IS_BUTTON (widget))
352 if (temp_widget == widget)
357 temp_widget = gtk_widget_get_parent (temp_widget);
363 static AtkRelationSet*
364 gail_widget_ref_relation_set (AtkObject *obj)
367 AtkRelationSet *relation_set;
370 AtkRelation* relation;
372 gail_return_val_if_fail (GAIL_IS_WIDGET (obj), NULL);
374 widget = GTK_ACCESSIBLE (obj)->widget;
381 relation_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_relation_set (obj);
383 if (GTK_IS_BOX (widget))
385 * Do not report labelled-by for a GtkBox which could be a
390 if (!atk_relation_set_contains (relation_set, ATK_RELATION_LABELLED_BY))
392 label = find_label (widget);
395 if (GTK_IS_BUTTON (widget))
397 * Handle the case where GnomeIconEntry is the mnemonic widget.
398 * The GtkButton which is a grandchild of the GnomeIconEntry
399 * should really be the mnemonic widget. See bug #133967.
402 GtkWidget *temp_widget;
404 temp_widget = gtk_widget_get_parent (widget);
406 if (GTK_IS_ALIGNMENT (temp_widget))
408 temp_widget = gtk_widget_get_parent (temp_widget);
409 if (GTK_IS_BOX (temp_widget))
411 label = find_label (temp_widget);
414 label = find_label (gtk_widget_get_parent (temp_widget));
418 else if (GTK_IS_COMBO_BOX (widget))
420 * Handle the case when GtkFileChooserButton is the mnemonic
421 * widget. The GtkComboBox which is a child of the
422 * GtkFileChooserButton should be the mnemonic widget.
426 GtkWidget *temp_widget;
428 temp_widget = gtk_widget_get_parent (widget);
429 if (GTK_IS_HBOX (temp_widget))
431 label = find_label (temp_widget);
438 array [0] = gtk_widget_get_accessible (label);
440 relation = atk_relation_new (array, 1, ATK_RELATION_LABELLED_BY);
441 atk_relation_set_add (relation_set, relation);
442 g_object_unref (relation);
450 gail_widget_ref_state_set (AtkObject *accessible)
452 GtkWidget *widget = GTK_ACCESSIBLE (accessible)->widget;
453 AtkStateSet *state_set;
455 state_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_state_set (accessible);
459 atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
463 if (gtk_widget_is_sensitive (widget))
465 atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
466 atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
469 if (gtk_widget_get_can_focus (widget))
471 atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
474 * We do not currently generate notifications when an ATK object
475 * corresponding to a GtkWidget changes visibility by being scrolled
476 * on or off the screen. The testcase for this is the main window
477 * of the testgtk application in which a set of buttons in a GtkVBox
478 * is in a scrooled window with a viewport.
480 * To generate the notifications we would need to do the following:
481 * 1) Find the GtkViewPort among the antecendents of the objects
482 * 2) Create an accesible for the GtkViewPort
483 * 3) Connect to the value-changed signal on the viewport
484 * 4) When the signal is received we need to traverse the children
485 * of the viewport and check whether the children are visible or not
486 * visible; we may want to restrict this to the widgets for which
487 * accessible objects have been created.
488 * 5) We probably need to store a variable on_screen in the
489 * GailWidget data structure so we can determine whether the value has
492 if (gtk_widget_get_visible (widget))
494 atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
495 if (gail_widget_on_screen (widget) && gtk_widget_get_mapped (widget) &&
496 gail_widget_all_parents_visible (widget))
498 atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
502 if (gtk_widget_has_focus (widget) && (widget == focus_widget))
504 AtkObject *focus_obj;
506 focus_obj = g_object_get_data (G_OBJECT (accessible), "gail-focus-object");
507 if (focus_obj == NULL)
508 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
510 if (gtk_widget_has_default (widget))
512 atk_state_set_add_state (state_set, ATK_STATE_DEFAULT);
519 gail_widget_get_index_in_parent (AtkObject *accessible)
522 GtkWidget *parent_widget;
527 type = g_type_from_name ("GailCanvasWidget");
528 widget = GTK_ACCESSIBLE (accessible)->widget;
536 if (accessible->accessible_parent)
540 parent = accessible->accessible_parent;
542 if (GAIL_IS_NOTEBOOK_PAGE (parent) ||
543 G_TYPE_CHECK_INSTANCE_TYPE ((parent), type))
548 gboolean found = FALSE;
550 n_children = atk_object_get_n_accessible_children (parent);
551 for (i = 0; i < n_children; i++)
555 child = atk_object_ref_accessible_child (parent, i);
556 if (child == accessible)
559 g_object_unref (child);
566 gail_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
567 parent_widget = widget->parent;
568 if (parent_widget == NULL)
570 gail_return_val_if_fail (GTK_IS_CONTAINER (parent_widget), -1);
572 children = gtk_container_get_children (GTK_CONTAINER (parent_widget));
574 index = g_list_index (children, widget);
575 g_list_free (children);
580 atk_component_interface_init (AtkComponentIface *iface)
583 * Use default implementation for contains and get_position
585 iface->add_focus_handler = gail_widget_add_focus_handler;
586 iface->get_extents = gail_widget_get_extents;
587 iface->get_size = gail_widget_get_size;
588 iface->get_layer = gail_widget_get_layer;
589 iface->grab_focus = gail_widget_grab_focus;
590 iface->remove_focus_handler = gail_widget_remove_focus_handler;
591 iface->set_extents = gail_widget_set_extents;
592 iface->set_position = gail_widget_set_position;
593 iface->set_size = gail_widget_set_size;
597 gail_widget_add_focus_handler (AtkComponent *component,
598 AtkFocusHandler handler)
600 GSignalMatchType match_type;
604 match_type = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC;
605 signal_id = g_signal_lookup ("focus-event", ATK_TYPE_OBJECT);
607 ret = g_signal_handler_find (component, match_type, signal_id, 0, NULL,
608 (gpointer) handler, NULL);
611 return g_signal_connect_closure_by_id (component,
614 G_CALLBACK (handler), NULL,
615 (GClosureNotify) NULL),
625 gail_widget_get_extents (AtkComponent *component,
630 AtkCoordType coord_type)
633 gint x_window, y_window;
634 gint x_toplevel, y_toplevel;
635 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
643 gail_return_if_fail (GTK_IS_WIDGET (widget));
645 *width = widget->allocation.width;
646 *height = widget->allocation.height;
647 if (!gail_widget_on_screen (widget) || (!gtk_widget_is_drawable (widget)))
656 *x = widget->allocation.x;
657 *y = widget->allocation.y;
658 window = gtk_widget_get_parent_window (widget);
664 window = widget->window;
666 gdk_window_get_origin (window, &x_window, &y_window);
671 if (coord_type == ATK_XY_WINDOW)
673 window = gdk_window_get_toplevel (widget->window);
674 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
682 gail_widget_get_size (AtkComponent *component,
686 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
694 gail_return_if_fail (GTK_IS_WIDGET (widget));
696 *width = widget->allocation.width;
697 *height = widget->allocation.height;
701 gail_widget_get_layer (AtkComponent *component)
704 layer = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (component), "atk-component-layer"));
706 return (AtkLayer) layer;
710 gail_widget_grab_focus (AtkComponent *component)
712 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
715 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
716 if (gtk_widget_get_can_focus (widget))
718 gtk_widget_grab_focus (widget);
719 toplevel = gtk_widget_get_toplevel (widget);
720 if (gtk_widget_is_toplevel (toplevel))
722 #ifdef GDK_WINDOWING_X11
723 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
725 gtk_window_present (GTK_WINDOW (toplevel));
735 gail_widget_remove_focus_handler (AtkComponent *component,
738 g_signal_handler_disconnect (component, handler_id);
742 gail_widget_set_extents (AtkComponent *component,
747 AtkCoordType coord_type)
749 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
756 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
758 if (gtk_widget_is_toplevel (widget))
760 if (coord_type == ATK_XY_WINDOW)
762 gint x_current, y_current;
763 GdkWindow *window = widget->window;
765 gdk_window_get_origin (window, &x_current, &y_current);
768 if (x_current < 0 || y_current < 0)
772 gtk_window_move (GTK_WINDOW (widget), x_current, y_current);
773 gtk_widget_set_size_request (widget, width, height);
777 else if (coord_type == ATK_XY_SCREEN)
779 gtk_window_move (GTK_WINDOW (widget), x, y);
780 gtk_widget_set_size_request (widget, width, height);
788 gail_widget_set_position (AtkComponent *component,
791 AtkCoordType coord_type)
793 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
800 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
802 if (gtk_widget_is_toplevel (widget))
804 if (coord_type == ATK_XY_WINDOW)
806 gint x_current, y_current;
807 GdkWindow *window = widget->window;
809 gdk_window_get_origin (window, &x_current, &y_current);
812 if (x_current < 0 || y_current < 0)
816 gtk_window_move (GTK_WINDOW (widget), x_current, y_current);
820 else if (coord_type == ATK_XY_SCREEN)
822 gtk_window_move (GTK_WINDOW (widget), x, y);
830 gail_widget_set_size (AtkComponent *component,
834 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
841 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
843 if (gtk_widget_is_toplevel (widget))
845 gtk_widget_set_size_request (widget, width, height);
853 * This function is a signal handler for notify_in_event and focus_out_event
854 * signal which gets emitted on a GtkWidget.
857 gail_widget_focus_gtk (GtkWidget *widget,
858 GdkEventFocus *event)
860 GailWidget *gail_widget;
861 GailWidgetClass *klass;
863 gail_widget = GAIL_WIDGET (gtk_widget_get_accessible (widget));
864 klass = GAIL_WIDGET_GET_CLASS (gail_widget);
865 if (klass->focus_gtk)
866 return klass->focus_gtk (widget, event);
872 * This function is the signal handler defined for focus_in_event and
873 * focus_out_event got GailWidget.
875 * It emits a focus-event signal on the GailWidget.
878 gail_widget_real_focus_gtk (GtkWidget *widget,
879 GdkEventFocus *event)
881 AtkObject* accessible;
885 accessible = gtk_widget_get_accessible (widget);
886 g_signal_emit_by_name (accessible, "focus_event", event->in, &return_val);
891 gail_widget_size_allocate_gtk (GtkWidget *widget,
892 GtkAllocation *allocation)
894 AtkObject* accessible;
897 accessible = gtk_widget_get_accessible (widget);
898 if (ATK_IS_COMPONENT (accessible))
900 rect.x = allocation->x;
901 rect.y = allocation->y;
902 rect.width = allocation->width;
903 rect.height = allocation->height;
904 g_signal_emit_by_name (accessible, "bounds_changed", &rect);
909 * This function is the signal handler defined for map and unmap signals.
912 gail_widget_map_gtk (GtkWidget *widget)
914 AtkObject* accessible;
916 accessible = gtk_widget_get_accessible (widget);
917 atk_object_notify_state_change (accessible, ATK_STATE_SHOWING,
918 gtk_widget_get_mapped (widget));
923 * This function is a signal handler for notify signal which gets emitted
924 * when a property changes value on the GtkWidget associated with the object.
926 * It calls a function for the GailWidget type
929 gail_widget_notify_gtk (GObject *obj,
933 GailWidgetClass *klass;
935 widget = GAIL_WIDGET (gtk_widget_get_accessible (GTK_WIDGET (obj)));
936 klass = GAIL_WIDGET_GET_CLASS (widget);
937 if (klass->notify_gtk)
938 klass->notify_gtk (obj, pspec);
942 * This function is a signal handler for notify signal which gets emitted
943 * when a property changes value on the GtkWidget associated with a GailWidget.
945 * It constructs an AtkPropertyValues structure and emits a "property_changed"
946 * signal which causes the user specified AtkPropertyChangeHandler
950 gail_widget_real_notify_gtk (GObject *obj,
953 GtkWidget* widget = GTK_WIDGET (obj);
954 AtkObject* atk_obj = gtk_widget_get_accessible (widget);
958 if (strcmp (pspec->name, "has-focus") == 0)
960 * We use focus-in-event and focus-out-event signals to catch
961 * focus changes so we ignore this.
964 else if (strcmp (pspec->name, "visible") == 0)
966 state = ATK_STATE_VISIBLE;
967 value = gtk_widget_get_visible (widget);
969 else if (strcmp (pspec->name, "sensitive") == 0)
971 state = ATK_STATE_SENSITIVE;
972 value = gtk_widget_get_sensitive (widget);
977 atk_object_notify_state_change (atk_obj, state, value);
978 if (state == ATK_STATE_SENSITIVE)
979 atk_object_notify_state_change (atk_obj, ATK_STATE_ENABLED, value);
984 gail_widget_focus_event (AtkObject *obj,
987 AtkObject *focus_obj;
989 focus_obj = g_object_get_data (G_OBJECT (obj), "gail-focus-object");
990 if (focus_obj == NULL)
992 atk_object_notify_state_change (focus_obj, ATK_STATE_FOCUSED, focus_in);
996 gail_widget_find_viewport (GtkWidget *widget)
999 * Find an antecedent which is a GtkViewPort
1003 parent = widget->parent;
1004 while (parent != NULL)
1006 if (GTK_IS_VIEWPORT (parent))
1008 parent = parent->parent;
1014 * This function checks whether the widget has an antecedent which is
1015 * a GtkViewport and, if so, whether any part of the widget intersects
1016 * the visible rectangle of the GtkViewport.
1018 static gboolean gail_widget_on_screen (GtkWidget *widget)
1020 GtkWidget *viewport;
1021 gboolean return_value;
1023 viewport = gail_widget_find_viewport (widget);
1026 GtkAdjustment *adjustment;
1027 GdkRectangle visible_rect;
1029 adjustment = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport));
1030 visible_rect.y = adjustment->value;
1031 adjustment = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport));
1032 visible_rect.x = adjustment->value;
1033 visible_rect.width = viewport->allocation.width;
1034 visible_rect.height = viewport->allocation.height;
1036 if (((widget->allocation.x + widget->allocation.width) < visible_rect.x) ||
1037 ((widget->allocation.y + widget->allocation.height) < visible_rect.y) ||
1038 (widget->allocation.x > (visible_rect.x + visible_rect.width)) ||
1039 (widget->allocation.y > (visible_rect.y + visible_rect.height)))
1040 return_value = FALSE;
1042 return_value = TRUE;
1047 * Check whether the widget has been placed of the screen. The
1048 * widget may be MAPPED as when toolbar items do not fit on the toolbar.
1050 if (widget->allocation.x + widget->allocation.width <= 0 &&
1051 widget->allocation.y + widget->allocation.height <= 0)
1052 return_value = FALSE;
1054 return_value = TRUE;
1057 return return_value;
1061 * gail_widget_all_parents_visible:
1062 * @widget: a #GtkWidget
1064 * Checks if all the predecesors (the parent widget, his parent, etc) are visible
1065 * Used to check properly the SHOWING state.
1067 * Return value: TRUE if all the parent hierarchy is visible, FALSE otherwise
1069 static gboolean gail_widget_all_parents_visible (GtkWidget *widget)
1071 GtkWidget *iter_parent = NULL;
1072 gboolean result = TRUE;
1074 for (iter_parent = gtk_widget_get_parent (widget); iter_parent;
1075 iter_parent = gtk_widget_get_parent (iter_parent))
1077 if (!gtk_widget_get_visible (iter_parent))