+static gboolean
+restore_settings_header_view (ModestConf *conf, ModestHeaderView *header_view,
+ const gchar *name)
+{
+ guint col, width;
+ gint sort;
+ gchar *key;
+ gchar *sort_key;
+ TnyFolder *folder;
+ TnyFolderType type;
+ ModestHeaderViewStyle style;
+ gint sort_flag_id = 0;
+ gint sort_colid = -1, sort_type = GTK_SORT_DESCENDING;
+
+ folder = modest_header_view_get_folder (header_view);
+ if (!folder)
+ return TRUE; /* no folder: no settings */
+
+ type = modest_tny_folder_guess_folder_type (folder);
+ if (type == TNY_FOLDER_TYPE_INVALID)
+ g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__);
+
+ style = modest_header_view_get_style (header_view);
+
+ key = _modest_widget_memory_get_keyname_with_double_type (name, type, style,
+ MODEST_WIDGET_MEMORY_PARAM_COLUMN_WIDTH);
+ sort_key = _modest_widget_memory_get_keyname_with_double_type (name, type, style,
+ MODEST_WIDGET_MEMORY_PARAM_COLUMN_SORT);
+
+ if (modest_conf_key_exists (conf, sort_key, NULL)) {
+ gchar *value = modest_conf_get_string (conf, sort_key, NULL);
+ sscanf (value, "%d:%d:%d", &sort_colid, &sort_type, &sort_flag_id);
+ g_free (value);
+ }
+
+ if (modest_conf_key_exists (conf, key, NULL)) {
+
+ 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));
+ }
+
+ g_free (key);
+ g_free (sort_key);
+
+ g_object_unref (G_OBJECT (folder));
+
+ return TRUE;
+}
+
+
+
+static gboolean
+save_settings_folder_view (ModestConf *conf, ModestFolderView *folder_view,
+ const gchar *name)
+{
+ return TRUE;
+}