diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2003-10-14 01:38:16 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2003-10-14 01:38:16 +0800 |
commit | 442741fc4fb9b63c78c37f305d443f8aa57ff67e (patch) | |
tree | 834a2350618ff9378d1aaea422e1db9e0e9a304b /src/prefs-dialog.c | |
parent | ab827f639671b79f2b802b19f86e937a92612ad7 (diff) | |
download | gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.gz gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.bz2 gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.lz gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.xz gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.tar.zst gsoc2013-epiphany-442741fc4fb9b63c78c37f305d443f8aa57ff67e.zip |
Encodings menu improvements, part 3: Refactored the encodings list; it no
2003-10-13 Christian Persch <chpe@cvs.gnome.org>
* embed/ephy-embed-single.c: (ephy_embed_single_free_passwords):
* embed/ephy-embed-single.h:
* embed/ephy-embed-utils.c:
(ephy_embed_utils_build_encodings_submenu):
* embed/mozilla/mozilla-embed-single.cpp:
* embed/mozilla/mozilla-notifiers.cpp:
* lib/Makefile.am:
* lib/ephy-encodings.c: (ephy_encoding_info_free),
(encodings_info_cmp), (ephy_encodings_get_list):
* lib/ephy-encodings.h:
* lib/ephy-langs.c: (ephy_lang_group_info_free),
(lang_group_info_cmp), (ephy_lang_get_group_list),
(fonts_language_info_cmp), (ephy_font_langs_get_codes_list),
(ephy_font_langs_get_list):
* lib/ephy-langs.h:
* po/POTFILES.in:
* src/ephy-encoding-menu.c: (ephy_encoding_menu_set_window),
(ephy_encoding_menu_rebuild):
* src/prefs-dialog.c: (prefs_dialog_finalize),
(get_current_language_code), (create_fonts_language_menu),
(default_encoding_menu_changed_cb), (find_encoding_in_list_cmp),
(create_default_encoding_menu):
Encodings menu improvements, part 3: Refactored the encodings
list; it no longer is neccessary to have it in the embed single.
Ported all callers to new infrastructure.
Diffstat (limited to 'src/prefs-dialog.c')
-rw-r--r-- | src/prefs-dialog.c | 52 |
1 files changed, 12 insertions, 40 deletions
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c index 0ab2bdbe5..1b0999956 100644 --- a/src/prefs-dialog.c +++ b/src/prefs-dialog.c @@ -32,6 +32,7 @@ #include "eel-gconf-extensions.h" #include "language-editor.h" #include "ephy-langs.h" +#include "ephy-encodings.h" #include <bonobo/bonobo-i18n.h> #include <gtk/gtkframe.h> @@ -382,7 +383,7 @@ prefs_dialog_finalize (GObject *object) g_list_foreach (pd->priv->langs, (GFunc) free_lang_item, NULL); g_list_free (pd->priv->langs); - g_list_foreach (pd->priv->encodings, (GFunc) encoding_info_free, NULL); + g_list_foreach (pd->priv->encodings, (GFunc) ephy_encoding_info_free, NULL); g_list_free (pd->priv->encodings); g_list_foreach (pd->priv->autodetectors, (GFunc) g_free, NULL); @@ -418,7 +419,7 @@ static const gchar * get_current_language_code (PrefsDialog *dialog) { GList *lang; - FontsLanguageInfo *info; + const FontsLanguageInfo *info; lang = g_list_nth (dialog->priv->fonts_languages, dialog->priv->language); g_assert (lang != NULL); @@ -629,12 +630,6 @@ setup_size_controls (PrefsDialog *dialog) setup_size_control (dialog, CONF_RENDERING_FONT_MIN_SIZE, 7, 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) { @@ -658,33 +653,16 @@ create_fonts_language_menu (PrefsDialog *dialog) { GtkWidget *optionmenu, *menu; GList *l = NULL; - guint i; - guint n_fonts_languages; - const FontsLanguageInfo *fonts_language; + guint n_fonts_languages, i = 0; char **lang_codes; - n_fonts_languages = ephy_langs_get_n_font_languages (); - fonts_language = ephy_langs_get_font_languages (); - - 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 (); + dialog->priv->fonts_languages = ephy_font_langs_get_list (); + n_fonts_languages = g_list_length (dialog->priv->fonts_languages); for (l = dialog->priv->fonts_languages; l != NULL; l = l->next) { FontsLanguageInfo *info = (FontsLanguageInfo *) l->data; @@ -698,7 +676,6 @@ create_fonts_language_menu (PrefsDialog *dialog) gtk_option_menu_set_menu (GTK_OPTION_MENU(optionmenu), menu); lang_codes = g_new0 (char *, n_fonts_languages); - i = 0; for (l = dialog->priv->fonts_languages; l != NULL; l = l->next) { FontsLanguageInfo *info = (FontsLanguageInfo *) l->data; @@ -709,6 +686,7 @@ create_fonts_language_menu (PrefsDialog *dialog) } ephy_dialog_add_enum (EPHY_DIALOG (dialog), FONTS_LANGUAGE_PROP, n_fonts_languages, (const char **) lang_codes); + /* the entries themselves are const, so don't use g_strfreev here */ g_free (lang_codes); dialog->priv->language = @@ -725,18 +703,18 @@ default_encoding_menu_changed_cb (GtkOptionMenu *option_menu, { GList *encoding; gint i; - EncodingInfo *info; + const EphyEncodingInfo *info; i = gtk_option_menu_get_history (option_menu); encoding = g_list_nth (dialog->priv->encodings, i); g_assert (encoding != NULL); - info = (EncodingInfo *) encoding->data; + info = (EphyEncodingInfo *) encoding->data; eel_gconf_set_string (CONF_LANGUAGE_DEFAULT_ENCODING, info->encoding); } static gint -find_encoding_in_list_cmp (const EncodingInfo *info, const gchar *encoding) +find_encoding_in_list_cmp (const EphyEncodingInfo *info, const char *encoding) { return strcmp (info->encoding, encoding); } @@ -747,22 +725,16 @@ create_default_encoding_menu (PrefsDialog *dialog) GList *l; GtkWidget *menu, *optionmenu; gchar *encoding; - EphyEmbedSingle *single; - - single = ephy_embed_shell_get_embed_single - (EPHY_EMBED_SHELL (ephy_shell)); - - ephy_embed_single_get_encodings (single, LG_ALL, TRUE, - &dialog->priv->encodings); menu = gtk_menu_new (); optionmenu = ephy_dialog_get_control (EPHY_DIALOG (dialog), DEFAULT_ENCODING_PROP); + dialog->priv->encodings = ephy_encodings_get_list (LG_ALL, TRUE); for (l = dialog->priv->encodings; l != NULL; l = l->next) { - EncodingInfo *info = (EncodingInfo *) l->data; + const EphyEncodingInfo *info = (EphyEncodingInfo *) l->data; GtkWidget *item; item = gtk_menu_item_new_with_label (info->title); |