Re: [evolution-patches] Patch about a11y bugs in addressbook



hi, hpj

I made the changes as follow,  please review it again.
Thanks for your help.

best regards
hao.sheng


Hans Petter Jansson wrote:
On Sun, 2004-10-31 at 19:04 -0800, shenghao wrote:

  
Attach is a patch about a11y bug in addressbook part for HEAD.
It fixes the bug as follow:
Steps to reproduce:
1. Launch GOK and Evolution.
2. Ensure there are enough contacts in contacts folder, such as Local
Contacts Folder.
3. Select UI Grab in GOK.
Bug observation:
Contacts in contacts folder cannot be grabbed in GOK.

Please Would you like to spend a little time to review it, please?
    

In ea-minicard-view.c, don't use MINICARD_VIEW_ACTION_NUM to count the
elements in the array. Use G_N_ELEMENTS (action_name) whenever you need
the count.

Same in ea-minicard.c.

In ea_minicard_get_name(), leave the #define in the first column (no
space before the #), and remove the blank line before the first variable
declaration.

What does the removed chunk of code in ea_minicard_get_name() do?
  
   the code removed are about the list items in the Eminicard, and now it was unusable...
In atk_action_interface_do_action() in ea-minicard.c, there's a call to
activiate_editor(). I assume this should be activate_editor()? I.e.
without the 'i' thrown in. Same for the declaration in e-minicard.c. It
looks like this typo was there already - I don't mind if you correct it
in this patch. Or you can leave it alone, if you wish.
  
You're also making activiate_editor() be a public function - when doing
so, it's necessary to namespace it - add e_minicard_ before it, so it
doesn't clash with other declarations. I.e.
e_minicard_activate_editor().
  
   I have changed it in patch.
You also change a lot of spacing unnecessarily, but I can live with
that. Try to avoid it in the future, it makes patches harder to review.

Please make these changes and repost the patch. Thanks!

  

? a11y/addressbook/5108596.diff
? addressbook/gui/widgets/book
Index: a11y/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ChangeLog,v
retrieving revision 1.20
diff -u -p -r1.20 ChangeLog
--- a11y/ChangeLog	30 Sep 2004 07:32:36 -0000	1.20
+++ a11y/ChangeLog	3 Nov 2004 12:15:20 -0000
@@ -1,3 +1,35 @@
+2004-10-29  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).
+
 2004-09-23  Li Yuan  <li yuan sun com>
 
 	* calendar/ea-cal-view-event.c: (ea_cal_view_event_get_type),
Index: a11y/addressbook/ea-addressbook-view.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/addressbook/ea-addressbook-view.c,v
retrieving revision 1.1
diff -u -p -r1.1 ea-addressbook-view.c
--- a11y/addressbook/ea-addressbook-view.c	15 Mar 2004 06:21:53 -0000	1.1
+++ a11y/addressbook/ea-addressbook-view.c	3 Nov 2004 12:15:25 -0000
@@ -104,7 +104,7 @@ ea_ab_view_get_description (AtkObject *a
 }
 
 AtkObject* 
-ea_ab_view_new (GtkWidget *obj)
+ea_ab_view_new (GObject *obj)
 {
 	GObject *object;
 	AtkObject *accessible;
Index: a11y/addressbook/ea-addressbook-view.h
===================================================================
RCS file: /cvs/gnome/evolution/a11y/addressbook/ea-addressbook-view.h,v
retrieving revision 1.1
diff -u -p -r1.1 ea-addressbook-view.h
--- a11y/addressbook/ea-addressbook-view.h	15 Mar 2004 06:21:53 -0000	1.1
+++ a11y/addressbook/ea-addressbook-view.h	3 Nov 2004 12:15:27 -0000
@@ -51,7 +51,7 @@ struct _EaABViewClass
 };
 
 GType ea_ab_view_get_type (void);
-AtkObject* ea_ab_view_new(GtkWidget *obj);
+AtkObject* ea_ab_view_new(GObject *obj);
 
 #ifdef __cplusplus
 }
