Code

change API: separate functions creating a blur filter, one for a given item, another...
[inkscape.git] / src / inkview.cpp
index 8be261dcdfc3273213cb352c1bbbfe49b1fe2e19..95af5b73432b4596d485d4ae6ab720978e05b965 100644 (file)
 # include "config.h"
 #endif
 
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+
 #include <string.h>
 #include <sys/stat.h>
 #include <locale.h>
 
+#include <glib/gmem.h>
 #include <libnr/nr-macros.h>
 
+// #include <stropts.h>
+
 #include <libxml/tree.h>
 #include <gdk/gdkkeysyms.h>
 #include <gtk/gtkmain.h>
@@ -67,6 +74,9 @@ Inkscape::Application *inkscape;
 #define bind_textdomain_codeset(p,c)
 #endif
 
+extern char *optarg;
+extern int  optind, opterr;
+
 struct SPSlideShow {
     char **slides;
     int size;
@@ -76,6 +86,7 @@ struct SPSlideShow {
     GtkWidget *view;
     GtkWindow *window;
     bool fullscreen;
+    int timer;
 };
 
 static GtkWidget *sp_svgview_control_show (struct SPSlideShow *ss);
@@ -164,6 +175,24 @@ main (int argc, const char **argv)
 
     struct SPSlideShow ss;
 
+    int option,
+        num_parsed_options = 0;
+
+    // the list of arguments is in the net line
+    while ((option = getopt(argc, (char* const* )argv, "t:")) != -1) 
+    {
+        switch(option) {
+           case 't': // for timer
+                // fprintf(stderr, "set timer arg %s\n", optarg );
+               ss.timer = atoi(optarg);        
+               num_parsed_options += 2; // 2 because of flag + option
+                break;
+            case '?':
+            default:
+               usage();
+        }      
+    }
+   
     GtkWidget *w;
     int i;
 
@@ -191,7 +220,7 @@ main (int argc, const char **argv)
     ss.size = 32;
     ss.length = 0;
     ss.current = 0;
-    ss.slides = nr_new (char *, ss.size);
+    ss.slides = g_new (char *, ss.size);
     ss.current = 0;
     ss.doc = NULL;
     ss.view = NULL;
@@ -199,8 +228,10 @@ main (int argc, const char **argv)
 
     inkscape = (Inkscape::Application *)g_object_new (SP_TYPE_INKSCAPE, NULL);
     Inkscape::Preferences::load();
-
-    for (i = 1; i < argc; i++) {
+    
+    // starting at where the commandline options stopped parsing because
+    // we want all the files to be in the list
+    for (i = num_parsed_options + 1 ; i < argc; i++) {
        struct stat st;
        if (stat (argv[i], &st)
              || !S_ISREG (st.st_mode)
@@ -230,7 +261,7 @@ main (int argc, const char **argv)
                        if (ss.length >= ss.size) {
                            /* Expand */
                            ss.size <<= 1;
-                           ss.slides = nr_renew (ss.slides, char *, ss.size);
+                           ss.slides = g_renew (char *, ss.slides, ss.size);
                        }
 
                        ss.doc = sp_document_new_from_mem ((const gchar *)gba->data,
@@ -252,7 +283,7 @@ main (int argc, const char **argv)
                if (ss.length >= ss.size) {
                    /* Expand */
                    ss.size <<= 1;
-                   ss.slides = nr_renew (ss.slides, char *, ss.size);
+                   ss.slides = g_renew (char *, ss.slides, ss.size);
 
                }
 
@@ -459,11 +490,14 @@ is_jar(char const *filename)
 static void usage()
 {
     fprintf(stderr,
-           "Usage: inkview [FILES ...]\n"
+           "Usage: inkview [OPTIONS...] [FILES ...]\n"
            "\twhere FILES are SVG (.svg or .svgz)"
 #ifdef WITH_INKJAR
-           "or archives of SVGs (.sxw, .jar)"
+           " or archives of SVGs (.sxw, .jar)"
 #endif
+           "\n\n"
+           "Available options:\n"
+           "\t-t\t\tTimer for automatically changing slides in seconds.\n"
            "\n");
     exit(1);
 }