Revision: 1730
http://geeqie.svn.sourceforge.net/geeqie/?rev=1730&view=rev
Author: nadvornik
Date: 2009-06-06 16:14:07 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
better implementation of tree_view_row_get_visibility,
gtk_tree_view_set_cursor is not sufficient in some cases, call also
tree_view_row_make_visible
Modified Paths:
--------------
trunk/src/ui_tree_edit.c
trunk/src/view_dir_tree.c
Modified: trunk/src/ui_tree_edit.c
===================================================================
--- trunk/src/ui_tree_edit.c 2009-06-06 15:33:56 UTC (rev 1729)
+++ trunk/src/ui_tree_edit.c 2009-06-06 16:14:07 UTC (rev 1730)
@@ -343,9 +343,54 @@
*height = MIN(*height, wy + wh - (*y));
}
+#if GTK_CHECK_VERSION(2,8,0)
+/* an implementation that uses gtk_tree_view_get_visible_range */
gint tree_view_row_get_visibility(GtkTreeView *widget, GtkTreeIter *iter,
gboolean fully_visible)
{
GtkTreeModel *store;
+ GtkTreePath *tpath, *start_path, *end_path;
+ gint ret = 0;
+
+ if (!gtk_tree_view_get_visible_range(widget, &start_path, &end_path))
return -1; /* we will most probably scroll down, needed for
tree_view_row_make_visible */
+
+ store = gtk_tree_view_get_model(widget);
+ tpath = gtk_tree_model_get_path(store, iter);
+
+ if (fully_visible)
+ {
+ if (gtk_tree_path_compare(tpath, start_path) <= 0)
+ {
+ ret = -1;
+ }
+ else if (gtk_tree_path_compare(tpath, end_path) >= 0)
+ {
+ ret = 1;
+ }
+ }
+ else
+ {
+ if (gtk_tree_path_compare(tpath, start_path) < 0)
+ {
+ ret = -1;
+ }
+ else if (gtk_tree_path_compare(tpath, end_path) > 0)
+ {
+ ret = 1;
+ }
+ }
+
+ gtk_tree_path_free(tpath);
+ gtk_tree_path_free(start_path);
+ gtk_tree_path_free(end_path);
+ return ret;
+}
+
+#else
+/* an implementation that uses gtk_tree_view_get_visible_rect, it seems to be
more error prone than the variant above */
+
+gint tree_view_row_get_visibility(GtkTreeView *widget, GtkTreeIter *iter,
gboolean fully_visible)
+{
+ GtkTreeModel *store;
GtkTreePath *tpath;
gint cx, cy;
@@ -379,6 +424,7 @@
if (cy > vrect.y + vrect.height) return 1;
return 0;
}
+#endif
gint tree_view_row_make_visible(GtkTreeView *widget, GtkTreeIter *iter,
gboolean center)
{
Modified: trunk/src/view_dir_tree.c
===================================================================
--- trunk/src/view_dir_tree.c 2009-06-06 15:33:56 UTC (rev 1729)
+++ trunk/src/view_dir_tree.c 2009-06-06 16:14:07 UTC (rev 1730)
@@ -720,6 +720,10 @@
{
/* setting the cursor scrolls the view; do not do that
unless it is necessary */
gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view),
tpath, NULL, FALSE);
+
+ /* gtk_tree_view_set_cursor scrolls the window itself,
but it sometimes
+ does not work (switch from dir_list to dir_tree) */
+ tree_view_row_make_visible(GTK_TREE_VIEW(vd->view),
&iter, TRUE);
}
gtk_tree_path_free(tpath);
gtk_tree_path_free(old_tpath);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn