Revision: 747 Author: ntrel Date: 2006-08-20 04:40:09 -0700 (Sun, 20 Aug 2006) ViewCVS: http://svn.sourceforge.net/geany/?rev=747&view=rev
Log Message: ----------- Fix opening more than one file from the command-line (with fifo)
Modified Paths: -------------- trunk/ChangeLog trunk/src/callbacks.c trunk/src/main.c Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2006-08-19 15:07:11 UTC (rev 746) +++ trunk/ChangeLog 2006-08-20 11:40:09 UTC (rev 747) @@ -1,3 +1,9 @@ +2006-08-20 Nick Treleaven nick.treleaven@btinternet.com + + * src/callbacks.c, src/main.c: + Fix opening more than one file from the command-line (with fifo). + + 2006-08-19 Enrico Tröger enrico.troeger@uvena.de
* geany.glade, src/interface.c, src/keybindings.c, src/utils.c,
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-08-19 15:07:11 UTC (rev 746) +++ trunk/src/callbacks.c 2006-08-20 11:40:09 UTC (rev 747) @@ -91,8 +91,8 @@ // delete the fifo early, because we don't accept new files anymore if (app->fifo_ioc != NULL) { + g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL); g_io_channel_unref(app->fifo_ioc); - g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL); } unlink(fifo); g_free(fifo);
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2006-08-19 15:07:11 UTC (rev 746) +++ trunk/src/main.c 2006-08-20 11:40:09 UTC (rev 747) @@ -331,9 +331,11 @@
//status = g_io_channel_read_to_end(source, &buffer, &len, NULL); status = g_io_channel_read_line(source, &buffer, &len, NULL, NULL); + g_strstrip(buffer); // remove \n char
// try to interpret the received data as a filename, otherwise do nothing - if (g_file_test(buffer, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK)) + if (status == G_IO_STATUS_NORMAL && + g_file_test(buffer, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK)) { document_open_file(-1, buffer, 0, FALSE, NULL, NULL); gtk_window_deiconify(GTK_WINDOW(app->window)); @@ -344,16 +346,7 @@ } g_free(buffer);
- if (status != G_IO_STATUS_NORMAL) - return TRUE; - else - { - g_io_channel_unref(app->fifo_ioc); - g_io_channel_shutdown(app->fifo_ioc, FALSE, NULL); - app->fifo_ioc = g_io_channel_unix_new(open(fifo_name, O_RDONLY | O_NONBLOCK)); - g_io_add_watch(app->fifo_ioc, G_IO_IN | G_IO_PRI, read_fifo, NULL); - return FALSE; - } + return TRUE; // allow receiving more data }
@@ -362,19 +355,24 @@ gint i; GIOChannel *ioc;
+ ioc = g_io_channel_unix_new(open(fifo_name, O_WRONLY)); + for(i = 1; i < argc && argv[i] != NULL; i++) { gchar *filename = get_argv_filename(argv[i]);
if (filename && g_file_test(filename, G_FILE_TEST_IS_REGULAR || G_FILE_TEST_IS_SYMLINK)) { - ioc = g_io_channel_unix_new(open(fifo_name, O_WRONLY)); g_io_channel_write_chars(ioc, filename, -1, NULL, NULL); + g_io_channel_write_chars(ioc, "\n", -1, NULL, NULL); // each line has one file g_io_channel_flush(ioc, NULL); - g_io_channel_shutdown(ioc, TRUE, NULL); } + else + g_printerr(_("Could not find file "%s".\n"), filename); g_free(filename); } + g_io_channel_shutdown(ioc, TRUE, NULL); + g_io_channel_unref(ioc); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.