[geany/geany] 73f345: Use standard include paths for "open selected file"
Jiří Techet
git-noreply at xxxxx
Thu Jul 26 00:02:57 UTC 2012
Branch: refs/heads/document-messages
Author: Jiří Techet <techet at gmail.com>
Committer: Colomban Wendling <ban at herbesfolles.org>
Date: Wed, 11 Jan 2012 21:57:31
Commit: 73f345eb09e52a195f823d6e28bc52702b735388
https://github.com/geany/geany/commit/73f345eb09e52a195f823d6e28bc52702b735388
Log Message:
-----------
Use standard include paths for "open selected file"
Under linux, try to locate the file with the given
name also under /usr/local/include and /usr/include.
This feature is probably most often used for
opening include files so this helps for the system
ones.
In addition, fix locale/utf8 encoding usage.
Modified Paths:
--------------
src/callbacks.c
Modified: src/callbacks.c
22 files changed, 18 insertions(+), 4 deletions(-)
===================================================================
@@ -1603,10 +1603,11 @@ G_MODULE_EXPORT void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem,
g_return_if_fail(doc != NULL);
sel = editor_get_default_selection(doc->editor, TRUE, wc);
+ setptr(sel, utils_get_locale_from_utf8(sel));
if (sel != NULL)
{
- gchar *locale_filename, *filename = NULL;
+ gchar *filename = NULL;
if (g_path_is_absolute(sel))
filename = g_strdup(sel);
@@ -1615,6 +1616,7 @@ G_MODULE_EXPORT void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem,
gchar *path;
path = utils_get_current_file_dir_utf8();
+ setptr(path, utils_get_locale_from_utf8(path));
if (!path)
path = g_get_current_dir();
@@ -1625,16 +1627,28 @@ G_MODULE_EXPORT void on_menu_open_selected_file1_activate(GtkMenuItem *menuitem,
{
/* try the project's base path */
setptr(path, project_get_base_path());
+ setptr(path, utils_get_locale_from_utf8(path));
setptr(filename, g_build_path(G_DIR_SEPARATOR_S, path, sel, NULL));
}
g_free(path);
+#ifdef G_OS_UNIX
+ if (! g_file_test(filename, G_FILE_TEST_EXISTS))
+ setptr(filename, g_build_path(G_DIR_SEPARATOR_S, "/usr/local/include", sel, NULL));
+
+ if (! g_file_test(filename, G_FILE_TEST_EXISTS))
+ setptr(filename, g_build_path(G_DIR_SEPARATOR_S, "/usr/include", sel, NULL));
+#endif
}
- locale_filename = utils_get_locale_from_utf8(filename);
- document_open_file(locale_filename, FALSE, NULL, NULL);
+ if (g_file_test(filename, G_FILE_TEST_EXISTS))
+ document_open_file(filename, FALSE, NULL, NULL);
+ else
+ {
+ setptr(sel, utils_get_utf8_from_locale(sel));
+ ui_set_statusbar(TRUE, _("Could not open file %s (File not found)"), sel);
+ }
g_free(filename);
- g_free(locale_filename);
g_free(sel);
}
}
@@ Diff output truncated at 100000 characters. @@
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: TBD).
More information about the Commits
mailing list