Kaydet (Commit) ad78c7e1 authored tarafından Nick Treleaven's avatar Nick Treleaven

Print an error message (instead of debug message) when a

command-line file cannot be loaded.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1178 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 9a341056
2007-01-13 Nick Treleaven <nick.treleaven@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@btinternet.com>
* src/sci_cb.c, src/symbols.c, src/symbols.h:
......
......@@ -29,3 +29,4 @@ src/search.c
src/notebook.c
src/symbols.c
src/tools.c
src/socket.c
......@@ -335,6 +335,7 @@ gchar *get_argv_filename(const gchar *filename)
{
//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 @@ static void signal_cb(gint sig)
}
// 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,34 +616,17 @@ gint main(gint argc, gchar **argv)
// 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;
......
......@@ -42,6 +42,7 @@
#include "main.h"
#include "socket.h"
#include "document.h"
#include "support.h"
......@@ -75,6 +76,37 @@ static gint socket_fd_close (gint sock);
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 @@ gint socket_init(gint argc, gchar **argv)
// 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment