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