evolution-3.6.4/libgnomecanvas/gailcanvasgroup.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 "gailcanvasgroup.h"
 27 
 28 static gint       gail_canvas_group_get_n_children  (AtkObject            *obj);
 29 static AtkObject * gail_canvas_group_ref_child       (AtkObject            *obj,
 30                                                      gint                 i);
 31 
 32 G_DEFINE_TYPE (GailCanvasGroup,
 33 	      gail_canvas_group,
 34 	      GAIL_TYPE_CANVAS_ITEM);
 35 
 36 static void
 37 gail_canvas_group_init (GailCanvasGroup *foo)
 38 {
 39   ;
 40 }
 41 
 42 AtkObject *
 43 gail_canvas_group_new (GObject *obj)
 44 {
 45   gpointer object;
 46   AtkObject *atk_object;
 47 
 48   g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (obj), NULL);
 49   object = g_object_new (GAIL_TYPE_CANVAS_GROUP, NULL);
 50   atk_object = ATK_OBJECT (object);
 51   atk_object_initialize (atk_object, obj);
 52   atk_object->role = ATK_ROLE_PANEL;
 53   return atk_object;
 54 }
 55 
 56 static void
 57 gail_canvas_group_class_init (GailCanvasGroupClass *klass)
 58 {
 59   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
 60 
 61   class->get_n_children = gail_canvas_group_get_n_children;
 62   class->ref_child = gail_canvas_group_ref_child;
 63 }
 64 
 65 static gint
 66 gail_canvas_group_get_n_children (AtkObject *obj)
 67 {
 68   AtkGObjectAccessible *atk_gobject;
 69   GnomeCanvasGroup *group;
 70   GObject *g_obj;
 71 
 72   g_return_val_if_fail (GAIL_IS_CANVAS_ITEM (obj), 0);
 73   atk_gobject = ATK_GOBJECT_ACCESSIBLE (obj);
 74   g_obj = atk_gobject_accessible_get_object (atk_gobject);
 75   g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (g_obj), 0);
 76   group = GNOME_CANVAS_GROUP (g_obj);
 77   return g_list_length (group->item_list);
 78 }
 79 
 80 static AtkObject *
 81 gail_canvas_group_ref_child (AtkObject *obj,
 82                              gint i)
 83 {
 84   AtkGObjectAccessible *atk_gobject;
 85   GnomeCanvasGroup *group;
 86   GnomeCanvasItem *item;
 87   AtkObject *accessible;
 88   GObject *g_obj;
 89   GList *list_item;
 90 
 91   g_return_val_if_fail (GAIL_IS_CANVAS_ITEM (obj), NULL);
 92   atk_gobject = ATK_GOBJECT_ACCESSIBLE (obj);
 93   g_obj = atk_gobject_accessible_get_object (atk_gobject);
 94   g_return_val_if_fail (GNOME_IS_CANVAS_GROUP (g_obj), NULL);
 95   group = GNOME_CANVAS_GROUP (g_obj);
 96 
 97   list_item = g_list_nth (group->item_list, i);
 98   if (!list_item)
 99 	  return NULL;
100   g_return_val_if_fail (list_item->data, NULL);
101   item = GNOME_CANVAS_ITEM (list_item->data);
102   accessible = atk_gobject_accessible_for_object (G_OBJECT (item));
103   g_object_ref (accessible);
104   return accessible;
105 }