SF.net SVN: geany: [1178] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Sat Jan 13 12:42:13 UTC 2007
Revision: 1178
http://svn.sourceforge.net/geany/?rev=1178&view=rev
Author: ntrel
Date: 2007-01-13 04:42:12 -0800 (Sat, 13 Jan 2007)
Log Message:
-----------
Print an error message (instead of debug message) when a
command-line file cannot be loaded.
Modified Paths:
--------------
trunk/ChangeLog
trunk/po/POTFILES.in
trunk/src/main.c
trunk/src/socket.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2007-01-12 16:56:23 UTC (rev 1177)
+++ trunk/ChangeLog 2007-01-13 12:42:12 UTC (rev 1178)
@@ -1,3 +1,10 @@
+2007-01-13 Nick Treleaven <nick.treleaven at btinternet.com>
+
+ * src/main.c, src/socket.c, po/POTFILES.in:
+ Print an error message (instead of debug message) when a
+ command-line file cannot be loaded.
+
+
2007-01-12 Nick Treleaven <nick.treleaven at btinternet.com>
* src/sci_cb.c, src/symbols.c, src/symbols.h:
Modified: trunk/po/POTFILES.in
===================================================================
--- trunk/po/POTFILES.in 2007-01-12 16:56:23 UTC (rev 1177)
+++ trunk/po/POTFILES.in 2007-01-13 12:42:12 UTC (rev 1178)
@@ -29,3 +29,4 @@
src/notebook.c
src/symbols.c
src/tools.c
+src/socket.c
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2007-01-12 16:56:23 UTC (rev 1177)
+++ trunk/src/main.c 2007-01-13 12:42:12 UTC (rev 1178)
@@ -335,6 +335,7 @@
{
//use current dir
gchar *cur_dir = g_get_current_dir();
+
result = g_strjoin(
G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
g_free(cur_dir);
@@ -466,6 +467,41 @@
}
+// open files from command line
+gboolean open_cl_files(gint argc, gchar **argv)
+{
+ gint i;
+
+ if (argc <= 1) return FALSE;
+
+ for(i = 1; i < argc; i++)
+ {
+ gchar *filename = get_argv_filename(argv[i]);
+
+ if (filename &&
+ g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+ {
+ gint idx;
+
+ idx = document_open_file(-1, filename, 0, FALSE, NULL, NULL);
+ // add recent file manually because opening_session_files is set
+ if (DOC_IDX_VALID(idx))
+ ui_add_recent_file(doc_list[idx].file_name);
+ }
+ else
+ {
+ gchar *msg = _("Could not find file '%s'.");
+
+ g_printerr(msg, filename); // also print to the terminal
+ g_printerr("\n");
+ msgwin_status_add(msg, filename);
+ }
+ g_free(filename);
+ }
+ return TRUE;
+}
+
+
gint main(gint argc, gchar **argv)
{
gint idx;
@@ -580,36 +616,19 @@
// apply all configuration options
apply_settings();
- // open files from command line
+ // load any command line files or session files
app->opening_session_files = TRUE;
- if (argc > 1)
+ if (! open_cl_files(argc, argv))
{
- gint i;
- for(i = 1; i < argc; i++)
+ if (app->pref_main_load_session && cl_options.load_session)
{
- if (argv[i] && g_file_test(argv[i], G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+ if (! configuration_open_files())
{
- gchar *filename = get_argv_filename(argv[i]);
- gint idx;
-
- idx = document_open_file(-1, filename, 0, FALSE, NULL, NULL);
- // add recent file manually because opening_session_files is set
- if (DOC_IDX_VALID(idx))
- ui_add_recent_file(doc_list[idx].file_name);
- g_free(filename);
+ ui_update_popup_copy_items(-1);
+ ui_update_popup_reundo_items(-1);
}
- else
- geany_debug("Could not load file '%s'.", argv[i]);
}
}
- else if (app->pref_main_load_session && cl_options.load_session)
- {
- if (! configuration_open_files())
- {
- ui_update_popup_copy_items(-1);
- ui_update_popup_reundo_items(-1);
- }
- }
app->opening_session_files = FALSE;
// open a new file if no other file was opened
Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c 2007-01-12 16:56:23 UTC (rev 1177)
+++ trunk/src/socket.c 2007-01-13 12:42:12 UTC (rev 1178)
@@ -42,6 +42,7 @@
#include "main.h"
#include "socket.h"
#include "document.h"
+#include "support.h"
@@ -75,6 +76,37 @@
+void send_open_command(gint sock, gint argc, gchar **argv)
+{
+ gint i;
+ gchar *filename;
+
+ g_return_if_fail(argc > 1);
+ geany_debug("using running instance of Geany");
+
+ socket_fd_write_all(sock, "open\n", 5);
+
+ for(i = 1; i < argc && argv[i] != NULL; i++)
+ {
+ filename = get_argv_filename(argv[i]);
+
+ if (filename != NULL &&
+ g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+ {
+ socket_fd_write_all(sock, filename, strlen(filename));
+ socket_fd_write_all(sock, "\n", 1);
+ }
+ else
+ {
+ g_printerr(_("Could not find file '%s'."), filename);
+ g_printerr("\n"); // keep translation from open_cl_files() in main.c.
+ }
+ g_free(filename);
+ }
+ socket_fd_write_all(sock, ".\n", 2);
+}
+
+
/* (Unix domain) socket support to replace the old FIFO code
* (taken from Sylpheed, thanks) */
gint socket_init(gint argc, gchar **argv)
@@ -118,25 +150,7 @@
// remote command mode, here we have another running instance and want to use it
if (argc > 1)
{
- gint i;
- gchar *filename;
-
- geany_debug("using running instance of Geany");
-
- socket_fd_write_all(sock, "open\n", 5);
-
- for(i = 1; i < argc && argv[i] != NULL; i++)
- {
- filename = get_argv_filename(argv[i]);
-
- if (filename != NULL)
- {
- socket_fd_write_all(sock, filename, strlen(filename));
- socket_fd_write_all(sock, "\n", 1);
- g_free(filename);
- }
- }
- socket_fd_write_all(sock, ".\n", 2);
+ send_open_command(sock, argc, argv);
}
socket_fd_close(sock);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list