aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2003-10-14 01:38:16 +0800
committerChristian Persch <chpe@src.gnome.org>2003-10-14 01:38:16 +0800
commit442741fc4fb9b63c78c37f305d443f8aa57ff67e (patch)
tree834a2350618ff9378d1aaea422e1db9e0e9a304b /src
parentab827f639671b79f2b802b19f86e937a92612ad7 (diff)
downloadgsoc2013-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')
-rw-r--r--src/ephy-encoding-menu.c42
-rw-r--r--src/prefs-dialog.c52
2 files changed, 28 insertions, 66 deletions
diff --git a/src/ephy-encoding-menu.c b/src/ephy-encoding-menu.c
index 2f3596c23..0773a9fc5 100644
--- a/src/ephy-encoding-menu.c
+++ b/src/ephy-encoding-menu.c
@@ -25,8 +25,9 @@
#endif
#include "ephy-encoding-menu.h"
+#include "ephy-langs.h"
+#include "ephy-encodings.h"
#include "ephy-string.h"
-#include "ephy-shell.h"
#include "ephy-debug.h"
#include <bonobo/bonobo-i18n.h>
@@ -174,7 +175,6 @@ update_encoding_menu_cb (GtkAction *dummy, EphyEncodingMenu *menu)
static void
ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
{
- EphyEmbedSingle *single;
GtkActionGroup *action_group;
GtkAction *action;
GList *encodings, *groups, *l;
@@ -188,14 +188,10 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
action_group = gtk_action_group_new ("EncodingActions");
menu->priv->action_group = action_group;
- single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell));
- g_return_if_fail (single != NULL);
-
- ephy_embed_single_get_encodings (single, LG_ALL, FALSE, &encodings);
-
+ encodings = ephy_encodings_get_list (LG_ALL, FALSE);
for (l = encodings; l != NULL; l = l->next)
{
- const EncodingInfo *info = (EncodingInfo *) l->data;
+ const EphyEncodingInfo *info = (EphyEncodingInfo *) l->data;
char name[32];
g_snprintf (name, 32, "Encoding%s", info->encoding);
@@ -215,14 +211,13 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
g_object_unref (action);
}
- g_list_foreach (encodings, (GFunc) encoding_info_free, NULL);
+ g_list_foreach (encodings, (GFunc) ephy_encoding_info_free, NULL);
g_list_free (encodings);
- ephy_embed_single_get_language_groups (single, &groups);
-
+ groups = ephy_lang_get_group_list ();
for (l = groups; l != NULL; l = l->next)
{
- const LanguageGroupInfo *info = (LanguageGroupInfo *) l->data;
+ const EphyLanguageGroupInfo *info = (EphyLanguageGroupInfo *) l->data;
char name[32];
g_snprintf (name, 32, "EncodingGroup%d", info->group);
@@ -235,7 +230,7 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
g_object_unref (action);
}
- g_list_foreach (groups, (GFunc) language_group_info_free, NULL);
+ g_list_foreach (groups, (GFunc) ephy_lang_group_info_free, NULL);
g_list_free (groups);
gtk_ui_manager_insert_action_group (menu->priv->manager,
@@ -319,12 +314,8 @@ ephy_encoding_menu_new (EphyWindow *window)
static void
ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
{
- EphyEmbedSingle *single;
EphyEncodingMenuPrivate *p = menu->priv;
- GList *encodings, *groups, *l;
-
- single = ephy_embed_shell_get_embed_single (EPHY_EMBED_SHELL (ephy_shell));
- ephy_embed_single_get_language_groups (single, &groups);
+ GList *groups, *l;
if (p->merge_id > 0)
{
@@ -338,11 +329,12 @@ ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
"ViewEncodingMenu", "ViewEncoding",
GTK_UI_MANAGER_MENU, FALSE);
+ groups = ephy_lang_get_group_list ();
for (l = groups; l != NULL; l = l->next)
{
- const LanguageGroupInfo *info = (LanguageGroupInfo *) l->data;
+ const EphyLanguageGroupInfo *info = (EphyLanguageGroupInfo *) l->data;
char name[32], action[36], path[128];
- GList *enc;
+ GList *encodings, *enc;
g_snprintf (action, 32, "EncodingGroup%d", info->group);
g_snprintf (name, 36, "%sMenu", action);
@@ -353,12 +345,10 @@ ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
name, action,
GTK_UI_MANAGER_MENU, FALSE);
- ephy_embed_single_get_encodings (single, info->group,
- FALSE, &encodings);
-
+ encodings = ephy_encodings_get_list (info->group, FALSE);
for (enc = encodings; enc != NULL; enc = enc->next)
{
- const EncodingInfo *info = (EncodingInfo *) enc->data;
+ const EphyEncodingInfo *info = (EphyEncodingInfo *) enc->data;
g_snprintf (action, 32, "Encoding%s", info->encoding);
g_snprintf (name, 36, "%sItem", action);
@@ -368,10 +358,10 @@ ephy_encoding_menu_rebuild (EphyEncodingMenu *menu)
GTK_UI_MANAGER_MENUITEM, FALSE);
}
- g_list_foreach (encodings, (GFunc) encoding_info_free, NULL);
+ g_list_foreach (encodings, (GFunc) ephy_encoding_info_free, NULL);
g_list_free (encodings);
}
- g_list_foreach (groups, (GFunc) language_group_info_free, NULL);
+ g_list_foreach (groups, (GFunc) ephy_lang_group_info_free, NULL);
g_list_free (groups);
}
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);