aboutsummaryrefslogtreecommitdiffstats
path: root/a11y/addressbook/ea-minicard.c
diff options
context:
space:
mode:
authorSteven Zhang <steven.zhang@sun.com>2004-11-08 14:12:18 +0800
committerHarry Lu <haip@src.gnome.org>2004-11-08 14:12:18 +0800
commit345004653e87e63250fcae74961e20a950153b01 (patch)
treeb27bbe463c583a2820b8613dc983a660fe91580e /a11y/addressbook/ea-minicard.c
parentab63574fbb9e61901d13837bf3f481d3199334b0 (diff)
downloadgsoc2013-evolution-345004653e87e63250fcae74961e20a950153b01.tar.gz
gsoc2013-evolution-345004653e87e63250fcae74961e20a950153b01.tar.zst
gsoc2013-evolution-345004653e87e63250fcae74961e20a950153b01.zip
Implement accessible feature for e-minicard and e-mini-card-view. Add
2004-11-08 Steven Zhang <steven.zhang@sun.com> Implement accessible feature for e-minicard and e-mini-card-view. Add get_n_children, ref_child, ref_state_set, atk_selection_interface, and action_interface for ea-minicard-view and ea-minicard *ea-minicard-view.c: (ea_minicard_view_get_n_children), (ea_minicard_view_ref_child), (ea_minicard_view_ref_state_set), (atk_selection_interface_init), (selection_interface_add_selection), (selection_interface_clear_selection), (selection_interface_ref_selection), (selection_interface_get_selection_count), (selection_interface_is_child_selected), (atk_action_interface_init), (atk_action_interface_do_action), (atk_action_interface_get_n_action), (atk_action_interface_get_description), (atk_action_interface_get_name). *ea-minicard.c: (ea_minicard_get_n_children), (ea_minicard_ref_child), (ea_minicard_ref_state_set), (atk_action_interface_init), (atk_action_interface_do_action), (atk_action_interface_get_n_action), (atk_action_interface_get_description), (atk_action_interface_get_name). svn path=/trunk/; revision=27861
Diffstat (limited to 'a11y/addressbook/ea-minicard.c')
-rw-r--r--a11y/addressbook/ea-minicard.c163
1 files changed, 124 insertions, 39 deletions
diff --git a/a11y/addressbook/ea-minicard.c b/a11y/addressbook/ea-minicard.c
index c49f759d58..d7b61cfd8d 100644
--- a/a11y/addressbook/ea-minicard.c
+++ b/a11y/addressbook/ea-minicard.c
@@ -24,12 +24,29 @@
#include <string.h>
#include <libgnome/gnome-i18n.h>
#include "ea-minicard.h"
+#include "ea-minicard-view.h"
+#include "e-minicard.h"
+
+static const char * action_name[] = {
+ N_("Open")
+};
static G_CONST_RETURN gchar* ea_minicard_get_name (AtkObject *accessible);
static G_CONST_RETURN gchar* ea_minicard_get_description (AtkObject *accessible);
static void ea_minicard_class_init (EaMinicardClass *klass);
+static gint ea_minicard_get_n_children (AtkObject *obj);
+static AtkObject* ea_minicard_ref_child(AtkObject *obj, gint i);
+
+static AtkStateSet *ea_minicard_ref_state_set (AtkObject *obj);
+
+static void atk_action_interface_init (AtkActionIface *iface);
+static gboolean atk_action_interface_do_action (AtkAction *iface, gint i);
+static gint atk_action_interface_get_n_action (AtkAction *iface);
+static G_CONST_RETURN gchar* atk_action_interface_get_description (AtkAction *iface, gint i);
+static G_CONST_RETURN gchar* atk_action_interface_get_name (AtkAction *iface, gint i);
+
static gpointer parent_class = NULL;
GType
@@ -54,6 +71,12 @@ ea_minicard_get_type (void)
NULL /* value table */
};
+ static const GInterfaceInfo atk_action_info = {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
/*
* Figure out the size of the class and instance
* we are run-time deriving from (GailWidget, in this case)
@@ -69,6 +92,8 @@ ea_minicard_get_type (void)
type = g_type_register_static ( derived_atk_type,
"EaMinicard", &tinfo, 0);
+ g_type_add_interface_static (type, ATK_TYPE_ACTION,
+ &atk_action_info);
}
return type;
@@ -83,6 +108,9 @@ ea_minicard_class_init (EaMinicardClass *klass)
class->get_name = ea_minicard_get_name;
class->get_description = ea_minicard_get_description;
+ class->ref_state_set = ea_minicard_ref_state_set;
+ class->get_n_children = ea_minicard_get_n_children;
+ class->ref_child = ea_minicard_ref_child;
}
/*
@@ -93,21 +121,23 @@ static G_CONST_RETURN gchar*
ea_minicard_get_name (AtkObject *accessible)
{
#define BUFFERSIZE 500
+
static gchar name[BUFFERSIZE];
GString *new_str = g_string_new (NULL);
gchar *string;
EMinicard *card;
- GList *list;
g_return_val_if_fail (EA_IS_MINICARD(accessible), NULL);
memset (name, '\0', BUFFERSIZE);
- g_string_append (new_str, _("contact's header: "));
-
card = E_MINICARD(atk_gobject_accessible_get_object
(ATK_GOBJECT_ACCESSIBLE(accessible)));
g_object_get (card->header_text, "text", &string, NULL);
+ if (e_contact_get (card->contact, E_CONTACT_IS_LIST))
+ g_string_append (new_str, _("Contact List: "));
+ else g_string_append (new_str, _("Contact: "));
+
/* get header of current card */
g_string_append (new_str, string);
g_free (string);
@@ -118,43 +148,12 @@ ea_minicard_get_name (AtkObject *accessible)
return name;
}
- g_string_append (new_str, " ");
-
- for ( list = card->fields; list; list = g_list_next( list ) ) {
- gchar *f, *fn;
- EMinicardLabel *label;
-
- label = E_MINICARD_LABEL (E_MINICARD_FIELD (list->data)->label);
-
- /* get field name */
- g_object_get (label->fieldname, "text", &fn, NULL);
- g_string_append (new_str, fn);
- g_free (fn);
-
- if (new_str->len >= BUFFERSIZE) {
- strncpy(name, new_str->str, BUFFERSIZE);
- return name;
- }
-
- g_string_append (new_str, " ");
-
- /* get field */
- g_object_get (label->field, "text", &f, NULL);
- g_string_append (new_str, f);
- g_free (f);
-
- if (new_str->len >= BUFFERSIZE) {
- strncpy (name, new_str->str, BUFFERSIZE);
- return name;
- }
-
- g_string_append (new_str, " ");
- }
-
strcpy (name, new_str->str);
g_string_free (new_str, TRUE);
- return name;
+ ATK_OBJECT_CLASS (parent_class)->set_name (accessible, name);
+
+ return accessible->name;
}
static G_CONST_RETURN gchar*
@@ -162,7 +161,7 @@ ea_minicard_get_description (AtkObject *accessible)
{
if (accessible->description)
return accessible->description;
-
+
return _("evolution minicard");
}
@@ -179,6 +178,92 @@ ea_minicard_new (GObject *obj)
accessible = ATK_OBJECT (object);
atk_object_initialize (accessible, obj);
- accessible->role = ATK_ROLE_PANEL;
+ accessible->role = ATK_ROLE_UNKNOWN;
return accessible;
}
+
+static AtkStateSet *ea_minicard_ref_state_set (AtkObject *obj)
+{
+ AtkStateSet *state_set = NULL;
+ GObject *gobj = NULL;
+
+ state_set = ATK_OBJECT_CLASS (parent_class)->ref_state_set (obj);
+ if( !state_set )
+ return NULL;
+ gobj = atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (obj));
+ if( !gobj )
+ return NULL;
+
+ atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
+ atk_state_set_add_state (state_set, ATK_STATE_ENABLED);
+ atk_state_set_add_state (state_set, ATK_STATE_SENSITIVE);
+ atk_state_set_add_state (state_set, ATK_STATE_SHOWING);
+
+ return state_set;
+}
+
+static gint
+ea_minicard_get_n_children (AtkObject *accessible)
+{
+ return 0;
+}
+
+static AtkObject *
+ea_minicard_ref_child (AtkObject *accessible, gint index)
+{
+ return NULL;
+}
+
+static void atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = atk_action_interface_do_action;
+ iface->get_n_actions = atk_action_interface_get_n_action;
+ iface->get_description = atk_action_interface_get_description;
+ iface->get_name = atk_action_interface_get_name;
+}
+
+static gboolean atk_action_interface_do_action (AtkAction *iface, gint i)
+{
+ EMinicard *minicard = NULL;
+
+ minicard = E_MINICARD (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (iface)));
+ if( minicard == NULL )
+ return FALSE;
+
+ if( i >= G_N_ELEMENTS (action_name) || i < 0 )
+ return FALSE;
+
+ switch (i) {
+ // open card
+ case 0:
+ e_minicard_activiate_editor (minicard);
+ break;
+ default:
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gint atk_action_interface_get_n_action (AtkAction *iface)
+{
+ return G_N_ELEMENTS (action_name);
+}
+
+static G_CONST_RETURN gchar*
+atk_action_interface_get_description (AtkAction *iface, gint i)
+{
+ return atk_action_interface_get_name (iface, i);
+}
+
+static G_CONST_RETURN gchar*
+atk_action_interface_get_name (AtkAction *iface, gint i)
+{
+ if( i >= G_N_ELEMENTS (action_name) || i < 0)
+ return NULL;
+
+ return action_name[i];
+}
+