]> Pileus Git - ~andy/gtk/blob - modules/other/gail/gailclistcell.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / modules / other / gail / gailclistcell.c
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 #include "config.h"
21
22 #include <gtk/gtk.h>
23 #include "gailclistcell.h"
24
25 static void      gail_clist_cell_class_init        (GailCListCellClass *klass);
26 static void      gail_clist_cell_init              (GailCListCell      *cell);
27
28 static G_CONST_RETURN gchar* gail_clist_cell_get_name (AtkObject *accessible);
29
30 G_DEFINE_TYPE (GailCListCell, gail_clist_cell, GAIL_TYPE_CELL)
31
32 static void      
33 gail_clist_cell_class_init (GailCListCellClass *klass)
34 {
35   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
36
37   class->get_name = gail_clist_cell_get_name;
38 }
39
40 static void
41 gail_clist_cell_init (GailCListCell *cell)
42 {
43 }
44
45 AtkObject* 
46 gail_clist_cell_new (void)
47 {
48   GObject *object;
49   AtkObject *atk_object;
50
51   object = g_object_new (GAIL_TYPE_CLIST_CELL, NULL);
52
53   g_return_val_if_fail (object != NULL, NULL);
54
55   atk_object = ATK_OBJECT (object);
56   atk_object->role = ATK_ROLE_TABLE_CELL;
57
58   g_return_val_if_fail (!ATK_IS_TEXT (atk_object), NULL);
59   
60   return atk_object;
61 }
62
63 static G_CONST_RETURN gchar*
64 gail_clist_cell_get_name (AtkObject *accessible)
65 {
66   if (accessible->name)
67     return accessible->name;
68   else
69     {
70       /*
71        * Get the cell's text if it exists
72        */
73       GailCell *cell = GAIL_CELL (accessible);
74       GtkWidget* widget = cell->widget;
75       GtkCellType cell_type;
76       GtkCList *clist;
77       gchar *text = NULL;
78       gint row, column;
79
80       if (widget == NULL)
81         /*
82          * State is defunct
83          */
84         return NULL;
85  
86       clist = GTK_CLIST (widget);
87       g_return_val_if_fail (clist->columns, NULL);
88       row = cell->index / clist->columns;
89       column = cell->index % clist->columns;
90       cell_type = gtk_clist_get_cell_type (clist, row, column);
91       switch (cell_type)
92         {
93         case GTK_CELL_TEXT:
94           gtk_clist_get_text (clist, row, column, &text);
95           break;
96         case GTK_CELL_PIXTEXT:
97           gtk_clist_get_pixtext (clist, row, column, &text, NULL, NULL, NULL);
98           break;
99         default:
100           break;
101         }
102       return text;
103     }
104 }