[gtk+] Improve AtkAction implementations
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Improve AtkAction implementations
- Date: Mon, 4 Feb 2013 06:03:29 +0000 (UTC)
commit 935d458fa1b72b8f1b0a36566b7c40c06870bb9f
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Feb 4 00:53:48 2013 -0500
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
gtk/a11y/gtkbooleancellaccessible.c | 18 +++++++++++++++---
gtk/a11y/gtkbuttonaccessible.c | 26 +++++++++++++++++++++++---
gtk/a11y/gtkcellaccessible.c | 25 ++++++++++++++++++++++---
gtk/a11y/gtkcolorswatchaccessible.c | 29 +++++++++++++++++++++++++++++
gtk/a11y/gtkcomboboxaccessible.c | 26 +++++++++++++++++++++++---
gtk/a11y/gtkentryaccessible.c | 26 +++++++++++++++++++++++---
gtk/a11y/gtkexpanderaccessible.c | 26 +++++++++++++++++++++++---
gtk/a11y/gtkmenuitemaccessible.c | 28 +++++++++++++++++++++++++---
gtk/a11y/gtkscalebuttonaccessible.c | 27 ++++++++++++++++++++++++++-
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 a649bd5..f114261 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 f7dece9..3ba94d3 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 e9b2b8f..e03496b 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 4ca6c7d..6ad4138 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 8a7008d..385b26a 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 07fea6e..31414c6 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 ae15a22..6986e50 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 4e14a71..15ef15d 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 7e9253d..fa87e70 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 3607f8e..bd94d3e 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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]