]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkcolorswatchaccessible.c
Change FSF Address
[~andy/gtk] / gtk / a11y / gtkcolorswatchaccessible.c
1 /*
2  * Copyright 2012 Red Hat, 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, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include "config.h"
19
20 #include <gtk/gtk.h>
21 #include "gtkcolorswatchaccessible.h"
22
23 static void atk_action_interface_init (AtkActionIface *iface);
24
25 G_DEFINE_TYPE_WITH_CODE (GtkColorSwatchAccessible, _gtk_color_swatch_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
26                          G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
27
28 static void
29 _gtk_color_swatch_accessible_class_init (GtkColorSwatchAccessibleClass *klass)
30 {
31 }
32
33 static void
34 _gtk_color_swatch_accessible_init (GtkColorSwatchAccessible *scale)
35 {
36 }
37
38 static gint
39 gtk_color_swatch_accessible_get_n_actions (AtkAction *action)
40 {
41   return 3;
42 }
43
44 static const gchar *
45 gtk_color_swatch_accessible_get_keybinding (AtkAction *action,
46                                             gint       i)
47 {
48   return NULL;
49 }
50
51 static const gchar *
52 gtk_color_swatch_accessible_get_name (AtkAction *action,
53                                       gint       i)
54 {
55   switch (i)
56     {
57     case 0: return "select";
58     case 1: return "activate";
59     case 2: return "customize";
60     default: return NULL;
61     }
62 }
63
64 static gboolean
65 gtk_color_swatch_accessible_do_action (AtkAction *action,
66                                        gint       i)
67 {
68   GtkWidget *widget;
69
70   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
71   if (widget == NULL)
72     return FALSE;
73
74   switch (i)
75     {
76     case 0:
77       gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
78       break;
79
80     case 1:
81       g_signal_emit_by_name (widget, "activate");
82       break;
83
84     case 2:
85       g_signal_emit_by_name (widget, "customize");
86       break;
87
88     default:
89       return FALSE;
90     }
91
92   return TRUE;
93 }
94
95 static void
96 atk_action_interface_init (AtkActionIface *iface)
97 {
98   iface->do_action = gtk_color_swatch_accessible_do_action;
99   iface->get_n_actions = gtk_color_swatch_accessible_get_n_actions;
100   iface->get_keybinding = gtk_color_swatch_accessible_get_keybinding;
101   iface->get_name = gtk_color_swatch_accessible_get_name;
102 }