| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#include "config.h" |
| 21 |
|
| 22 |
#undef GTK_DISABLE_DEPRECATED |
| 23 |
|
| 24 |
#include <gtk/gtk.h> |
| 25 |
#include "gaillist.h" |
| 26 |
#include "gailcombo.h" |
| 27 |
|
| 28 |
static void gail_list_class_init (GailListClass *klass); |
| 29 |
|
| 30 |
static void gail_list_init (GailList *list); |
| 31 |
|
| 32 |
static void gail_list_initialize (AtkObject *accessible, |
| 33 |
gpointer data); |
| 34 |
|
| 35 |
static gint gail_list_get_index_in_parent (AtkObject *accessible); |
| 36 |
|
| 37 |
static void atk_selection_interface_init (AtkSelectionIface *iface); |
| 38 |
static gboolean gail_list_add_selection (AtkSelection *selection, |
| 39 |
gint i); |
| 40 |
static gboolean gail_list_clear_selection (AtkSelection *selection); |
| 41 |
static AtkObject* gail_list_ref_selection (AtkSelection *selection, |
| 42 |
gint i); |
| 43 |
static gint gail_list_get_selection_count (AtkSelection *selection); |
| 44 |
static gboolean gail_list_is_child_selected (AtkSelection *selection, |
| 45 |
gint i); |
| 46 |
static gboolean gail_list_remove_selection (AtkSelection *selection, |
| 47 |
gint i); |
| 48 |
|
| 49 |
|
| 50 |
G_DEFINE_TYPE_WITH_CODE (GailList, gail_list, GAIL_TYPE_CONTAINER, |
| 51 |
G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init)) |
| 52 |
|
| 53 |
static void |
| 54 |
gail_list_class_init (GailListClass *klass) |
| 55 |
{ |
| 56 |
AtkObjectClass *class = ATK_OBJECT_CLASS (klass); |
| 57 |
|
| 58 |
class->initialize = gail_list_initialize; |
| 59 |
class->get_index_in_parent = gail_list_get_index_in_parent; |
| 60 |
} |
| 61 |
|
| 62 |
static void |
| 63 |
gail_list_init (GailList *list) |
| 64 |
{ |
| 65 |
} |
| 66 |
|
| 67 |
static void |
| 68 |
gail_list_initialize (AtkObject *accessible, |
| 69 |
gpointer data) |
| 70 |
{ |
| 71 |
ATK_OBJECT_CLASS (gail_list_parent_class)->initialize (accessible, data); |
| 72 |
|
| 73 |
accessible->role = ATK_ROLE_LIST; |
| 74 |
} |
| 75 |
|
| 76 |
static gint |
| 77 |
gail_list_get_index_in_parent (AtkObject *accessible) |
| 78 |
{ |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
if (accessible->accessible_parent) |
| 84 |
{ |
| 85 |
if (GAIL_IS_COMBO (accessible->accessible_parent)) |
| 86 |
return 0; |
| 87 |
} |
| 88 |
return ATK_OBJECT_CLASS (gail_list_parent_class)->get_index_in_parent (accessible); |
| 89 |
} |
| 90 |
|
| 91 |
static void |
| 92 |
atk_selection_interface_init (AtkSelectionIface *iface) |
| 93 |
{ |
| 94 |
iface->add_selection = gail_list_add_selection; |
| 95 |
iface->clear_selection = gail_list_clear_selection; |
| 96 |
iface->ref_selection = gail_list_ref_selection; |
| 97 |
iface->get_selection_count = gail_list_get_selection_count; |
| 98 |
iface->is_child_selected = gail_list_is_child_selected; |
| 99 |
iface->remove_selection = gail_list_remove_selection; |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
} |
| 105 |
|
| 106 |
static gboolean |
| 107 |
gail_list_add_selection (AtkSelection *selection, |
| 108 |
gint i) |
| 109 |
{ |
| 110 |
GtkList *list; |
| 111 |
GtkWidget *widget; |
| 112 |
|
| 113 |
widget = GTK_ACCESSIBLE (selection)->widget; |
| 114 |
if (widget == NULL) |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
return FALSE; |
| 119 |
|
| 120 |
list = GTK_LIST (widget); |
| 121 |
|
| 122 |
gtk_list_select_item (list, i); |
| 123 |
return TRUE; |
| 124 |
} |
| 125 |
|
| 126 |
static gboolean |
| 127 |
gail_list_clear_selection (AtkSelection *selection) |
| 128 |
{ |
| 129 |
GtkList *list; |
| 130 |
GtkWidget *widget; |
| 131 |
|
| 132 |
widget = GTK_ACCESSIBLE (selection)->widget; |
| 133 |
if (widget == NULL) |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
return FALSE; |
| 138 |
|
| 139 |
list = GTK_LIST (widget); |
| 140 |
|
| 141 |
gtk_list_unselect_all (list); |
| 142 |
return TRUE; |
| 143 |
} |
| 144 |
|
| 145 |
static AtkObject* |
| 146 |
gail_list_ref_selection (AtkSelection *selection, |
| 147 |
gint i) |
| 148 |
{ |
| 149 |
GtkList *list; |
| 150 |
GList *g_list; |
| 151 |
GtkWidget *item; |
| 152 |
AtkObject *obj; |
| 153 |
GtkWidget *widget; |
| 154 |
|
| 155 |
widget = GTK_ACCESSIBLE (selection)->widget; |
| 156 |
if (widget == NULL) |
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
return NULL; |
| 161 |
|
| 162 |
list = GTK_LIST (widget); |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
if (i != 0) |
| 168 |
return NULL; |
| 169 |
|
| 170 |
g_list = list->selection; |
| 171 |
|
| 172 |
if (g_list == NULL) |
| 173 |
return NULL; |
| 174 |
|
| 175 |
item = GTK_WIDGET (g_list->data); |
| 176 |
|
| 177 |
obj = gtk_widget_get_accessible (item); |
| 178 |
g_object_ref (obj); |
| 179 |
return obj; |
| 180 |
} |
| 181 |
|
| 182 |
static gint |
| 183 |
gail_list_get_selection_count (AtkSelection *selection) |
| 184 |
{ |
| 185 |
GtkList *list; |
| 186 |
GList *g_list; |
| 187 |
GtkWidget *widget; |
| 188 |
|
| 189 |
widget = GTK_ACCESSIBLE (selection)->widget; |
| 190 |
if (widget == NULL) |
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
return 0; |
| 195 |
|
| 196 |
list = GTK_LIST (widget); |
| 197 |
|
| 198 |
g_list = list->selection; |
| 199 |
|
| 200 |
return g_list_length (g_list);; |
| 201 |
} |
| 202 |
|
| 203 |
static gboolean |
| 204 |
gail_list_is_child_selected (AtkSelection *selection, |
| 205 |
gint i) |
| 206 |
{ |
| 207 |
GtkList *list; |
| 208 |
GList *g_list; |
| 209 |
GtkWidget *item; |
| 210 |
gint j; |
| 211 |
GtkWidget *widget; |
| 212 |
|
| 213 |
widget = GTK_ACCESSIBLE (selection)->widget; |
| 214 |
if (widget == NULL) |
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
return FALSE; |
| 219 |
|
| 220 |
list = GTK_LIST (widget); |
| 221 |
|
| 222 |
g_list = list->selection; |
| 223 |
|
| 224 |
if (g_list == NULL) |
| 225 |
return FALSE; |
| 226 |
|
| 227 |
item = GTK_WIDGET (g_list->data); |
| 228 |
|
| 229 |
j = g_list_index (list->children, item); |
| 230 |
|
| 231 |
return (j == i); |
| 232 |
} |
| 233 |
|
| 234 |
static gboolean |
| 235 |
gail_list_remove_selection (AtkSelection *selection, |
| 236 |
gint i) |
| 237 |
{ |
| 238 |
if (atk_selection_is_child_selected (selection, i)) |
| 239 |
atk_selection_clear_selection (selection); |
| 240 |
|
| 241 |
return TRUE; |
| 242 |
} |