aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog24
-rw-r--r--data/epiphany.schemas.in15
-rw-r--r--data/glade/prefs-dialog.glade192
-rw-r--r--embed/mozilla/mozilla-notifiers.cpp61
-rw-r--r--lib/ephy-langs.h39
-rw-r--r--src/prefs-dialog.c228
6 files changed, 299 insertions, 260 deletions
diff --git a/ChangeLog b/ChangeLog
index e7567d77a..9844c1bbb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2003-05-29 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/ephy-langs.h:
+ * data/glade/prefs-dialog.glade:
+ * src/prefs-dialog.c: (autodetector_info_free), (prefs_dialog_finalize),
+ (get_current_language_code), (setup_font_menu), (setup_size_control),
+ (fonts_language_info_cmp), (create_fonts_language_menu),
+ (autodetect_encoding_menu_changed_cb), (autodetector_info_cmp),
+ (find_autodetector_info), (create_encoding_autodetectors_menu),
+ (prefs_dialog_init):
+
+ Sort the lists of encoding autodetectors and of fonts languages.
+
+ * data/epiphany.schemas.in:
+
+ Document the possible values for the encoding autodetectors.
+
+ * embed/mozilla/mozilla-notifiers.cpp: (mozilla_notifiers_init),
+ (mozilla_default_encoding_notifier),
+ (mozilla_autodetect_encoding_notifier):
+
+ Adapted for the changes in the prefs dialog.
+ The default encoding notifier now propagates the setting to mozilla :)
+
2003-05-28 Christian Persch <chpe@cvs.gnome.org>
The "s/charset/encoding/" mega patch :)
diff --git a/data/epiphany.schemas.in b/data/epiphany.schemas.in
index a50684d32..efceb1dc5 100644
--- a/data/epiphany.schemas.in
+++ b/data/epiphany.schemas.in
@@ -417,9 +417,20 @@
<key>/schemas/apps/epiphany/rendering/autodetect_encoding</key>
<applyto>/apps/epiphany/rendering/autodetect_encoding</applyto>
<owner>epiphany</owner>
- <type>int</type>
- <default>0</default>
+ <type>string</type>
+ <default></default>
<locale name="C">
+ <short>The charset autodetector. Empty string means autodetect is off</short>
+ <long>
+ The charset autodetector. Valid entries are <empty string> (autodetectors
+ off), cjk_parallel_state_machine (autodetect east asian encodings),
+ ja_parallel_state_machine (autodetect japanese encodings),
+ ko_parallel_state_machine (autodetect korean encodings), ruprob
+ (autodetect russian encodings), ukprob (autodetect ukrainian encodings),
+ zh_parallel_state_machine (autodetect chinese encodings),
+ zhcn_parallel_state_machine (autodetect simplified chinese encodings) and
+ zhtw_parallel_state_machine (autodetect traditional chinese encodings).
+ </long>
</locale>
</schema>
<schema>
diff --git a/data/glade/prefs-dialog.glade b/data/glade/prefs-dialog.glade
index c4bd6a2e9..69a6cab64 100644
--- a/data/glade/prefs-dialog.glade
+++ b/data/glade/prefs-dialog.glade
@@ -710,7 +710,6 @@
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
- <property name="mnemonic_widget">optionmenu2</property>
</widget>
<packing>
<property name="left_attach">0</property>
@@ -723,127 +722,14 @@
</child>
<child>
- <widget class="GtkOptionMenu" id="optionmenu2">
+ <widget class="GtkOptionMenu" id="fonts_language_optionmenu">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="history">0</property>
- <signal name="changed" handler="fonts_language_optionmenu_changed_cb" last_modification_time="Fri, 17 May 2002 10:44:00 GMT"/>
+ <property name="history">-1</property>
<child internal-child="menu">
<widget class="GtkMenu" id="menu2">
<property name="visible">True</property>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem18">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Western</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem19">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Central European</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem20">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Japanese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem21">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Traditional Chinese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem22">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Simplified Chinese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem23">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Korean</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem24">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Cyrillic</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem25">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Baltic</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem26">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Greek</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem27">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Turkish</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem28">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Unicode</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem29">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Thai</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem30">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Hebrew</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem31">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Arabic</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
</widget>
</child>
</widget>
@@ -2137,83 +2023,11 @@
<widget class="GtkOptionMenu" id="auto_encoding_optionmenu">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="history">0</property>
+ <property name="history">-1</property>
<child internal-child="menu">
<widget class="GtkMenu" id="menu6">
<property name="visible">True</property>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem39">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Off</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem40">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Chinese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem41">
- <property name="visible">True</property>
- <property name="label" translatable="yes">East asian</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem42">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Japanese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem43">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Korean</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem44">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Russian</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem45">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Simplified Chinese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem46">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Traditional Chinese</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
-
- <child>
- <widget class="GtkMenuItem" id="menuitem47">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Ukrainian</property>
- <property name="use_underline">True</property>
- </widget>
- </child>
</widget>
</child>
</widget>
diff --git a/embed/mozilla/mozilla-notifiers.cpp b/embed/mozilla/mozilla-notifiers.cpp
index de02d9a38..a84bacc75 100644
--- a/embed/mozilla/mozilla-notifiers.cpp
+++ b/embed/mozilla/mozilla-notifiers.cpp
@@ -387,7 +387,7 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
}
/* fonts notifiers */
- for (i = 0; i < n_lang_encode_items; i++)
+ for (i = 0; i < n_fonts_languages; i++)
{
guint k;
char *types [] = { "serif", "sans-serif", "cursive", "fantasy", "monospace" };
@@ -396,33 +396,33 @@ mozilla_notifiers_init(EphyEmbedSingle *single)
for (k = 0; k < G_N_ELEMENTS (types); k++)
{
- info = g_strconcat (types[k], ".", lang_encode_item[i], NULL);
+ info = g_strconcat (types[k], ".", fonts_language[i].code, NULL);
- sprintf (key, "%s_%s_%s", CONF_RENDERING_FONT,
+ snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT,
types[k],
- lang_encode_item[i]);
+ fonts_language[i].code);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_notifier,
info);
font_infos = g_list_append (font_infos, info);
}
- sprintf (key, "%s_%s", CONF_RENDERING_FONT_MIN_SIZE, lang_encode_item[i]);
- info = g_strconcat ("minimum-size", ".", lang_encode_item[i], NULL);
+ snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_MIN_SIZE, fonts_language[i].code);
+ info = g_strconcat ("minimum-size", ".", fonts_language[i].code, NULL);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_size_notifier,
info);
font_infos = g_list_append (font_infos, info);
- sprintf (key, "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, lang_encode_item[i]);
- info = g_strconcat ("size.fixed", ".", lang_encode_item[i], NULL);
+ snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_FIXED_SIZE, fonts_language[i].code);
+ info = g_strconcat ("size.fixed", ".", fonts_language[i].code, NULL);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_size_notifier,
info);
font_infos = g_list_append (font_infos, info);
- sprintf (key, "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, lang_encode_item[i]);
- info = g_strconcat ("size.variable", ".", lang_encode_item[i], NULL);
+ snprintf (key, 255, "%s_%s", CONF_RENDERING_FONT_VAR_SIZE, fonts_language[i].code);
+ info = g_strconcat ("size.variable", ".", fonts_language[i].code, NULL);
add_notification_and_notify (client, key,
(GConfClientNotifyFunc)mozilla_font_size_notifier,
info);
@@ -532,7 +532,14 @@ mozilla_default_encoding_notifier(GConfClient *client,
GConfEntry *entry,
EphyEmbedSingle *single)
{
- /* FIXME */
+ gchar *encoding;
+
+ encoding = eel_gconf_get_string (CONF_LANGUAGE_DEFAULT_ENCODING);
+ if (encoding == NULL) encoding = g_strdup ("ISO-8859-1");
+
+ mozilla_prefs_set_string ("intl.charset.default", encoding);
+
+ g_free (encoding);
}
@@ -633,36 +640,20 @@ mozilla_language_notifier(GConfClient *client,
g_slist_free (languages);
}
-static char *autodetect_encoding_prefs[] =
-{
- "",
- "zh_parallel_state_machine",
- "cjk_parallel_state_machine",
- "ja_parallel_state_machine",
- "ko_parallel_state_machine",
- "ruprob",
- "zhcn_parallel_state_machine",
- "zhtw_parallel_state_machine",
- "ukprob"
-};
-
static void
mozilla_autodetect_encoding_notifier(GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
EphyEmbedSingle *single)
{
- int encoding = eel_gconf_get_integer (CONF_LANGUAGE_AUTODETECT_ENCODING);
- if (encoding < 0 ||
- encoding >= (int)(sizeof(autodetect_encoding_prefs)
- / sizeof(autodetect_encoding_prefs[0])))
- {
- g_warning ("mozilla_autodetect_encoding_notifier: "
- "unsupported value: %d", encoding);
- return;
- }
- mozilla_prefs_set_string ("intl.charset.detector",
- autodetect_encoding_prefs[encoding]);
+ gchar *detector;
+
+ detector = eel_gconf_get_string (CONF_LANGUAGE_AUTODETECT_ENCODING);
+ if (detector == NULL) detector = g_strdup (""); // Off
+
+ mozilla_prefs_set_string ("intl.charset.detector", detector);
+
+ g_free (detector);
}
static void
diff --git a/lib/ephy-langs.h b/lib/ephy-langs.h
index 2d2c79dd2..dfe5ec2ee 100644
--- a/lib/ephy-langs.h
+++ b/lib/ephy-langs.h
@@ -24,6 +24,7 @@
#endif
#include <glib.h>
+#include <bonobo/bonobo-i18n.h>
G_BEGIN_DECLS
@@ -64,24 +65,30 @@ typedef struct
} EncodingInfo;
/* language encoding groups */
-static const gchar *lang_encode_item[] =
+typedef struct
+{
+ gchar *title;
+ gchar* code;
+} FontsLanguageInfo;
+
+static const FontsLanguageInfo fonts_language[] =
{
- "x-western",
- "x-central-euro",
- "ja",
- "zh-TW",
- "zh-CN",
- "ko",
- "x-cyrillic",
- "x-baltic",
- "el",
- "tr",
- "x-unicode",
- "th",
- "he",
- "ar"
+ { N_("Arabic"), "ar" },
+ { N_("Baltic"), "x-baltic" },
+ { N_("Central European"), "x-central-euro" },
+ { N_("Cyrillic"), "x-cyrillic" },
+ { N_("Greek"), "el" },
+ { N_("Hebrew"), "he" },
+ { N_("Japanese"), "ja" },
+ { N_("Korean"), "ko" },
+ { N_("Simplified Chinese"), "zh-CN" },
+ { N_("Thai"), "th" },
+ { N_("Traditional Chinese"), "zh-TW" },
+ { N_("Turkish"), "tr" },
+ { N_("Unicode"), "x-unicode" },
+ { N_("Western"), "x-western" },
};
-static const guint n_lang_encode_items = G_N_ELEMENTS (lang_encode_item);
+static const guint n_fonts_languages = G_N_ELEMENTS (fonts_language);
void language_group_info_free (LanguageGroupInfo *info);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 1f4bf8485..53170f8f3 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -139,6 +139,26 @@ languages [] =
};
static guint n_languages = G_N_ELEMENTS (languages);
+typedef struct
+{
+ gchar *title;
+ gchar *name;
+} EncodingAutodetectorInfo;
+
+static EncodingAutodetectorInfo encoding_autodetector[] =
+{
+ { N_("Off"), "" },
+ { N_("Chinese"), "zh_parallel_state_machine" },
+ { N_("East asian"), "cjk_parallel_state_machine" },
+ { N_("Japanese"), "ja_parallel_state_machine" },
+ { N_("Korean"), "ko_parallel_state_machine" },
+ { N_("Russian"), "ruprob" },
+ { N_("Simplified Chinese"), "zhcn_parallel_state_machine" },
+ { N_("Traditional Chinese"), "zhtw_parallel_state_machine" },
+ { N_("Ukrainian"), "ukprob" }
+};
+static guint n_encoding_autodetectors = G_N_ELEMENTS (encoding_autodetector);
+
enum
{
FONT_TYPE_SERIF,
@@ -182,6 +202,7 @@ enum
LANGUAGE_PROP,
/* Appeareance */
+ FONTS_LANGUAGE_PROP,
SERIF_PROP,
SANSSERIF_PROP,
MONOSPACE_PROP,
@@ -213,11 +234,12 @@ EphyDialogProperty properties [] =
/* General */
{ OPEN_IN_TABS_PROP, "open_in_tabs_checkbutton", CONF_TABS_TABBED, PT_AUTOAPPLY, NULL },
{ HOMEPAGE_ENTRY_PROP, "homepage_entry", CONF_GENERAL_HOMEPAGE, PT_AUTOAPPLY, NULL },
- { AUTO_ENCODING_PROP, "auto_encoding_optionmenu", CONF_LANGUAGE_AUTODETECT_ENCODING, PT_AUTOAPPLY, NULL },
+ { AUTO_ENCODING_PROP, "auto_encoding_optionmenu", NULL, PT_NORMAL, NULL },
{ DEFAULT_ENCODING_PROP, "default_encoding_optionmenu", NULL, PT_NORMAL, NULL },
{ LANGUAGE_PROP, "language_optionmenu", NULL, PT_NORMAL, NULL },
/* Appeareance */
+ { FONTS_LANGUAGE_PROP, "fonts_language_optionmenu", NULL, PT_NORMAL, NULL },
{ SERIF_PROP, "serif_combo", NULL, PT_NORMAL, NULL },
{ SANSSERIF_PROP, "sansserif_combo", NULL, PT_NORMAL, NULL },
{ MONOSPACE_PROP, "monospace_combo", NULL, PT_NORMAL, NULL },
@@ -256,8 +278,10 @@ struct PrefsDialogPrivate
GList *langs;
GList *encodings;
+ GList *autodetectors;
+ GList *fonts_languages;
- int language;
+ guint language;
gboolean switching;
};
@@ -343,6 +367,12 @@ prefs_dialog_finalize (GObject *object)
g_list_foreach (pd->priv->encodings, (GFunc) encoding_info_free, NULL);
g_list_free (pd->priv->encodings);
+ g_list_foreach (pd->priv->autodetectors, (GFunc) g_free, NULL);
+ g_list_free (pd->priv->autodetectors);
+
+ g_list_foreach (pd->priv->fonts_languages, (GFunc) g_free, NULL);
+ g_list_free (pd->priv->fonts_languages);
+
g_free (pd->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -368,6 +398,19 @@ prefs_dialog_show_help (PrefsDialog *pd)
ephy_gui_help (GTK_WINDOW (pd), "epiphany", help_preferences[id]);
}
+static const gchar *
+get_current_language_code (PrefsDialog *dialog)
+{
+ GList *lang;
+ FontsLanguageInfo *info;
+
+ lang = g_list_nth (dialog->priv->fonts_languages, dialog->priv->language);
+ g_assert (lang != NULL);
+ info = (FontsLanguageInfo *) lang->data;
+
+ return info->code;
+}
+
static void
setup_font_menu (PrefsDialog *dialog,
const char *type,
@@ -375,7 +418,7 @@ setup_font_menu (PrefsDialog *dialog,
{
char *default_font;
GList *fonts;
- const char *name;
+ gchar *name;
char key[255];
int pos;
GtkWidget *entry = GTK_COMBO(combo)->entry;
@@ -385,16 +428,16 @@ setup_font_menu (PrefsDialog *dialog,
(EPHY_EMBED_SHELL (ephy_shell));
ephy_embed_single_get_font_list (single,
- lang_encode_item[dialog->priv->language],
+ get_current_language_code (dialog),
type, &fonts, &default_font);
/* Get the default font */
- sprintf (key, "%s_%s_%s", CONF_RENDERING_FONT, type,
- lang_encode_item[dialog->priv->language]);
+ snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT, type,
+ get_current_language_code (dialog));
name = eel_gconf_get_string (key);
if (name == NULL)
{
- name = default_font;
+ name = g_strdup (default_font);
}
/* set popdown doesnt like NULL */
@@ -415,6 +458,7 @@ setup_font_menu (PrefsDialog *dialog,
}
g_free (default_font);
+ g_free (name);
g_list_foreach (fonts, (GFunc)g_free, NULL);
g_list_free (fonts);
@@ -428,8 +472,7 @@ save_font_menu (PrefsDialog *dialog,
char *name;
char key[255];
- name = gtk_editable_get_chars
- (GTK_EDITABLE(entry), 0, -1);
+ name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1);
/* do not save empty fonts */
if (!name || *name == '\0')
@@ -438,9 +481,9 @@ save_font_menu (PrefsDialog *dialog,
return;
}
- sprintf (key, "%s_%s_%s", CONF_RENDERING_FONT,
- fonts_types[type],
- lang_encode_item[dialog->priv->language]);
+ snprintf (key, 255, "%s_%s_%s", CONF_RENDERING_FONT,
+ fonts_types[type],
+ get_current_language_code (dialog));
eel_gconf_set_string (key, name);
g_free (name);
}
@@ -494,9 +537,9 @@ size_spinbutton_changed_cb (GtkWidget *spin, PrefsDialog *dialog)
type = GPOINTER_TO_INT(g_object_get_data (G_OBJECT(spin), "type"));
- sprintf (key, "%s_%s",
- size_prefs[type],
- lang_encode_item[dialog->priv->language]);
+ snprintf (key, 255, "%s_%s",
+ size_prefs[type],
+ get_current_language_code (dialog));
eel_gconf_set_integer (key, gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin)));
}
@@ -539,8 +582,8 @@ setup_size_control (PrefsDialog *dialog,
char key[255];
int size;
- sprintf (key, "%s_%s", pref,
- lang_encode_item[dialog->priv->language]);
+ snprintf (key, 255, "%s_%s", pref,
+ get_current_language_code (dialog));
size = eel_gconf_get_integer (key);
if (size == 0) size = default_size;
@@ -566,6 +609,12 @@ setup_size_controls (PrefsDialog *dialog)
setup_size_control (dialog, CONF_RENDERING_FONT_MIN_SIZE, 0, spin);
}
+static gint
+fonts_language_info_cmp (const FontsLanguageInfo *i1, const FontsLanguageInfo *i2)
+{
+ return g_utf8_collate (i1->title, i2->title);
+}
+
static void
setup_fonts (PrefsDialog *dialog)
{
@@ -589,6 +638,52 @@ setup_fonts (PrefsDialog *dialog)
}
static void
+create_fonts_language_menu (PrefsDialog *dialog)
+{
+ GtkWidget *optionmenu, *menu;
+ GList *l = NULL;
+ guint i;
+
+ for (i = 0; i < n_fonts_languages; i++)
+ {
+ FontsLanguageInfo *info;
+
+ info = g_new0 (FontsLanguageInfo, 1);
+ info->title = _(fonts_language[i].title);
+ info->code = fonts_language[i].code;
+
+ l = g_list_prepend (l, info);
+ }
+
+ l = g_list_sort (l, (GCompareFunc) fonts_language_info_cmp);
+ dialog->priv->fonts_languages = l;
+
+ optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ FONTS_LANGUAGE_PROP);
+
+ menu = gtk_menu_new ();
+
+ for (l = dialog->priv->fonts_languages; l != NULL; l = l->next)
+ {
+ FontsLanguageInfo *info = (FontsLanguageInfo *) l->data;
+ GtkWidget *item;
+
+ item = gtk_menu_item_new_with_label (info->title);
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
+ gtk_widget_show (item);
+ }
+
+ gtk_option_menu_set_menu (GTK_OPTION_MENU(optionmenu), menu);
+
+ /* FIXME: find a way to set this to the user's current locale's lang */
+ gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu),
+ dialog->priv->language);
+ g_signal_connect (optionmenu, "changed",
+ G_CALLBACK (fonts_language_optionmenu_changed_cb),
+ dialog);
+}
+
+static void
default_encoding_menu_changed_cb (GtkOptionMenu *option_menu,
PrefsDialog *dialog)
{
@@ -657,6 +752,99 @@ create_default_encoding_menu (PrefsDialog *dialog)
dialog);
}
+static void
+autodetect_encoding_menu_changed_cb (GtkOptionMenu *option_menu, gpointer data)
+{
+ GList *l;
+ guint i;
+ EncodingAutodetectorInfo *info;
+
+ g_return_if_fail (IS_PREFS_DIALOG (data));
+
+ i = gtk_option_menu_get_history (option_menu);
+
+ l = g_list_nth (PREFS_DIALOG (data)->priv->autodetectors, i);
+
+ if (l)
+ {
+ info = (EncodingAutodetectorInfo *) l->data;
+
+ eel_gconf_set_string (CONF_LANGUAGE_AUTODETECT_ENCODING, info->name);
+ }
+}
+
+static gint
+autodetector_info_cmp (const EncodingAutodetectorInfo *i1, const EncodingAutodetectorInfo *i2)
+{
+ return g_utf8_collate (i1->title, i2->title);
+}
+
+static gint
+find_autodetector_info (const EncodingAutodetectorInfo *info, const gchar *name)
+{
+ return strcmp (info->name, name);
+}
+
+static void
+create_encoding_autodetectors_menu (PrefsDialog *dialog)
+{
+ GtkWidget *optionmenu, *menu, *item;
+ gint i, position = 0;
+ GList *l, *list = NULL;
+ gchar *detector = NULL;
+ EncodingAutodetectorInfo *info;
+
+ optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ AUTO_ENCODING_PROP);
+
+ for (i = 0; i < n_encoding_autodetectors; i++)
+ {
+ info = g_new0 (EncodingAutodetectorInfo, 1);
+
+ info->title = _(encoding_autodetector[i].title);
+ info->name = encoding_autodetector[i].name;
+
+ list = g_list_prepend (list, info);
+ }
+
+ list = g_list_sort (list, (GCompareFunc) autodetector_info_cmp);
+ dialog->priv->autodetectors = list;
+
+ menu = gtk_menu_new ();
+
+ for (l = list; l != NULL; l = l->next)
+ {
+ info = (EncodingAutodetectorInfo *) l->data;
+
+ item = gtk_menu_item_new_with_label (info->title);
+ gtk_menu_shell_append (GTK_MENU_SHELL(menu), item);
+ gtk_widget_show (item);
+ g_object_set_data (G_OBJECT (item), "desc", info->title);
+ }
+
+ gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
+
+ /* init value */
+ detector = eel_gconf_get_string (CONF_LANGUAGE_AUTODETECT_ENCODING);
+ if (detector == NULL) detector = g_strdup ("");
+
+ l = g_list_find_custom (list, detector,
+ (GCompareFunc) find_autodetector_info);
+
+ g_free (detector);
+
+ if (l)
+ {
+ position = g_list_position (list, l);
+ }
+
+ gtk_option_menu_set_history (GTK_OPTION_MENU(optionmenu), position);
+
+ g_signal_connect (optionmenu, "changed",
+ G_CALLBACK (autodetect_encoding_menu_changed_cb),
+ dialog);
+}
+
static gint
compare_lang_items (const EphyLangItem *i1, const EphyLangItem *i2)
{
@@ -849,6 +1037,8 @@ prefs_dialog_init (PrefsDialog *pd)
pd->priv->notebook = ephy_dialog_get_control (dialog, NOTEBOOK_PROP);
pd->priv->langs = NULL;
pd->priv->encodings = NULL;
+ pd->priv->autodetectors = NULL;
+ pd->priv->fonts_languages = NULL;
icon = gtk_widget_render_icon (pd->priv->window,
GTK_STOCK_PREFERENCES,
@@ -858,12 +1048,14 @@ prefs_dialog_init (PrefsDialog *pd)
g_object_unref(icon);
pd->priv->switching = FALSE;
+ create_fonts_language_menu (pd);
setup_fonts (pd);
setup_size_controls (pd);
attach_fonts_signals (pd);
attach_size_controls_signals (pd);
create_languages_list (pd);
create_default_encoding_menu (pd);
+ create_encoding_autodetectors_menu (pd);
create_language_menu (pd);
}
@@ -911,7 +1103,7 @@ void
fonts_language_optionmenu_changed_cb (GtkWidget *optionmenu,
EphyDialog *dialog)
{
- int i;
+ guint i;
PrefsDialog *pd = PREFS_DIALOG (dialog);
i = gtk_option_menu_get_history