Index: a11y/addressbook/ea-addressbook.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/addressbook/ea-addressbook.c,v
retrieving revision 1.1
diff -u -p -r1.1 ea-addressbook.c
--- a11y/addressbook/ea-addressbook.c	15 Mar 2004 06:21:53 -0000	1.1
+++ a11y/addressbook/ea-addressbook.c	3 Nov 2004 12:15:31 -0000
@@ -74,13 +74,13 @@ ea_addressbook_focus_watcher (GSignalInv
 	object = g_value_get_object (param_values + 0);
 	event = g_value_get_boxed (param_values + 1);
 
-	if (E_IS_MINICARD(object)) {
+	if (E_IS_MINICARD (object)) {
 		EMinicard *minicard = E_MINICARD (object);
-                GnomeCanvasItem *item = GNOME_CANVAS_ITEM(object);
-		ea_event = atk_gobject_accessible_for_object(minicard);
+                GnomeCanvasItem *item = GNOME_CANVAS_ITEM (object);
+		ea_event = atk_gobject_accessible_for_object (ATK_OBJECT (minicard));
 		if (event->type == GDK_FOCUS_CHANGE) {
-			if ((event->focus_change.in) && (E_IS_MINICARD(item->canvas->focused_item)))
-				atk_focus_tracker_notify(ea_event);
+			if ((event->focus_change.in) && (E_IS_MINICARD (item->canvas->focused_item)))
+				atk_focus_tracker_notify (ea_event);
 		}
 	}
 
Index: a11y/addressbook/ea-minicard-view.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/addressbook/ea-minicard-view.c,v
retrieving revision 1.1
diff -u -p -r1.1 ea-minicard-view.c
--- a11y/addressbook/ea-minicard-view.c	15 Mar 2004 06:21:53 -0000	1.1
+++ a11y/addressbook/ea-minicard-view.c	3 Nov 2004 12:15:34 -0000
@@ -2,7 +2,7 @@
 /* 
  * ea-minicard-view.c
  * Copyright (C) 2000  Ximian, Inc.
- * Author:  Leon Zhang < leon zhang sun com>
+ * Author:  Leon Zhang < leon zhang sun com> 
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of version 2 of the GNU General Public
@@ -22,14 +22,46 @@
 #include <config.h>
 #include <libgnome/gnome-i18n.h>
 #include <string.h>
+#include <gtk/gtkaccessible.h>
+#include <glib/gstrfuncs.h>
+#include <libgnome/gnome-i18n.h>
 #include "ea-minicard.h"
 #include "ea-minicard-view.h"
+#include "eab-gui-util.h"
+#include "e-addressbook-view.h"
+
+static const char * action_name[] = {
+	N_("New Contact"),
+	N_("New Contact List")
+};
+
 
 static G_CONST_RETURN gchar* ea_minicard_view_get_name (AtkObject *accessible);
 static G_CONST_RETURN gchar* ea_minicard_view_get_description (AtkObject *accessible);
 
 static void ea_minicard_view_class_init (EaMinicardViewClass *klass);
 
+static gint ea_minicard_view_get_n_children (AtkObject *obj);
+static AtkObject *ea_minicard_view_ref_child (AtkObject *obj, gint i);
+
+static AtkStateSet *ea_minicard_view_ref_state_set(AtkObject *obj);
+
+static void atk_selection_interface_init (AtkSelectionIface *iface);
+static gboolean selection_interface_add_selection (AtkSelection *selection,
+						   gint i);
+static gboolean selection_interface_clear_selection (AtkSelection *selection);
+static AtkObject* selection_interface_ref_selection (AtkSelection *selection,
+						     gint i);
+static gint selection_interface_get_selection_count (AtkSelection *selection);
+static gboolean selection_interface_is_child_selected (AtkSelection *selection,
+						       gint i);
+
+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 +86,18 @@ ea_minicard_view_get_type (void)
 			NULL /* value table */
 		};
 
+		static const GInterfaceInfo atk_selection_info = {
+			(GInterfaceInitFunc) atk_selection_interface_init,
+			(GInterfaceFinalizeFunc) NULL,
+			NULL
+		};
+			
+		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) */
@@ -68,6 +112,11 @@ ea_minicard_view_get_type (void)
 
 		type = g_type_register_static (derived_atk_type,
 						"EaMinicardView", &tinfo, 0);
+		g_type_add_interface_static (type, ATK_TYPE_SELECTION,
+					     &atk_selection_info);
+		g_type_add_interface_static (type, ATK_TYPE_ACTION,
+					     &atk_action_info);
+		
 	}
 
 	return type;
