+
+ gchar *data, *cursor;
+ GList *cols = NULL;
+ GList *colwidths = NULL;
+ GList *colsortables = NULL;
+ GtkTreeModel *sortable;
+
+ cursor = data = modest_conf_get_string (conf, key, NULL);
+ while (cursor && sscanf (cursor, "%d:%d:%d ", &col, &width, &sort) == 3) {
+
+ cols = g_list_append (cols, GINT_TO_POINTER(col));
+ colwidths = g_list_append (colwidths, GINT_TO_POINTER(width));
+ colsortables = g_list_append (colsortables, GINT_TO_POINTER(sort));
+ cursor = strchr (cursor + 1, ' ');
+ }
+ g_free (data);
+
+ /* Use defaults if gconf has no, or empty information: */
+ /* We don't know why the value is empty sometimes. */
+ if (g_list_length(cols) == 0) {
+ g_warning("%s: gconf key %s was empty. Using default column IDs.\n",
+ __FUNCTION__, key);
+ g_list_free (cols);
+ cols = NULL;
+ }
+
+ if (!cols)
+ cols = modest_init_get_default_header_view_column_ids (type, style);
+
+ if (cols) {
+ GList *viewcolumns, *colcursor, *widthcursor;
+ modest_header_view_set_columns (header_view, cols, type);
+ sortable = gtk_tree_view_get_model (GTK_TREE_VIEW (header_view));
+
+ widthcursor = colwidths;
+ colcursor = viewcolumns = gtk_tree_view_get_columns (GTK_TREE_VIEW(header_view));
+ while (colcursor && widthcursor) {
+ int width = GPOINTER_TO_INT(widthcursor->data);
+ int view_column_id = GPOINTER_TO_INT (g_object_get_data (
+ G_OBJECT (colcursor->data),
+ MODEST_HEADER_VIEW_COLUMN));
+ if (width > 0)
+ gtk_tree_view_column_set_max_width(GTK_TREE_VIEW_COLUMN(colcursor->data),
+ width);
+ if (((view_column_id == MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_IN) ||
+ (view_column_id == MODEST_HEADER_VIEW_COLUMN_COMPACT_HEADER_OUT)) &&
+ (sort_flag_id != 0))
+ g_object_set_data (G_OBJECT (colcursor->data),
+ MODEST_HEADER_VIEW_FLAG_SORT, GINT_TO_POINTER (sort_flag_id));
+ colcursor = g_list_next (colcursor);
+ widthcursor = g_list_next (widthcursor);
+ }
+
+ g_list_free (cols);
+ g_list_free (colwidths);
+ g_list_free (colsortables);
+ g_list_free (viewcolumns);
+ }
+ }
+
+ if (sort_colid >= 0) {
+ GtkTreeModel *sortable =
+ gtk_tree_model_filter_get_model (
+ GTK_TREE_MODEL_FILTER (gtk_tree_view_get_model (GTK_TREE_VIEW (header_view))));
+ if (sort_colid == TNY_GTK_HEADER_LIST_MODEL_FLAGS_COLUMN)
+ modest_header_view_sort_by_column_id (header_view, 0, sort_type);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(sortable),
+ sort_colid,
+ sort_type);
+ modest_header_view_sort_by_column_id (header_view, sort_colid, sort_type);
+ gtk_tree_sortable_sort_column_changed (GTK_TREE_SORTABLE(sortable));