diff options
author | Milan Crha <mcrha@redhat.com> | 2013-08-01 23:48:47 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2013-08-01 23:48:47 +0800 |
commit | 098b06524243b6c9a66fd1702796634d448f3341 (patch) | |
tree | 4c0a70f20cf9c3122cc30fb27900a0722be25e8f | |
parent | ca67414c22d003f5e005cc05689efdec38dcd4e7 (diff) | |
download | gsoc2013-evolution-098b06524243b6c9a66fd1702796634d448f3341.tar.gz gsoc2013-evolution-098b06524243b6c9a66fd1702796634d448f3341.tar.zst gsoc2013-evolution-098b06524243b6c9a66fd1702796634d448f3341.zip |
Bug #699603 - Message list scrolls to cursor on style change
-rw-r--r-- | e-util/e-table-item.c | 15 | ||||
-rw-r--r-- | e-util/e-table-item.h | 2 | ||||
-rw-r--r-- | e-util/e-tree.c | 46 |
3 files changed, 63 insertions, 0 deletions
diff --git a/e-util/e-table-item.c b/e-util/e-table-item.c index c552922a34..3f88d8cb7e 100644 --- a/e-util/e-table-item.c +++ b/e-util/e-table-item.c @@ -4077,3 +4077,18 @@ e_table_item_is_editing (ETableItem *eti) return eti_editing (eti); } + +/** + * e_table_item_cursor_scrolled: + * @eti: an %ETableItem + * + * Does necessary recalculations after cursor scrolled, like whether + * the cursor is on screen or not anymore. + **/ +void +e_table_item_cursor_scrolled (ETableItem *eti) +{ + g_return_if_fail (E_IS_TABLE_ITEM (eti)); + + eti_check_cursor_bounds (eti); +} diff --git a/e-util/e-table-item.h b/e-util/e-table-item.h index 01e6a227dd..47ae5caa00 100644 --- a/e-util/e-table-item.h +++ b/e-util/e-table-item.h @@ -258,6 +258,8 @@ gint e_table_item_row_diff (ETableItem *eti, gboolean e_table_item_is_editing (ETableItem *eti); +void e_table_item_cursor_scrolled (ETableItem *eti); + G_END_DECLS #endif /* _E_TABLE_ITEM_H_ */ diff --git a/e-util/e-tree.c b/e-util/e-tree.c index de11f96d19..208b2687f2 100644 --- a/e-util/e-tree.c +++ b/e-util/e-tree.c @@ -157,6 +157,8 @@ struct _ETreePrivate { gint length_threshold; + GtkAdjustment *table_canvas_vadjustment; + /* * Configuration settings */ @@ -491,10 +493,16 @@ et_dispose (GObject *object) priv->info_text_resize_id = 0; if (priv->table_canvas != NULL) { + g_signal_handlers_disconnect_by_data (priv->table_canvas, object); gtk_widget_destroy (GTK_WIDGET (priv->table_canvas)); priv->table_canvas = NULL; } + if (priv->table_canvas_vadjustment) { + g_signal_handlers_disconnect_by_data (priv->table_canvas_vadjustment, object); + g_clear_object (&priv->table_canvas_vadjustment); + } + /* do not unref it, it was owned by priv->table_canvas */ priv->item = NULL; @@ -1236,6 +1244,40 @@ table_canvas_focus_event_cb (GtkWidget *widget, } static void +e_tree_table_canvas_scrolled_cb (GtkAdjustment *vadjustment, + GParamSpec *param, + ETree *tree) +{ + g_return_if_fail (E_IS_TREE (tree)); + + if (tree->priv->item) + e_table_item_cursor_scrolled (E_TABLE_ITEM (tree->priv->item)); +} + +static void +et_setup_table_canvas_vadjustment (ETree *tree) +{ + GtkAdjustment *vadjustment = NULL; + + g_return_if_fail (E_IS_TREE (tree)); + + if (tree->priv->table_canvas_vadjustment) { + g_signal_handlers_disconnect_by_data (tree->priv->table_canvas_vadjustment, tree); + g_clear_object (&tree->priv->table_canvas_vadjustment); + } + + if (tree->priv->table_canvas) + vadjustment = gtk_scrollable_get_vadjustment ( + GTK_SCROLLABLE (tree->priv->table_canvas)); + + if (vadjustment) { + tree->priv->table_canvas_vadjustment = g_object_ref (vadjustment); + g_signal_connect (vadjustment, "notify::value", + G_CALLBACK (e_tree_table_canvas_scrolled_cb), tree); + } +} + +static void e_tree_setup_table (ETree *tree) { GtkWidget *widget; @@ -1281,6 +1323,10 @@ e_tree_setup_table (ETree *tree) tree->priv->table_canvas, "reflow", G_CALLBACK (tree_canvas_reflow), tree); + et_setup_table_canvas_vadjustment (tree); + g_signal_connect_swapped (tree->priv->table_canvas, "notify::vadjustment", + G_CALLBACK (et_setup_table_canvas_vadjustment), tree); + widget = GTK_WIDGET (tree->priv->table_canvas); style = gtk_widget_get_style (widget); |