aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-encoding-menu.c
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-01-06 22:36:23 +0800
committerChristian Persch <chpe@src.gnome.org>2004-01-06 22:36:23 +0800
commitfe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee (patch)
treef6381d82b2f5f2736ecba8e5c0e8c4d8757b0c01 /src/ephy-encoding-menu.c
parent1158a826cc4f3b9d71745bff312f25e0122ec445 (diff)
downloadgsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.tar
gsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.tar.gz
gsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.tar.bz2
gsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.tar.lz
gsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.tar.xz
gsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.tar.zst
gsoc2013-epiphany-fe2f4ed250c08dc3a4f7b2816fcf6894f446f1ee.zip
Behave better when the encoding used on the page is unknown to us.
2004-01-06 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-encodings.c: (add_encoding), (ephy_encodings_get_node), (ephy_encodings_add_recent), (ephy_encodings_get_recent), (ephy_encodings_init): * embed/ephy-encodings.h: * src/ephy-encoding-dialog.c: (sync_embed_cb): * src/ephy-encoding-menu.c: (update_encoding_menu_cb), (add_action), (ephy_encoding_menu_set_window): * src/prefs-dialog.c: (create_node_combo): Behave better when the encoding used on the page is unknown to us. Previously we skipped important steps in menu building, resulting in incorrect encoding indicator. Now, we dynamically add an entry with name "Unknown" to our menu. Also add back some rarely used encodings (us-ascii, UTF-16*, UTF-32*) to our known encodings repertoire.
Diffstat (limited to 'src/ephy-encoding-menu.c')
-rw-r--r--src/ephy-encoding-menu.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/src/ephy-encoding-menu.c b/src/ephy-encoding-menu.c
index ee42f692d..11c4d44aa 100644
--- a/src/ephy-encoding-menu.c
+++ b/src/ephy-encoding-menu.c
@@ -183,11 +183,8 @@ update_encoding_menu_cb (GtkAction *dummy, EphyEncodingMenu *menu)
encoding = info->encoding;
- enc_node = ephy_encodings_get_node (p->encodings, encoding);
- if (!EPHY_IS_NODE (enc_node))
- {
- goto build_menu;
- }
+ enc_node = ephy_encodings_get_node (p->encodings, encoding, TRUE);
+ g_assert (EPHY_IS_NODE (enc_node));
/* set the encodings group's active member */
g_snprintf (name, sizeof (name), "Encoding%s", encoding);
@@ -207,7 +204,7 @@ update_encoding_menu_cb (GtkAction *dummy, EphyEncodingMenu *menu)
if (g_list_find (related, enc_node) == NULL
&& g_list_find (recent, enc_node) == NULL)
{
- recent = g_list_prepend (recent, enc_node);
+ related = g_list_prepend (related, enc_node);
}
/* make sure related and recent are disjoint so we don't display twice */
@@ -227,7 +224,6 @@ build_menu:
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), is_automatic);
g_object_set (G_OBJECT (action), "sensitive", !is_automatic, NULL);
-
/* clear the menu */
if (p->merge_id > 0)
{
@@ -313,7 +309,7 @@ encoding_activate_cb (GtkAction *action, EphyEncodingMenu *menu)
}
static void
-add_action (EphyNode *node, EphyEncodingMenu *menu)
+add_action (EphyNode *encodings, EphyNode *node, EphyEncodingMenu *menu)
{
GtkAction *action;
char name[128];
@@ -324,6 +320,8 @@ add_action (EphyNode *node, EphyEncodingMenu *menu)
title = ephy_node_get_property_string
(node, EPHY_NODE_ENCODING_PROP_TITLE);
+ LOG ("add_action for encoding '%s'", encoding)
+
g_snprintf (name, sizeof (name), "Encoding%s", encoding);
action = g_object_new (GTK_TYPE_RADIO_ACTION,
@@ -397,7 +395,9 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
{
GtkActionGroup *action_group;
GtkAction *action;
- GList *encodings;
+ EphyNode *encodings;
+ GPtrArray *children;
+ int i;
g_return_if_fail (EPHY_IS_WINDOW (window));
@@ -413,9 +413,25 @@ ephy_encoding_menu_set_window (EphyEncodingMenu *menu, EphyWindow *window)
gtk_action_group_add_toggle_actions (action_group, toggle_menu_entries,
n_toggle_menu_entries, menu);
- encodings = ephy_encodings_get_encodings (menu->priv->encodings, LG_ALL);
- g_list_foreach (encodings, (GFunc) add_action, menu);
- g_list_free (encodings);
+ /* add actions for the existing encodings */
+ encodings = ephy_encodings_get_all (menu->priv->encodings);
+ children = ephy_node_get_children (encodings);
+ for (i = 0; i < children->len; i++)
+ {
+ EphyNode *encoding;
+
+ encoding = (EphyNode *) g_ptr_array_index (children, i);
+ add_action (encodings, encoding, menu);
+ }
+
+ /* when we encounter an unknown encoding, it is added to the database,
+ * so we need to listen to child_added on the encodings node to
+ * add an action for it
+ */
+ ephy_node_signal_connect_object (encodings,
+ EPHY_NODE_CHILD_ADDED,
+ (EphyNodeCallback) add_action,
+ G_OBJECT (menu));
gtk_ui_manager_insert_action_group (menu->priv->manager,
action_group, 0);