aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/table/e-table.c52
-rw-r--r--widgets/table/e-tree.c29
2 files changed, 76 insertions, 5 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",
diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c
index 9bb71f6c92..6bbf20f16c 100644
--- a/widgets/table/e-tree.c
+++ b/widgets/table/e-tree.c
@@ -698,6 +698,31 @@ et_canvas_button_press (GtkWidget *canvas, GdkEventButton *event, ETree *e_tree)
return FALSE;
}
+/* Handler for focus events in the table_canvas; we have to repaint ourselves
+ * and give the focus to some ETableItem.
+ */
+static gint
+table_canvas_focus_event_cb (GtkWidget *widget, GdkEventFocus *event, gpointer data)
+{
+ GnomeCanvas *canvas;
+ ETree *tree;
+
+ gtk_widget_queue_draw (widget);
+
+ if (!event->in)
+ return TRUE;
+
+ canvas = GNOME_CANVAS (widget);
+ tree = E_TREE (data);
+
+ if (!canvas->focused_item) {
+ e_table_item_set_cursor (E_TABLE_ITEM (tree->priv->item), 0, 0);
+ gnome_canvas_item_grab_focus (tree->priv->item);
+ }
+
+ return TRUE;
+}
+
static void
e_tree_setup_table (ETree *e_tree)
{
@@ -707,10 +732,10 @@ e_tree_setup_table (ETree *e_tree)
GTK_SIGNAL_FUNC (tree_canvas_size_allocate), e_tree);
gtk_signal_connect (
GTK_OBJECT (e_tree->priv->table_canvas), "focus_in_event",
- GTK_SIGNAL_FUNC (gtk_widget_queue_draw), e_tree);
+ GTK_SIGNAL_FUNC (table_canvas_focus_event_cb), e_tree);
gtk_signal_connect (
GTK_OBJECT (e_tree->priv->table_canvas), "focus_out_event",
- GTK_SIGNAL_FUNC (gtk_widget_queue_draw), e_tree);
+ GTK_SIGNAL_FUNC (table_canvas_focus_event_cb), e_tree);
gtk_signal_connect (
GTK_OBJECT (e_tree->priv->table_canvas), "drag_begin",