[evolution-patches] patch for combo-button's a11y bug



hi, hpj

Attach is the patch to make the combo-button's a11y work.
The first patch i sent to you has some warnings, So i make it again.
It has been checked up with gok .

The bug's link is http://bugzilla.ximian.com/show_bug.cgi?id=62830

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

Best regards
hao.sheng

? a11y/activate.diff
? a11y/warning.diff
? a11y/widgets/ea-combo-button.c
? a11y/widgets/ea-combo-button.h
? a11y/widgets/newbutton_a11y.diff
? widgets/misc/diff.123
? widgets/misc/e-combo-button.loT
? widgets/misc/test-title-bar
Index: a11y/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ChangeLog,v
retrieving revision 1.24
diff -u -p -r1.24 ChangeLog
--- a11y/ChangeLog	2 Dec 2004 02:51:24 -0000	1.24
+++ a11y/ChangeLog	6 Dec 2004 09:46:58 -0000
@@ -1,3 +1,17 @@
+2004-12-5   Harry Lu <harry lu sun com>
+
+	* widgets/ea-combo-button.h:
+	* widgets/ea-combo-button.c: add accessibility to combo-button.
+	* widgets/ea-widgets.c: 
+	(e_combo_button_a11y_init): init the combo-button's accessibility.
+	* widgets/Makefile.am: add ea-combo-button.[ch] to Makefile.
+
 2004-12-1   Hao Sheng <hao sheng sun com>
 
 	* a11y/addressbook/ea-minicard.c:
Index: a11y/widgets/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/Makefile.am,v
retrieving revision 1.3
diff -u -p -r1.3 Makefile.am
--- a11y/widgets/Makefile.am	6 Dec 2003 18:07:33 -0000	1.3
+++ a11y/widgets/Makefile.am	6 Dec 2004 09:47:00 -0000
@@ -23,6 +23,8 @@ libevolution_widgets_a11y_la_SOURCES =		
 	ea-calendar-item.h			\
 	ea-calendar-cell.c			\
 	ea-calendar-cell.h			\
+	ea-combo-button.c			\
+	ea-combo-button.h			\
 	ea-widgets.c				\
 	ea-widgets.h
 
