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.
24 #ifdef GDK_WINDOWING_X11
25 #include <gdk/x11/gdkx.h>
27 #include "gailwidget.h"
28 #include "gailnotebookpage.h"
29 #include "gail-private-macros.h"
31 extern GtkWidget *focus_widget;
33 static void gail_widget_class_init (GailWidgetClass *klass);
34 static void gail_widget_init (GailWidget *accessible);
35 static void gail_widget_connect_widget_destroyed (GtkAccessible *accessible);
36 static void gail_widget_destroyed (GtkWidget *widget,
37 GtkAccessible *accessible);
39 static G_CONST_RETURN gchar* gail_widget_get_description (AtkObject *accessible);
40 static AtkObject* gail_widget_get_parent (AtkObject *accessible);
41 static AtkStateSet* gail_widget_ref_state_set (AtkObject *accessible);
42 static AtkRelationSet* gail_widget_ref_relation_set (AtkObject *accessible);
43 static gint gail_widget_get_index_in_parent (AtkObject *accessible);
45 static void atk_component_interface_init (AtkComponentIface *iface);
47 static guint gail_widget_add_focus_handler
48 (AtkComponent *component,
49 AtkFocusHandler handler);
51 static void gail_widget_get_extents (AtkComponent *component,
56 AtkCoordType coord_type);
58 static void gail_widget_get_size (AtkComponent *component,
62 static AtkLayer gail_widget_get_layer (AtkComponent *component);
64 static gboolean gail_widget_grab_focus (AtkComponent *component);
67 static void gail_widget_remove_focus_handler
68 (AtkComponent *component,
71 static gboolean gail_widget_set_extents (AtkComponent *component,
76 AtkCoordType coord_type);
78 static gboolean gail_widget_set_position (AtkComponent *component,
81 AtkCoordType coord_type);
83 static gboolean gail_widget_set_size (AtkComponent *component,
87 static gint gail_widget_map_gtk (GtkWidget *widget);
88 static void gail_widget_real_notify_gtk (GObject *obj,
90 static void gail_widget_notify_gtk (GObject *obj,
92 static gboolean gail_widget_focus_gtk (GtkWidget *widget,
93 GdkEventFocus *event);
94 static gboolean gail_widget_real_focus_gtk (GtkWidget *widget,
95 GdkEventFocus *event);
96 static void gail_widget_size_allocate_gtk (GtkWidget *widget,
97 GtkAllocation *allocation);
99 static void gail_widget_focus_event (AtkObject *obj,
102 static void gail_widget_real_initialize (AtkObject *obj,
104 static GtkWidget* gail_widget_find_viewport (GtkWidget *widget);
105 static gboolean gail_widget_on_screen (GtkWidget *widget);
107 G_DEFINE_TYPE_WITH_CODE (GailWidget, gail_widget, GTK_TYPE_ACCESSIBLE,
108 G_IMPLEMENT_INTERFACE (ATK_TYPE_COMPONENT, atk_component_interface_init))
111 gail_widget_class_init (GailWidgetClass *klass)
113 AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
114 GtkAccessibleClass *accessible_class = GTK_ACCESSIBLE_CLASS (klass);
116 klass->notify_gtk = gail_widget_real_notify_gtk;
117 klass->focus_gtk = gail_widget_real_focus_gtk;
119 accessible_class->connect_widget_destroyed = gail_widget_connect_widget_destroyed;
121 class->get_description = gail_widget_get_description;
122 class->get_parent = gail_widget_get_parent;
123 class->ref_relation_set = gail_widget_ref_relation_set;
124 class->ref_state_set = gail_widget_ref_state_set;
125 class->get_index_in_parent = gail_widget_get_index_in_parent;
126 class->initialize = gail_widget_real_initialize;
130 gail_widget_init (GailWidget *accessible)
135 * This function specifies the GtkWidget for which the GailWidget was created
136 * and specifies a handler to be called when the GtkWidget is destroyed.
139 gail_widget_real_initialize (AtkObject *obj,
142 GtkAccessible *accessible;
145 g_return_if_fail (GTK_IS_WIDGET (data));
147 widget = GTK_WIDGET (data);
149 accessible = GTK_ACCESSIBLE (obj);
150 accessible->widget = widget;
151 gtk_accessible_connect_widget_destroyed (accessible);
152 g_signal_connect_after (widget,
154 G_CALLBACK (gail_widget_focus_gtk),
156 g_signal_connect_after (widget,
158 G_CALLBACK (gail_widget_focus_gtk),
160 g_signal_connect (widget,
162 G_CALLBACK (gail_widget_notify_gtk),
164 g_signal_connect (widget,
166 G_CALLBACK (gail_widget_size_allocate_gtk),
168 atk_component_add_focus_handler (ATK_COMPONENT (accessible),
169 gail_widget_focus_event);
171 * Add signal handlers for GTK signals required to support property changes
173 g_signal_connect (widget,
175 G_CALLBACK (gail_widget_map_gtk),
177 g_signal_connect (widget,
179 G_CALLBACK (gail_widget_map_gtk),
181 g_object_set_data (G_OBJECT (obj), "atk-component-layer",
182 GINT_TO_POINTER (ATK_LAYER_WIDGET));
184 obj->role = ATK_ROLE_UNKNOWN;
188 gail_widget_new (GtkWidget *widget)
191 AtkObject *accessible;
193 g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
195 object = g_object_new (GAIL_TYPE_WIDGET, NULL);
197 accessible = ATK_OBJECT (object);
198 atk_object_initialize (accessible, widget);
204 * This function specifies the function to be called when the widget
208 gail_widget_connect_widget_destroyed (GtkAccessible *accessible)
210 if (accessible->widget)
212 g_signal_connect_after (accessible->widget,
214 G_CALLBACK (gail_widget_destroyed),
220 * This function is called when the widget is destroyed.
221 * It sets the widget field in the GtkAccessible structure to NULL
222 * and emits a state-change signal for the state ATK_STATE_DEFUNCT
225 gail_widget_destroyed (GtkWidget *widget,
226 GtkAccessible *accessible)
228 accessible->widget = NULL;
229 atk_object_notify_state_change (ATK_OBJECT (accessible), ATK_STATE_DEFUNCT,
233 static G_CONST_RETURN gchar*
234 gail_widget_get_description (AtkObject *accessible)
236 if (accessible->description)
237 return accessible->description;
240 /* Get the tooltip from the widget */
241 GtkAccessible *obj = GTK_ACCESSIBLE (accessible);
242 GtkTooltipsData *data;
244 gail_return_val_if_fail (obj, NULL);
246 if (obj->widget == NULL)
252 gail_return_val_if_fail (GTK_WIDGET (obj->widget), NULL);
254 data = gtk_tooltips_data_get (obj->widget);
258 return data->tip_text;
263 gail_widget_get_parent (AtkObject *accessible)
267 parent = accessible->accessible_parent;
270 g_return_val_if_fail (ATK_IS_OBJECT (parent), NULL);
273 GtkWidget *widget, *parent_widget;
275 widget = GTK_ACCESSIBLE (accessible)->widget;
281 gail_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
283 parent_widget = widget->parent;
284 if (parent_widget == NULL)
288 * For a widget whose parent is a GtkNoteBook, we return the
289 * accessible object corresponding the GtkNotebookPage containing
290 * the widget as the accessible parent.
292 if (GTK_IS_NOTEBOOK (parent_widget))
296 GtkNotebook *notebook;
299 notebook = GTK_NOTEBOOK (parent_widget);
302 child = gtk_notebook_get_nth_page (notebook, page_num);
307 parent = gtk_widget_get_accessible (parent_widget);
308 parent = atk_object_ref_accessible_child (parent, page_num);
309 g_object_unref (parent);
316 parent = gtk_widget_get_accessible (parent_widget);
322 find_label (GtkWidget *widget)
326 GtkWidget *temp_widget;
328 labels = gtk_widget_list_mnemonic_labels (widget);
336 g_warning ("Widget (%s) has more than one label", G_OBJECT_TYPE_NAME (widget));
341 label = labels->data;
344 g_list_free (labels);
348 * Ignore a label within a button; bug #136602
350 if (label && GTK_IS_BUTTON (widget))
355 if (temp_widget == widget)
360 temp_widget = gtk_widget_get_parent (temp_widget);
366 static AtkRelationSet*
367 gail_widget_ref_relation_set (AtkObject *obj)
370 AtkRelationSet *relation_set;
373 AtkRelation* relation;
375 gail_return_val_if_fail (GAIL_IS_WIDGET (obj), NULL);
377 widget = GTK_ACCESSIBLE (obj)->widget;
384 relation_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_relation_set (obj);
386 if (GTK_IS_BOX (widget) && !GTK_IS_COMBO (widget))
388 * Do not report labelled-by for a GtkBox which could be a
393 if (!atk_relation_set_contains (relation_set, ATK_RELATION_LABELLED_BY))
395 label = find_label (widget);
398 if (GTK_IS_BUTTON (widget))
400 * Handle the case where GnomeIconEntry is the mnemonic widget.
401 * The GtkButton which is a grandchild of the GnomeIconEntry
402 * should really be the mnemonic widget. See bug #133967.
405 GtkWidget *temp_widget;
407 temp_widget = gtk_widget_get_parent (widget);
409 if (GTK_IS_ALIGNMENT (temp_widget))
411 temp_widget = gtk_widget_get_parent (temp_widget);
412 if (GTK_IS_BOX (temp_widget))
414 label = find_label (temp_widget);
417 label = find_label (gtk_widget_get_parent (temp_widget));
421 else if (GTK_IS_COMBO (widget))
423 * Handle the case when GnomeFileEntry is the mnemonic widget.
424 * The GnomeEntry which is a grandchild of the GnomeFileEntry
425 * should be the mnemonic widget. See bug #137584.
428 GtkWidget *temp_widget;
430 temp_widget = gtk_widget_get_parent (widget);
432 if (GTK_IS_HBOX (temp_widget))
434 temp_widget = gtk_widget_get_parent (temp_widget);
435 if (GTK_IS_BOX (temp_widget))
437 label = find_label (temp_widget);
441 else if (GTK_IS_COMBO_BOX (widget))
443 * Handle the case when GtkFileChooserButton is the mnemonic
444 * widget. The GtkComboBox which is a child of the
445 * GtkFileChooserButton should be the mnemonic widget.
449 GtkWidget *temp_widget;
451 temp_widget = gtk_widget_get_parent (widget);
452 if (GTK_IS_HBOX (temp_widget))
454 label = find_label (temp_widget);
461 array [0] = gtk_widget_get_accessible (label);
463 relation = atk_relation_new (array, 1, ATK_RELATION_LABELLED_BY);
464 atk_relation_set_add (relation_set, relation);
465 g_object_unref (relation);
473 gail_widget_ref_state_set (AtkObject *accessible)
475 GtkWidget *widget = GTK_ACCESSIBLE (accessible)->widget;
476 AtkStateSet *state_set;
478 state_set = ATK_OBJECT_CLASS (gail_widget_parent_class)->ref_state_set (accessible);
482 atk_state_set_add_state (state_set, ATK_STATE_DEFUNCT);
486 if (GTK_WIDGET_IS_SENSITIVE (widget))
488 atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
489 atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
492 if (GTK_WIDGET_CAN_FOCUS (widget))
494 atk_state_set_add_state (state_set, ATK_STATE_FOCUSABLE);
497 * We do not currently generate notifications when an ATK object
498 * corresponding to a GtkWidget changes visibility by being scrolled
499 * on or off the screen. The testcase for this is the main window
500 * of the testgtk application in which a set of buttons in a GtkVBox
501 * is in a scrooled window with a viewport.
503 * To generate the notifications we would need to do the following:
504 * 1) Find the GtkViewPort among the antecendents of the objects
505 * 2) Create an accesible for the GtkViewPort
506 * 3) Connect to the value-changed signal on the viewport
507 * 4) When the signal is received we need to traverse the children
508 * of the viewport and check whether the children are visible or not
509 * visible; we may want to restrict this to the widgets for which
510 * accessible objects have been created.
511 * 5) We probably need to store a variable on_screen in the
512 * GailWidget data structure so we can determine whether the value has
515 if (GTK_WIDGET_VISIBLE (widget))
517 atk_state_set_add_state (state_set, ATK_STATE_VISIBLE);
518 if (gail_widget_on_screen (widget) &&
519 GTK_WIDGET_MAPPED (widget))
521 atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
525 if (GTK_WIDGET_HAS_FOCUS (widget) && (widget == focus_widget))
527 AtkObject *focus_obj;
529 focus_obj = g_object_get_data (G_OBJECT (accessible), "gail-focus-object");
530 if (focus_obj == NULL)
531 atk_state_set_add_state (state_set, ATK_STATE_FOCUSED);
533 if (GTK_WIDGET_HAS_DEFAULT(widget))
535 atk_state_set_add_state (state_set, ATK_STATE_DEFAULT);
542 gail_widget_get_index_in_parent (AtkObject *accessible)
545 GtkWidget *parent_widget;
550 type = g_type_from_name ("GailCanvasWidget");
551 widget = GTK_ACCESSIBLE (accessible)->widget;
559 if (accessible->accessible_parent)
563 parent = accessible->accessible_parent;
565 if (GAIL_IS_NOTEBOOK_PAGE (parent) ||
566 G_TYPE_CHECK_INSTANCE_TYPE ((parent), type))
571 gboolean found = FALSE;
573 n_children = atk_object_get_n_accessible_children (parent);
574 for (i = 0; i < n_children; i++)
578 child = atk_object_ref_accessible_child (parent, i);
579 if (child == accessible)
582 g_object_unref (child);
589 gail_return_val_if_fail (GTK_IS_WIDGET (widget), -1);
590 parent_widget = widget->parent;
591 if (parent_widget == NULL)
593 gail_return_val_if_fail (GTK_IS_CONTAINER (parent_widget), -1);
595 children = gtk_container_get_children (GTK_CONTAINER (parent_widget));
597 index = g_list_index (children, widget);
598 g_list_free (children);
603 atk_component_interface_init (AtkComponentIface *iface)
606 * Use default implementation for contains and get_position
608 iface->add_focus_handler = gail_widget_add_focus_handler;
609 iface->get_extents = gail_widget_get_extents;
610 iface->get_size = gail_widget_get_size;
611 iface->get_layer = gail_widget_get_layer;
612 iface->grab_focus = gail_widget_grab_focus;
613 iface->remove_focus_handler = gail_widget_remove_focus_handler;
614 iface->set_extents = gail_widget_set_extents;
615 iface->set_position = gail_widget_set_position;
616 iface->set_size = gail_widget_set_size;
620 gail_widget_add_focus_handler (AtkComponent *component,
621 AtkFocusHandler handler)
623 GSignalMatchType match_type;
627 match_type = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC;
628 signal_id = g_signal_lookup ("focus-event", ATK_TYPE_OBJECT);
630 ret = g_signal_handler_find (component, match_type, signal_id, 0, NULL,
631 (gpointer) handler, NULL);
634 return g_signal_connect_closure_by_id (component,
637 G_CALLBACK (handler), NULL,
638 (GClosureNotify) NULL),
648 gail_widget_get_extents (AtkComponent *component,
653 AtkCoordType coord_type)
656 gint x_window, y_window;
657 gint x_toplevel, y_toplevel;
658 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
666 gail_return_if_fail (GTK_IS_WIDGET (widget));
668 *width = widget->allocation.width;
669 *height = widget->allocation.height;
670 if (!gail_widget_on_screen (widget) || (!GTK_WIDGET_DRAWABLE (widget)))
679 *x = widget->allocation.x;
680 *y = widget->allocation.y;
681 window = gtk_widget_get_parent_window (widget);
687 window = widget->window;
689 gdk_window_get_origin (window, &x_window, &y_window);
694 if (coord_type == ATK_XY_WINDOW)
696 window = gdk_window_get_toplevel (widget->window);
697 gdk_window_get_origin (window, &x_toplevel, &y_toplevel);
705 gail_widget_get_size (AtkComponent *component,
709 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
717 gail_return_if_fail (GTK_IS_WIDGET (widget));
719 *width = widget->allocation.width;
720 *height = widget->allocation.height;
724 gail_widget_get_layer (AtkComponent *component)
727 layer = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (component), "atk-component-layer"));
729 return (AtkLayer) layer;
733 gail_widget_grab_focus (AtkComponent *component)
735 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
738 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
739 if (GTK_WIDGET_CAN_FOCUS (widget))
741 gtk_widget_grab_focus (widget);
742 toplevel = gtk_widget_get_toplevel (widget);
743 if (GTK_WIDGET_TOPLEVEL (toplevel))
745 #ifdef GDK_WINDOWING_X11
746 gtk_window_present_with_time (GTK_WINDOW (toplevel), gdk_x11_get_server_time (widget->window));
748 gtk_window_present (GTK_WINDOW (toplevel));
758 gail_widget_remove_focus_handler (AtkComponent *component,
761 g_signal_handler_disconnect (component, handler_id);
765 gail_widget_set_extents (AtkComponent *component,
770 AtkCoordType coord_type)
772 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
779 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
781 if (GTK_WIDGET_TOPLEVEL (widget))
783 if (coord_type == ATK_XY_WINDOW)
785 gint x_current, y_current;
786 GdkWindow *window = widget->window;
788 gdk_window_get_origin (window, &x_current, &y_current);
791 if (x_current < 0 || y_current < 0)
795 gtk_widget_set_uposition (widget, x_current, y_current);
796 gtk_widget_set_usize (widget, width, height);
800 else if (coord_type == ATK_XY_SCREEN)
802 gtk_widget_set_uposition (widget, x, y);
803 gtk_widget_set_usize (widget, width, height);
811 gail_widget_set_position (AtkComponent *component,
814 AtkCoordType coord_type)
816 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
823 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
825 if (GTK_WIDGET_TOPLEVEL (widget))
827 if (coord_type == ATK_XY_WINDOW)
829 gint x_current, y_current;
830 GdkWindow *window = widget->window;
832 gdk_window_get_origin (window, &x_current, &y_current);
835 if (x_current < 0 || y_current < 0)
839 gtk_widget_set_uposition (widget, x_current, y_current);
843 else if (coord_type == ATK_XY_SCREEN)
845 gtk_widget_set_uposition (widget, x, y);
853 gail_widget_set_size (AtkComponent *component,
857 GtkWidget *widget = GTK_ACCESSIBLE (component)->widget;
864 gail_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
866 if (GTK_WIDGET_TOPLEVEL (widget))
868 gtk_widget_set_usize (widget, width, height);
876 * This function is a signal handler for notify_in_event and focus_out_event
877 * signal which gets emitted on a GtkWidget.
880 gail_widget_focus_gtk (GtkWidget *widget,
881 GdkEventFocus *event)
883 GailWidget *gail_widget;
884 GailWidgetClass *klass;
886 gail_widget = GAIL_WIDGET (gtk_widget_get_accessible (widget));
887 klass = GAIL_WIDGET_GET_CLASS (gail_widget);
888 if (klass->focus_gtk)
889 return klass->focus_gtk (widget, event);
895 * This function is the signal handler defined for focus_in_event and
896 * focus_out_event got GailWidget.
898 * It emits a focus-event signal on the GailWidget.
901 gail_widget_real_focus_gtk (GtkWidget *widget,
902 GdkEventFocus *event)
904 AtkObject* accessible;
908 accessible = gtk_widget_get_accessible (widget);
909 g_signal_emit_by_name (accessible, "focus_event", event->in, &return_val);
914 gail_widget_size_allocate_gtk (GtkWidget *widget,
915 GtkAllocation *allocation)
917 AtkObject* accessible;
920 accessible = gtk_widget_get_accessible (widget);
921 if (ATK_IS_COMPONENT (accessible))
923 rect.x = allocation->x;
924 rect.y = allocation->y;
925 rect.width = allocation->width;
926 rect.height = allocation->height;
927 g_signal_emit_by_name (accessible, "bounds_changed", &rect);
932 * This function is the signal handler defined for map and unmap signals.
935 gail_widget_map_gtk (GtkWidget *widget)
937 AtkObject* accessible;
939 accessible = gtk_widget_get_accessible (widget);
940 atk_object_notify_state_change (accessible, ATK_STATE_SHOWING,
941 GTK_WIDGET_MAPPED (widget));
946 * This function is a signal handler for notify signal which gets emitted
947 * when a property changes value on the GtkWidget associated with the object.
949 * It calls a function for the GailWidget type
952 gail_widget_notify_gtk (GObject *obj,
956 GailWidgetClass *klass;
958 widget = GAIL_WIDGET (gtk_widget_get_accessible (GTK_WIDGET (obj)));
959 klass = GAIL_WIDGET_GET_CLASS (widget);
960 if (klass->notify_gtk)
961 klass->notify_gtk (obj, pspec);
965 * This function is a signal handler for notify signal which gets emitted
966 * when a property changes value on the GtkWidget associated with a GailWidget.
968 * It constructs an AtkPropertyValues structure and emits a "property_changed"
969 * signal which causes the user specified AtkPropertyChangeHandler
973 gail_widget_real_notify_gtk (GObject *obj,
976 GtkWidget* widget = GTK_WIDGET (obj);
977 AtkObject* atk_obj = gtk_widget_get_accessible (widget);
981 if (strcmp (pspec->name, "has-focus") == 0)
983 * We use focus-in-event and focus-out-event signals to catch
984 * focus changes so we ignore this.
987 else if (strcmp (pspec->name, "visible") == 0)
989 state = ATK_STATE_VISIBLE;
990 value = GTK_WIDGET_VISIBLE (widget);
992 else if (strcmp (pspec->name, "sensitive") == 0)
994 state = ATK_STATE_SENSITIVE;
995 value = GTK_WIDGET_SENSITIVE (widget);
1000 atk_object_notify_state_change (atk_obj, state, value);
1004 gail_widget_focus_event (AtkObject *obj,
1007 AtkObject *focus_obj;
1009 focus_obj = g_object_get_data (G_OBJECT (obj), "gail-focus-object");
1010 if (focus_obj == NULL)
1012 atk_object_notify_state_change (focus_obj, ATK_STATE_FOCUSED, focus_in);
1016 gail_widget_find_viewport (GtkWidget *widget)
1019 * Find an antecedent which is a GtkViewPort
1023 parent = widget->parent;
1024 while (parent != NULL)
1026 if (GTK_IS_VIEWPORT (parent))
1028 parent = parent->parent;
1034 * This function checks whether the widget has an antecedent which is
1035 * a GtkViewport and, if so, whether any part of the widget intersects
1036 * the visible rectangle of the GtkViewport.
1038 static gboolean gail_widget_on_screen (GtkWidget *widget)
1040 GtkWidget *viewport;
1041 gboolean return_value;
1043 viewport = gail_widget_find_viewport (widget);
1046 GtkAdjustment *adjustment;
1047 GdkRectangle visible_rect;
1049 adjustment = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport));
1050 visible_rect.y = adjustment->value;
1051 adjustment = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport));
1052 visible_rect.x = adjustment->value;
1053 visible_rect.width = viewport->allocation.width;
1054 visible_rect.height = viewport->allocation.height;
1056 if (((widget->allocation.x + widget->allocation.width) < visible_rect.x) ||
1057 ((widget->allocation.y + widget->allocation.height) < visible_rect.y) ||
1058 (widget->allocation.x > (visible_rect.x + visible_rect.width)) ||
1059 (widget->allocation.y > (visible_rect.y + visible_rect.height)))
1060 return_value = FALSE;
1062 return_value = TRUE;
1067 * Check whether the widget has been placed of the screen. The
1068 * widget may be MAPPED as when toolbar items do not fit on the toolbar.
1070 if (widget->allocation.x + widget->allocation.width <= 0 &&
1071 widget->allocation.y + widget->allocation.height <= 0)
1072 return_value = FALSE;
1074 return_value = TRUE;
1077 return return_value;