X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fa11y%2Fgtkcomboboxaccessible.c;h=385b26a7315f22d73fc80eeee1e563fb275c041b;hb=56bcb1933f6de613e5d8689e23420d47b65425c3;hp=58f8763630cf6b22598288ca9557bf8f6a005be5;hpb=89e57c6978822b9ebcd8565d9b271cc520f55766;p=~andy%2Fgtk diff --git a/gtk/a11y/gtkcomboboxaccessible.c b/gtk/a11y/gtkcomboboxaccessible.c index 58f876363..385b26a73 100644 --- a/gtk/a11y/gtkcomboboxaccessible.c +++ b/gtk/a11y/gtkcomboboxaccessible.c @@ -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 @@ -12,16 +12,21 @@ * 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 . */ #include "config.h" +#include #include #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); @@ -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"); } } @@ -65,13 +70,13 @@ gtk_combo_box_accessible_initialize (AtkObject *obj, 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,12 +89,12 @@ 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); } -static const gchar* +static const gchar * gtk_combo_box_accessible_get_name (AtkObject *obj) { GtkWidget *widget; @@ -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))) @@ -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) { - 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 @@ -222,18 +232,17 @@ gtk_combo_box_accessible_do_action (AtkAction *action, if (!gtk_widget_get_sensitive (widget) || !gtk_widget_get_visible (widget)) return FALSE; - if (i == 0) - { - combo_box = GTK_COMBO_BOX (widget); - g_object_get (combo_box, "popup-shown", &popup_shown, NULL); - if (popup_shown) - gtk_combo_box_popdown (combo_box); - else - gtk_combo_box_popup (combo_box); - return TRUE; - } - else + if (i != 0) return FALSE; + + combo_box = GTK_COMBO_BOX (widget); + g_object_get (combo_box, "popup-shown", &popup_shown, NULL); + if (popup_shown) + gtk_combo_box_popdown (combo_box); + else + gtk_combo_box_popup (combo_box); + + return TRUE; } static gint @@ -274,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)) @@ -291,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 @@ -304,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