Use utf8/locale encoding wrappers.
git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@711 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
c308b37049
commit
0dcbacec1f
@ -4,6 +4,8 @@
|
||||
Use wrappers for converting between utf8 and locale encoding.
|
||||
Fixed small memory leak.
|
||||
* src/vte.c: Added the GTK IM menu items to the VTE popup menu.
|
||||
* src/utils.c, src/dialogs.c, src/build.c, src/callbacks.c,
|
||||
src/search.c, src/keyfile.c: Use utf8/locale encoding wrappers.
|
||||
|
||||
|
||||
2006-08-12 Enrico Tröger <enrico.troeger@uvena.de>
|
||||
|
24
src/build.c
24
src/build.c
@ -81,8 +81,7 @@ GPid build_view_tex_file(gint idx, gint mode)
|
||||
view_file = g_strconcat(executable, (mode == 0) ? ".dvi" : ".pdf", NULL);
|
||||
|
||||
// try convert in locale for stat()
|
||||
locale_filename = g_locale_from_utf8(view_file, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(view_file);
|
||||
locale_filename = utils_get_locale_from_utf8(view_file);
|
||||
|
||||
// check wether view_file exists
|
||||
if (stat(locale_filename, &st) != 0)
|
||||
@ -101,8 +100,7 @@ GPid build_view_tex_file(gint idx, gint mode)
|
||||
cmd_string = utils_str_replace(cmd_string, "%e", executable);
|
||||
|
||||
// try convert in locale
|
||||
locale_cmd_string = g_locale_from_utf8(cmd_string, -1, NULL, NULL, NULL);
|
||||
if (locale_cmd_string == NULL) locale_cmd_string = g_strdup(view_file);
|
||||
locale_cmd_string = utils_get_locale_from_utf8(cmd_string);
|
||||
|
||||
argv = g_new0(gchar *, 4);
|
||||
argv[0] = g_strdup("/bin/sh");
|
||||
@ -183,8 +181,7 @@ GPid build_link_file(gint idx)
|
||||
|
||||
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
|
||||
|
||||
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
|
||||
executable = utils_remove_ext_from_filename(locale_filename);
|
||||
object_file = g_strdup_printf("%s.o", executable);
|
||||
@ -258,8 +255,7 @@ static GPid build_spawn_cmd(gint idx, gchar **cmd)
|
||||
cmd_string = g_strjoinv(" ", cmd);
|
||||
g_strfreev(cmd);
|
||||
|
||||
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
|
||||
executable = utils_remove_ext_from_filename(locale_filename);
|
||||
|
||||
@ -272,8 +268,7 @@ static GPid build_spawn_cmd(gint idx, gchar **cmd)
|
||||
g_free(tmp);
|
||||
g_free(executable);
|
||||
|
||||
utf8_cmd_string = g_locale_to_utf8(cmd_string, -1, NULL, NULL, NULL);
|
||||
if (utf8_cmd_string == NULL) utf8_cmd_string = g_strdup(cmd_string);
|
||||
utf8_cmd_string = utils_get_utf8_from_locale(cmd_string);
|
||||
|
||||
argv = g_new0(gchar *, 4);
|
||||
argv[0] = g_strdup("/bin/sh");
|
||||
@ -342,11 +337,9 @@ GPid build_run_cmd(gint idx)
|
||||
|
||||
script_name = g_strdup("./geany_run_script.sh");
|
||||
|
||||
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
|
||||
locale_term_cmd = g_locale_from_utf8(app->tools_term_cmd, -1, NULL, NULL, NULL);
|
||||
if (locale_term_cmd == NULL) locale_term_cmd = g_strdup(app->tools_term_cmd);
|
||||
locale_term_cmd = utils_get_locale_from_utf8(app->tools_term_cmd);
|
||||
// split the term_cmd, so arguments will work too
|
||||
term_argv = g_strsplit(locale_term_cmd, " ", -1);
|
||||
term_argv_len = g_strv_length(term_argv);
|
||||
@ -393,8 +386,7 @@ GPid build_run_cmd(gint idx)
|
||||
if (chdir(working_dir) != 0)
|
||||
{
|
||||
gchar *utf8_working_dir = NULL;
|
||||
utf8_working_dir = g_locale_to_utf8(working_dir, -1, NULL, NULL, NULL);
|
||||
if (utf8_working_dir == NULL) utf8_working_dir = g_strdup(working_dir);
|
||||
utf8_working_dir = utils_get_utf8_from_locale(working_dir);
|
||||
|
||||
msgwin_status_add(_("Failed to change the working directory to %s"), working_dir);
|
||||
result_id = (GPid) 1; // return 1, to prevent error handling of the caller
|
||||
|
@ -847,8 +847,7 @@ void
|
||||
on_file_open_entry_activate (GtkEntry *entry,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar *locale_filename = g_locale_from_utf8(gtk_entry_get_text(entry), -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(gtk_entry_get_text(entry));
|
||||
gchar *locale_filename = utils_get_locale_from_utf8(gtk_entry_get_text(entry));
|
||||
|
||||
if (g_file_test(locale_filename, G_FILE_TEST_IS_DIR))
|
||||
{
|
||||
@ -874,8 +873,7 @@ on_file_open_selection_changed (GtkFileChooser *filechooser,
|
||||
if (filename)
|
||||
{
|
||||
// try to get the UTF-8 equivalent for the filename, fallback to filename if error
|
||||
gchar *utf8_filename = g_locale_to_utf8(filename, -1, NULL, NULL, NULL);
|
||||
if (utf8_filename == NULL) utf8_filename = g_strdup(filename);
|
||||
gchar *utf8_filename = utils_get_utf8_from_locale(filename);
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(lookup_widget(
|
||||
GTK_WIDGET(filechooser), "file_entry")), utf8_filename);
|
||||
@ -1672,10 +1670,7 @@ on_build_make_activate (GtkMenuItem *menuitem,
|
||||
case 2: //make object
|
||||
{
|
||||
gchar *locale_filename, *short_file, *noext, *object_file; //temp
|
||||
locale_filename = g_locale_from_utf8(doc_list[idx].file_name,
|
||||
-1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL)
|
||||
locale_filename = g_strdup(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
|
||||
short_file = g_path_get_basename(locale_filename);
|
||||
g_free(locale_filename);
|
||||
@ -2265,9 +2260,7 @@ void
|
||||
on_recent_file_activate (GtkMenuItem *menuitem,
|
||||
gpointer user_data)
|
||||
{
|
||||
gchar *locale_filename = g_locale_from_utf8((gchar*) user_data, -1, NULL, NULL, NULL);
|
||||
|
||||
if (locale_filename == NULL) locale_filename = g_strdup((gchar*) user_data);
|
||||
gchar *locale_filename = utils_get_locale_from_utf8((gchar*) user_data);
|
||||
|
||||
document_open_file(-1, locale_filename, 0, FALSE, NULL, NULL);
|
||||
utils_recent_file_loaded((gchar*) user_data);
|
||||
|
@ -125,8 +125,7 @@ void dialogs_show_open_file ()
|
||||
{
|
||||
gchar *locale_filename;
|
||||
|
||||
locale_filename = g_locale_from_utf8(initdir, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(initdir);
|
||||
locale_filename = utils_get_locale_from_utf8(initdir);
|
||||
|
||||
if (g_path_is_absolute(locale_filename))
|
||||
gtk_file_chooser_set_current_folder(
|
||||
@ -178,8 +177,7 @@ void dialogs_show_save_as()
|
||||
// If the current document has a filename we use that as the default.
|
||||
if (doc_list[idx].file_name != NULL)
|
||||
{
|
||||
gchar *locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(doc_list[idx].file_name);
|
||||
gchar *locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
|
||||
if (g_path_is_absolute(locale_filename))
|
||||
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(app->save_filesel), locale_filename);
|
||||
@ -1061,8 +1059,7 @@ void dialogs_show_file_properties(gint idx)
|
||||
|
||||
|
||||
#if defined(HAVE_SYS_STAT_H) && defined(TIME_WITH_SYS_TIME) && defined(HAVE_SYS_TYPES_H)
|
||||
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(doc_list[idx].file_name);
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
if (stat(locale_filename, &st) == 0)
|
||||
{
|
||||
// first copy the returned string and the trim it, to not modify the static glibc string
|
||||
|
@ -424,8 +424,7 @@ gboolean configuration_open_files()
|
||||
else file = array[1];
|
||||
|
||||
// try to get the locale equivalent for the filename, fallback to filename if error
|
||||
locale_filename = g_locale_from_utf8(file, -1, NULL, NULL, NULL);
|
||||
if (locale_filename == NULL) locale_filename = g_strdup(file);
|
||||
locale_filename = utils_get_locale_from_utf8(file);
|
||||
|
||||
if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR || G_FILE_TEST_IS_SYMLINK))
|
||||
{
|
||||
|
@ -730,8 +730,7 @@ on_find_in_files_dialog_response(GtkDialog *dialog, gint response, gpointer user
|
||||
(invert ? FIF_INVERT_MATCH : 0) |
|
||||
(case_sens ? FIF_CASE_SENSITIVE : 0);
|
||||
|
||||
locale_dir = g_locale_from_utf8(utf8_dir, -1, NULL, NULL, NULL);
|
||||
if (locale_dir == NULL) locale_dir = g_strdup(utf8_dir);
|
||||
locale_dir = utils_get_locale_from_utf8(utf8_dir);
|
||||
|
||||
if (search_find_in_files(search_text, locale_dir, opts))
|
||||
{
|
||||
|
@ -967,7 +967,7 @@ gboolean utils_check_disk_status(gint idx)
|
||||
|
||||
if (doc_list[idx].last_check > (t - GEANY_CHECK_FILE_DELAY)) return FALSE;
|
||||
|
||||
locale_filename = g_locale_from_utf8(doc_list[idx].file_name, -1, NULL, NULL, NULL);
|
||||
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
|
||||
if (stat(locale_filename, &st) != 0) return FALSE;
|
||||
|
||||
if (doc_list[idx].mtime > t || st.st_mtime > t)
|
||||
@ -1836,7 +1836,7 @@ static void utils_recreate_recent_menu()
|
||||
|
||||
void utils_recent_file_loaded(const gchar *filename)
|
||||
{
|
||||
GList *item =
|
||||
GList *item =
|
||||
g_queue_find_custom(app->recent_queue, filename, (GCompareFunc) strcmp);
|
||||
gchar *data;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user