Command line option to print current filename
authorColin Clark <cclark@mcb.net>
Thu, 29 Dec 2016 16:33:08 +0000 (16:33 +0000)
committerColin Clark <cclark@mcb.net>
Thu, 29 Dec 2016 16:33:08 +0000 (16:33 +0000)
Command line remote option to print the filename of the currently
displayed image.

geeqie --remote --tell

Originator:
https://sourceforge.net/p/geeqie/mailman/geeqie-
devel/thread/20161227192724.GC1622%40hodi/#msg35573019

doc/docbook/GuideReferenceCommandLine.xml
src/remote.c

index 145d09f..da17bef 100644 (file)
             <entry>file:&lt;file&gt;</entry>\r
             <entry>Change main window to display &lt;file&gt;</entry>\r
           </row>\r
+          <row>\r
+            <entry />\r
+            <entry>--tell</entry>\r
+            <entry>Print filename of current image</entry>\r
+          </row>\r
           <row>\r
             <entry />\r
             <entry>view:&lt;file&gt;</entry>\r
index c89eff9..9147bf9 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "collect.h"
 #include "filedata.h"
+#include "image.h"
 #include "img-view.h"
 #include "layout.h"
 #include "layout_image.h"
@@ -522,6 +523,14 @@ static void gr_file_load(const gchar *text, GIOChannel *channel, gpointer data)
        g_free(filename);
 }
 
+static void gr_file_tell(const gchar *text, GIOChannel *channel, gpointer data)
+{
+       LayoutWindow *lw = NULL; /* NULL to force layout_valid() to do some magic */
+       if (!layout_valid(&lw)) return;
+       if (image_get_path(lw->image))
+               printf_term("%s %s\n", GQ_APPNAME, image_get_path(lw->image));
+}
+
 static void gr_config_load(const gchar *text, GIOChannel *channel, gpointer data)
 {
        gchar *filename = expand_tilde(text);
@@ -666,6 +675,7 @@ static RemoteCommandEntry remote_commands[] = {
        { NULL, "--get-sidecars:",      gr_get_sidecars,        TRUE,  FALSE, N_("<FILE>"), N_("get list of sidecars of FILE") },
        { NULL, "--get-destination:",   gr_get_destination,     TRUE,  FALSE, N_("<FILE>"), N_("get destination path of FILE") },
        { NULL, "file:",                gr_file_load,           TRUE,  FALSE, N_("<FILE>"), N_("open FILE") },
+       { NULL, "--tell",               gr_file_tell,           FALSE, FALSE, NULL, N_("print filename of current image") },
        { NULL, "view:",                gr_file_view,           TRUE,  FALSE, N_("<FILE>"), N_("open FILE in new window") },
        { NULL, "--list-clear",         gr_list_clear,          FALSE, FALSE, NULL, N_("clear command line collection list") },
        { NULL, "--list-add:",          gr_list_add,            TRUE,  FALSE, N_("<FILE>"), N_("add FILE to command line collection list") },