From aba053264da43f60b0628077e79cd52e3d78394a Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 18 Dec 2003 15:58:01 +0000 Subject: Factor out the common encoding is_automatic check. 2003-12-18 Christian Persch * embed/ephy-encodings.c: (ephy_encoding_info_is_automatic): * embed/ephy-encodings.h: * src/ephy-encoding-dialog.c: (sync_embed_cb): * src/ephy-encoding-menu.c: (update_encoding_menu_cb): Factor out the common encoding is_automatic check. --- ChangeLog | 9 +++++++++ embed/ephy-encodings.c | 9 +++++++++ embed/ephy-encodings.h | 2 ++ src/ephy-encoding-dialog.c | 10 +--------- src/ephy-encoding-menu.c | 2 +- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index c832fe7fe..7c3411635 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-12-18 Christian Persch + + * embed/ephy-encodings.c: (ephy_encoding_info_is_automatic): + * embed/ephy-encodings.h: + * src/ephy-encoding-dialog.c: (sync_embed_cb): + * src/ephy-encoding-menu.c: (update_encoding_menu_cb): + + Factor out the common encoding is_automatic check. + 2003-12-17 Christian Persch * src/ephy-tab.c: (ephy_tab_dom_mouse_click_cb): diff --git a/embed/ephy-encodings.c b/embed/ephy-encodings.c index c50ba19c2..c66adde85 100644 --- a/embed/ephy-encodings.c +++ b/embed/ephy-encodings.c @@ -457,6 +457,15 @@ ephy_encoding_info_free (EphyEncodingInfo *info) } } +gboolean +ephy_encoding_info_is_automatic (EphyEncodingInfo *info) +{ + g_return_val_if_fail (info != NULL, FALSE); + + return (info->encoding_source < EMBED_ENCODING_PARENT_FORCED) + && (info->forced_encoding == NULL || info->forced_encoding[0] == '\0'); +} + EphyEncodings * ephy_encodings_new (void) { diff --git a/embed/ephy-encodings.h b/embed/ephy-encodings.h index 6832b160c..9a565344a 100644 --- a/embed/ephy-encodings.h +++ b/embed/ephy-encodings.h @@ -146,6 +146,8 @@ GList *ephy_encodings_get_recent (EphyEncodings *encodings); void ephy_encoding_info_free (EphyEncodingInfo *info); +gboolean ephy_encoding_info_is_automatic (EphyEncodingInfo *info); + G_END_DECLS #endif diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c index 7c6efd7f6..c61db7b46 100644 --- a/src/ephy-encoding-dialog.c +++ b/src/ephy-encoding-dialog.c @@ -107,14 +107,6 @@ ephy_encoding_dialog_get_type (void) return ephy_type_encoding_dialog; } -static gboolean -encoding_is_automatic (EphyEncodingInfo *info) -{ - g_return_val_if_fail (info != NULL, FALSE); - - return (info->encoding_source < EMBED_ENCODING_PARENT_FORCED); -} - static void sync_embed_cb (EphyEncodingDialog *dialog, GParamSpec *pspec, gpointer dummy) { @@ -159,7 +151,7 @@ sync_embed_cb (EphyEncodingDialog *dialog, GParamSpec *pspec, gpointer dummy) g_list_free (rows); } - is_automatic = encoding_is_automatic (info); + is_automatic = ephy_encoding_info_is_automatic (info); button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), is_automatic); diff --git a/src/ephy-encoding-menu.c b/src/ephy-encoding-menu.c index 4c5901bf4..2b26d4fb7 100644 --- a/src/ephy-encoding-menu.c +++ b/src/ephy-encoding-menu.c @@ -200,7 +200,7 @@ update_encoding_menu_cb (GtkAction *dummy, EphyEncodingMenu *menu) gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE); /* check if encoding was overridden */ - is_automatic = (info->encoding_source < EMBED_ENCODING_PARENT_FORCED); + is_automatic = ephy_encoding_info_is_automatic (info); action = gtk_action_group_get_action (p->action_group, "ViewEncodingAutomatic"); -- cgit v1.2.3