Index: a11y/widgets/ea-combo-button.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-combo-button.c
diff -u -p -r1.2 ea-combo-button.c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-combo-button.c   2 Dec 2004 10:54:45 -0000
@@ -0,0 +1,166 @@
+/*
+ * Authors: Harry Lu  <harry lu sun com>
+ *
+ * Copyright (C) 2004 Ximian, Inc.
+ */
+
+#include <config.h>
+#include "ea-combo-button.h"
+#include <gtk/gtkbutton.h>
+#include <gtk/gtklabel.h>
+#include <glib/gi18n.h>
+
+static AtkObjectClass *parent_class;
+static GType parent_type;
+
+struct _GalA11yETreePrivate {
+       AtkObject *child_item;
+};
+
+/* Static functions */
+static G_CONST_RETURN gchar*
+ea_combo_button_get_name (AtkObject *a11y)
+{
+       GtkWidget *widget;
+       GtkWidget *label;
+       EComboButton *button;
+
+       widget = GTK_ACCESSIBLE (a11y)->widget;
+       if (!widget)
+               return NULL;
+
+       button = E_COMBO_BUTTON (widget);
+       label = e_combo_button_get_label (button);
+       if (label)
+               return gtk_label_get_text (GTK_LABEL (label));
+
+       return _("Combo Button");
+}
+
+/* Action interface */
+static G_CONST_RETURN gchar *
+ea_combo_button_action_get_name (AtkAction *action, gint i)
+{
+       switch (i)
+       {
+               case 0:
+                       return _("Activate Default");
+               case 1:
+                       return _("Popup Menu");
+               default:
+                       return NULL;
+       }
+}
+
+static gboolean
+ea_combo_button_do_action (AtkAction *action,
+                       gint      i)
+{
+       GtkWidget *widget;
+       EComboButton *button;
+
+       widget = GTK_ACCESSIBLE (action)->widget;
+       if (!widget || !GTK_WIDGET_IS_SENSITIVE (widget) || !GTK_WIDGET_VISIBLE (widget))
+               return FALSE;
+
+       button = E_COMBO_BUTTON (widget);
+
+       switch (i)
+       {
+               case 0:
+                       g_signal_emit_by_name (button, "activate_default");
+                       return TRUE;
+               case 1:
+                       return e_combo_button_popup_menu (button);
+               default:
+                       return FALSE;
+       }
+}
+
+static gint
+ea_combo_button_get_n_actions (AtkAction *action)
+{
+  return 2;
+}
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+       g_return_if_fail (iface != NULL);
+
+       iface->do_action = ea_combo_button_do_action;
+       iface->get_n_actions = ea_combo_button_get_n_actions;
+       iface->get_name = ea_combo_button_action_get_name;
+}
+
+static void
+ea_combo_button_class_init (EaComboButtonClass *klass)
+{
+       AtkObjectClass *atk_object_class = ATK_OBJECT_CLASS (klass);
+
+       parent_class  = g_type_class_ref (parent_type);
+
+       atk_object_class->get_name = ea_combo_button_get_name;
+}
+
+static void
+ea_combo_button_init (EaComboButton *a11y)
+{
+}
+
+GType
+ea_combo_button_get_type (void)
+{
+       static GType type = 0;
+
+       if (!type) {
+               AtkObjectFactory *factory;
+               GTypeQuery query;
+
+               GTypeInfo info = {
+                       sizeof (EaComboButtonClass),
+                       (GBaseInitFunc) NULL,
+                       (GBaseFinalizeFunc) NULL,
+                       (GClassInitFunc) ea_combo_button_class_init,
+                       (GClassFinalizeFunc) NULL,
+                       NULL, /* class_data */
+                       sizeof (EaComboButton),
+                       0,
+                       (GInstanceInitFunc) ea_combo_button_init,
+                       NULL /* value_tree */
+               };
+
+               static const GInterfaceInfo atk_action_info = {
+                       (GInterfaceInitFunc) atk_action_interface_init,
+                       (GInterfaceFinalizeFunc) NULL,
+                       NULL
+               };
+
+               factory = atk_registry_get_factory (atk_get_default_registry (), GTK_TYPE_BUTTON);
+               parent_type = atk_object_factory_get_accessible_type (factory);
+               g_type_query (parent_type, &query);
+
+               info.class_size = query.class_size;
+               info.instance_size = query.instance_size;
+
+               type = g_type_register_static (parent_type, "EaComboButton", &info, 0);
+               g_type_add_interface_static (type, ATK_TYPE_ACTION,
+                                            &atk_action_info);
+
+       }
+
+       return type;
+}
+
+AtkObject *
+ea_combo_button_new (GtkWidget *widget)
+{
+       EaComboButton *a11y;
+
+       a11y = g_object_new (ea_combo_button_get_type (), NULL);
+
+       GTK_ACCESSIBLE (a11y)->widget = GTK_WIDGET (widget);
+       ATK_OBJECT (a11y)->role = ATK_ROLE_PUSH_BUTTON;
+
+       return ATK_OBJECT (a11y);
+}
Index: a11y/widgets/ea-combo-button.h
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-combo-button.h
diff -u -p -r1.2 ea-combo-button.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-combo-button.h   2 Dec 2004 10:54:45 -0000
@@ -0,0 +1,36 @@
+/*
+ * Authors: Harry Lu  <harry lu sun com>
+ *
+ * Copyright (C) 2004 Ximian, Inc.
+ */
+
+#ifndef __EA_COMBO_BUTTON_H_
+#define __EA_COMBO_BUTTON_H_
+
+#include <gtk/gtkaccessible.h>
+#include <misc/e-combo-button.h>
+
+#define EA_TYPE_COMBO_BUTTON                   (ea_combo_button_get_type ())
+#define EA_COMBO_BUTTON(obj)                   (G_TYPE_CHECK_INSTANCE_CAST ((obj), EA_TYPE_COMBO_BUTTON, EaComboButton))
+#define EA_COMBO_BUTTON_CLASS(klass)           (G_TYPE_CHECK_CLASS_CAST ((klass), EA_TYPE_COMBO_BUTTON, EaComboButtonClass))+#define EA_IS_COMBO_BUTTON(obj)                        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EA_TYPE_COMBO_BUTTON))
+#define EA_IS_COMBO_BUTTON_CLASS(klass)        (G_TYPE_CHECK_CLASS_TYPE ((klass), EA_TYPE_COMBO_BUTTON))
+
+typedef struct _EaComboButton EaComboButton;
+typedef struct _EaComboButtonClass EaComboButtonClass;
+typedef struct _EaComboButtonPrivate EaComboButtonPrivate;
+
+struct _EaComboButton {
+       GtkAccessible object;
+};
+
+struct _EaComboButtonClass {
+       GtkAccessibleClass parent_class;
+};
+
+
+/* Standard Glib function */
+GType      ea_combo_button_get_type  (void);
+AtkObject *ea_combo_button_new       (GtkWidget *combo_button);
+
+#endif /* ! __EA_COMBO_BUTTON_H_ */
Index: a11y/widgets/ea-widgets.c
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-widgets.c,v
retrieving revision 1.2
diff -u -p -r1.2 ea-widgets.c
--- a11y/widgets/ea-widgets.c	11 Nov 2003 10:33:43 -0000	1.2
+++ a11y/widgets/ea-widgets.c	6 Dec 2004 09:47:01 -0000
@@ -25,11 +25,18 @@
 
 #include "ea-factory.h"
 #include "widgets/ea-calendar-item.h"
+#include "widgets/ea-combo-button.h"
 #include "ea-widgets.h"
 
-EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new)
+EA_FACTORY_GOBJECT (EA_TYPE_CALENDAR_ITEM, ea_calendar_item, ea_calendar_item_new);
+EA_FACTORY (EA_TYPE_COMBO_BUTTON, ea_combo_button, ea_combo_button_new);
 
 void e_calendar_item_a11y_init (void)
 {
     EA_SET_FACTORY (e_calendar_item_get_type (), ea_calendar_item);
 }
+
+void e_combo_button_a11y_init (void)
+{
+    EA_SET_FACTORY (e_combo_button_get_type (), ea_combo_button);
+}
Index: a11y/widgets/ea-widgets.h
===================================================================
RCS file: /cvs/gnome/evolution/a11y/widgets/ea-widgets.h,v
retrieving revision 1.1
diff -u -p -r1.1 ea-widgets.h
--- a11y/widgets/ea-widgets.h	27 Aug 2003 03:36:42 -0000	1.1
+++ a11y/widgets/ea-widgets.h	6 Dec 2004 09:47:01 -0000
@@ -30,5 +30,6 @@
 #define _EA_WIDGETS_H__
 
 void e_calendar_item_a11y_init (void);
+void e_combo_button_a11y_init (void);
 
 #endif /* _EA_WIDGETS_H__ */
Index: widgets/misc/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/ChangeLog,v
retrieving revision 1.333
diff -u -p -r1.333 ChangeLog
--- widgets/misc/ChangeLog	26 Nov 2004 15:15:36 -0000	1.333
+++ widgets/misc/ChangeLog	6 Dec 2004 09:47:16 -0000
@@ -1,3 +1,13 @@
+2004-12-5   Harry Lu  <harry lu sun com>
+
+	* e-combo-button.c:
+	(e_combo_button_popup): add popup event to combo-button.
+	(impl_button_press_event): use e_combo_button_popup instead 
+	of gtk_menu_popup.
+	(e_combo_button_class_init): add the a11y init.
+	(e_combo_button_get_label): get the combo-button's label.
+	(e_combo_button_popup_menu): popup menu after clicked combo-button.
+
 2004-11-26  JP Rosevear  <jpr novell com>
 
 	* test-info-label.c: test prog