@@ -82,21 +131,24 @@ ea_minicard_view_class_init (EaMinicardV
 
 	class->get_name = ea_minicard_view_get_name;
 	class->get_description = ea_minicard_view_get_description;
+	class->ref_state_set = ea_minicard_view_ref_state_set;
+	class->get_n_children = ea_minicard_view_get_n_children;
+	class->ref_child = ea_minicard_view_ref_child;
 }
 
 static G_CONST_RETURN gchar*
 ea_minicard_view_get_name (AtkObject *accessible)
 {
-	static gchar name[100];
+	gchar name[100];
 	GString *new_str = g_string_new (NULL);
 	gchar str[10];
 	EReflow *reflow;
 
-	g_return_val_if_fail (EA_IS_MINICARD_VIEW(accessible), NULL);
+	g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), NULL);
 	memset (name, '\0', 100);
 	memset (str, '\0', 10);
 
-	reflow = E_REFLOW(atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)));
+	reflow = E_REFLOW(atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible)));
 	sprintf (str, "%d", reflow->count);
 	g_string_append (new_str, _("current addressbook folder "));
 	g_string_append (new_str, (reflow->count) > 1 ? _("have ") : _("has "));
@@ -106,7 +158,8 @@ ea_minicard_view_get_name (AtkObject *ac
 	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*
@@ -129,6 +182,231 @@ ea_minicard_view_new (GObject *obj)
 	object = g_object_new (EA_TYPE_MINICARD_VIEW, NULL);
 	accessible = ATK_OBJECT (object);
 	atk_object_initialize (accessible, obj);
-	accessible->role = ATK_ROLE_PANEL;
+	accessible->role = ATK_ROLE_UNKNOWN;
 	return accessible;
 }
