gail: Implement AtkObject::get_attributes() in GailEntry

And return the GtkEntry placeholder text as a new attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=440963
This commit is contained in:
Carlos Garcia Campos 2011-03-02 18:17:05 +01:00 committed by Carlos Garcia Campos
parent ef061c4e96
commit e13794bef9

View File

@ -41,6 +41,7 @@ static gint gail_entry_get_index_in_parent (AtkObject *access
/* atkobject.h */ /* atkobject.h */
static AtkStateSet* gail_entry_ref_state_set (AtkObject *accessible); static AtkStateSet* gail_entry_ref_state_set (AtkObject *accessible);
static AtkAttributeSet* gail_entry_get_attributes (AtkObject *accessible);
/* atktext.h */ /* atktext.h */
@ -150,13 +151,13 @@ static gboolean gail_entry_do_action (AtkAction *actio
gint i); gint i);
static gboolean idle_do_action (gpointer data); static gboolean idle_do_action (gpointer data);
static gint gail_entry_get_n_actions (AtkAction *action); static gint gail_entry_get_n_actions (AtkAction *action);
static G_CONST_RETURN gchar* gail_entry_get_description (AtkAction *action, static G_CONST_RETURN gchar* gail_entry_action_get_description (AtkAction *action,
gint i); gint i);
static G_CONST_RETURN gchar* gail_entry_get_keybinding (AtkAction *action, static G_CONST_RETURN gchar* gail_entry_get_keybinding (AtkAction *action,
gint i); gint i);
static G_CONST_RETURN gchar* gail_entry_action_get_name (AtkAction *action, static G_CONST_RETURN gchar* gail_entry_action_get_name (AtkAction *action,
gint i); gint i);
static gboolean gail_entry_set_description (AtkAction *action, static gboolean gail_entry_action_set_description (AtkAction *action,
gint i, gint i,
const gchar *desc); const gchar *desc);
@ -187,6 +188,7 @@ gail_entry_class_init (GailEntryClass *klass)
class->ref_state_set = gail_entry_ref_state_set; class->ref_state_set = gail_entry_ref_state_set;
class->get_index_in_parent = gail_entry_get_index_in_parent; class->get_index_in_parent = gail_entry_get_index_in_parent;
class->initialize = gail_entry_real_initialize; class->initialize = gail_entry_real_initialize;
class->get_attributes = gail_entry_get_attributes;
widget_class->notify_gtk = gail_entry_real_notify_gtk; widget_class->notify_gtk = gail_entry_real_notify_gtk;
} }
@ -403,6 +405,33 @@ gail_entry_ref_state_set (AtkObject *accessible)
return state_set; return state_set;
} }
static AtkAttributeSet *
gail_entry_get_attributes (AtkObject *accessible)
{
GtkWidget *widget;
AtkAttributeSet *attributes;
AtkAttribute *placeholder_text;
const gchar *text;
attributes = ATK_OBJECT_CLASS (gail_entry_parent_class)->get_attributes (accessible);
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (accessible));
if (widget == NULL)
return attributes;
text = gtk_entry_get_placeholder_text (GTK_ENTRY (widget));
if (text == NULL)
return attributes;
placeholder_text = g_malloc (sizeof (AtkAttribute));
placeholder_text->name = g_strdup ("placeholder-text");
placeholder_text->value = g_strdup (text);
attributes = g_slist_append (attributes, placeholder_text);
return attributes;
}
/* atktext.h */ /* atktext.h */
static void static void
@ -1216,10 +1245,10 @@ atk_action_interface_init (AtkActionIface *iface)
{ {
iface->do_action = gail_entry_do_action; iface->do_action = gail_entry_do_action;
iface->get_n_actions = gail_entry_get_n_actions; iface->get_n_actions = gail_entry_get_n_actions;
iface->get_description = gail_entry_get_description; iface->get_description = gail_entry_action_get_description;
iface->get_keybinding = gail_entry_get_keybinding; iface->get_keybinding = gail_entry_get_keybinding;
iface->get_name = gail_entry_action_get_name; iface->get_name = gail_entry_action_get_name;
iface->set_description = gail_entry_set_description; iface->set_description = gail_entry_action_set_description;
} }
static gboolean static gboolean
@ -1281,7 +1310,7 @@ gail_entry_get_n_actions (AtkAction *action)
} }
static G_CONST_RETURN gchar* static G_CONST_RETURN gchar*
gail_entry_get_description (AtkAction *action, gail_entry_action_get_description (AtkAction *action,
gint i) gint i)
{ {
GailEntry *entry; GailEntry *entry;
@ -1383,7 +1412,7 @@ gail_entry_action_get_name (AtkAction *action,
} }
static gboolean static gboolean
gail_entry_set_description (AtkAction *action, gail_entry_action_set_description (AtkAction *action,
gint i, gint i,
const gchar *desc) const gchar *desc)
{ {