[evolution-patches] Patch for gal keyboard navigation
- From: wu yang <Yang Wu sun com>
- To: Mike Kestner <mkestner ximian com>
- Cc: sceri-evolution-acc sun com, evolution-patches ximian com
- Subject: [evolution-patches] Patch for gal keyboard navigation
- Date: Sun, 23 Nov 2003 20:26:20 +0800
Hi, Mike
This patch fixed Bug 51252, 51254, 51255
enable some keyboard navigation in ETableHeader.
enable "shift + F10" to popup a menu in table head
enable "left" and "right" to navigation in table head
enable "space" key to sort the column in table head
Thanks
Index: gal/e-table/e-table-header-item.c
===================================================================
RCS file: /export/src/cvs/gal/gal/e-table/e-table-header-item.c,v
retrieving revision 1.2
diff -u -b -B -r1.2 e-table-header-item.c
--- gal/e-table/e-table-header-item.c 2003/10/15 15:38:17 1.2
+++ gal/e-table/e-table-header-item.c 2003/11/23 08:09:31
@@ -35,6 +35,7 @@
#include <libgnomecanvas/gnome-canvas-polygon.h>
#include <libgnomecanvas/gnome-canvas-rect-ellipse.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdkkeysyms.h>
#include "gal/widgets/e-cursors.h"
#include "gal/util/e-i18n.h"
#include "gal/util/e-util.h"
@@ -1061,6 +1062,8 @@
return TRUE;
}
+ if (return_col)
+ *return_col = col;
if (total > pos + TOLERANCE)
return FALSE;
@@ -1521,16 +1524,13 @@
}
static void
-ethi_change_sort_state (ETableHeaderItem *ethi, gdouble x)
+ethi_change_sort_state (ETableHeaderItem *ethi, ETableCol *col)
{
- ETableCol *col;
int model_col;
int length;
int i;
int found = FALSE;
- col = e_table_header_get_column (ethi->eth, ethi_find_col_by_x (ethi, x));
-
if (col == NULL)
return;
@@ -1667,6 +1667,9 @@
ethi->click_x = e->button.x;
ethi->click_y = e->button.y;
ethi->maybe_drag = TRUE;
+ is_pointer_on_division (ethi, x, &start, &col);
+ ethi->selected_col = col;
+ e_canvas_item_grab_focus (item, TRUE);
} else if (e->button.button == 3){
ethi_header_context_menu (ethi, &e->button);
} else
@@ -1703,14 +1706,65 @@
if (ethi->resize_col != -1){
needs_ungrab = (ethi->resize_guide != NULL);
ethi_end_resize (ethi);
- } else if (was_maybe_drag && ethi->sort_info)
- ethi_change_sort_state (ethi, e->button.x);
+ } else if (was_maybe_drag && ethi->sort_info) {
+ ETableCol *col;
+ col = e_table_header_get_column (ethi->eth, ethi_find_col_by_x (ethi, e->button.x));
+ ethi_change_sort_state (ethi, col);
+ }
+
if (needs_ungrab)
gnome_canvas_item_ungrab (item, e->button.time);
break;
}
+ case GDK_KEY_PRESS:
+ if ((e->key.keyval == GDK_F10) && (e->key.state & GDK_SHIFT_MASK)) {
+ EthiHeaderInfo *info = g_new(EthiHeaderInfo, 1);
+ ETableCol *col;
+ GtkMenu *popup;
+
+ info->ethi = ethi;
+ info->col = ethi->selected_col;
+ col = e_table_header_get_column (ethi->eth, info->col);
+
+ popup = e_popup_menu_create_with_domain (ethi_context_menu,
+ 1 +
+ (col->sortable ? 0 : 2) +
+ ((ethi->table || ethi->tree) ? 0 : 4) +
+ ((e_table_header_count (ethi->eth) > 1) ? 0 : 8),
+ ((e_table_sort_info_get_can_group (ethi->sort_info)) ? 0 : 16) +
+ 128, info, E_I18N_DOMAIN);
+ g_object_ref (popup);
+ gtk_object_sink (GTK_OBJECT (popup));
+ g_signal_connect (popup, "selection-done",
+ G_CALLBACK (free_popup_info), info);
+ e_popup_menu (popup, NULL);
+ } else if (e->key.keyval == GDK_space) {
+ ETableCol *col;
+
+ col = e_table_header_get_column (ethi->eth, ethi->selected_col);
+ ethi_change_sort_state (ethi, col);
+ } else if ((e->key.keyval == GDK_Right) || (e->key.keyval == GDK_KP_Right)) {
+ ETableCol *col;
+
+ if ((ethi->selected_col < 0) || (ethi->selected_col >= ethi->eth->col_count - 1))
+ ethi->selected_col = 0;
+ else
+ ethi->selected_col++;
+ col = e_table_header_get_column (ethi->eth, ethi->selected_col);
+ ethi_change_sort_state (ethi, col);
+ } else if ((e->key.keyval == GDK_Left) || (e->key.keyval == GDK_KP_Left)) {
+ ETableCol *col;
+
+ if ((ethi->selected_col <= 0) || (ethi->selected_col >= ethi->eth->col_count))
+ ethi->selected_col = ethi->eth->col_count - 1;
+ else
+ ethi->selected_col--;
+ col = e_table_header_get_column (ethi->eth, ethi->selected_col);
+ ethi_change_sort_state (ethi, col);
+ }
+ break;
default:
return FALSE;
@@ -1830,6 +1884,8 @@
ethi->group_indent_width = 0;
ethi->table = NULL;
ethi->tree = NULL;
+
+ ethi->selected_col = 0;
}
E_MAKE_TYPE (e_table_header_item,
Index: gal/e-table/e-table-header-item.h
===================================================================
RCS file: /export/src/cvs/gal/gal/e-table/e-table-header-item.h,v
retrieving revision 1.1.1.1
diff -u -b -B -r1.1.1.1 e-table-header-item.h
--- gal/e-table/e-table-header-item.h 2003/09/26 06:37:14 1.1.1.1
+++ gal/e-table/e-table-header-item.h 2003/11/23 08:09:31
@@ -96,6 +96,10 @@
ETable *table;
ETree *tree;
void *config;
+
+ /* For keyboard navigation*/
+ int selected_col;
+
} ETableHeaderItem;
typedef struct {
Index: gal/e-table/e-table.c
===================================================================
RCS file: /export/src/cvs/gal/gal/e-table/e-table.c,v
retrieving revision 1.3
diff -u -b -B -r1.3 e-table.c
--- gal/e-table/e-table.c 2003/10/14 18:00:15 1.3
+++ gal/e-table/e-table.c 2003/11/23 08:09:32
@@ -658,7 +658,6 @@
{
char *pointer;
e_table->header_canvas = GNOME_CANVAS (e_canvas_new ());
- GTK_WIDGET_UNSET_FLAGS (e_table->header_canvas, GTK_CAN_FOCUS);
gtk_widget_show (GTK_WIDGET (e_table->header_canvas));
Index: ChangeLog
===================================================================
RCS file: /export/src/cvs/gal/ChangeLog,v
retrieving revision 1.25
diff -u -b -B -r1.25 ChangeLog
--- ChangeLog 2003/11/22 09:42:32 1.25
+++ ChangeLog 2003/11/23 11:51:44
@@ -1,3 +1,13 @@
+2003-11-23 Andrew Wu <yang wu sun com>
+
+ Fixed Bug 51252, 51254, 51255.
+ * gal/e-table/e-table-header-item.c:
+ (ethi_event):add some code deal with key press event.
+ * gal/e-table/e-table-header-item.h
+ add a member "selected_col" for keyboard navigation.
+ * gal/e-table/e-table.c
+ (e_table_setup_header):make header can focus.
+
2003-11-22 Tim Wo <tim wo sun com>
* gal/a11y/e-table/gal-a11y-e-cell-toggle.c:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]