Re: Gqview feature request: tabbed views in main window

John Ellis <[email protected]> Sat, 28 Oct 2006 03:08:54 -0400
Newsgroups gmane.comp.gnome.apps.gqview.devel
Message-ID <[email protected]>
Magnus Pym wrote:
> Hi,
> 
> First of all, thanks a lot for continuing gqview development.
> I was afraid that it had been abandoned.
> 
> I have a feature request. I would like to have the feature to
> open images in "tabs" in the main window, like firefox or
> mozilla, from all possible contexts where the current
> "open in new window" functionality is supported. I believe
> this wil be a wonderful feature and would enhance
> gqview no end.

Tabs should not be too hard, I will stick them on the TODO for consideration.

> 
> While I am on the topic, I would also request a faster
> "sort" option for the file list. The sorting in gqview
> is, for some reason, extremely slow when the
> icon view is disabled. When the icon view is enabled,
> the sorting is very very fast.

Since you posted this to a devel list, this patch should fix up the speed 
issue, use:

   patch view_file_list.c gqview-fast-list-sort.patch

and recompile. I need feedback if the patch works or creates any new 
problems. The patch should work for any 2.0.x or 2.1.x. release (I only 
tried 2.0.2 and 2.1.2).

The speed boost is quite noticeable, sorting 7600 images for me drops from 
170 to 2 seconds on GTK+ 2.10.4.


Greetings,
John


-- 
John Ellis <[email protected]>

http://gqview.sourceforge.net <GQview> | http://hideseek.sourceforge.net
http://gqmpeg.sourceforge.net <GQmpeg> |     <Preferences Hide and Seek>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642

_______________________________________________
Gqview-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gqview-devel
gqview-fast-list-sort.patch (text/x-patch, 3.5 KB)
Index: view_file_list.c
===================================================================
RCS file: /devel/cvs/gqview/src/view_file_list.c,v
retrieving revision 1.37
diff -u -r1.37 view_file_list.c
--- view_file_list.c	15 Aug 2005 21:16:05 -0000	1.37
+++ view_file_list.c	28 Oct 2006 03:57:30 -0000
@@ -734,10 +734,23 @@
  *-----------------------------------------------------------------------------
  */
 
+static gboolean vflist_dummy_select_cb(GtkTreeSelection *selection, GtkTreeModel *store, GtkTreePath *tpath,
+				        gboolean path_currently_selected, gpointer data)
+{
+	return TRUE;
+}
+
 void vflist_sort_set(ViewFileList *vfl, SortType type, gint ascend)
 {
+	GtkTreeModel *model;
 	GtkListStore *store;
 	GList *work;
+	GtkTreeSelection *selection;
+	GtkTreePath *tpath;
+	GtkTreeIter iter;
+	GList *select_list;
+	FileData *cursor_fd = NULL;
+	gint single_select;
 
 	if (vfl->sort_method == type && vfl->sort_ascend == ascend) return;
 
@@ -748,9 +761,12 @@
 
 	vfl->list = filelist_sort(vfl->list, vfl->sort_method, vfl->sort_ascend);
 
+	/* now reorder the treeview, maintaining current selection */
+
+#if 0
+	/* this is simpler, but much slower */
 	store = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(vfl->listview)));
 
-	/* reorder the treeview, maintaining current selection */
 	work = g_list_last(vfl->list);
 	while (work)
 		{
@@ -765,6 +781,90 @@
 
 		work = work->prev;
 		}
+#endif
+
+	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vfl->listview));
+
+	gtk_tree_selection_set_select_function(selection, vflist_dummy_select_cb, vfl, NULL);
+
+	select_list = gtk_tree_selection_get_selected_rows(selection, &model);
+	work = select_list;
+	while (work)
+		{
+		FileData *fd;
+
+		tpath = work->data;
+		gtk_tree_model_get_iter(model, &iter, tpath);
+		gtk_tree_model_get(model, &iter, FILE_COLUMN_POINTER, &fd, -1);
+		gtk_tree_path_free(tpath);
+
+		work->data = fd;
+		work = work->next;
+		}
+
+	select_list = filelist_sort(select_list, vfl->sort_method, vfl->sort_ascend);
+
+	gtk_tree_view_get_cursor(GTK_TREE_VIEW(vfl->listview), &tpath, NULL);
+	if (tpath)
+		{
+		if (gtk_tree_model_get_iter(model, &iter, tpath))
+			{
+			gtk_tree_model_get(model, &iter, FILE_COLUMN_POINTER, &cursor_fd, -1);
+			}
+		gtk_tree_path_free(tpath);
+		}
+
+	single_select = (select_list && !select_list->next);
+	if (single_select) cursor_fd = select_list->data;
+
+	store = GTK_LIST_STORE(model);
+	gtk_list_store_clear(store);
+
+	work = vfl->list;
+	while (work)
+		{
+		FileData *fd;
+		gchar *size;
+
+		fd = work->data;
+		size = text_from_size(fd->size);
+		gtk_list_store_append(store, &iter);
+		gtk_list_store_set(store, &iter, FILE_COLUMN_POINTER, fd,
+						 FILE_COLUMN_THUMB, (vfl->thumbs_enabled) ? fd->pixbuf : NULL,
+						 FILE_COLUMN_NAME, fd->name,
+						 FILE_COLUMN_SIZE, size,
+						 FILE_COLUMN_DATE, text_from_time(fd->date),
+						 FILE_COLUMN_COLOR, FALSE, -1);
+		g_free(size);
+
+		if (select_list && select_list->data == fd)
+			{
+			select_list = g_list_remove(select_list, fd);
+			gtk_tree_selection_select_iter(selection, &iter);
+			}
+
+		work = work->next;
+		}
+
+	g_list_free(select_list);
+
+	if (cursor_fd)
+		{
+		GtkTreeIter iter;
+		if (vflist_find_row(vfl, cursor_fd, &iter) >= 0)
+			{
+			if (single_select)
+				{
+				vflist_move_cursor(vfl, &iter);
+				}
+			else
+				{
+				tree_view_row_make_visible(GTK_TREE_VIEW(vfl->listview), &iter, TRUE);
+				}
+			}
+		}
+
+	gtk_tree_selection_set_select_function(selection, vflist_select_cb, vfl, NULL);
 }
 
 /*