SF.net SVN: geany:[2795] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Jul 21 14:12:16 UTC 2008
Revision: 2795
http://geany.svn.sourceforge.net/geany/?rev=2795&view=rev
Author: ntrel
Date: 2008-07-21 14:12:15 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
Fix filename encoding for new files at startup from the command-line.
Make socket open command support filename:line:column syntax.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/main.c
trunk/src/main.h
trunk/src/socket.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-07-20 18:07:53 UTC (rev 2794)
+++ trunk/ChangeLog 2008-07-21 14:12:15 UTC (rev 2795)
@@ -1,3 +1,10 @@
+2008-07-21 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
+
+ * src/main.c, src/socket.c, src/main.h:
+ Fix filename encoding for new files at startup from the command-line.
+ Make socket open command support filename:line:column syntax.
+
+
2008-07-20 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/keybindings.c:
Modified: trunk/src/main.c
===================================================================
--- trunk/src/main.c 2008-07-20 18:07:53 UTC (rev 2794)
+++ trunk/src/main.c 2008-07-21 14:12:15 UTC (rev 2795)
@@ -634,45 +634,40 @@
}
-static void handle_cl_filename(gchar *const filename)
+/* Used for command-line arguments at startup or from socket.
+ * this will strip any :line:col filename suffix from locale_filename */
+gboolean main_handle_filename(gchar *locale_filename)
{
GeanyDocument *doc;
+ gint line = -1, column = -1;
- if (filename != NULL)
- {
- gint line = -1, column = -1;
+ g_return_val_if_fail(locale_filename, FALSE);
- get_line_and_column_from_filename(filename, &line, &column);
- if (line >= 0)
- cl_options.goto_line = line;
- if (column >= 0)
- cl_options.goto_column = column;
- }
+ get_line_and_column_from_filename(locale_filename, &line, &column);
+ if (line >= 0)
+ cl_options.goto_line = line;
+ if (column >= 0)
+ cl_options.goto_column = column;
- if (filename != NULL &&
- g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+ if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
{
- doc = document_open_file(filename, FALSE, NULL, NULL);
- /* add recent file manually because opening_session_files is set */
- if (doc != NULL)
+ doc = document_open_file(locale_filename, FALSE, NULL, NULL);
+ /* add recent file manually if opening_session_files is set */
+ if (doc != NULL && main_status.opening_session_files)
ui_add_recent_file(doc->file_name);
+ return TRUE;
}
- else if (filename != NULL)
- { /* create new file if it doesn't exist */
- doc = document_new_file(filename, NULL, NULL);
+ else
+ { /* create new file with the given filename */
+ gchar *utf8_filename = utils_get_utf8_from_locale(locale_filename);
+
+ doc = document_new_file(utf8_filename, NULL, NULL);
if (doc != NULL)
- {
ui_add_recent_file(doc->file_name);
- }
+ g_free(utf8_filename);
+ return TRUE;
}
- else
- {
- const gchar *msg = _("Could not find file '%s'.");
-
- g_printerr(msg, filename); /* also print to the terminal */
- g_printerr("\n");
- ui_set_statusbar(TRUE, msg, filename);
- }
+ return FALSE;
}
@@ -687,7 +682,14 @@
{
gchar *filename = get_argv_filename(argv[i]);
- handle_cl_filename(filename);
+ if (filename && !main_handle_filename(filename))
+ {
+ const gchar *msg = _("Could not find file '%s'.");
+
+ g_printerr(msg, filename); /* also print to the terminal */
+ g_printerr("\n");
+ ui_set_statusbar(TRUE, msg, filename);
+ }
g_free(filename);
}
return TRUE;
Modified: trunk/src/main.h
===================================================================
--- trunk/src/main.h 2008-07-20 18:07:53 UTC (rev 2794)
+++ trunk/src/main.h 2008-07-21 14:12:15 UTC (rev 2795)
@@ -53,4 +53,6 @@
void main_quit(void);
+gboolean main_handle_filename(gchar *locale_filename);
+
#endif
Modified: trunk/src/socket.c
===================================================================
--- trunk/src/socket.c 2008-07-20 18:07:53 UTC (rev 2794)
+++ trunk/src/socket.c 2008-07-21 14:12:15 UTC (rev 2795)
@@ -142,7 +142,7 @@
socket_fd_write_all(sock, "open\n", 5);
- for(i = 1; i < argc && argv[i] != NULL; i++)
+ for (i = 1; i < argc && argv[i] != NULL; i++)
{
filename = get_argv_filename(argv[i]);
@@ -484,20 +484,9 @@
utf8_filename = g_strdup(buf);
locale_filename = utils_get_locale_from_utf8(utf8_filename);
-
- if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
- document_open_file(locale_filename, FALSE, NULL, NULL);
- else
- { /* create new file if it doesn't exist */
- GeanyDocument *doc;
-
- doc = document_new_file(utf8_filename, NULL, NULL);
- if (doc != NULL)
- ui_add_recent_file(doc->file_name);
- else
- geany_debug("got data from socket, but it does not look like a filename");
- }
g_free(utf8_filename);
+ if (locale_filename)
+ main_handle_filename(locale_filename);
g_free(locale_filename);
}
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