Package: qiv
Version: 2.0-4.2
Severity: wishlist
Tags: patch

By default, qiv sorts the agglomerate list of files before displaying
the images to the user.  I believe it would be useful to have an
option to avoid the sorting all-together, such that the user could
specify a list of files to be viewed in a given order without the need
to rename the files in order to coerce qiv into producing that order.

Since I was unable to find a way to accomplish this with the current
qiv options, I have added a -D,--no_sort option to qiv which causes
qiv to bypass the sorting algorithm.  With the attached patch, qiv
still sorts all files by default, and if any of the sort-specifier
options are passed (-P,-M,-N) in addition to the new -D option, the
-D option is overridden.

I hope you find this useful, and will consider its addition.

Cheers,
Kevin

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17.20060719a
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages qiv depends on:
ii  gdk-imlib11                  1.9.14-30   imaging library for use with gtk
ii  libc6                        2.3.6-19    GNU C Library: Shared libraries
ii  libglib1.2                   1.2.10-10.1 The GLib library of C routines
ii  libgtk1.2                    1.2.10-18   The GIMP Toolkit set of widgets fo
ii  libx11-6                     2:1.0.0-7   X11 client-side library
ii  libxext6                     1:1.0.0-4   X11 miscellaneous extension librar
ii  libxi6                       1:1.0.0-5   X11 Input extension library
ii  libxinerama1                 1:1.0.1-4   X11 Xinerama extension library

qiv recommends no packages.

-- no debconf information
diff -ur qiv-2.0.orig/options.c qiv-2.0/options.c
--- qiv-2.0.orig/options.c	2006-08-14 15:08:45.000000000 -0600
+++ qiv-2.0/options.c	2006-08-14 18:55:02.000000000 -0600
@@ -22,7 +22,7 @@
 extern int rreaddir(const char *);
 extern int rreadfile(const char *);
 
-static char *short_options = "hexyzmtb:c:g:niIpaGA:vo:srRSd:u:fw:W:PMNF:T";
+static char *short_options = "hexyzmtb:c:g:niIpaGA:vo:srRSd:u:fw:W:DPMNF:T";
 static struct option long_options[] =
 {
     {"help",             0, NULL, 'h'},
@@ -52,6 +52,7 @@
     {"fullscreen",       0, NULL, 'f'},
     {"fixed_width",      1, NULL, 'w'},
     {"fixed_zoom",       1, NULL, 'W'},
+    {"no_sort",          0, NULL, 'D'},
     {"ignore_path_sort", 0, NULL, 'P'},
     {"merged_case_sort", 0, NULL, 'M'},
     {"numeric_sort",     0, NULL, 'N'},
@@ -187,7 +188,7 @@
 
 void options_read(int argc, char **argv, qiv_image *q)
 {
-    int long_index, shuffle = 0, need_sort = 0;
+    int long_index, shuffle = 0, need_sort = 1;
     int c, cnt;
     int force_statusbar=-1;             /* default is don't force */
     struct stat sb;
@@ -260,7 +261,6 @@
                           g_print("Error: %s is not a directory.\n",optarg);
                           gdk_exit(1);
                       }
-                      need_sort=1;
 		      break;
 	    case 'f': fullscreen=1;
 		      break;
@@ -268,17 +268,18 @@
 		      break;
 	    case 'W': fixed_zoom_factor = (checked_atoi(optarg) - 100) / 10;
 		      break;
-	    case 'P': need_sort = ignore_path_sort = 1;
+	    case 'D': need_sort = 0;
 		      break;
-	    case 'M': need_sort = merged_case_sort = 1;
+	    case 'P': ignore_path_sort = 1;
 		      break;
-	    case 'N': need_sort = numeric_sort = 1;
+	    case 'M': merged_case_sort = 1;
+		      break;
+	    case 'N': numeric_sort = 1;
 		      break;
 	    case 'F': if(rreadfile(optarg) < 0) {
                           g_print("Error: %s could not be opened: %s.\n",optarg, strerror(errno));
                           gdk_exit(1);
                       }
-                      need_sort=1;
 		      break;
         case 'T': watch_file=1;
 		      break;
@@ -288,6 +289,9 @@
 	}
     }
 
+    /* In case user specified -D and -P, -M, or -N */
+    need_sort = need_sort || ignore_path_sort || merged_case_sort || numeric_sort;
+
     /* default: show statusbar only in fullscreen mode */
     /* user wants to override? */
     if (force_statusbar != -1) {
@@ -302,7 +306,6 @@
         while (cnt-- > 0) {
             if (stat(argv[optind], &sb) >= 0 && S_ISDIR(sb.st_mode)) {
                 rreaddir(argv[optind++]);
-                need_sort=1;
             }
             else {
                 if (images >= max_image_cnt) {
diff -ur qiv-2.0.orig/qiv.1 qiv-2.0/qiv.1
--- qiv-2.0.orig/qiv.1	2006-08-14 15:08:45.000000000 -0600
+++ qiv-2.0/qiv.1	2006-08-14 18:55:00.000000000 -0600
@@ -130,6 +130,9 @@
 baz01.jpg through baz99.jpg (because the longer group of zero-padded
 digits indicates that they shouldn't be intermingled).
 .TP
+.B \-D, \-\-no_sort
+Do not apply any sorting to the list of files.
+.TP
 .B \-T, \-\-watch
 Reload the image if it has changed on disk.
 .SH EXAMPLES

Reply via email to