]> Pileus Git - ~andy/gtk/blobdiff - gtk/a11y/gtkcomboboxaccessible.c
filechooser: Show FUSE mounted locations in shortcuts
[~andy/gtk] / gtk / a11y / gtkcomboboxaccessible.c
index eca78810454bf59ea706319e0c43fb8695d6722d..385b26a7315f22d73fc80eeee1e563fb275c041b 100644 (file)
@@ -1,4 +1,4 @@
-/* GAIL - The GNOME Accessibility Implementation Library
+/* GTK+ - accessibility implementations
  * Copyright 2004 Sun Microsystems Inc.
  *
  * This library is free software; you can redistribute it and/or
  * 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/>.
  */
 
 #include "config.h"
 
+#include <glib/gi18n-lib.h>
 #include <gtk/gtk.h>
 #include "gtkcomboboxaccessible.h"
 
+struct _GtkComboBoxAccessiblePrivate
+{
+  gchar         *name;
+  gint           old_selection;
+  gboolean       popup_set;
+};
 
 static void atk_action_interface_init    (AtkActionIface    *iface);
 static void atk_selection_interface_init (AtkSelectionIface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (GtkComboBoxAccessible, _gtk_combo_box_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
+G_DEFINE_TYPE_WITH_CODE (GtkComboBoxAccessible, gtk_combo_box_accessible, GTK_TYPE_CONTAINER_ACCESSIBLE,
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_ACTION, atk_action_interface_init)
                          G_IMPLEMENT_INTERFACE (ATK_TYPE_SELECTION, atk_selection_interface_init))
 
@@ -43,11 +48,11 @@ changed_cb (GtkWidget *widget)
   index = gtk_combo_box_get_active (combo_box);
   obj = gtk_widget_get_accessible (widget);
   accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
-  if (accessible->old_selection != index)
+  if (accessible->priv->old_selection != index)
     {
-      accessible->old_selection = index;
+      accessible->priv->old_selection = index;
       g_object_notify (G_OBJECT (obj), "accessible-name");
-      g_signal_emit_by_name (obj, "selection_changed");
+      g_signal_emit_by_name (obj, "selection-changed");
     }
 }
 
@@ -59,19 +64,19 @@ gtk_combo_box_accessible_initialize (AtkObject *obj,
   GtkComboBoxAccessible *accessible;
   AtkObject *popup;
 
-  ATK_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->initialize (obj, data);
+  ATK_OBJECT_CLASS (gtk_combo_box_accessible_parent_class)->initialize (obj, data);
 
   combo_box = GTK_COMBO_BOX (data);
   accessible = GTK_COMBO_BOX_ACCESSIBLE (obj);
 
   g_signal_connect (combo_box, "changed", G_CALLBACK (changed_cb), NULL);
-  accessible->old_selection = gtk_combo_box_get_active (combo_box);
+  accessible->priv->old_selection = gtk_combo_box_get_active (combo_box);
 
   popup = gtk_combo_box_get_popup_accessible (combo_box);
   if (popup)
     {
       atk_object_set_parent (popup, obj);
-      accessible->popup_set = TRUE;
+      accessible->priv->popup_set = TRUE;
     }
   if (gtk_combo_box_get_has_entry (combo_box))
     atk_object_set_parent (gtk_widget_get_accessible (gtk_bin_get_child (GTK_BIN (combo_box))), obj);
@@ -84,9 +89,9 @@ gtk_combo_box_accessible_finalize (GObject *object)
 {
   GtkComboBoxAccessible *combo_box = GTK_COMBO_BOX_ACCESSIBLE (object);
 
-  g_free (combo_box->name);
+  g_free (combo_box->priv->name);
 
-  G_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->finalize (object);
+  G_OBJECT_CLASS (gtk_combo_box_accessible_parent_class)->finalize (object);
 }
 
 static const gchar *
@@ -101,7 +106,7 @@ gtk_combo_box_accessible_get_name (AtkObject *obj)
   gint n_columns;
   gint i;
 
-  name = ATK_OBJECT_CLASS (_gtk_combo_box_accessible_parent_class)->get_name (obj);
+  name = ATK_OBJECT_CLASS (gtk_combo_box_accessible_parent_class)->get_name (obj);
   if (name)
     return name;
 
@@ -117,13 +122,13 @@ gtk_combo_box_accessible_get_name (AtkObject *obj)
       n_columns = gtk_tree_model_get_n_columns (model);
       for (i = 0; i < n_columns; i++)
         {
-          GValue value = { 0, };
+          GValue value = G_VALUE_INIT;
 
           gtk_tree_model_get_value (model, &iter, i, &value);
           if (G_VALUE_HOLDS_STRING (&value))
             {
-              g_free (accessible->name);
-              accessible->name =  g_strdup (g_value_get_string (&value));
+              g_free (accessible->priv->name);
+              accessible->priv->name =  g_strdup (g_value_get_string (&value));
               g_value_unset (&value);
               break;
             }
@@ -131,7 +136,7 @@ gtk_combo_box_accessible_get_name (AtkObject *obj)
             g_value_unset (&value);
         }
     }
-  return accessible->name;
+  return accessible->priv->name;
 }
 
 static gint
@@ -167,10 +172,10 @@ gtk_combo_box_accessible_ref_child (AtkObject *obj,
     {
       child = gtk_combo_box_get_popup_accessible (GTK_COMBO_BOX (widget));
       box = GTK_COMBO_BOX_ACCESSIBLE (obj);
-      if (box->popup_set == FALSE)
+      if (!box->priv->popup_set)
         {
           atk_object_set_parent (child, obj);
-          box->popup_set = TRUE;
+          box->priv->popup_set = TRUE;
         }
     }
   else if (i == 1 && gtk_combo_box_get_has_entry (GTK_COMBO_BOX (widget)))
@@ -186,7 +191,7 @@ gtk_combo_box_accessible_ref_child (AtkObject *obj,
 }
 
 static void
-_gtk_combo_box_accessible_class_init (GtkComboBoxAccessibleClass *klass)
+gtk_combo_box_accessible_class_init (GtkComboBoxAccessibleClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
   AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
@@ -197,14 +202,19 @@ _gtk_combo_box_accessible_class_init (GtkComboBoxAccessibleClass *klass)
   class->get_n_children = gtk_combo_box_accessible_get_n_children;
   class->ref_child = gtk_combo_box_accessible_ref_child;
   class->initialize = gtk_combo_box_accessible_initialize;
+
+  g_type_class_add_private (klass, sizeof (GtkComboBoxAccessiblePrivate));
 }
 
 static void
-_gtk_combo_box_accessible_init (GtkComboBoxAccessible *combo_box)
+gtk_combo_box_accessible_init (GtkComboBoxAccessible *combo_box)
 {
-  combo_box->old_selection = -1;
-  combo_box->name = NULL;
-  combo_box->popup_set = FALSE;
+  combo_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (combo_box,
+                                                 GTK_TYPE_COMBO_BOX_ACCESSIBLE,
+                                                 GtkComboBoxAccessiblePrivate);
+  combo_box->priv->old_selection = -1;
+  combo_box->priv->name = NULL;
+  combo_box->priv->popup_set = FALSE;
 }
 
 static gboolean
@@ -273,7 +283,7 @@ gtk_combo_box_accessible_get_keybinding (AtkAction *action,
     {
       target = atk_relation_get_target (relation);
       target_object = g_ptr_array_index (target, 0);
-      widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
+      label = gtk_accessible_get_widget (GTK_ACCESSIBLE (target_object));
     }
   g_object_unref (set);
   if (GTK_IS_LABEL (label))
@@ -290,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
@@ -303,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