aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-12-19 01:43:42 +0800
committerChristian Persch <chpe@src.gnome.org>2003-12-19 01:43:42 +0800
commit761ce65b7b47e7bc17cdbcf118cbb345c7b635e3 (patch)
treec018c3fef8d1a36e97c9bb25c5c29431be54b82a /embed
parentaba053264da43f60b0628077e79cd52e3d78394a (diff)
downloadgsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.tar
gsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.tar.gz
gsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.tar.bz2
gsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.tar.lz
gsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.tar.xz
gsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.tar.zst
gsoc2013-epiphany-761ce65b7b47e7bc17cdbcf118cbb345c7b635e3.zip
In-line the language editor in the prefs dialogue.
2003-12-18 Christian Persch <chpe@cvs.gnome.org> * data/glade/prefs-dialog.glade: * embed/mozilla/mozilla-notifiers.cpp: * src/Makefile.am: * src/language-editor.c: * src/language-editor.h: * src/prefs-dialog.c: (prefs_dialog_finalize), (prefs_dialog_class_init), (language_editor_add), (language_editor_update_pref), (language_editor_update_buttons), (add_lang_dialog_response_cb), (setup_add_language_dialog), (language_editor_add_button_clicked_cb), (language_editor_remove_button_clicked_cb), (language_editor_up_button_clicked_cb), (language_editor_down_button_clicked_cb), (language_editor_treeview_drag_end_cb), (language_editor_selection_changed_cb), (create_language_section), (prefs_dialog_init): In-line the language editor in the prefs dialogue.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp62
1 files changed, 43 insertions, 19 deletions
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index 105700302..b742a3bfe 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2000 Nate Case
- * Copyright (C) 2003 Marco Pesenti Gritti
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,8 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
*/
#ifdef HAVE_CONFIG_H
@@ -745,12 +742,14 @@ get_system_language ()
char *lang = (char *)sys_langs->data;
/* FIXME this probably need to be smarter */
+ /* FIXME this can be up to 8 chars, not just 2 */
if (strcmp (lang, "C") != 0)
{
return g_strndup (lang, 2);
}
}
+ /* fallback to english */
return g_strdup ("en");
}
@@ -760,43 +759,68 @@ mozilla_language_notifier(GConfClient *client,
GConfEntry *entry,
EphyEmbedSingle *single)
{
- GSList *languages, *l;
+ GSList *languages, *l, *ulist = NULL;
GString *result;
languages = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
- if (languages == NULL) return;
result = g_string_new ("");
- for (l = languages; l != NULL; l = l->next)
+ /* substitute the system language */
+ l = g_slist_find_custom (languages, "system", (GCompareFunc) strcmp);
+ if (l != NULL)
{
- char *lang = (char *)l->data;
+ char *sys_lang;
+ int index;
+
+ index = g_slist_position (languages, l);
+ g_free (l->data);
+ languages = g_slist_delete_link (languages, l);
- if (strcmp (lang, "system") == 0)
+ sys_lang = get_system_language ();
+
+ if (sys_lang)
{
- char *sys_lang;
-
- sys_lang = get_system_language ();
- if (sys_lang)
+ char **s;
+ int i = 0;
+
+ s = g_strsplit (sys_lang, ",", -1);
+ while (s[i] != NULL)
{
- g_string_append (result, sys_lang);
- g_free (sys_lang);
+ languages = g_slist_insert (languages, g_strdup (s[i]), index);
+
+ index ++;
+ i++;
}
- }
- else
+
+ g_strfreev (s);
+ }
+ }
+
+ /* now make a list of unique entries */
+ for (l = languages; l != NULL; l = l->next)
+ {
+ if (g_slist_find_custom (ulist, l->data, (GCompareFunc) strcmp) == NULL)
{
- g_string_append (result, (char *)l->data);
+ ulist = g_slist_prepend (ulist, l->data);
}
+ }
+ ulist = g_slist_reverse (ulist);
+
+ for (l = ulist; l != NULL; l = l->next)
+ {
+ g_string_append (result, (char *)l->data);
if (l->next) g_string_append (result, ",");
}
-
+
mozilla_prefs_set_string ("intl.accept_languages", result->str);
g_string_free (result, TRUE);
-
+
g_slist_foreach (languages, (GFunc) g_free, NULL);
g_slist_free (languages);
+ g_slist_free (ulist);
}
static void