Index: widgets/misc/e-combo-button.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-combo-button.c,v
retrieving revision 1.19
diff -u -p -r1.19 e-combo-button.c
--- widgets/misc/e-combo-button.c	26 Nov 2004 15:15:36 -0000	1.19
+++ widgets/misc/e-combo-button.c	6 Dec 2004 09:47:17 -0000
@@ -25,6 +25,7 @@
 #endif
 
 #include "e-combo-button.h"
+#include "ea-widgets.h"
 #include <e-util/e-icon-factory.h>
 
 #include <gtk/gtkarrow.h>
@@ -251,6 +252,30 @@ impl_destroy (GtkObject *object)
 }
 
 
+
+static gboolean
+e_combo_button_popup (EComboButton *combo_button, GdkEventButton *event)
+{
+	EComboButtonPrivate *priv;
+
+	g_return_val_if_fail (combo_button != NULL, FALSE);
+	g_return_val_if_fail (E_IS_COMBO_BUTTON (combo_button), FALSE);
+
+	priv = combo_button->priv;
+
+	priv->menu_popped_up = TRUE;
+
+	if (event)
+		gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
+				menu_position_func, combo_button,
+				event->button, event->time);
+	else
+		gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
+				menu_position_func, combo_button,
+				0, gtk_get_current_event_time());
+
+	return TRUE;
+}
 /* GtkWidget methods.  */
 
 static int
@@ -272,10 +297,7 @@ impl_button_press_event (GtkWidget *widg
 			/* User clicked on the right side: pop up the menu.  */
 			gtk_button_pressed (GTK_BUTTON (widget));
 
-			priv->menu_popped_up = TRUE;
-			gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
-					menu_position_func, combo_button,
-					event->button, event->time);
+			e_combo_button_popup (combo_button, event);
 		} else {
 			/* User clicked on the left side: just behave like a
 			   normal button (i.e. not a toggle).  */
@@ -393,6 +415,8 @@ e_combo_button_class_init (EComboButtonC
 						    G_STRUCT_OFFSET (EComboButtonClass, activate_default),
 						    gtk_marshal_NONE__NONE,
 						    GTK_TYPE_NONE, 0);
+
+	e_combo_button_a11y_init ();
 }
 
 static void
@@ -509,3 +533,22 @@ e_combo_button_set_menu (EComboButton *c
 			    G_CALLBACK (menu_deactivate_callback),
 			    combo_button);
 }
+
+GtkWidget *
+e_combo_button_get_label (EComboButton *combo_button)
+{
+	EComboButtonPrivate *priv;
+
+	g_return_val_if_fail (combo_button != NULL, NULL);
+	g_return_val_if_fail (E_IS_COMBO_BUTTON (combo_button), NULL);
+
+	priv = combo_button->priv;
+
+	return priv->label;
+}
+
+gboolean
+e_combo_button_popup_menu (EComboButton *combo_button)
+{
+	return e_combo_button_popup (combo_button, NULL);
+}
Index: widgets/misc/e-combo-button.h
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-combo-button.h,v
retrieving revision 1.3
diff -u -p -r1.3 e-combo-button.h
--- widgets/misc/e-combo-button.h	2 Dec 2002 03:28:22 -0000	1.3
+++ widgets/misc/e-combo-button.h	6 Dec 2004 09:47:17 -0000
@@ -73,6 +73,10 @@ void       e_combo_button_set_label  (EC
 void       e_combo_button_set_menu   (EComboButton *combo_button,
 				      GtkMenu      *menu);
 
+GtkWidget *e_combo_button_get_label  (EComboButton *combo_button);
+
+gboolean   e_combo_button_popup_menu (EComboButton *combo_button);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
begin:vcard
fn:hao sheng
n:sheng;hao
org:Sun Microsystems China Engineering & Research Institute;Desktop Group
adr:;;10/F Chuangxin Plaza, Tsinghua Science Park;Beijing;;100083;P.R.China
email;internet:hao sheng sun com
title:Software Engineer Intern
tel;work:+8610-82618200-82111
tel;cell:+86-13520134555
version:2.1
end:vcard



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