]> Pileus Git - ~andy/gtk/blob - gtk/a11y/gtkcolorswatchaccessible.c
filechooser: Rename _gtk_file_is_path_not_local() to _gtk_file_has_native_path()
[~andy/gtk] / gtk / a11y / gtkcolorswatchaccessible.c
1 /* GTK+ - accessibility implementations
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 <glib/gi18n-lib.h>
21 #include <gtk/gtk.h>
22 #include "gtkcolorswatchaccessibleprivate.h"
23
24 static void atk_action_interface_init (AtkActionIface *iface);
25
26 G_DEFINE_TYPE_WITH_CODE (GtkColorSwatchAccessible, _gtk_color_swatch_accessible, GTK_TYPE_WIDGET_ACCESSIBLE,
27                          G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init))
28
29 static void
30 _gtk_color_swatch_accessible_class_init (GtkColorSwatchAccessibleClass *klass)
31 {
32 }
33
34 static void
35 _gtk_color_swatch_accessible_init (GtkColorSwatchAccessible *scale)
36 {
37 }
38
39 static gint
40 gtk_color_swatch_accessible_get_n_actions (AtkAction *action)
41 {
42   return 3;
43 }
44
45 static const gchar *
46 gtk_color_swatch_accessible_get_keybinding (AtkAction *action,
47                                             gint       i)
48 {
49   return NULL;
50 }
51
52 static const gchar *
53 gtk_color_swatch_accessible_get_name (AtkAction *action,
54                                       gint       i)
55 {
56   switch (i)
57     {
58     case 0: return "select";
59     case 1: return "activate";
60     case 2: return "customize";
61     default: return NULL;
62     }
63 }
64
65 static const gchar *
66 gtk_color_swatch_accessible_get_localized_name (AtkAction *action,
67                                                 gint       i)
68 {
69   switch (i)
70     {
71     case 0: return C_("Action name", "Select");
72     case 1: return C_("Action name", "Activate");
73     case 2: return C_("Action name", "Customize");
74     default: return NULL;
75     }
76 }
77
78 static const gchar *
79 gtk_color_swatch_accessible_get_description (AtkAction *action,
80                                              gint       i)
81 {
82   switch (i)
83     {
84     case 0: return C_("Action description", "Selects the color");
85     case 1: return C_("Action description", "Activates the color");
86     case 2: return C_("Action description", "Customizes the color");
87     default: return NULL;
88     }
89 }
90
91 static gboolean
92 gtk_color_swatch_accessible_do_action (AtkAction *action,
93                                        gint       i)
94 {
95   GtkWidget *widget;
96
97   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
98   if (widget == NULL)
99     return FALSE;
100
101   switch (i)
102     {
103     case 0:
104       gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
105       break;
106
107     case 1:
108       g_signal_emit_by_name (widget, "activate");
109       break;
110
111     case 2:
112       g_signal_emit_by_name (widget, "customize");
113       break;
114
115     default:
116       return FALSE;
117     }
118
119   return TRUE;
120 }
121
122 static void
123 atk_action_interface_init (AtkActionIface *iface)
124 {
125   iface->do_action = gtk_color_swatch_accessible_do_action;
126   iface->get_n_actions = gtk_color_swatch_accessible_get_n_actions;
127   iface->get_keybinding = gtk_color_swatch_accessible_get_keybinding;
128   iface->get_name = gtk_color_swatch_accessible_get_name;
129   iface->get_localized_name = gtk_color_swatch_accessible_get_localized_name;
130   iface->get_description = gtk_color_swatch_accessible_get_description;
131 }