From: Murray Cumming Date: Thu, 14 Jun 2007 10:22:39 +0000 (+0000) Subject: 2007-06-14 Murray Cumming X-Git-Tag: git_migration_finished~3288 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=873bcb131187d4d459a438b8a37a206acf24d4e8 2007-06-14 Murray Cumming * src/modest-init.h: * src/modest-init.c: Added modest_init_get_default_header_view_column_ids(). * src/modest-widget-memory.c: (restore_settings_header_view): Use the new function to get defaults, if the gconf key is empty, instead of not creating any columns. This seems to fix the empty right-hand pane problems. * src/widgets/modest-header-view.h: Improved documentation. pmo-trunk-r2224 --- diff --git a/ChangeLog2 b/ChangeLog2 index a3a7749..1c50237 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,16 @@ +2007-06-14 Murray Cumming + + * src/modest-init.h: + * src/modest-init.c: + Added modest_init_get_default_header_view_column_ids(). + + * src/modest-widget-memory.c: (restore_settings_header_view): + Use the new function to get defaults, if the gconf key is empty, + instead of not creating any columns. This seems to fix the + empty right-hand pane problems. + + * src/widgets/modest-header-view.h: Improved documentation. + 2007-06-13 Murray Cumming * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account): diff --git a/src/modest-init.c b/src/modest-init.c index a51ca27..3fe6eb8 100644 --- a/src/modest-init.c +++ b/src/modest-init.c @@ -122,6 +122,54 @@ static const TnyFolderType LOCAL_FOLDERS[] = { }; #endif /* MODEST_PLATFORM_MAEMO */ +static GList* new_cold_ids_gslist_from_array( const FolderCols* cols, guint col_num) +{ + GList *result = NULL; + + guint i = 0; + for (i = 0; i < col_num; ++i) { + result = g_list_append (result, GINT_TO_POINTER (cols[i].col)); + } + + return result; +} + +GList * modest_init_get_default_header_view_column_ids (TnyFolderType folder_type, ModestHeaderViewStyle style) +{ + GList *result = NULL; + + switch (folder_type) { + case TNY_FOLDER_TYPE_SENT: + case TNY_FOLDER_TYPE_DRAFTS: + if (style == MODEST_HEADER_VIEW_STYLE_DETAILS) + result = new_cold_ids_gslist_from_array (OUTBOX_COLUMNS_DETAILS, + G_N_ELEMENTS(OUTBOX_COLUMNS_DETAILS)); + else if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES) + result = new_cold_ids_gslist_from_array (SENT_COLUMNS_TWOLINES, + G_N_ELEMENTS(SENT_COLUMNS_TWOLINES)); + break; + case TNY_FOLDER_TYPE_OUTBOX: + if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES) + result = new_cold_ids_gslist_from_array (OUTBOX_COLUMNS_TWOLINES, + G_N_ELEMENTS(OUTBOX_COLUMNS_TWOLINES)); + break; + + default: + if (style == MODEST_HEADER_VIEW_STYLE_DETAILS) + result = new_cold_ids_gslist_from_array (INBOX_COLUMNS_DETAILS, + G_N_ELEMENTS(INBOX_COLUMNS_DETAILS)); + else if (style == MODEST_HEADER_VIEW_STYLE_TWOLINES) + result = new_cold_ids_gslist_from_array (INBOX_COLUMNS_TWOLINES, + G_N_ELEMENTS(INBOX_COLUMNS_TWOLINES)); + }; + + if (!result) { + g_warning("DEBUG: %s: No default columns IDs found for " + "folder_type=%d, style=%d\n", __FUNCTION__, folder_type, style); + } + + return result; +} gboolean modest_init_init_core (void) diff --git a/src/modest-init.h b/src/modest-init.h index 0503c84..493202e 100644 --- a/src/modest-init.h +++ b/src/modest-init.h @@ -33,6 +33,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -91,6 +92,15 @@ gboolean modest_init_local_folders (const gchar* location_filepath); */ gboolean modest_init_one_local_folder (gchar *maildir_path); +/** + * modest_init_get_default_header_view_column_widths: + * + * Get a GList* containing the default column ids, + * for when suitable values cannot be retrieved from gconf. + * The result should be freed with g_slist_free(). + * Use (ModestHeaderViewColumn(GPOINTER_TO_INT(item->data)) to get the IDs. + */ +GList * modest_init_get_default_header_view_column_ids (TnyFolderType folder_type, ModestHeaderViewStyle style); G_END_DECLS diff --git a/src/modest-tny-local-folders-account.c b/src/modest-tny-local-folders-account.c index 1ef8ef0..aa3948e 100644 --- a/src/modest-tny-local-folders-account.c +++ b/src/modest-tny-local-folders-account.c @@ -245,7 +245,7 @@ void modest_tny_local_folders_account_add_merged_outbox_folders (ModestTnyLocalF } /* Add the merged outbox folder to the virtual local-folders store: */ - printf ("Debug: %s: adding merged outbox.\n", __FUNCTION__); + /* printf ("Debug: %s: adding merged outbox.\n", __FUNCTION__); */ modest_tny_local_folders_account_add_extra_folder (self, TNY_FOLDER(merged_outbox)); g_object_unref (merged_outbox); merged_outbox = NULL; diff --git a/src/modest-widget-memory.c b/src/modest-widget-memory.c index 794f7e8..b6ab67f 100644 --- a/src/modest-widget-memory.c +++ b/src/modest-widget-memory.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -347,6 +348,18 @@ restore_settings_header_view (ModestConf *conf, ModestHeaderView *header_view, } 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, *sortablecursor; modest_header_view_set_columns (header_view, cols, type); diff --git a/src/widgets/modest-header-view.h b/src/widgets/modest-header-view.h index 3859bb6..ac213ff 100644 --- a/src/widgets/modest-header-view.h +++ b/src/widgets/modest-header-view.h @@ -172,7 +172,7 @@ TnyFolder *modest_header_view_get_folder (ModestHeaderView *self); /** * modest_header_view_set_columns: * @self: a ModestHeaderView instance - * @columns: a list of ModestHeaderViewColumn + * @columns: a list of gint ModestHeaderViewColumn column IDs, using GINT_TO_POINTER() and GPOINTER_TO_INT(). * @type: #TnyFolderType type * * set the columns for this ModestHeaderView.