+
+static gint
+ea_minicard_view_get_n_children (AtkObject *accessible)
+{
+	EReflow *reflow;
+	
+	gint child_num = 0;
+	
+	g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), -1);
+	
+	reflow = E_REFLOW (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE(accessible)));
+
+	if (!reflow)
+		return -1;
+	
+	child_num = reflow->count;
+	
+	return child_num;
+}
+
+static AtkStateSet *ea_minicard_view_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_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 AtkObject *
+ea_minicard_view_ref_child (AtkObject *accessible, gint index)
+{
+	EReflow *reflow;
+	gint child_num;
+	AtkObject *atk_object = NULL;
+	EMinicard *card = NULL;
+
+	g_return_val_if_fail (EA_IS_MINICARD_VIEW (accessible), NULL);
+	
+	child_num = atk_object_get_n_accessible_children (accessible);
+	if (child_num <= 0 || index < 0 || index >= child_num)
+		return NULL;
+	
+	reflow = E_REFLOW (atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible)));
+	if (!reflow)
+		return NULL;
+	if (!reflow->items )
+		return NULL;
+		/* a minicard */
+	if (index < child_num) {
+		card = E_MINICARD (reflow->items[index]);
+		atk_object = atk_gobject_accessible_for_object (G_OBJECT (card));
+	} else {
+		return NULL;
+	}
+
+	g_object_ref (atk_object);
+		return atk_object;
+}
+
+/* atkselection interface */
+
+static void
+atk_selection_interface_init (AtkSelectionIface *iface)
+{
+	g_return_if_fail (iface != NULL);
+
+	iface->add_selection = selection_interface_add_selection;
+	iface->clear_selection = selection_interface_clear_selection;
+	iface->ref_selection = selection_interface_ref_selection;
+	iface->get_selection_count = selection_interface_get_selection_count;
+	iface->is_child_selected = selection_interface_is_child_selected;
+}
+
+static gboolean
+selection_interface_add_selection (AtkSelection *selection, gint i)
+{
+	AtkGObjectAccessible *atk_gobj= NULL;
+	EReflow *reflow = NULL;
+	
+	atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection);
+	reflow = E_REFLOW (atk_gobject_accessible_get_object (atk_gobj));
+	
+	if (!reflow)
+		return FALSE;
+	
+	selection_interface_clear_selection (selection);
+	e_selection_model_select_single_row (reflow->selection, i);
+
+	return TRUE;
+}
+
+static gboolean
+selection_interface_clear_selection (AtkSelection *selection)
+{
+	AtkGObjectAccessible *atk_gobj = NULL;
+	EReflow *reflow = NULL;
+
+	atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection);
+	reflow = E_REFLOW(atk_gobject_accessible_get_object (atk_gobj));
+
+	if( !reflow )
+		return FALSE;
+	
+	e_selection_model_clear (reflow->selection);
+	
+	return TRUE;
+}
+
+static AtkObject*
+selection_interface_ref_selection (AtkSelection *selection, gint i)
+{
+	return ea_minicard_view_ref_child (ATK_OBJECT (selection), i);
+}
+
+static gint
+selection_interface_get_selection_count (AtkSelection *selection)
+{
+	AtkGObjectAccessible *atk_gobj = NULL;
+	EReflow *reflow = NULL;
+
+	atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection);
+	reflow = E_REFLOW (atk_gobject_accessible_get_object (atk_gobj));
+
+	if (!reflow )
+		return FALSE;
+	
+	return e_selection_model_selected_count (reflow->selection);
+}
+
+static gboolean
+selection_interface_is_child_selected (AtkSelection *selection, gint i)
+{
+	AtkGObjectAccessible *atk_gobj = NULL;
+	EReflow *reflow = NULL;
+
+	atk_gobj = ATK_GOBJECT_ACCESSIBLE (selection);
+	reflow = E_REFLOW(atk_gobject_accessible_get_object (atk_gobj));
+
+	if( !reflow )
+		return FALSE;
+
+	return e_selection_model_is_row_selected (reflow->selection, i);
+}
+
+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 *action, gint i)
+{
+	gboolean return_value = TRUE;
+	EMinicardView *card_view;
+	EContact *contact = e_contact_new();
+
+	AtkGObjectAccessible *atk_gobj= NULL;
+        EReflow *reflow = NULL;
+	EBook *book;
+
+	atk_gobj = ATK_GOBJECT_ACCESSIBLE (action);
+	reflow = E_REFLOW (atk_gobject_accessible_get_object (atk_gobj));
+
+	if (reflow == NULL)
+		return FALSE;
+
+	card_view = E_MINICARD_VIEW (reflow);
+	g_object_get(card_view,
+		     "book", &book,
+		     NULL);
+	g_assert (E_IS_BOOK (book));
+
+	switch (i) {
+		case 0:
+		/* New Contact */
+			eab_show_contact_editor (book, contact, TRUE, TRUE);
+			break;
+		case 1:
+		/* New Contact List */
+			eab_show_contact_list_editor (book, contact, TRUE, TRUE);
+			break;
+		default:
+                	return_value = FALSE;
+			break;
+	}
+	g_object_unref (book);
+	g_object_unref (contact);
+	return return_value;
+}
+
+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];
+}
+		
Index: a11y/addressbook/ea-minicard.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/addressbook/ea-minicard.c,v
retrieving revision 1.1
diff -u -p -r1.1 ea-minicard.c
--- a11y/addressbook/ea-minicard.c	15 Mar 2004 06:21:53 -0000	1.1
+++ a11y/addressbook/ea-minicard.c	3 Nov 2004 12:15:36 -0000
@@ -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 
 
 	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 *accessi
 		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 *
 {
 	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];
+}
+		
Index: addressbook/gui/widgets/e-minicard.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-minicard.c,v
retrieving revision 1.117
diff -u -p -r1.117 e-minicard.c
--- addressbook/gui/widgets/e-minicard.c	17 May 2004 19:09:40 -0000	1.117
+++ addressbook/gui/widgets/e-minicard.c	3 Nov 2004 12:15:44 -0000
@@ -531,14 +531,14 @@ editor_closed_cb (GtkObject *editor, gpo
 	minicard->editor = NULL;
 }
 
