[evolution-patches] Improved patch for trunk, fixing bug #51626: can't navigate to the Click to add a task area by Tab Key



The last patch i proposed one week ago is find incomplete. There are two
main problems:

1. You can't delete the existing tasks by popup menu, as when the focus return back to the canvas which displays the tasks, it will turn to the "click_to_add", so the task item you have chosen will not be deleted.

In this new patch, i don't force the focus to go to the "click_to_add" first, but instead just provide a Ctrl+Tab way to navigate between
   the "click_to_add" and the existing tasks.

2. When you navigate to or choose some other items while editing the "click_to_add" item and then return to it, you can not type any letters
   into it.

  This new patch has made the modification to correct this.

I wonder if the new patch is acceptable for trunk, since the focus-related problems are extremely confusing.

Please check it, thx !
Index: gal/e-table/ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/ChangeLog,v
retrieving revision 1.925
diff -u -r1.925 ChangeLog
--- gal/e-table/ChangeLog	10 Mar 2004 06:28:46 -0000	1.925
+++ gal/e-table/ChangeLog	11 Apr 2004 13:23:18 -0000
@@ -1,3 +1,16 @@
+2004-04-11  Bruce Tao  <bruce tao sun com>
+
+	Fixes #51626
+
+	* e-table-click-to-add.c: (etcta_event):
+	Add an entry for focus_in event, do the same thing as button_press event.
+
+	* e-table.c: (table_canvas_focus_event_cb), (canvas_vbox_event),
+	(click_to_add_event), (e_table_setup_table):
+	Enable you to navigate between click_to_add and the existing tasks by
+	pressing Ctrl+Tab. However, if there is no existing task, you can still jump
+	out of click_to_add by this way.
+
 2004-03-10  Hao Sheng  <hao sheng sun com>
 
 	Fixes #55198
Index: gal/e-table/e-table-click-to-add.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-click-to-add.c,v
retrieving revision 1.37
diff -u -r1.37 e-table-click-to-add.c
--- gal/e-table/e-table-click-to-add.c	17 Dec 2003 02:35:20 -0000	1.37
+++ gal/e-table/e-table-click-to-add.c	11 Apr 2004 13:23:19 -0000
@@ -348,6 +348,10 @@
 	ETableClickToAdd *etcta = E_TABLE_CLICK_TO_ADD (item);
 
 	switch (e->type){
+	case GDK_FOCUS_CHANGE:
+		if (!e->focus_change.in)
+			return TRUE;
+
 	case GDK_BUTTON_PRESS:
 		if (etcta->text) {
 			gtk_object_destroy(etcta->text);
Index: gal/e-table/e-table.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table.c,v
retrieving revision 1.228
diff -u -r1.228 e-table.c
--- gal/e-table/e-table.c	2 Dec 2003 07:55:14 -0000	1.228
+++ gal/e-table/e-table.c	11 Apr 2004 13:23:22 -0000
@@ -1117,12 +1117,77 @@
 
 	etable = E_TABLE (data);
 
-	if (!canvas->focused_item && etable->group)
-		focus_first_etable_item (etable->group);
+	if (e_table_model_row_count(etable->model) < 1 && !(E_TABLE_CLICK_TO_ADD(etable->click_to_add)->row)) {
+		gnome_canvas_item_grab_focus (etable->canvas_vbox);
+		gnome_canvas_item_grab_focus (etable->click_to_add);
+	}
+	else {
+		if (!canvas->focused_item && etable->group)
+                       	focus_first_etable_item (etable->group);
+	}
 
 	return TRUE;
 }
 
+static gboolean
+canvas_vbox_event (ECanvasVbox *vbox, GdkEvent *e, ETable *etable)
+{
+	GnomeCanvas *canvas;
+
+	canvas = GNOME_CANVAS (etable->table_canvas);
+
+	switch (e->type) {
+		case GDK_KEY_PRESS:
+			switch (e->key.keyval) {
+				case GDK_Tab:
+				case GDK_KP_Tab:
+				case GDK_ISO_Left_Tab:
+					if (e->key.state & GDK_CONTROL_MASK) {
+						gnome_canvas_item_grab_focus (etable->click_to_add);
+						break;
+					}
+				default:
+					return FALSE;
+			}
+			break;
+		default:
+			return FALSE;
+	}
+	return TRUE;
+}
+
+static gboolean
+click_to_add_event (ETableClickToAdd *etcta, GdkEvent *e, ETable *etable)
+{
+	GnomeCanvas *canvas;
+
+	canvas = GNOME_CANVAS (etable->table_canvas);
+	switch (e->type) {
+		case GDK_KEY_PRESS:
+			switch (e->key.keyval) {
+				case GDK_Tab:
+				case GDK_KP_Tab:
+				case GDK_ISO_Left_Tab:
+					if (e->key.state & GDK_CONTROL_MASK) {
+						if (etable->group) {
+							if (e_table_model_row_count(etable->model) > 0)
+								focus_first_etable_item (etable->group);
+							else
+								gtk_widget_child_focus (
+									gtk_widget_get_toplevel(GTK_WIDGET(etable->table_canvas)), GTK_DIR_TAB_FORWARD);
+							break;
+						}
+					}
+				default:
+					return FALSE;
+			}
+			break;
+		default:
+			return FALSE;
+	}
+	return TRUE;
+}
+
 static void
 e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *header,
 		     ETableModel *model)
@@ -1190,6 +1255,10 @@
 		"spacing", 10.0,
 		NULL);
 
+	g_signal_connect (
+		G_OBJECT (e_table->canvas_vbox), "event",
+		G_CALLBACK (canvas_vbox_event), e_table);
+
 	et_build_groups(e_table);
 
 	if (e_table->use_click_to_add) {
@@ -1210,6 +1279,9 @@
 				E_CANVAS_VBOX(e_table->canvas_vbox),
 				e_table->click_to_add);
 
+		g_signal_connect (
+			G_OBJECT (e_table->click_to_add), "event",
+			G_CALLBACK (click_to_add_event), e_table);
 		g_signal_connect (
 			G_OBJECT (e_table->click_to_add), "cursor_change",
 			G_CALLBACK (click_to_add_cursor_change), e_table);


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