SF.net SVN: geany: [711] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun Aug 13 09:07:23 UTC 2006


Revision: 711
Author:   eht16
Date:     2006-08-13 02:07:10 -0700 (Sun, 13 Aug 2006)
ViewCVS:  http://svn.sourceforge.net/geany/?rev=711&view=rev

Log Message:
-----------
Use utf8/locale encoding wrappers.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/build.c
    trunk/src/callbacks.c
    trunk/src/dialogs.c
    trunk/src/keyfile.c
    trunk/src/search.c
    trunk/src/utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/ChangeLog	2006-08-13 09:07:10 UTC (rev 711)
@@ -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 at uvena.de>

Modified: trunk/src/build.c
===================================================================
--- trunk/src/build.c	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/src/build.c	2006-08-13 09:07:10 UTC (rev 711)
@@ -81,8 +81,7 @@
 	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 @@
 	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 @@
 
 	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 @@
 	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 @@
 	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 @@
 
 	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 @@
 	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

Modified: trunk/src/callbacks.c
===================================================================
--- trunk/src/callbacks.c	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/src/callbacks.c	2006-08-13 09:07:10 UTC (rev 711)
@@ -847,8 +847,7 @@
 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 @@
 	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 @@
 		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,10 +2260,8 @@
 on_recent_file_activate                (GtkMenuItem     *menuitem,
                                         gpointer         user_data)
 {
-	gchar *locale_filename = g_locale_from_utf8((gchar*) user_data, -1, NULL, NULL, NULL);
+	gchar *locale_filename = utils_get_locale_from_utf8((gchar*) user_data);
 
-	if (locale_filename == NULL) locale_filename = g_strdup((gchar*) user_data);
-
 	document_open_file(-1, locale_filename, 0, FALSE, NULL, NULL);
 	utils_recent_file_loaded((gchar*) user_data);
 

Modified: trunk/src/dialogs.c
===================================================================
--- trunk/src/dialogs.c	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/src/dialogs.c	2006-08-13 09:07:10 UTC (rev 711)
@@ -125,8 +125,7 @@
 			{
 				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 @@
 	// 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 @@
 
 
 #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

Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/src/keyfile.c	2006-08-13 09:07:10 UTC (rev 711)
@@ -424,8 +424,7 @@
 			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))
 			{

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/src/search.c	2006-08-13 09:07:10 UTC (rev 711)
@@ -730,8 +730,7 @@
 						(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))
 			{

Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c	2006-08-13 08:45:59 UTC (rev 710)
+++ trunk/src/utils.c	2006-08-13 09:07:10 UTC (rev 711)
@@ -967,7 +967,7 @@
 
 	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 @@
 
 void utils_recent_file_loaded(const gchar *filename)
 {
-	GList *item = 
+	GList *item =
 		g_queue_find_custom(app->recent_queue, filename, (GCompareFunc) strcmp);
 	gchar *data;
 


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