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



JP,
    Sorry. Attached is the new patch.
    Please review it.
    Thanks!
       Harry

JP Rosevear wrote:
On Mon, 2004-12-06 at 18:08 -0800, hao.sheng wrote:
  
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.
    

Oops, I take it this patch replaces the earlier version, unfortunately
the patch appears to be malformed when attempting to apply it.

-JP
  
Index: a11y/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/a11y/ChangeLog,v
retrieving revision 1.24
diff -u -r1.24 ChangeLog
--- a11y/ChangeLog	2 Dec 2004 02:51:24 -0000	1.24
+++ a11y/ChangeLog	8 Dec 2004 10:03:30 -0000
@@ -1,3 +1,11 @@
+2004-12-08  Harry Lu  <harry lu sun com>
+
+	* widgets/Makefile.am: add ea-combo-button.[ch] to Makefile.
+	* widgets/ea-combo-button.c: 
+	* widgets/ea-combo-button.h: implement a11y object for e-combo-button.
+	* widgets/ea-widgets.c: (e_combo_button_a11y_init): set a11y factory.
+	* widgets/ea-widgets.h: add declaration.
+
 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 -r1.3 Makefile.am
--- a11y/widgets/Makefile.am	6 Dec 2003 18:07:33 -0000	1.3
+++ a11y/widgets/Makefile.am	8 Dec 2004 10:03:31 -0000
@@ -23,6 +23,8 @@
 	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: a11y/widgets/ea-combo-button.c
diff -N a11y/widgets/ea-combo-button.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-combo-button.c	8 Dec 2004 10:03:31 -0000
@@ -0,0 +1,163 @@
+/*
+ * 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;
+
+/* 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)
+{
+	/* Empty for new */
+}
+
+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: a11y/widgets/ea-combo-button.h
diff -N a11y/widgets/ea-combo-button.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ a11y/widgets/ea-combo-button.h	8 Dec 2004 10:03:31 -0000
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+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 -r1.2 ea-widgets.c
--- a11y/widgets/ea-widgets.c	11 Nov 2003 10:33:43 -0000	1.2
+++ a11y/widgets/ea-widgets.c	8 Dec 2004 10:03:31 -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 -r1.1 ea-widgets.h
--- a11y/widgets/ea-widgets.h	27 Aug 2003 03:36:42 -0000	1.1
+++ a11y/widgets/ea-widgets.h	8 Dec 2004 10:03:31 -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/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/widgets/ChangeLog,v
retrieving revision 1.127
diff -u -r1.127 ChangeLog
--- widgets/ChangeLog	12 Nov 2004 13:52:17 -0000	1.127
+++ widgets/ChangeLog	8 Dec 2004 10:03:33 -0000
@@ -1,3 +1,13 @@
+2004-12-08  Harry Lu  <harry lu sun com>
+
+	* misc/e-combo-button.c: (e_combo_button_popup): new internal function
+	to popup the menu.
+	(impl_button_press_event): call the new function.
+	(e_combo_button_class_init): init a11y.
+	(e_combo_button_get_label): new function to return label.
+	(e_combo_button_popup_menu): new function to popup menu.
+	* misc/e-combo-button.h: add function declarations.
+
 2004-11-12  JP Rosevear  <jpr novell com>
 
 	* menus/gal-view-menus.c: Convert to G_DEFINE_TYPE
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 -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	8 Dec 2004 10:03:34 -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 @@
 }
 
 
+
+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 @@
 			/* 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 @@
 						    G_STRUCT_OFFSET (EComboButtonClass, activate_default),
 						    gtk_marshal_NONE__NONE,
 						    GTK_TYPE_NONE, 0);
+
+	e_combo_button_a11y_init ();
 }
 
 static void
@@ -508,4 +532,23 @@
 	g_signal_connect((menu), "deactivate",
 			    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 -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	8 Dec 2004 10:03:34 -0000
@@ -73,6 +73,10 @@
 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 */


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