SF.net SVN: geany: [569] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Jul 16 19:28:28 UTC 2006
Revision: 569
Author: eht16
Date: 2006-07-16 12:28:13 -0700 (Sun, 16 Jul 2006)
ViewCVS: http://svn.sourceforge.net/geany/?rev=569&view=rev
Log Message:
-----------
Added filename to an error message.
Removed function encodings_get_encodings().
Simplified locale detection and little speed up.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/document.c
trunk/src/encodings.c
trunk/src/encodings.h
trunk/src/utils.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2006-07-16 18:58:57 UTC (rev 568)
+++ trunk/ChangeLog 2006-07-16 19:28:13 UTC (rev 569)
@@ -3,6 +3,9 @@
* src/encodings.c:
Reordered encodings in the file menu, divided into subregions.
* geany.glade, src/interface.c: Added missing mnemonics to file menu.
+ * src/document.c: Added filename to an error message.
+ * src/encodings.c: Removed function encodings_get_encodings().
+ * src/utils.c: Simplified locale detection and little speed up.
2006-07-16 Nick Treleaven <nick.treleaven at btinternet.com>
Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c 2006-07-16 18:58:57 UTC (rev 568)
+++ trunk/src/document.c 2006-07-16 19:28:13 UTC (rev 569)
@@ -467,7 +467,9 @@
if (converted_text == NULL)
{
- msgwin_status_add(_("The file does not look like a text file or the file encoding is not supported."));
+ msgwin_status_add(
+ _("The file \"%s\" does not look like a text file or the file encoding is not supported."),
+ utf8_filename);
utils_beep();
g_free(data);
g_free(utf8_filename);
Modified: trunk/src/encodings.c
===================================================================
--- trunk/src/encodings.c 2006-07-16 18:58:57 UTC (rev 568)
+++ trunk/src/encodings.c 2006-07-16 19:28:13 UTC (rev 569)
@@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
+ * $Id$
*/
@@ -193,22 +194,6 @@
}
-/* Encodings */
-GList *encodings_get_encodings(void)
-{
- GList *res = NULL;
- gint i;
-
- for (i = 0; i < GEANY_ENCODINGS_MAX; i++)
- {
- if (&encodings[i] != NULL)
- res = g_list_append(res, (gpointer)&encodings[i]);
- }
-
- return res;
-}
-
-
void encodings_init(void)
{
GtkWidget *item, *menu, *submenu, *menu_westeuro, *menu_easteuro, *menu_eastasian, *menu_asian,
Modified: trunk/src/encodings.h
===================================================================
--- trunk/src/encodings.h 2006-07-16 18:58:57 UTC (rev 568)
+++ trunk/src/encodings.h 2006-07-16 19:28:13 UTC (rev 569)
@@ -62,8 +62,6 @@
gchar* encodings_to_string(const GeanyEncoding* enc);
const gchar* encodings_get_charset(const GeanyEncoding* enc);
-GList* encodings_get_encodings(void);
-
void encodings_init(void);
Modified: trunk/src/utils.c
===================================================================
--- trunk/src/utils.c 2006-07-16 18:58:57 UTC (rev 568)
+++ trunk/src/utils.c 2006-07-16 19:28:13 UTC (rev 569)
@@ -830,7 +830,6 @@
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(charset != NULL, NULL);
- geany_debug("Trying to convert from %s to UTF-8", charset);
converted_contents = g_convert(buffer, size, "UTF-8", charset, NULL,
&bytes_written, &conv_error);
@@ -860,39 +859,26 @@
gchar *utils_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_encoding)
{
- GList *encodings = NULL;
- GList *start;
gchar *locale_charset = NULL;
+ gchar *utf8_content;
+ gchar *charset;
+ gboolean check_current = FALSE;
+ guint i;
- encodings = encodings_get_encodings();
-
if (g_get_charset((const gchar**)&locale_charset) == FALSE)
- {
- const GeanyEncoding *locale_encoding;
+ check_current = TRUE; // current locale is not UTF-8, we have to check this charset
- // not using an UTF-8 locale, so try converting from that first
- if (locale_charset != NULL)
+ for (i = 0; i < GEANY_ENCODINGS_MAX; i++)
+ {
+ if (check_current)
{
- locale_encoding = encodings_get_from_charset(locale_charset);
-
- encodings = g_list_prepend(encodings,
- (gpointer) locale_encoding);
- geany_debug("Current charset = %s", locale_charset);
+ charset = locale_charset;
+ i = -1;
}
- }
+ else
+ charset = encodings[i].charset;
- start = encodings;
-
- while (encodings != NULL)
- {
- GeanyEncoding *enc;
- const gchar *charset;
- gchar *utf8_content;
-
- enc = (GeanyEncoding*)encodings->data;
-
- charset = encodings_get_charset(enc);
- geany_debug("Trying to convert %d bytes of data into UTF-8.", size);
+ geany_debug("Trying to convert %d bytes of data from %s into UTF-8.", size, charset);
utf8_content = utils_convert_to_utf8_from_charset(buffer, size, charset);
if (utf8_content != NULL)
@@ -908,11 +894,8 @@
}
return utf8_content;
}
- encodings = encodings->next;
}
- g_list_free(start);
-
return NULL;
}
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