aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--src/prefs-dialog.c116
2 files changed, 116 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d164df2e..032151435 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-01-17 Christian Persch <chpe@cvs.gnome.org>
+
+ * src/prefs-dialog.c: (row_is_separator), (setup_fonts_dialog),
+ (create_autodetectors_combo), (prefs_dialog_init):
+
+ Put "Off" at the top of the combo, followed by a separator row.
+ Bug #125723.
+
2006-01-17 Crispin Flowerday <gnome@flowerday.cx>
* lib/widgets/ephy-node-view.c (ephy_node_view_add_column):
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index a850d9ad0..ca4bb6eb5 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -268,6 +268,13 @@ enum
COL_ENC_CODE
};
+enum
+{
+ COL_AUTODETECTOR_NAME,
+ COL_AUTODETECTOR_DATA,
+ COL_AUTODETECTOR_IS_SEP
+};
+
#define EPHY_PREFS_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_PREFS_DIALOG, PrefsDialogPrivate))
struct PrefsDialogPrivate
@@ -495,9 +502,12 @@ row_is_separator (GtkTreeModel *model,
GtkTreeIter *iter,
gpointer data)
{
- gboolean is_sep;
- gtk_tree_model_get (model, iter, COL_FONT_IS_SEP, &is_sep, -1);
- return is_sep;
+ int column = GPOINTER_TO_INT (data);
+ gboolean is_sep;
+
+ gtk_tree_model_get (model, iter, column, &is_sep, -1);
+
+ return is_sep;
}
static EphyDialog *
@@ -554,10 +564,10 @@ setup_fonts_dialog (PrefsDialog *pd)
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (variable_combo),
(GtkTreeViewRowSeparatorFunc) row_is_separator,
- NULL, NULL);
+ GINT_TO_POINTER (COL_FONT_IS_SEP), NULL);
gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (monospace_combo),
(GtkTreeViewRowSeparatorFunc) row_is_separator,
- NULL, NULL);
+ GINT_TO_POINTER (COL_FONT_IS_SEP), NULL);
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
@@ -697,6 +707,96 @@ create_node_combo (EphyDialog *dialog,
}
static void
+create_autodetectors_combo (EphyDialog *dialog,
+ int prop,
+ EphyEncodings *encodings,
+ EphyNode *node,
+ const char *key,
+ const char *default_value)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GPtrArray *children;
+ GtkComboBox *combo;
+ GtkCellRenderer *renderer;
+ char *code;
+ const char *off_title = NULL;
+ guint i;
+
+ code = eel_gconf_get_string (key);
+ if (code == NULL || ephy_encodings_get_node (encodings, code, FALSE) == NULL)
+ {
+ /* safe default */
+ eel_gconf_set_string (key, default_value);
+ }
+ g_free (code);
+
+ combo = GTK_COMBO_BOX (ephy_dialog_get_control (dialog, properties[prop].id));
+
+ store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN);
+
+ children = ephy_node_get_children (node);
+ for (i = 0; i < children->len; ++i)
+ {
+ EphyNode *kid = g_ptr_array_index (children, i);
+ const char *code, *title;
+
+ code = ephy_node_get_property_string (kid, EPHY_NODE_ENCODING_PROP_ENCODING);
+ g_return_if_fail (code != NULL);
+
+ title = ephy_node_get_property_string (kid, EPHY_NODE_ENCODING_PROP_TITLE_ELIDED);
+ if (code[0] == '\0')
+ {
+ off_title = title;
+ }
+ else
+ {
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ COL_AUTODETECTOR_NAME, title,
+ COL_AUTODETECTOR_DATA, code,
+ COL_AUTODETECTOR_IS_SEP, FALSE,
+ -1);
+ }
+ }
+
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ COL_AUTODETECTOR_NAME,
+ GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+ GTK_TREE_SORTABLE_UNSORTED_SORT_COLUMN_ID,
+ GTK_SORT_ASCENDING);
+
+ g_assert (off_title != NULL);
+
+ gtk_list_store_insert_with_values (store, &iter, 0,
+ COL_AUTODETECTOR_NAME, off_title,
+ COL_AUTODETECTOR_DATA, "",
+ COL_AUTODETECTOR_IS_SEP, FALSE,
+ -1);
+ gtk_list_store_insert_with_values (store, &iter, 1,
+ COL_AUTODETECTOR_NAME, NULL,
+ COL_AUTODETECTOR_DATA, "",
+ COL_AUTODETECTOR_IS_SEP, TRUE,
+ -1);
+
+ gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (combo),
+ (GtkTreeViewRowSeparatorFunc) row_is_separator,
+ GINT_TO_POINTER (COL_AUTODETECTOR_IS_SEP), NULL);
+
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
+ "text", COL_AUTODETECTOR_NAME,
+ NULL);
+
+ ephy_dialog_set_data_column (dialog, properties[prop].id, COL_AUTODETECTOR_DATA);
+}
+
+static void
language_editor_add (PrefsDialog *pd,
const char *code,
const char *desc)
@@ -1484,9 +1584,9 @@ prefs_dialog_init (PrefsDialog *pd)
create_node_combo (dialog, DEFAULT_ENCODING_PROP, encodings,
ephy_encodings_get_all (encodings),
CONF_LANGUAGE_DEFAULT_ENCODING, "ISO-8859-1");
- create_node_combo (dialog, AUTO_ENCODING_PROP, encodings,
- ephy_encodings_get_detectors (encodings),
- CONF_LANGUAGE_AUTODETECT_ENCODING, "");
+ create_autodetectors_combo (dialog, AUTO_ENCODING_PROP, encodings,
+ ephy_encodings_get_detectors (encodings),
+ CONF_LANGUAGE_AUTODETECT_ENCODING, "");
create_language_section (dialog);