aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-table.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-10-26 12:47:53 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-10-26 12:47:53 +0800
commit6784b6928ac929846fa1ac36131a1193bc9294fd (patch)
tree6eb476f7d388e84bcfee816f3cee8701671477e5 /widgets/table/e-table.c
parentccdcf468c80b1dd870100c44c084cbd674a86c91 (diff)
downloadgsoc2013-evolution-6784b6928ac929846fa1ac36131a1193bc9294fd.tar.gz
gsoc2013-evolution-6784b6928ac929846fa1ac36131a1193bc9294fd.tar.zst
gsoc2013-evolution-6784b6928ac929846fa1ac36131a1193bc9294fd.zip
Fixes Ximian bug #6832.
2001-10-25 Federico Mena Quintero <federico@ximian.com> Fixes Ximian bug #6832. * e-table.c (e_table_setup_table): Use a callback instead of gtk_widget_queue_draw() for focus events, as the latter does not have the correct prototype for an event handler. (group_start_drag): Emit START_DRAG, not KEY_PRESS! (focus_first_etable_item): Focus the first row in the first ETableItem if there is no focused item. * e-tree.c (e_tree_setup_table): Same change as in e_table_setup_table(). (table_canvas_focus_event_cb): Focus the first row in the tree item if there is no focused item. svn path=/trunk/; revision=14124
Diffstat (limited to 'widgets/table/e-table.c')
-rw-r--r--widgets/table/e-table.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index add74d030b..04e6c57e03 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -538,7 +538,7 @@ group_start_drag (ETableGroup *etg, int row, int col, GdkEvent *event, ETable *e
{
int return_val = 0;
gtk_signal_emit (GTK_OBJECT (et),
- et_signals [KEY_PRESS],
+ et_signals [START_DRAG],
row, col, event, &return_val);
return return_val;
}
@@ -731,6 +731,52 @@ et_canvas_root_event (GnomeCanvasItem *root, GdkEvent *event, ETable *e_table)
return FALSE;
}
+/* Finds the first descendant of the group that is an ETableItem and focuses it */
+static void
+focus_first_etable_item (ETableGroup *group)
+{
+ GnomeCanvasGroup *cgroup;
+ GList *l;
+
+ cgroup = GNOME_CANVAS_GROUP (group);
+
+ for (l = cgroup->item_list; l; l = l->next) {
+ GnomeCanvasItem *i;
+
+ i = GNOME_CANVAS_ITEM (l->data);
+
+ if (E_IS_TABLE_GROUP (i))
+ focus_first_etable_item (E_TABLE_GROUP (i));
+ else if (E_IS_TABLE_ITEM (i)) {
+ e_table_item_set_cursor (E_TABLE_ITEM (i), 0, 0);
+ gnome_canvas_item_grab_focus (i);
+ }
+ }
+}
+
+/* Handler for focus events in the table_canvas; we have to repaint ourselves
+ * always, and also give the focus to some ETableItem if we get focused.
+ */
+static gint
+table_canvas_focus_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ GnomeCanvas *canvas;
+ ETable *etable;
+
+ gtk_widget_queue_draw (widget);
+
+ if (!event->in)
+ return TRUE;
+
+ canvas = GNOME_CANVAS (widget);
+ etable = E_TABLE (data);
+
+ if (!canvas->focused_item)
+ focus_first_etable_item (etable->group);
+
+ return TRUE;
+}
+
static void
e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *header,
ETableModel *model)
@@ -741,10 +787,10 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
GTK_SIGNAL_FUNC (table_canvas_size_allocate), e_table);
gtk_signal_connect (
GTK_OBJECT (e_table->table_canvas), "focus_in_event",
- GTK_SIGNAL_FUNC (gtk_widget_queue_draw), e_table);
+ GTK_SIGNAL_FUNC (table_canvas_focus_event_cb), e_table);
gtk_signal_connect (
GTK_OBJECT (e_table->table_canvas), "focus_out_event",
- GTK_SIGNAL_FUNC (gtk_widget_queue_draw), e_table);
+ GTK_SIGNAL_FUNC (table_canvas_focus_event_cb), e_table);
gtk_signal_connect (
GTK_OBJECT (e_table), "drag_begin",