#include <cx/buffer.h>
#include <cx/utils.h>
+#include <cx/array_list.h>
static XtAppContext app;
static Display *display;
static Widget toplevel_window;
-static char *open_file_arg;
+static CxList *open_file_arg;
static int event_pipe[2];
display = XtOpenDisplay(app, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv);
if(argc > 1) {
- struct stat s;
- if(stat(argv[1], &s)) {
- fprintf(stderr, "Cannot open file: %s\n", argv[1]);
- perror("");
- return 1;
+ open_file_arg = cxArrayListCreateSimple(CX_STORE_POINTERS, argc-1);
+ for(int i=1;i<argc;i++) {
+ struct stat s;
+ if(stat(argv[1], &s)) {
+ fprintf(stderr, "Cannot open file: %s\n", argv[1]);
+ perror("");
+ return 1;
+ }
+ cxListAdd(open_file_arg, argv[i]);
}
- open_file_arg = argv[1];
}
// load settings
free(instance_path);
if(instance_fd >= 0) {
- write(instance_fd, "open ", 5);
- write(instance_fd, open_file_arg, strlen(open_file_arg));
- write(instance_fd, "\n", 1);
+ CxIterator i = cxListIterator(open_file_arg);
+ cx_foreach(char *, file, i) {
+ write(instance_fd, "open ", 5);
+ write(instance_fd, file, strlen(file));
+ write(instance_fd, "\n", 1);
+ }
close(instance_fd);
return 0;
}
write(event_pipe[1], &cb, sizeof(cb));
}
-char* GetOpenFileArg(void) {
+CxList* GetOpenFileArgs(void) {
return open_file_arg;
}
-void CleanOpenFileArg(void) {
+void CleanOpenFileArgs(void) {
+ cxListDestroy(open_file_arg);
open_file_arg = NULL;
}
}
static void WindowRealized(MainWindow *win) {
- char *open_file = GetOpenFileArg();
+ CxList *open_file = GetOpenFileArgs();
if(open_file) {
- PlayListAddFile(win, open_file);
+ CxIterator i = cxListIterator(open_file);
+ cx_foreach(char *, file, i) {
+ PlayListAddFile(win, file);
+ }
PlayListPlayNext(win, true);
- CleanOpenFileArg();
+ CleanOpenFileArgs();
}
if(!blank_cursor_init) {