diff options
author | Matthias Clasen <mclasen@redhat.com> | 2013-02-04 00:53:48 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2013-02-04 00:57:46 -0500 |
commit | 935d458fa1b72b8f1b0a36566b7c40c06870bb9f (patch) | |
tree | b24b4ef7078b330a73af953a2e093cbd3688bb46 | |
parent | b396e37b96d652195fce7e393da13d0363aefe34 (diff) | |
download | gtk+-935d458fa1b72b8f1b0a36566b7c40c06870bb9f.tar.gz |
Improve AtkAction implementations
Implement get_localized_name, and also translate the strings
returned by get_description.
https://bugzilla.gnome.org/show_bug.cgi?id=525226
-rw-r--r-- | gtk/a11y/gtkbooleancellaccessible.c | 18 | ||||
-rw-r--r-- | gtk/a11y/gtkbuttonaccessible.c | 26 | ||||
-rw-r--r-- | gtk/a11y/gtkcellaccessible.c | 25 | ||||
-rw-r--r-- | gtk/a11y/gtkcolorswatchaccessible.c | 29 | ||||
-rw-r--r-- | gtk/a11y/gtkcomboboxaccessible.c | 26 | ||||
-rw-r--r-- | gtk/a11y/gtkentryaccessible.c | 26 | ||||
-rw-r--r-- | gtk/a11y/gtkexpanderaccessible.c | 26 | ||||
-rw-r--r-- | gtk/a11y/gtkmenuitemaccessible.c | 28 | ||||
-rw-r--r-- | gtk/a11y/gtkscalebuttonaccessible.c | 27 | ||||
-rw-r--r-- | gtk/a11y/gtkswitchaccessible.c | 26 |
10 files changed, 232 insertions, 25 deletions
diff --git a/gtk/a11y/gtkbooleancellaccessible.c b/gtk/a11y/gtkbooleancellaccessible.c index a649bd5135..f114261901 100644 --- a/gtk/a11y/gtkbooleancellaccessible.c +++ b/gtk/a11y/gtkbooleancellaccessible.c @@ -18,6 +18,7 @@ #include "config.h" #include <gtk/gtk.h> +#include <glib/gi18n-lib.h> #include "gtkbooleancellaccessible.h" struct _GtkBooleanCellAccessiblePrivate @@ -39,7 +40,7 @@ gtk_boolean_cell_accessible_get_description (AtkAction *action, gint i) { if (i == 0) - return "toggles the cell"; + return C_("Action description", "Toggles the cell"); return parent_action_iface->get_description (action, i - 1); } @@ -54,14 +55,24 @@ gtk_boolean_cell_accessible_action_get_name (AtkAction *action, return parent_action_iface->get_description (action, i - 1); } +static const gchar * +gtk_boolean_cell_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action name", "Toggle"); + + return parent_action_iface->get_description (action, i - 1); +} + static gboolean gtk_boolean_cell_accessible_do_action (AtkAction *action, gint i) { if (i == 0) return parent_action_iface->do_action (action, 2); - else - return parent_action_iface->do_action (action, i - 1); + + return parent_action_iface->do_action (action, i - 1); } static void @@ -73,6 +84,7 @@ gtk_boolean_cell_accessible_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_boolean_cell_accessible_get_n_actions; iface->get_description = gtk_boolean_cell_accessible_get_description; iface->get_name = gtk_boolean_cell_accessible_action_get_name; + iface->get_localized_name = gtk_boolean_cell_accessible_action_get_localized_name; } diff --git a/gtk/a11y/gtkbuttonaccessible.c b/gtk/a11y/gtkbuttonaccessible.c index f7dece930b..3ba94d30cf 100644 --- a/gtk/a11y/gtkbuttonaccessible.c +++ b/gtk/a11y/gtkbuttonaccessible.c @@ -19,6 +19,7 @@ #include <string.h> #include <gtk/gtk.h> +#include <glib/gi18n-lib.h> #include "gtkbuttonaccessible.h" @@ -327,10 +328,27 @@ static const gchar * gtk_button_accessible_action_get_name (AtkAction *action, gint i) { - if (i != 0) - return NULL; + if (i == 0) + return "click"; + return NULL; +} + +static const gchar * +gtk_button_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action name", "Click"); + return NULL; +} - return "click"; +static const gchar * +gtk_button_accessible_action_get_description (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action description", "Clicks the button"); + return NULL; } static void @@ -340,6 +358,8 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_button_accessible_get_n_actions; iface->get_keybinding = gtk_button_accessible_get_keybinding; iface->get_name = gtk_button_accessible_action_get_name; + iface->get_localized_name = gtk_button_accessible_action_get_localized_name; + iface->get_description = gtk_button_accessible_action_get_description; } static const gchar * diff --git a/gtk/a11y/gtkcellaccessible.c b/gtk/a11y/gtkcellaccessible.c index e9b2b8f790..e03496b85a 100644 --- a/gtk/a11y/gtkcellaccessible.c +++ b/gtk/a11y/gtkcellaccessible.c @@ -17,6 +17,7 @@ #include "config.h" +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include "gtkcontainercellaccessible.h" #include "gtkcellaccessibleprivate.h" @@ -248,17 +249,34 @@ gtk_cell_accessible_action_get_name (AtkAction *action, } static const gchar * +gtk_cell_accessible_action_get_localized_name (AtkAction *action, + gint index) +{ + switch (index) + { + case 0: + return C_("Action name", "Expand or contract"); + case 1: + return C_("Action name", "Edit"); + case 2: + return C_("Action name", "Activate"); + default: + return NULL; + } +} + +static const gchar * gtk_cell_accessible_action_get_description (AtkAction *action, gint index) { switch (index) { case 0: - return "expands or contracts the row in the tree view containing this cell"; + return C_("Action description", "Expands or contracts the row in the tree view containing this cell"); case 1: - return "creates a widget in which the contents of the cell can be edited"; + return C_("Action description", "Creates a widget in which the contents of the cell can be edited"); case 2: - return "activate the cell"; + return C_("Action description", "Activates the cell"); default: return NULL; } @@ -308,6 +326,7 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_cell_accessible_action_get_n_actions; iface->do_action = gtk_cell_accessible_action_do_action; iface->get_name = gtk_cell_accessible_action_get_name; + iface->get_localized_name = gtk_cell_accessible_action_get_localized_name; iface->get_description = gtk_cell_accessible_action_get_description; iface->get_keybinding = gtk_cell_accessible_action_get_keybinding; } diff --git a/gtk/a11y/gtkcolorswatchaccessible.c b/gtk/a11y/gtkcolorswatchaccessible.c index 4ca6c7df5d..6ad4138e5f 100644 --- a/gtk/a11y/gtkcolorswatchaccessible.c +++ b/gtk/a11y/gtkcolorswatchaccessible.c @@ -17,6 +17,7 @@ #include "config.h" +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include "gtkcolorswatchaccessibleprivate.h" @@ -61,6 +62,32 @@ gtk_color_swatch_accessible_get_name (AtkAction *action, } } +static const gchar * +gtk_color_swatch_accessible_get_localized_name (AtkAction *action, + gint i) +{ + switch (i) + { + case 0: return C_("Action name", "Select"); + case 1: return C_("Action name", "Activate"); + case 2: return C_("Action name", "Customize"); + default: return NULL; + } +} + +static const gchar * +gtk_color_swatch_accessible_get_description (AtkAction *action, + gint i) +{ + switch (i) + { + case 0: return C_("Action description", "Selects the color"); + case 1: return C_("Action description", "Activates the color"); + case 2: return C_("Action description", "Customizes the color"); + default: return NULL; + } +} + static gboolean gtk_color_swatch_accessible_do_action (AtkAction *action, gint i) @@ -99,4 +126,6 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_color_swatch_accessible_get_n_actions; iface->get_keybinding = gtk_color_swatch_accessible_get_keybinding; iface->get_name = gtk_color_swatch_accessible_get_name; + iface->get_localized_name = gtk_color_swatch_accessible_get_localized_name; + iface->get_description = gtk_color_swatch_accessible_get_description; } diff --git a/gtk/a11y/gtkcomboboxaccessible.c b/gtk/a11y/gtkcomboboxaccessible.c index 8a7008dd3d..385b26a731 100644 --- a/gtk/a11y/gtkcomboboxaccessible.c +++ b/gtk/a11y/gtkcomboboxaccessible.c @@ -17,6 +17,7 @@ #include "config.h" +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include "gtkcomboboxaccessible.h" @@ -299,10 +300,27 @@ static const gchar * gtk_combo_box_accessible_action_get_name (AtkAction *action, gint i) { - if (i != 0) - return NULL; + if (i == 0) + return "press"; + return NULL; +} + +static const gchar * +gtk_combo_box_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action name", "Press"); + return NULL; +} - return "press"; +static const gchar * +gtk_combo_box_accessible_action_get_description (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action description", "Presses the combobox"); + return NULL; } static void @@ -312,6 +330,8 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_combo_box_accessible_get_n_actions; iface->get_keybinding = gtk_combo_box_accessible_get_keybinding; iface->get_name = gtk_combo_box_accessible_action_get_name; + iface->get_localized_name = gtk_combo_box_accessible_action_get_localized_name; + iface->get_description = gtk_combo_box_accessible_action_get_description; } static gboolean diff --git a/gtk/a11y/gtkentryaccessible.c b/gtk/a11y/gtkentryaccessible.c index 07fea6e079..31414c6184 100644 --- a/gtk/a11y/gtkentryaccessible.c +++ b/gtk/a11y/gtkentryaccessible.c @@ -17,6 +17,7 @@ #include "config.h" +#include <glib/gi18n-lib.h> #include <string.h> #include <gtk/gtk.h> #include "gtkpango.h" @@ -1527,10 +1528,27 @@ static const gchar* gtk_entry_accessible_action_get_name (AtkAction *action, gint i) { - if (i != 0) - return NULL; + if (i == 0) + return "activate"; + return NULL; +} - return "activate"; +static const gchar* +gtk_entry_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action name", "Activate"); + return NULL; +} + +static const gchar* +gtk_entry_accessible_action_get_description (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action description", "Activates the entry"); + return NULL; } static void @@ -1540,4 +1558,6 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_entry_accessible_get_n_actions; iface->get_keybinding = gtk_entry_accessible_get_keybinding; iface->get_name = gtk_entry_accessible_action_get_name; + iface->get_localized_name = gtk_entry_accessible_action_get_localized_name; + iface->get_description = gtk_entry_accessible_action_get_description; } diff --git a/gtk/a11y/gtkexpanderaccessible.c b/gtk/a11y/gtkexpanderaccessible.c index ae15a22f37..6986e50899 100644 --- a/gtk/a11y/gtkexpanderaccessible.c +++ b/gtk/a11y/gtkexpanderaccessible.c @@ -17,6 +17,7 @@ #include "config.h" +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include "gtkexpanderaccessible.h" @@ -267,10 +268,27 @@ static const gchar * gtk_expander_accessible_action_get_name (AtkAction *action, gint i) { - if (i != 0) - return NULL; + if (i == 0) + return "activate"; + return NULL; +} - return "activate"; +static const gchar * +gtk_expander_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action name", "Activate"); + return NULL; +} + +static const gchar * +gtk_expander_accessible_action_get_description (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action description", "Activates the expander"); + return NULL; } static void @@ -280,4 +298,6 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_expander_accessible_get_n_actions; iface->get_keybinding = gtk_expander_accessible_get_keybinding; iface->get_name = gtk_expander_accessible_action_get_name; + iface->get_localized_name = gtk_expander_accessible_action_get_localized_name; + iface->get_description = gtk_expander_accessible_action_get_description; } diff --git a/gtk/a11y/gtkmenuitemaccessible.c b/gtk/a11y/gtkmenuitemaccessible.c index 4e14a7158c..15ef15dbed 100644 --- a/gtk/a11y/gtkmenuitemaccessible.c +++ b/gtk/a11y/gtkmenuitemaccessible.c @@ -15,6 +15,9 @@ * License along with this library. If not, see <http://www.gnu.org/licenses/>. */ +#include "config.h" + +#include <glib/gi18n-lib.h> #include <string.h> #include <gtk/gtk.h> #include "gtkmenuitemaccessible.h" @@ -420,10 +423,27 @@ static const gchar * gtk_menu_item_accessible_action_get_name (AtkAction *action, gint i) { - if (i != 0 || gtk_menu_item_accessible_get_n_actions (action) == 0) - return NULL; + if (i == 0 && gtk_menu_item_accessible_get_n_actions (action) > 0) + return "click"; + return NULL; +} + +static const gchar * +gtk_menu_item_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0 && gtk_menu_item_accessible_get_n_actions (action) > 0) + return C_("Action name", "Click"); + return NULL; +} - return "click"; +static const gchar * +gtk_menu_item_accessible_action_get_description (AtkAction *action, + gint i) +{ + if (i == 0 && gtk_menu_item_accessible_get_n_actions (action) > 0) + return C_("Action description", "Clicks the menuitem"); + return NULL; } static gboolean @@ -615,6 +635,8 @@ atk_action_interface_init (AtkActionIface *iface) iface->do_action = gtk_menu_item_accessible_do_action; iface->get_n_actions = gtk_menu_item_accessible_get_n_actions; iface->get_name = gtk_menu_item_accessible_action_get_name; + iface->get_localized_name = gtk_menu_item_accessible_action_get_localized_name; + iface->get_description = gtk_menu_item_accessible_action_get_description; iface->get_keybinding = gtk_menu_item_accessible_get_keybinding; } diff --git a/gtk/a11y/gtkscalebuttonaccessible.c b/gtk/a11y/gtkscalebuttonaccessible.c index 7e9253d018..fa87e70939 100644 --- a/gtk/a11y/gtkscalebuttonaccessible.c +++ b/gtk/a11y/gtkscalebuttonaccessible.c @@ -17,6 +17,7 @@ #include <config.h> +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include "gtkscalebuttonaccessible.h" @@ -133,7 +134,15 @@ static const gchar * gtk_scale_button_accessible_get_description (AtkAction *action, gint i) { - return NULL; + switch (i) + { + case 0: + return C_("Action description", "Pops up the slider"); + case 1: + return C_("Action description", "Dismisses the slider"); + default: + return NULL; + } } static const gchar * @@ -151,6 +160,21 @@ gtk_scale_button_accessible_action_get_name (AtkAction *action, } } +static const gchar * +gtk_scale_button_accessible_action_get_localized_name (AtkAction *action, + gint i) +{ + switch (i) + { + case 0: + return C_("Action name", "Popup"); + case 1: + return C_("Action name", "Dismiss"); + default: + return NULL; + } +} + static void atk_action_interface_init (AtkActionIface *iface) { @@ -158,6 +182,7 @@ atk_action_interface_init (AtkActionIface *iface) iface->get_n_actions = gtk_scale_button_accessible_get_n_actions; iface->get_description = gtk_scale_button_accessible_get_description; iface->get_name = gtk_scale_button_accessible_action_get_name; + iface->get_localized_name = gtk_scale_button_accessible_action_get_localized_name; } static void diff --git a/gtk/a11y/gtkswitchaccessible.c b/gtk/a11y/gtkswitchaccessible.c index 3607f8ebf7..bd94d3e910 100644 --- a/gtk/a11y/gtkswitchaccessible.c +++ b/gtk/a11y/gtkswitchaccessible.c @@ -24,6 +24,7 @@ #include "config.h" +#include <glib/gi18n-lib.h> #include <gtk/gtk.h> #include "gtkintl.h" #include "gtkswitchaccessible.h" @@ -87,10 +88,27 @@ static const gchar * gtk_switch_action_get_name (AtkAction *action, gint i) { - if (i != 0) - return NULL; + if (i == 0) + return "toggle"; + return NULL; +} + +static const gchar * +gtk_switch_action_get_localized_name (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action name", "Toggle"); + return NULL; +} - return "toggle"; +static const gchar * +gtk_switch_action_get_description (AtkAction *action, + gint i) +{ + if (i == 0) + return C_("Action description", "Toggles the switch"); + return NULL; } static gboolean @@ -122,4 +140,6 @@ atk_action_interface_init (AtkActionIface *iface) iface->do_action = gtk_switch_action_do_action; iface->get_n_actions = gtk_switch_action_get_n_actions; iface->get_name = gtk_switch_action_get_name; + iface->get_localized_name = gtk_switch_action_get_localized_name; + iface->get_description = gtk_switch_action_get_description; } |