-static gboolean
-activiate_editor(GnomeCanvasItem *item)
+gboolean
+e_minicard_activate_editor(EMinicard *minicard)
 {
-	EMinicard *e_minicard;
-	e_minicard = E_MINICARD (item);
-        
-	if (e_minicard->editor) {
-		eab_editor_raise (e_minicard->editor);
+	GnomeCanvasItem *item = NULL;
+	item = minicard;
+      
+	if (minicard->editor) {
+		eab_editor_raise (minicard->editor);
 	}
 	else {
 		EBook *book = NULL;
@@ -547,20 +547,20 @@ activiate_editor(GnomeCanvasItem *item)
 		}
 
 		if (book != NULL) {
-			if (e_contact_get (e_minicard->contact, E_CONTACT_IS_LIST)) {
-				EContactListEditor *editor = eab_show_contact_list_editor (book, e_minicard->contact,
-												FALSE, e_minicard->editable);
-				e_minicard->editor = EAB_EDITOR (editor);
+			if (e_contact_get (minicard->contact, E_CONTACT_IS_LIST)) {
+				EContactListEditor *editor = eab_show_contact_list_editor (book, minicard->contact,
+												FALSE, minicard->editable);
+				minicard->editor = EAB_EDITOR (editor);
 			}
 			else {
-				EContactEditor *editor = eab_show_contact_editor (book, e_minicard->contact,
-												FALSE, e_minicard->editable);
-				e_minicard->editor = EAB_EDITOR (editor);
+				EContactEditor *editor = eab_show_contact_editor (book, minicard->contact,
+												FALSE, minicard->editable);
+				minicard->editor = EAB_EDITOR (editor);
 			}
 
-			g_object_ref (e_minicard->editor);
-			g_signal_connect (e_minicard->editor, "editor_closed",
-							G_CALLBACK (editor_closed_cb), e_minicard);
+			g_object_ref (minicard->editor);
+			g_signal_connect (minicard->editor, "editor_closed",
+							G_CALLBACK (editor_closed_cb), minicard);
 
 			g_object_unref (book);
 		}
@@ -651,8 +651,8 @@ e_minicard_event (GnomeCanvasItem *item,
 		}
 		break;
 	case GDK_2BUTTON_PRESS:
-		if (event->button.button == 1 && E_IS_MINICARD_VIEW(item->parent)) {
-			return activiate_editor(item);
+		if (event->button.button == 1 && E_IS_MINICARD_VIEW (item->parent)) {
+			return e_minicard_activate_editor (e_minicard);
 		}
 		break;
 	case GDK_KEY_PRESS:
@@ -660,7 +660,7 @@ e_minicard_event (GnomeCanvasItem *item,
 			event->key.keyval == GDK_KP_Tab ||
 			event->key.keyval == GDK_ISO_Left_Tab) {
 
-			EMinicardView *view = E_MINICARD_VIEW(item->parent);
+			EMinicardView *view = E_MINICARD_VIEW (item->parent);
 			EReflow *reflow = E_REFLOW(view);
 
 			if (reflow == NULL) {
@@ -672,7 +672,7 @@ e_minicard_event (GnomeCanvasItem *item,
 					return FALSE;
 				}
 				else {
-					int row_count = e_selection_model_row_count(reflow->selection);
+					int row_count = e_selection_model_row_count (reflow->selection);
 					int model_index = e_selection_model_cursor_row (reflow->selection);
 					int view_index = e_sorter_model_to_sorted (reflow->selection->sorter, model_index);
 
@@ -682,7 +682,7 @@ e_minicard_event (GnomeCanvasItem *item,
 						view_index--;
 
 					model_index = e_sorter_sorted_to_model (E_SORTER (reflow->sorter), view_index);
-					e_canvas_item_grab_focus(reflow->items[model_index], FALSE);
+					e_canvas_item_grab_focus (reflow->items[model_index], FALSE);
 					return TRUE;
 				}
 			}
@@ -708,7 +708,7 @@ e_minicard_event (GnomeCanvasItem *item,
 		}
 		else if (event->key.keyval == GDK_Return ||
 				event->key.keyval == GDK_KP_Enter) {
-				return activiate_editor(item);
+				return e_minicard_activate_editor (e_minicard);
 		}
 		break;
 	default:
Index: addressbook/gui/widgets/e-minicard.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/widgets/e-minicard.h,v
retrieving revision 1.34
diff -u -p -r1.34 e-minicard.h
--- addressbook/gui/widgets/e-minicard.h	24 Mar 2004 20:18:49 -0000	1.34
+++ addressbook/gui/widgets/e-minicard.h	3 Nov 2004 12:15:45 -0000
@@ -122,6 +122,7 @@ int         e_minicard_compare      (EMi
 
 int         e_minicard_selected     (EMinicard *minicard,
 				     GdkEvent  *event);
+gboolean    e_minicard_activate_editor	(EMinicard *minicard);
 
 #ifdef __cplusplus
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]