2007-06-14 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Thu, 14 Jun 2007 10:22:39 +0000 (10:22 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Thu, 14 Jun 2007 10:22:39 +0000 (10:22 +0000)
* 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

ChangeLog2
src/modest-init.c
src/modest-init.h
src/modest-tny-local-folders-account.c
src/modest-widget-memory.c
src/widgets/modest-header-view.h

index a3a7749..1c50237 100644 (file)
@@ -1,3 +1,16 @@
+2007-06-14  Murray Cumming  <murrayc@murrayc.com>
+
+       * 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  <murrayc@murrayc.com>
 
        * src/maemo/easysetup/modest-easysetup-wizard.c: (create_account):
index a51ca27..3fe6eb8 100644 (file)
@@ -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)
index 0503c84..493202e 100644 (file)
@@ -33,6 +33,7 @@
 #include <glib.h>
 #include <glib-object.h>
 #include <modest-runtime.h>
+#include <widgets/modest-header-view.h>
 
 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
 
index 1ef8ef0..aa3948e 100644 (file)
@@ -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;
index 794f7e8..b6ab67f 100644 (file)
@@ -33,6 +33,7 @@
 #include <modest-account-mgr-helpers.h>
 #include <modest-tny-platform-factory.h>
 #include <modest-tny-folder.h>
+#include <modest-init.h>
 #include <widgets/modest-header-view.h>
 #include <widgets/modest-msg-view.h>
 #include <widgets/modest-folder-view.h>
@@ -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);
index 3859bb6..ac213ff 100644 (file)
@@ -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.