Re: [evolution-patches] New patch for trunk #51626: can't navigate to the Click to add area by Tab key



Sorry , i forget the patch just now.

Thx for your reviews!

Now i've justified the code style.
Further, as you see, i don't override the Tab key event of e-table-item, but add a Ctrl+Tab dealer, for i intend to let the user jump out of the "click to add" area immediately instead of going right until the last column and then jump out.

What's your opinion ?


Not Zed wrote:


A couple of style things below:

On Fri, 2004-04-23 at 18:40 -0400, Bruce Tao wrote:

Hi,

This new patch makes a correction to the last version which forgot to check if an
"etable " contains a "Click to add" area.

Please check it, thanks!

Best regards .
Plain text document attachment (patch)

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	23 Apr 2004 09:24:03 -0000
@@ -1,3 +1,19 @@
+2004-04-22  Bruce Tao  <bruce tao sun com <mailto: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-item.c: (eti_event):
+	Mask the Ctrl+Tab processing routine.
+
+	* 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 <mailto: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	23 Apr 2004 09:24:04 -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-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-item.c,v
retrieving revision 1.233
diff -u -r1.233 e-table-item.c
--- gal/e-table/e-table-item.c	26 Feb 2004 11:45:52 -0000	1.233
+++ gal/e-table/e-table-item.c	23 Apr 2004 09:24:14 -0000
@@ -2682,6 +2682,10 @@
		case GDK_Tab:
		case GDK_KP_Tab:
		case GDK_ISO_Left_Tab:
+			if ((e->key.state & GDK_CONTROL_MASK) != 0) {
+				return_val = FALSE;
+				break;
+			}
			if (eti->cursor_mode == E_CURSOR_SPREADSHEET) {
				if ((e->key.state & GDK_SHIFT_MASK) != 0){
				/* shift tab */

This seems to repeat the cursor state check. Do you really want to override the spreadsheet mode tab behaviour?

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	23 Apr 2004 09:24:23 -0000
@@ -1117,12 +1117,79 @@

	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 + && (etable->click_to_add) + && !(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);
+	}

use
} else if () {

here, not
  }
  else {
      if () {
      }
  }

	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;
+}

Since both of the above functions are just monitoring key press events, they should really only hook onto the 'key_press_event' signal.

static void
e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *header,
		     ETableModel *model)
@@ -1190,6 +1257,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) {
@@ -1211,8 +1282,11 @@
				e_table->click_to_add);

		g_signal_connect (
-			G_OBJECT (e_table->click_to_add), "cursor_change",
-			G_CALLBACK (click_to_add_cursor_change), e_table);
+			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);
	}
}

	*Michael Zucchi* <notzed ximian com <mailto:notzed ximian com>>

/Ximian Evolution <http://codeblogs.ximian.com/blogs/evolution/> and Free Software <http://www.gnu.org/philosophy/free-sw.html> Developer/

*Novell, Inc. <http://www.novell.com/>*


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	28 Apr 2004 07:13:14 -0000
@@ -1,3 +1,19 @@
+2004-04-22  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-item.c: (eti_event):
+	Mask the Ctrl+Tab processing routine.
+
+	* 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	28 Apr 2004 07:13:15 -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-item.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-table/e-table-item.c,v
retrieving revision 1.233
diff -u -r1.233 e-table-item.c
--- gal/e-table/e-table-item.c	26 Feb 2004 11:45:52 -0000	1.233
+++ gal/e-table/e-table-item.c	28 Apr 2004 07:13:22 -0000
@@ -2682,6 +2682,10 @@
 		case GDK_Tab:
 		case GDK_KP_Tab:
 		case GDK_ISO_Left_Tab:
+			if ((e->key.state & GDK_CONTROL_MASK) != 0) {
+				return_val = FALSE;
+				break;
+			}
 			if (eti->cursor_mode == E_CURSOR_SPREADSHEET) {
 				if ((e->key.state & GDK_SHIFT_MASK) != 0){
 				/* shift tab */
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	28 Apr 2004 07:13:37 -0000
@@ -1117,8 +1117,63 @@
 
 	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 
+	    && (etable->click_to_add) 
+	    && !(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, GdkEventKey *key, ETable *etable)
+{
+	GnomeCanvas *canvas;
+
+	canvas = GNOME_CANVAS (etable->table_canvas);
+	switch (key->keyval) {
+		case GDK_Tab:
+		case GDK_KP_Tab:
+		case GDK_ISO_Left_Tab:
+			if (key->state & GDK_CONTROL_MASK) {
+				gnome_canvas_item_grab_focus (etable->click_to_add);
+				break;
+			}
+		default:
+			return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+click_to_add_event (ETableClickToAdd *etcta, GdkEventKey *key, ETable *etable)
+{
+	GnomeCanvas *canvas;
+
+	canvas = GNOME_CANVAS (etable->table_canvas);
+	switch (key->keyval) {
+		case GDK_Tab:
+		case GDK_KP_Tab:
+		case GDK_ISO_Left_Tab:
+			if (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;
+	}
 
 	return TRUE;
 }
@@ -1190,6 +1245,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) {
@@ -1211,8 +1270,11 @@
 				e_table->click_to_add);
 
 		g_signal_connect (
-			G_OBJECT (e_table->click_to_add), "cursor_change",
-			G_CALLBACK (click_to_add_cursor_change), e_table);
+			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]