]> Pileus Git - ~andy/gtk/blobdiff - gtk/a11y/gtkswitchaccessible.c
gtkenums: correct various documentation typos
[~andy/gtk] / gtk / a11y / gtkswitchaccessible.c
index 71e9e913dfe56dcd529be675bf603428d9af0110..bd94d3e91041be281b69fb7b6767dcf6b517b36d 100644 (file)
@@ -1,5 +1,4 @@
-/* GTK - The GIMP Toolkit
- *
+/* GTK+ - accessibility implementations
  * Copyright (C) 2010  Intel Corporation
  * Copyright (C) 2010  RedHat, Inc.
  *
@@ -14,9 +13,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA  02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  *
  * Author:
  *      Emmanuele Bassi <ebassi@linux.intel.com>
@@ -27,6 +24,7 @@
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkintl.h"
 #include "gtkswitchaccessible.h"
@@ -55,17 +53,6 @@ gtk_switch_accessible_ref_state_set (AtkObject *accessible)
   return state_set;
 }
 
-static void
-gtk_switch_accessible_finalize (GObject *obj)
-{
-  GtkSwitchAccessible *accessible = (GtkSwitchAccessible *)obj;
-
-  if (accessible->action_idle)
-    g_source_remove (accessible->action_idle);
-
-  G_OBJECT_CLASS (gtk_switch_accessible_parent_class)->finalize (obj);
-}
-
 static void
 gtk_switch_accessible_initialize (AtkObject *accessible,
                                   gpointer   widget)
@@ -80,11 +67,8 @@ gtk_switch_accessible_initialize (AtkObject *accessible,
 static void
 gtk_switch_accessible_class_init (GtkSwitchAccessibleClass *klass)
 {
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   AtkObjectClass *atk_class = ATK_OBJECT_CLASS (klass);
 
-  object_class->finalize = gtk_switch_accessible_finalize;
-
   atk_class->initialize = gtk_switch_accessible_initialize;
   atk_class->ref_state_set = gtk_switch_accessible_ref_state_set;
 }
@@ -92,7 +76,6 @@ gtk_switch_accessible_class_init (GtkSwitchAccessibleClass *klass)
 static void
 gtk_switch_accessible_init (GtkSwitchAccessible *self)
 {
-  self->action_idle = 0;
 }
 
 static gint
@@ -105,38 +88,34 @@ static const gchar *
 gtk_switch_action_get_name (AtkAction *action,
                             gint       i)
 {
-  if (i != 0)
-    return NULL;
-
-  return "toggle";
+  if (i == 0)
+    return "toggle";
+  return NULL;
 }
 
-static gboolean
-idle_do_action (gpointer data)
+static const gchar *
+gtk_switch_action_get_localized_name (AtkAction *action,
+                                      gint       i)
 {
-  GtkSwitchAccessible *accessible = data;
-  GtkWidget *widget;
-  GtkSwitch *sw;
-
-  widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (data));
-  sw = GTK_SWITCH (widget);
-
-  accessible->action_idle = 0;
-
-  if (widget == NULL ||
-      !gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
-    return FALSE;
-
-  gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
+  if (i == 0)
+    return C_("Action name", "Toggle");
+  return NULL;
+}
 
-  return FALSE;
+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
 gtk_switch_action_do_action (AtkAction *action,
                              gint       i)
 {
-  GtkSwitchAccessible *accessible;
+  GtkSwitch *sw;
   GtkWidget *widget;
 
   widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (action));
@@ -149,10 +128,8 @@ gtk_switch_action_do_action (AtkAction *action,
   if (!gtk_widget_is_sensitive (widget) || !gtk_widget_get_visible (widget))
     return FALSE;
 
-  accessible = (GtkSwitchAccessible *)action;
-
-  if (!accessible->action_idle)
-    accessible->action_idle = gdk_threads_add_idle (idle_do_action, accessible);
+  sw = GTK_SWITCH (widget);
+  gtk_switch_set_active (sw, !gtk_switch_get_active (sw));
 
   return TRUE;
 }
@@ -163,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;
 }