Permalink
Browse files

Add a -r (repeat) argument

to loop back to the beginning, e.g. in slideshow mode.
  • Loading branch information...
1 parent ce6409b commit 346421aa1a6d09e03faeddb0103e9657c80fc994 @akkana committed Oct 19, 2014
Showing with 22 additions and 10 deletions.
  1. +2 −0 gmain.c
  2. +17 −10 pho.c
  3. +3 −0 pho.h
View
@@ -346,6 +346,8 @@ static void CheckArg(char* arg)
else Usage();
if (gDebug)
printf("Slideshow delay %d seconds\n", gDelaySeconds);
+ } else if (*arg == 'r') {
+ gRepeat = 1;
} else if (*arg == 'c') {
gCapFileFormat = strdup(arg+1);
if (gDebug)
View
@@ -43,6 +43,9 @@ int gDisplayMode = PHO_DISPLAY_NORMAL;
int gDelaySeconds = 0;
int gPendingTimeout = 0;
+/* Loop back to the first image after showing the last one */
+int gRepeat = 0;
+
static int RotateImage(PhoImage* img, int degrees); /* forward */
static gint DelayTimer(gpointer data)
@@ -186,14 +189,17 @@ int NextImage()
/* We're to the end of the list, after deleting something bogus */
return -1;
- else if ((gCurImage->next == 0) || (gCurImage->next == gFirstImage))
+ else if (!gCurImage->next || (gCurImage->next == gFirstImage))
/* We're at the end of the list, can't go farther.
* However, we may have gotten here by trying to go to
* the next image and failing, in which case we no longer
* have a pixmap loaded. So we still need to LoadImage,
* but we'll want to return -1 to indicate we didn't progress.
*/
- retval = -1;
+ if (gRepeat)
+ gCurImage = gFirstImage;
+ else
+ retval = -1;
/* We only want to go to ->next the first time;
* if we're looping because of an error, gCurImage is already set.
@@ -729,17 +735,18 @@ void Usage()
{
printf("pho version %s. Copyright 2002-2009 Akkana Peck akkana@shallowsky.com.\n", VERSION);
printf("Usage: pho [-dhnp] image [image ...]\n");
- printf("\t-p: Presentation mode (full screen, centered)\n");
+ printf("\t-p: Presentation mode (full screen, centered)\n");
printf("\t-p[resolution]: Projector mode:\n\tlike presentation mode but in upper left corner\n");
- printf("\t-P: No presentation mode (separate window) -- default\n");
- printf("\t-k: Keywords mode (show a Keywords dialog for each image)\n");
- printf("\t-n: Replace each image window with a new window (helpful for some window managers)\n");
+ printf("\t-P: No presentation mode (separate window) -- default\n");
+ printf("\t-k: Keywords mode (show a Keywords dialog for each image)\n");
+ printf("\t-n: Replace each image window with a new window (helpful for some window managers)\n");
printf("\t-sN: Slideshow mode, where N is the timeout in seconds\n");
+ printf("\t-r: Repeat: loop back to the first image after showing the last\n");
printf("\t-cpattern: Caption/Comment file pattern, format string for reworking filename\n");
- printf("\t--: Assume no more flags will follow\n");
- printf("\t-d: Debug messages\n");
- printf("\t-h: Help: Print this summary\n");
- printf("\t-v: Verbose help: Print a summary of key bindings\n");
+ printf("\t--: Assume no more flags will follow\n");
+ printf("\t-d: Debug messages\n");
+ printf("\t-h: Help: Print this summary\n");
+ printf("\t-v: Verbose help: Print a summary of key bindings\n");
exit(1);
}
View
@@ -131,6 +131,9 @@ extern int gMakeNewWindows;
*/
extern int gDelaySeconds;
+/* Loop back to the first image after showing the last one */
+extern int gRepeat;
+
/* Get the keyword string associated with a note number */
extern char* KeywordString(int notenum);

0 comments on commit 346421a

Please sign in to comment.