evolution-3.6.4/libgnomecanvas/gailcanvaswidget.c

No issues found

  1 /* GAIL - The GNOME Accessibility Implementation Library
  2  * Copyright 2001 Sun Microsystems Inc.
  3  *
  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.
  8  *
  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.
 13  *
 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.
 18  */
 19 
 20 #ifdef HAVE_CONFIG_H
 21 #include <config.h>
 22 #endif
 23 
 24 #include <gtk/gtk.h>
 25 #include <libgnomecanvas/gnome-canvas.h>
 26 #include <libgnomecanvas/gnome-canvas-widget.h>
 27 #include "gailcanvaswidget.h"
 28 
 29 static gint	gail_canvas_widget_get_n_children
 30 						(AtkObject *obj);
 31 static AtkObject *
 32 		gail_canvas_widget_ref_child	(AtkObject *obj,
 33                                                  gint i);
 34 
 35 G_DEFINE_TYPE (GailCanvasWidget,
 36 	       gail_canvas_widget,
 37 	       GAIL_TYPE_CANVAS_ITEM);
 38 
 39 static void
 40 gail_canvas_widget_init (GailCanvasWidget *foo)
 41 {
 42   ;
 43 }
 44 
 45 AtkObject *
 46 gail_canvas_widget_new (GObject *obj)
 47 {
 48   gpointer object;
 49   AtkObject *atk_object;
 50 
 51   g_return_val_if_fail (GNOME_IS_CANVAS_WIDGET (obj), NULL);
 52   object = g_object_new (GAIL_TYPE_CANVAS_WIDGET, NULL);
 53   atk_object = ATK_OBJECT (object);
 54   atk_object_initialize (atk_object, obj);
 55   atk_object->role = ATK_ROLE_PANEL;
 56   return atk_object;
 57 }
 58 
 59 static void
 60 gail_canvas_widget_class_init (GailCanvasWidgetClass *klass)
 61 {
 62   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
 63 
 64   class->get_n_children = gail_canvas_widget_get_n_children;
 65   class->ref_child = gail_canvas_widget_ref_child;
 66 }
 67 
 68 static gint
 69 gail_canvas_widget_get_n_children (AtkObject *obj)
 70 {
 71   AtkGObjectAccessible *atk_gobj;
 72   GnomeCanvasWidget *canvas_widget;
 73   GObject *g_obj;
 74 
 75   g_return_val_if_fail (GAIL_IS_CANVAS_WIDGET (obj), 0);
 76 
 77   atk_gobj = ATK_GOBJECT_ACCESSIBLE (obj);
 78   g_obj = atk_gobject_accessible_get_object (atk_gobj);
 79   if (g_obj == NULL)
 80     /* State is defunct */
 81     return 0;
 82 
 83   g_return_val_if_fail (GNOME_IS_CANVAS_WIDGET (g_obj), 0);
 84 
 85   canvas_widget = GNOME_CANVAS_WIDGET (g_obj);
 86   g_return_val_if_fail (canvas_widget->widget, 0);
 87   return 1;
 88 }
 89 
 90 static AtkObject *
 91 gail_canvas_widget_ref_child (AtkObject *obj,
 92                               gint i)
 93 {
 94   AtkGObjectAccessible *atk_gobj;
 95   GnomeCanvasWidget *canvas_widget;
 96   GObject *g_obj;
 97   AtkObject *atk_child;
 98 
 99   g_return_val_if_fail (GAIL_IS_CANVAS_WIDGET (obj), NULL);
100 
101   if (i != 0)
102     return NULL;
103 
104   atk_gobj = ATK_GOBJECT_ACCESSIBLE (obj);
105   g_obj = atk_gobject_accessible_get_object (atk_gobj);
106   if (g_obj == NULL)
107     /* State is defunct */
108     return NULL;
109 
110   g_return_val_if_fail (GNOME_IS_CANVAS_WIDGET (g_obj), NULL);
111 
112   canvas_widget = GNOME_CANVAS_WIDGET (g_obj);
113   g_return_val_if_fail (canvas_widget->widget, NULL);
114 
115   atk_child = gtk_widget_get_accessible (canvas_widget->widget);
116   g_object_ref (atk_child);
117   atk_object_set_parent (atk_child, obj);
118   return atk_child;
119 }