[evolution-patches] patch to fix #302154 (add support to sort table items by gok) [e-table]
- From: Li Yuan <Li Yuan Sun COM>
- To: JP Rosevear <jpr novell com>
- Cc: patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] patch to fix #302154 (add support to sort table items by gok) [e-table]
- Date: Wed, 27 Apr 2005 20:00:18 +0800
Hi,JP
Here is a patch to fix #302154. It makes gok can grub the table header
items
and 'click' them to sort the table items.
Please help me to review it.
Thank you very much.
Regards,
Li
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.926
diff -u -r1.926 ChangeLog
--- ChangeLog 27 Apr 2005 07:40:56 -0000 1.926
+++ ChangeLog 27 Apr 2005 11:51:48 -0000
@@ -1,3 +1,18 @@
+2005-04-27 Li Yuan <li yuan sun com>
+
+ * gal/a11y/e-table/Makefile.am:
+ * gal/a11y/e-table/gal-a11y-e-table-column-header.c:
+ * gal/a11y/e-table/gal-a11y-e-table-column-header.h:
+ add two files to sort table items.
+ * gal/a11y/e-table/gal-a11y-e-cell.c:
+ (gal_a11y_e_cell_get_index_in_parent):
+ add table header.
+ * gal/a11y/e-table/gal-a11y-e-table-item.c: (eti_get_n_children):
+ (eti_ref_child), (eti_get_n_rows), (eti_get_column_header):
+ ditto.
+
+ Fixes #302154
+
2005-04-26 Harish Krishnaswamy <kharish novell com>
* configure.in : bump version to 2.5.1
Index: gal/a11y/e-table/Makefile.am
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/Makefile.am,v
retrieving revision 1.8
diff -u -r1.8 Makefile.am
--- gal/a11y/e-table/Makefile.am 27 Jan 2005 05:24:18 -0000 1.8
+++ gal/a11y/e-table/Makefile.am 27 Apr 2005 11:51:48 -0000
@@ -24,6 +24,7 @@
gal-a11y-e-table-item.c \
gal-a11y-e-table-item-factory.c \
gal-a11y-e-table-click-to-add.c \
+ gal-a11y-e-table-column-header.c \
gal-a11y-e-table-click-to-add-factory.c \
gal-a11y-e-table-factory.c
@@ -43,5 +44,6 @@
gal-a11y-e-table-item.h \
gal-a11y-e-table-click-to-add-factory.h \
gal-a11y-e-table-click-to-add.h \
+ gal-a11y-e-table-column-header.h \
gal-a11y-e-table-item-factory.h \
gal-a11y-e-table-factory.h
Index: gal/a11y/e-table/gal-a11y-e-cell.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-cell.c,v
retrieving revision 1.10
diff -u -r1.10 gal-a11y-e-cell.c
--- gal/a11y/e-table/gal-a11y-e-cell.c 24 Feb 2005 05:36:39 -0000 1.10
+++ gal/a11y/e-table/gal-a11y-e-cell.c 27 Apr 2005 11:51:48 -0000
@@ -134,7 +134,7 @@
if (!is_valid (accessible))
return -1;
- return a11y->row * a11y->item->cols + a11y->view_col;
+ return (a11y->row + 1) * a11y->item->cols + a11y->view_col;
}
Index: gal/a11y/e-table/gal-a11y-e-table-column-header.c
===================================================================
RCS file: gal/a11y/e-table/gal-a11y-e-table-column-header.c
diff -N gal/a11y/e-table/gal-a11y-e-table-column-header.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gal/a11y/e-table/gal-a11y-e-table-column-header.c 27 Apr 2005 11:51:48 -0000
@@ -0,0 +1,190 @@
+/* Evolution Accessibility: gal-a11y-e-table-column-header.h
+ *
+ * Author: Li Yuan <li yuan sun com>
+ *
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <atk/atkobject.h>
+#include <atk/atkregistry.h>
+#include "e-table/e-table-header-item.h"
+#include "gal-a11y-e-table-column-header.h"
+
+static GObjectClass *parent_class;
+static GType parent_type;
+static gint priv_offset;
+
+#define GET_PRIVATE(object) ((GalA11yETableColumnHeaderPrivate *) (((char *) object) + priv_offset))
+#define PARENT_TYPE (atk_gobject_accessible_get_type ())
+
+struct _GalA11yETableColumnHeaderPrivate {
+ ETableItem *item;
+ AtkObject *parent;
+ AtkStateSet *state_set;
+};
+
+static void
+etch_init (GalA11yETableColumnHeader *a11y)
+{
+ GET_PRIVATE (a11y)->item = NULL;
+ GET_PRIVATE (a11y)->parent = NULL;
+ GET_PRIVATE (a11y)->state_set = NULL;
+}
+
+static AtkStateSet *
+gal_a11y_e_table_column_header_ref_state_set (AtkObject *accessible)
+{
+ GalA11yETableColumnHeaderPrivate *priv = GET_PRIVATE (accessible);
+
+ g_object_ref(priv->state_set);
+
+ return priv->state_set;
+}
+
+static void
+gal_a11y_e_table_column_header_real_initialize (AtkObject *obj, gpointer data)
+{
+ ATK_OBJECT_CLASS (parent_class)->initialize (obj, data);
+}
+
+static void
+etch_class_init (GalA11yETableColumnHeaderClass *klass)
+{
+ AtkObjectClass *class = ATK_OBJECT_CLASS (klass);
+ parent_class = g_type_class_ref (PARENT_TYPE);
+
+ class->ref_state_set = gal_a11y_e_table_column_header_ref_state_set;
+ class->initialize = gal_a11y_e_table_column_header_real_initialize;
+}
+
+inline static GObject *
+etch_a11y_get_gobject (AtkGObjectAccessible *accessible)
+{
+ return atk_gobject_accessible_get_object (ATK_GOBJECT_ACCESSIBLE (accessible));
+}
+
+static gboolean
+gal_a11y_e_table_column_header_do_action (AtkAction *action,
+ gint i)
+{
+ gboolean return_value = TRUE;
+ GtkWidget *widget;
+ GalA11yETableColumnHeader *a11y;
+ ETableHeaderItem *ethi;
+ ETableItem *item;
+ ETableCol *col;
+
+ switch (i) {
+ case 0:
+ a11y = GAL_A11Y_E_TABLE_COLUMN_HEADER (action);
+ col = E_TABLE_COL (etch_a11y_get_gobject (ATK_GOBJECT_ACCESSIBLE (a11y)));
+ item = GET_PRIVATE (a11y)->item;
+ widget = gtk_widget_get_parent (GTK_WIDGET (item->parent.canvas));
+ if (E_IS_TREE (widget)) {
+ ethi = E_TABLE_HEADER_ITEM (e_tree_get_header_item (E_TREE (widget)));
+ }
+ else if (E_IS_TABLE (widget))
+ ethi = E_TABLE_HEADER_ITEM (E_TABLE (widget)->header_item);
+ else
+ break;
+ ethi_change_sort_state (ethi, col);
+ default:
+ return_value = FALSE;
+ break;
+ }
+ return return_value;
+}
+
+static gint
+gal_a11y_e_table_column_header_get_n_actions (AtkAction *action)
+{
+ return 1;
+}
+
+static G_CONST_RETURN gchar*
+gal_a11y_e_table_column_header_action_get_name (AtkAction *action,
+ gint i)
+{
+ G_CONST_RETURN gchar *return_value;
+
+ switch (i) {
+ case 0:
+ return_value = _("sort");
+ break;
+ default:
+ return_value = NULL;
+ break;
+ }
+ return return_value;
+}
+
+static void
+atk_action_interface_init (AtkActionIface *iface)
+{
+ g_return_if_fail (iface != NULL);
+
+ iface->do_action = gal_a11y_e_table_column_header_do_action;
+ iface->get_n_actions = gal_a11y_e_table_column_header_get_n_actions;
+ iface->get_name = gal_a11y_e_table_column_header_action_get_name;
+}
+
+GType
+gal_a11y_e_table_column_header_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ GTypeInfo info = {
+ sizeof (GalA11yETableColumnHeaderClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) etch_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GalA11yETableColumnHeader),
+ 0,
+ (GInstanceInitFunc) etch_init,
+ NULL
+ };
+ static const GInterfaceInfo atk_action_info = {
+ (GInterfaceInitFunc) atk_action_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+
+ type = gal_a11y_type_register_static_with_private (PARENT_TYPE, "GalA11yETableColumnHeader", &info, 0,
+ sizeof (GalA11yETableColumnHeaderPrivate), &priv_offset);
+
+ g_type_add_interface_static (type, ATK_TYPE_ACTION, &atk_action_info);
+ }
+
+ return type;
+}
+
+AtkObject *
+gal_a11y_e_table_column_header_new (ETableCol *ecol, ETableItem *item)
+{
+ GalA11yETableColumnHeader *a11y;
+ AtkObject *accessible;
+
+ g_return_val_if_fail (E_IS_TABLE_COL (ecol), NULL);
+
+ a11y = g_object_new (gal_a11y_e_table_column_header_get_type(), NULL);
+ accessible = ATK_OBJECT(a11y);
+ atk_object_initialize (accessible, ecol);
+
+ GET_PRIVATE (a11y)->item = item;
+ GET_PRIVATE (a11y)->state_set = atk_state_set_new ();
+
+ atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_VISIBLE);
+ atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_SHOWING);
+ atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_SENSITIVE);
+ atk_state_set_add_state (GET_PRIVATE(a11y)->state_set, ATK_STATE_ENABLED);
+
+ if (ecol->text)
+ atk_object_set_name (accessible, ecol->text);
+ atk_object_set_role (accessible, ATK_ROLE_TABLE_COLUMN_HEADER);
+
+ return ATK_OBJECT(a11y);
+}
Index: gal/a11y/e-table/gal-a11y-e-table-column-header.h
===================================================================
RCS file: gal/a11y/e-table/gal-a11y-e-table-column-header.h
diff -N gal/a11y/e-table/gal-a11y-e-table-column-header.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gal/a11y/e-table/gal-a11y-e-table-column-header.h 27 Apr 2005 11:51:48 -0000
@@ -0,0 +1,38 @@
+/* Evolution Accessibility: gal-a11y-e-table-column-header.h
+ *
+ * Author: Li Yuan <li yuan sun com>
+ *
+ */
+
+
+#ifndef __GAL_A11Y_E_TABLE_COLUMN_HEADER_H__
+#define __GAL_A11Y_E_TABLE_COLUMN_HEADER_H__
+
+#include <glib-object.h>
+#include <atk/atkgobjectaccessible.h>
+
+#define GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER (gal_a11y_e_table_column_header_get_type ())
+#define GAL_A11Y_E_TABLE_COLUMN_HEADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER, GalA11yETableColumnHeader))
+#define GAL_A11Y_E_TABLE_COLUMN_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER, GalA11yETableColumnHeaderClass))
+#define GAL_A11Y_IS_E_TABLE_COLUMN_HEADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER))
+#define GAL_A11Y_IS_E_TABLE_COLUMN_HEADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GAL_A11Y_TYPE_E_TABLE_COLUMN_HEADER))
+
+typedef struct _GalA11yETableColumnHeader GalA11yETableColumnHeader;
+typedef struct _GalA11yETableColumnHeaderClass GalA11yETableColumnHeaderClass;
+typedef struct _GalA11yETableColumnHeaderPrivate GalA11yETableColumnHeaderPrivate;
+
+struct _GalA11yETableColumnHeader {
+ AtkGObjectAccessible parent;
+};
+
+struct _GalA11yETableColumnHeaderClass {
+ AtkGObjectAccessibleClass parent_class;
+};
+
+
+/* Standard Glib function */
+GType gal_a11y_e_table_column_header_get_type (void);
+AtkObject *gal_a11y_e_table_column_header_new (ETableCol *etc, ETableItem *item);
+void gal_a11y_e_table_column_header_init (void);
+
+#endif /* ! __GAL_A11Y_E_TABLE_COLUMN_HEADER_H__ */
Index: gal/a11y/e-table/gal-a11y-e-table-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/a11y/e-table/gal-a11y-e-table-item.c,v
retrieving revision 1.17
diff -u -r1.17 gal-a11y-e-table-item.c
--- gal/a11y/e-table/gal-a11y-e-table-item.c 24 Mar 2005 08:43:18 -0000 1.17
+++ gal/a11y/e-table/gal-a11y-e-table-item.c 27 Apr 2005 11:51:48 -0000
@@ -207,7 +207,7 @@
return 0;
return atk_table_get_n_columns (ATK_TABLE (accessible)) *
- atk_table_get_n_rows (ATK_TABLE (accessible));
+ (atk_table_get_n_rows (ATK_TABLE (accessible)) + 1);
}
static AtkObject*
@@ -221,7 +221,17 @@
if (!item)
return NULL;
- /* don't support column header now */
+ if (index < item->cols) {
+ ETableCol *ecol;
+ AtkObject *child;
+
+ ecol = e_table_header_get_column (item->header, index);
+ child = gal_a11y_e_table_column_header_new (ecol, item);
+ if (child)
+ g_object_ref (child);
+ return child;
+ }
+ index -= item->cols;
col = index % item->cols;
row = index / item->cols;
@@ -418,7 +428,7 @@
if (!item)
return -1;
- return item->rows;
+ return item->rows + 1;
}
static gint
@@ -503,12 +513,7 @@
ecol = e_table_header_get_column (item->header, column);
if (ecol) {
- atk_obj = atk_gobject_accessible_for_object (G_OBJECT (ecol));
- if (atk_obj) {
- if (ecol->text)
- atk_object_set_name (atk_obj, ecol->text);
- atk_object_set_role (atk_obj, ATK_ROLE_TABLE_COLUMN_HEADER);
- }
+ atk_obj = gal_a11y_e_table_column_header_new (ecol, item);
}
return atk_obj;
Index: gal/e-table/ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v
retrieving revision 1.948
diff -u -r1.948 ChangeLog
--- gal/e-table/ChangeLog 14 Mar 2005 06:34:26 -0000 1.948
+++ gal/e-table/ChangeLog 27 Apr 2005 11:51:53 -0000
@@ -1,3 +1,14 @@
+2005-04-27 Li Yuan <li yuan sun com>
+
+ * e-table-header-item.c:
+ * e-table-header-item.h:
+ export ethi_change_sort_state, so we can call it in a11y part.
+ * e-tree.c: (e_tree_get_header_item):
+ * e-tree.h:
+ return the header item of e-tree.
+
+ Fix for #302154.
+
2005-03-14 Theppitak Karoonboonyanan <theppitak gmail com>
* e-cell-text.c (e_cell_text_retrieve_surrounding_cb)
Index: gal/e-table/e-table-header-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-header-item.c,v
retrieving revision 1.128
diff -u -r1.128 e-table-header-item.c
--- gal/e-table/e-table-header-item.c 21 Dec 2004 20:47:40 -0000 1.128
+++ gal/e-table/e-table-header-item.c 27 Apr 2005 11:51:53 -0000
@@ -1537,7 +1537,7 @@
ethi_signals [BUTTON_PRESSED], 0, event);
}
-static void
+void
ethi_change_sort_state (ETableHeaderItem *ethi, ETableCol *col)
{
int model_col;
Index: gal/e-table/e-table-header-item.h
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-header-item.h,v
retrieving revision 1.30
diff -u -r1.30 e-table-header-item.h
--- gal/e-table/e-table-header-item.h 21 Dec 2004 20:47:40 -0000 1.30
+++ gal/e-table/e-table-header-item.h 27 Apr 2005 11:51:54 -0000
@@ -112,6 +112,9 @@
void (*button_pressed) (ETableHeaderItem *ethi, GdkEventButton *button);
} ETableHeaderItemClass;
+void
+ethi_change_sort_state (ETableHeaderItem *ethi, ETableCol *col);
+
GType e_table_header_item_get_type (void);
G_END_DECLS
Index: gal/e-table/e-tree.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-tree.c,v
retrieving revision 1.110
diff -u -r1.110 e-tree.c
--- gal/e-table/e-tree.c 4 Feb 2005 04:49:02 -0000 1.110
+++ gal/e-table/e-tree.c 27 Apr 2005 11:51:55 -0000
@@ -2163,6 +2163,14 @@
return E_TABLE_ITEM (et->priv->item);
}
+GnomeCanvasItem *
+e_tree_get_header_item(ETree * et)
+{
+ g_return_val_if_fail (et != NULL, NULL);
+ g_return_val_if_fail (E_IS_TREE (et), NULL);
+
+ return et->priv->header_item;
+}
struct _ETreeDragSourceSite
{
Index: gal/e-table/e-tree.h
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-tree.h,v
retrieving revision 1.28
diff -u -r1.28 e-tree.h
--- gal/e-table/e-tree.h 11 Oct 2003 03:00:59 -0000 1.28
+++ gal/e-table/e-tree.h 27 Apr 2005 11:51:55 -0000
@@ -306,6 +306,8 @@
ETableItem * e_tree_get_item(ETree * et);
+GnomeCanvasItem * e_tree_get_header_item(ETree * et);
+
G_END_DECLS
#endif /* _E_TREE_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]