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.
22 #ifdef GDK_WINDOWING_X11
23 #include <gdk/x11/gdkx.h>
25 #include "gailwidget.h"
26 #include "gailnotebookpage.h"
27 #include "gail-private-macros.h"
29 extern GtkWidget *focus_widget;
31 static void gail_widget_class_init (GailWidgetClass *klass);
32 static void gail_widget_init (GailWidget *accessible);
33 static void gail_widget_connect_widget_destroyed (GtkAccessible *accessible);
34 static void gail_widget_destroyed (GtkWidget *widget,
35 GtkAccessible *accessible);
37 static G_CONST_RETURN gchar* gail_widget_get_description (AtkObject *accessible);
38 static AtkObject* gail_widget_get_parent (AtkObject *accessible);
39 static AtkStateSet* gail_widget_ref_state_set (AtkObject *accessible);
40 static AtkRelationSet* gail_widget_ref_relation_set (AtkObject *accessible);
41 static gint gail_widget_get_index_in_parent (AtkObject *accessible);
43 static void atk_component_interface_init (AtkComponentIface *iface);
45 static guint gail_widget_add_focus_handler
46 (AtkComponent *component,
47 AtkFocusHandler handler);
49 static void gail_widget_get_extents (AtkComponent *component,
54 AtkCoordType coord_type);
56 static void gail_widget_get_size (AtkComponent *component,
60 static AtkLayer gail_widget_get_layer (AtkComponent *component);
62 static gboolean gail_widget_grab_focus (AtkComponent *component);
65 static void gail_widget_remove_focus_handler
66 (AtkComponent *component,
69 static gboolean gail_widget_set_extents (AtkComponent *component,
74 AtkCoordType coord_type);
76 static gboolean gail_widget_set_position (AtkComponent *component,
79 AtkCoordType coord_type);
81 static gboolean gail_widget_set_size (AtkComponent *component,
85 static gint gail_widget_map_gtk (GtkWidget *widget);
86 static void gail_widget_real_notify_gtk (GObject *obj,
88 static void gail_widget_notify_gtk (GObject *obj,
90 static gboolean gail_widget_focus_gtk (GtkWidget *widget,
91 GdkEventFocus *event);
92 static gboolean gail_widget_real_focus_gtk (GtkWidget *widget,
93 GdkEventFocus *event);
94 static void gail_widget_size_allocate_gtk (GtkWidget *widget,
95 GtkAllocation *allocation);
97 static void gail_widget_focus_event (AtkObject *obj,
100 static void gail_widget_real_initialize (AtkObject *obj,
102 static GtkWidget* gail_widget_find_viewport (GtkWidget *widget);
103 static gboolean gail_widget_on_screen (GtkWidget *widget);
105 G_DEFINE_TYPE_WITH_CODE (GailWidget, gail_widget, GTK_TYPE_ACCESSIBLE,
106 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
109 gail_widget_class_init (GailWidgetClass *klass)
111 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
112 GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
114 klass->notify_gtk = gail_widget_real_notify_gtk;
115 klass->focus_gtk = gail_widget_real_focus_gtk;
117 accessible_class->connect_widget_destroyed = gail_widget_connect_widget_destroyed;
119 class->get_description = gail_widget_get_description;
120 class->get_parent = gail_widget_get_parent;
121 class->ref_relation_set = gail_widget_ref_relation_set;
122 class->ref_state_set = gail_widget_ref_state_set;
123 class->get_index_in_parent = gail_widget_get_index_in_parent;
124 class->initialize = gail_widget_real_initialize;
128 gail_widget_init (GailWidget *accessible)
133 * This function specifies the GtkWidget for which the GailWidget was created
134 * and specifies a handler to be called when the GtkWidget is destroyed.
137 gail_widget_real_initialize (AtkObject *obj,
140 GtkAccessible *accessible;
143 g_return_if_fail (GTK_IS_WIDGET (data));
145 widget = GTK_WIDGET (data);
147 accessible = GTK_ACCESSIBLE (obj);
148 accessible->widget = widget;
149 gtk_accessible_connect_widget_destroyed (accessible);
150 g_signal_connect_after (widget,
152 G_CALLBACK (gail_widget_focus_gtk),
154 g_signal_connect_after (widget,
156 G_CALLBACK (gail_widget_focus_gtk),
158 g_signal_connect (widget,
160 G_CALLBACK (gail_widget_notify_gtk),
162 g_signal_connect (widget,
164 G_CALLBACK (gail_widget_size_allocate_gtk),
166 atk_component_add_focus_handler (ATK_COMPONENT (accessible),
167 gail_widget_focus_event);
169 * Add signal handlers for GTK signals required to support property changes
171 g_signal_connect (widget,
173 G_CALLBACK (gail_widget_map_gtk),
175 g_signal_connect (widget,
177 G_CALLBACK (gail_widget_map_gtk),
179 g_object_set_data (G_OBJECT (obj), "atk-component-layer",
180 GINT_TO_POINTER (ATK_LAYER_WIDGET));
182 obj->role = ATK_ROLE_UNKNOWN;
186 gail_widget_new (GtkWidget *widget)
189 AtkObject *accessible;
191 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
193 object = g_object_new (GAIL_TYPE_WIDGET, NULL);
195 accessible = ATK_OBJECT (object);
196 atk_object_initialize (accessible, widget);
202 * This function specifies the function to be called when the widget
206 gail_widget_connect_widget_destroyed (GtkAccessible *accessible)
208 if (accessible->widget)
210 g_signal_connect_after (accessible->widget,
212 G_CALLBACK (gail_widget_destroyed),
218 * This function is called when the widget is destroyed.
219 * It sets the widget field in the GtkAccessible structure to NULL
220 * and emits a state-change signal for the state ATK_STATE_DEFUNCT
223 gail_widget_destroyed (GtkWidget *widget,
224 GtkAccessible *accessible)
226 accessible->widget = NULL;
227 atk_object_notify_state_change (ATK_OBJECT (accessible), ATK_STATE_DEFUNCT,
231 static G_CONST_RETURN gchar*
232 gail_widget_get_description (AtkObject *accessible)
234 if (accessible->description)
235 return accessible->description;
238 /* Get the tooltip from the widget */
239 GtkAccessible *obj = GTK_ACCESSIBLE (accessible);
240 GtkTooltipsData *data;
242 gail_return_val_if_fail (obj, NULL);
244 if (obj->widget == NULL)
250 gail_return_val_if_fail (GTK_WIDGET (obj->widget), NULL);
252 data = gtk_tooltips_data_get (obj->widget);
256 return data->tip_text;
261 gail_widget_get_parent (AtkObject *accessible)
265 parent = accessible->accessible_parent;
268 g_return_val_if_fail (ATK_IS_OBJECT (parent), NULL);
271 GtkWidget *widget, *parent_widget;
273 widget = GTK_ACCESSIBLE (accessible)->widget;
279 gail_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
281 parent_widget = widget->parent;
282 if (parent_widget == NULL)
286 * For a widget whose parent is a GtkNoteBook, we return the
287 * accessible object corresponding the GtkNotebookPage containing
288 * the widget as the accessible parent.
290 if (GTK_IS_NOTEBOOK (parent_widget))
294 GtkNotebook *notebook;
297 notebook = GTK_NOTEBOOK (parent_widget);
300 child = gtk_notebook_get_nth_page (notebook, page_num);
305 parent = gtk_widget_get_accessible (parent_widget);
306 parent = atk_object_ref_accessible_child (parent, page_num);
307 g_object_unref (parent);
314 parent = gtk_widget_get_accessible (parent_widget);
320 find_label (GtkWidget *widget)
324 GtkWidget *temp_widget;
326 labels = gtk_widget_list_mnemonic_labels (widget);
334 g_warning ("Widget (%s) has more than one label", G_OBJECT_TYPE_NAME (widget));
339 label = labels->data;
342 g_list_free (labels);
346 * Ignore a label within a button; bug #136602
348 if (label && GTK_IS_BUTTON (widget))
353 if (temp_widget == widget)
358 temp_widget = gtk_widget_get_parent (temp_widget);
364 static AtkRelationSet*
365 gail_widget_ref_relation_set (AtkObject *obj)
368 AtkRelationSet *relation_set;
371 AtkRelation* relation;
373 gail_return_val_if_fail (GAIL_IS_WIDGET (obj), NULL);
375 widget = GTK_ACCESSIBLE (obj)->widget;
382 relation_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_relation_set (obj);
384 if (GTK_IS_BOX (widget) && !GTK_IS_COMBO (widget))
386 * Do not report labelled-by for a GtkBox which could be a
391 if (!atk_relation_set_contains (relation_set, ATK_RELATION_LABELLED_BY))
393 label = find_label (widget);
396 if (GTK_IS_BUTTON (widget))
398 * Handle the case where GnomeIconEntry is the mnemonic widget.
399 * The GtkButton which is a grandchild of the GnomeIconEntry
400 * should really be the mnemonic widget. See bug #133967.
403 GtkWidget *temp_widget;
405 temp_widget = gtk_widget_get_parent (widget);
407 if (GTK_IS_ALIGNMENT (temp_widget))
409 temp_widget = gtk_widget_get_parent (temp_widget);
410 if (GTK_IS_BOX (temp_widget))
412 label = find_label (temp_widget);
415 label = find_label (gtk_widget_get_parent (temp_widget));
419 else if (GTK_IS_COMBO (widget))
421 * Handle the case when GnomeFileEntry is the mnemonic widget.
422 * The GnomeEntry which is a grandchild of the GnomeFileEntry
423 * should be the mnemonic widget. See bug #137584.
426 GtkWidget *temp_widget;
428 temp_widget = gtk_widget_get_parent (widget);
430 if (GTK_IS_HBOX (temp_widget))
432 temp_widget = gtk_widget_get_parent (temp_widget);
433 if (GTK_IS_BOX (temp_widget))
435 label = find_label (temp_widget);
439 else if (GTK_IS_COMBO_BOX (widget))
441 * Handle the case when GtkFileChooserButton is the mnemonic
442 * widget. The GtkComboBox which is a child of the
443 * GtkFileChooserButton should be the mnemonic widget.
447 GtkWidget *temp_widget;
449 temp_widget = gtk_widget_get_parent (widget);
450 if (GTK_IS_HBOX (temp_widget))
452 label = find_label (temp_widget);
459 array [0] = gtk_widget_get_accessible (label);
461 relation = atk_relation_new (array, 1, ATK_RELATION_LABELLED_BY);
462 atk_relation_set_add (relation_set, relation);
463 g_object_unref (relation);
471 gail_widget_ref_state_set (AtkObject *accessible)
473 GtkWidget *widget = GTK_ACCESSIBLE (accessible)->widget;
474 AtkStateSet *state_set;
476 state_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_state_set (accessible);
480 atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
484 if (GTK_WIDGET_IS_SENSITIVE (widget))
486 atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
487 atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
490 if (GTK_WIDGET_CAN_FOCUS (widget))
492 atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
495 * We do not currently generate notifications when an ATK object
496 * corresponding to a GtkWidget changes visibility by being scrolled
497 * on or off the screen. The testcase for this is the main window
498 * of the testgtk application in which a set of buttons in a GtkVBox
499 * is in a scrooled window with a viewport.
501 * To generate the notifications we would need to do the following:
502 * 1) Find the GtkViewPort among the antecendents of the objects
503 * 2) Create an accesible for the GtkViewPort
504 * 3) Connect to the value-changed signal on the viewport
505 * 4) When the signal is received we need to traverse the children
506 * of the viewport and check whether the children are visible or not
507 * visible; we may want to restrict this to the widgets for which
508 * accessible objects have been created.
509 * 5) We probably need to store a variable on_screen in the
510 * GailWidget data structure so we can determine whether the value has
513 if (GTK_WIDGET_VISIBLE (widget))
515 atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
516 if (gail_widget_on_screen (widget) &&
517 GTK_WIDGET_MAPPED (widget))
519 atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
523 if (GTK_WIDGET_HAS_FOCUS (widget) && (widget == focus_widget))
525 AtkObject *focus_obj;
527 focus_obj = g_object_get_data (G_OBJECT (accessible), "gail-focus-object");
528 if (focus_obj == NULL)
529 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
531 if (GTK_WIDGET_HAS_DEFAULT(widget))
533 atk_state_set_add_state (state_set, ATK_STATE_DEFAULT);
540 gail_widget_get_index_in_parent (AtkObject *accessible)
543 GtkWidget *parent_widget;
548 type = g_type_from_name ("GailCanvasWidget");
549 widget = GTK_ACCESSIBLE (accessible)->widget;
557 if (accessible->accessible_parent)
561 parent = accessible->accessible_parent;
563 if (GAIL_IS_NOTEBOOK_PAGE (parent) ||
564 G_TYPE_CHECK_INSTANCE_TYPE ((parent), type))
569 gboolean found = FALSE;
571 n_children = atk_object_get_n_accessible_children (parent);
572 for (i = 0; i < n_children; i++)
576 child = atk_object_ref_accessible_child (parent, i);
577 if (child == accessible)
580 g_object_unref (child);
587 gail_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
588 parent_widget = widget->parent;
589 if (parent_widget == NULL)
591 gail_return_val_if_fail (GTK_IS_CONTAINER (parent_widget), -1);
593 children = gtk_container_get_children (GTK_CONTAINER (parent_widget));
595 index = g_list_index (children, widget);
596 g_list_free (children);
601 atk_component_interface_init (AtkComponentIface *iface)
604 * Use default implementation for contains and get_position
606 iface->add_focus_handler = gail_widget_add_focus_handler;
607 iface->get_extents = gail_widget_get_extents;
608 iface->get_size = gail_widget_get_size;
609 iface->get_layer = gail_widget_get_layer;
610 iface->grab_focus = gail_widget_grab_focus;
611 iface->remove_focus_handler = gail_widget_remove_focus_handler;
612 iface->set_extents = gail_widget_set_extents;
613 iface->set_position = gail_widget_set_position;
614 iface->set_size = gail_widget_set_size;
618 gail_widget_add_focus_handler (AtkComponent *component,
619 AtkFocusHandler handler)
621 GSignalMatchType match_type;
625 match_type = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC;
626 signal_id = g_signal_lookup ("focus-event", ATK_TYPE_OBJECT);
628 ret = g_signal_handler_find (component, match_type, signal_id, 0, NULL,
629 (gpointer) handler, NULL);
632 return g_signal_connect_closure_by_id (component,
635 G_CALLBACK (handler), NULL,
636 (GClosureNotify) NULL),
646 gail_widget_get_extents (AtkComponent *component,
651 AtkCoordType coord_type)
654 gint x_window, y_window;
655 gint x_toplevel, y_toplevel;
656 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
664 gail_return_if_fail (GTK_IS_WIDGET (widget));
666 *width = widget->allocation.width;
667 *height = widget->allocation.height;
668 if (!gail_widget_on_screen (widget) || (!GTK_WIDGET_DRAWABLE (widget)))
677 *x = widget->allocation.x;
678 *y = widget->allocation.y;
679 window = gtk_widget_get_parent_window (widget);
685 window = widget->window;
687 gdk_window_get_origin (window, &x_window, &y_window);
692 if (coord_type == ATK_XY_WINDOW)
694 window = gdk_window_get_toplevel (widget->window);
695 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
703 gail_widget_get_size (AtkComponent *component,
707 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
715 gail_return_if_fail (GTK_IS_WIDGET (widget));
717 *width = widget->allocation.width;
718 *height = widget->allocation.height;
722 gail_widget_get_layer (AtkComponent *component)
725 layer = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (component), "atk-component-layer"));
727 return (AtkLayer) layer;
731 gail_widget_grab_focus (AtkComponent *component)
733 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
736 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
737 if (GTK_WIDGET_CAN_FOCUS (widget))
739 gtk_widget_grab_focus (widget);
740 toplevel = gtk_widget_get_toplevel (widget);
741 if (GTK_WIDGET_TOPLEVEL (toplevel))
743 #ifdef GDK_WINDOWING_X11
744 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
746 gtk_window_present (GTK_WINDOW (toplevel));
756 gail_widget_remove_focus_handler (AtkComponent *component,
759 g_signal_handler_disconnect (component, handler_id);
763 gail_widget_set_extents (AtkComponent *component,
768 AtkCoordType coord_type)
770 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
777 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
779 if (GTK_WIDGET_TOPLEVEL (widget))
781 if (coord_type == ATK_XY_WINDOW)
783 gint x_current, y_current;
784 GdkWindow *window = widget->window;
786 gdk_window_get_origin (window, &x_current, &y_current);
789 if (x_current < 0 || y_current < 0)
793 gtk_widget_set_uposition (widget, x_current, y_current);
794 gtk_widget_set_usize (widget, width, height);
798 else if (coord_type == ATK_XY_SCREEN)
800 gtk_widget_set_uposition (widget, x, y);
801 gtk_widget_set_usize (widget, width, height);
809 gail_widget_set_position (AtkComponent *component,
812 AtkCoordType coord_type)
814 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
821 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
823 if (GTK_WIDGET_TOPLEVEL (widget))
825 if (coord_type == ATK_XY_WINDOW)
827 gint x_current, y_current;
828 GdkWindow *window = widget->window;
830 gdk_window_get_origin (window, &x_current, &y_current);
833 if (x_current < 0 || y_current < 0)
837 gtk_widget_set_uposition (widget, x_current, y_current);
841 else if (coord_type == ATK_XY_SCREEN)
843 gtk_widget_set_uposition (widget, x, y);
851 gail_widget_set_size (AtkComponent *component,
855 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
862 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
864 if (GTK_WIDGET_TOPLEVEL (widget))
866 gtk_widget_set_usize (widget, width, height);
874 * This function is a signal handler for notify_in_event and focus_out_event
875 * signal which gets emitted on a GtkWidget.
878 gail_widget_focus_gtk (GtkWidget *widget,
879 GdkEventFocus *event)
881 GailWidget *gail_widget;
882 GailWidgetClass *klass;
884 gail_widget = GAIL_WIDGET (gtk_widget_get_accessible (widget));
885 klass = GAIL_WIDGET_GET_CLASS (gail_widget);
886 if (klass->focus_gtk)
887 return klass->focus_gtk (widget, event);
893 * This function is the signal handler defined for focus_in_event and
894 * focus_out_event got GailWidget.
896 * It emits a focus-event signal on the GailWidget.
899 gail_widget_real_focus_gtk (GtkWidget *widget,
900 GdkEventFocus *event)
902 AtkObject* accessible;
906 accessible = gtk_widget_get_accessible (widget);
907 g_signal_emit_by_name (accessible, "focus_event", event->in, &return_val);
912 gail_widget_size_allocate_gtk (GtkWidget *widget,
913 GtkAllocation *allocation)
915 AtkObject* accessible;
918 accessible = gtk_widget_get_accessible (widget);
919 if (ATK_IS_COMPONENT (accessible))
921 rect.x = allocation->x;
922 rect.y = allocation->y;
923 rect.width = allocation->width;
924 rect.height = allocation->height;
925 g_signal_emit_by_name (accessible, "bounds_changed", &rect);
930 * This function is the signal handler defined for map and unmap signals.
933 gail_widget_map_gtk (GtkWidget *widget)
935 AtkObject* accessible;
937 accessible = gtk_widget_get_accessible (widget);
938 atk_object_notify_state_change (accessible, ATK_STATE_SHOWING,
939 GTK_WIDGET_MAPPED (widget));
944 * This function is a signal handler for notify signal which gets emitted
945 * when a property changes value on the GtkWidget associated with the object.
947 * It calls a function for the GailWidget type
950 gail_widget_notify_gtk (GObject *obj,
954 GailWidgetClass *klass;
956 widget = GAIL_WIDGET (gtk_widget_get_accessible (GTK_WIDGET (obj)));
957 klass = GAIL_WIDGET_GET_CLASS (widget);
958 if (klass->notify_gtk)
959 klass->notify_gtk (obj, pspec);
963 * This function is a signal handler for notify signal which gets emitted
964 * when a property changes value on the GtkWidget associated with a GailWidget.
966 * It constructs an AtkPropertyValues structure and emits a "property_changed"
967 * signal which causes the user specified AtkPropertyChangeHandler
971 gail_widget_real_notify_gtk (GObject *obj,
974 GtkWidget* widget = GTK_WIDGET (obj);
975 AtkObject* atk_obj = gtk_widget_get_accessible (widget);
979 if (strcmp (pspec->name, "has-focus") == 0)
981 * We use focus-in-event and focus-out-event signals to catch
982 * focus changes so we ignore this.
985 else if (strcmp (pspec->name, "visible") == 0)
987 state = ATK_STATE_VISIBLE;
988 value = GTK_WIDGET_VISIBLE (widget);
990 else if (strcmp (pspec->name, "sensitive") == 0)
992 state = ATK_STATE_SENSITIVE;
993 value = GTK_WIDGET_SENSITIVE (widget);
998 atk_object_notify_state_change (atk_obj, state, value);
1002 gail_widget_focus_event (AtkObject *obj,
1005 AtkObject *focus_obj;
1007 focus_obj = g_object_get_data (G_OBJECT (obj), "gail-focus-object");
1008 if (focus_obj == NULL)
1010 atk_object_notify_state_change (focus_obj, ATK_STATE_FOCUSED, focus_in);
1014 gail_widget_find_viewport (GtkWidget *widget)
1017 * Find an antecedent which is a GtkViewPort
1021 parent = widget->parent;
1022 while (parent != NULL)
1024 if (GTK_IS_VIEWPORT (parent))
1026 parent = parent->parent;
1032 * This function checks whether the widget has an antecedent which is
1033 * a GtkViewport and, if so, whether any part of the widget intersects
1034 * the visible rectangle of the GtkViewport.
1036 static gboolean gail_widget_on_screen (GtkWidget *widget)
1038 GtkWidget *viewport;
1039 gboolean return_value;
1041 viewport = gail_widget_find_viewport (widget);
1044 GtkAdjustment *adjustment;
1045 GdkRectangle visible_rect;
1047 adjustment = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport));
1048 visible_rect.y = adjustment->value;
1049 adjustment = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport));
1050 visible_rect.x = adjustment->value;
1051 visible_rect.width = viewport->allocation.width;
1052 visible_rect.height = viewport->allocation.height;
1054 if (((widget->allocation.x + widget->allocation.width) < visible_rect.x) ||
1055 ((widget->allocation.y + widget->allocation.height) < visible_rect.y) ||
1056 (widget->allocation.x > (visible_rect.x + visible_rect.width)) ||
1057 (widget->allocation.y > (visible_rect.y + visible_rect.height)))
1058 return_value = FALSE;
1060 return_value = TRUE;
1065 * Check whether the widget has been placed of the screen. The
1066 * widget may be MAPPED as when toolbar items do not fit on the toolbar.
1068 if (widget->allocation.x + widget->allocation.width <= 0 &&
1069 widget->allocation.y + widget->allocation.height <= 0)
1070 return_value = FALSE;
1072 return_value = TRUE;
1075 return return_value;