diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-10-26 12:47:53 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-10-26 12:47:53 +0800 |
commit | 6784b6928ac929846fa1ac36131a1193bc9294fd (patch) | |
tree | 6eb476f7d388e84bcfee816f3cee8701671477e5 /widgets | |
parent | ccdcf468c80b1dd870100c44c084cbd674a86c91 (diff) | |
download | gsoc2013-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')
-rw-r--r-- | widgets/table/e-table.c | 52 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 29 |
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", |