Kaydet (Commit) f481b55f authored tarafından Enrico Tröger's avatar Enrico Tröger

Added filename to an error message.

Removed function encodings_get_encodings().
Simplified locale detection and little speed up.


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@569 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 8e2430ac
......@@ -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@btinternet.com>
......
......@@ -467,7 +467,9 @@ int document_open_file(gint idx, const gchar *filename, gint pos, gboolean reado
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);
......
......@@ -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 @@ const gchar *encodings_get_charset(const GeanyEncoding* enc)
}
/* 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,
......
......@@ -62,8 +62,6 @@ const GeanyEncoding* encodings_get_from_index(gint index);
gchar* encodings_to_string(const GeanyEncoding* enc);
const gchar* encodings_get_charset(const GeanyEncoding* enc);
GList* encodings_get_encodings(void);
void encodings_init(void);
......
......@@ -830,7 +830,6 @@ gchar *utils_convert_to_utf8_from_charset(const gchar *buffer, gsize size, const
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_from_charset(const gchar *buffer, gsize size, const
gchar *utils_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_encoding)
{
GList *encodings = NULL;
GList *start;
gchar *locale_charset = NULL;
encodings = encodings_get_encodings();
gchar *utf8_content;
gchar *charset;
gboolean check_current = FALSE;
guint i;
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;
}
}
start = encodings;
while (encodings != NULL)
{
GeanyEncoding *enc;
const gchar *charset;
gchar *utf8_content;
enc = (GeanyEncoding*)encodings->data;
else
charset = encodings[i].charset;
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 @@ gchar *utils_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_encod
}
return utf8_content;
}
encodings = encodings->next;
}
g_list_free(start);
return NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment