* cleanup: added modest_tny_folder_get_help_id, and let modest-ui-actions use that
authorDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 2 Nov 2007 10:35:55 +0000 (10:35 +0000)
committerDirk-Jan C. Binnema <dirk-jan.binnema@nokia.com>
Fri, 2 Nov 2007 10:35:55 +0000 (10:35 +0000)
pmo-trunk-r3615

src/modest-tny-folder.c
src/modest-tny-folder.h
src/modest-ui-actions.c

index f9227e1..ff32e0e 100644 (file)
@@ -51,7 +51,7 @@ modest_tny_folder_guess_folder_type_from_name (const gchar* full_name)
        else if (strcmp (full_name, modest_local_folder_info_get_type_name(TNY_FOLDER_TYPE_DRAFTS)) == 0)
                return TNY_FOLDER_TYPE_DRAFTS;
        return
-               TNY_FOLDER_TYPE_UNKNOWN;
+               TNY_FOLDER_TYPE_NORMAL;
 }
 
 
@@ -81,6 +81,34 @@ modest_tny_folder_guess_folder_type (const TnyFolder *folder)
 }
 
 
+const gchar*
+modest_tny_folder_get_help_id (const TnyFolder *folder)
+{
+       TnyFolderType type;
+       const gchar* help_id = NULL;
+       
+       g_return_val_if_fail (folder, NULL);
+       g_return_val_if_fail (TNY_IS_FOLDER(folder), NULL);
+       
+       type = modest_tny_folder_guess_folder_type (TNY_FOLDER (folder));
+       
+       switch (type) {
+       case TNY_FOLDER_TYPE_NORMAL:  help_id = "applications_email_managefolders"; break;
+       case TNY_FOLDER_TYPE_INBOX:   help_id = "applications_email_inbox";break;
+       case TNY_FOLDER_TYPE_OUTBOX:  help_id = "applications_email_outbox";break;
+       case TNY_FOLDER_TYPE_SENT:    help_id = "applications_email_sent"; break;
+       case TNY_FOLDER_TYPE_DRAFTS:  help_id = "applications_email_drafts";break;
+       case TNY_FOLDER_TYPE_ARCHIVE: help_id = "applications_email_managefolders";break;
+
+       case TNY_FOLDER_TYPE_INVALID: g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__);break;
+       default:                      g_warning ("%s: BUG: unexpected folder type (%d)", __FUNCTION__, type);
+       }
+       
+       return help_id;
+}
+
+
+
 /* FIXME: encode all folder rules here */
 ModestTnyFolderRules
 modest_tny_folder_get_rules   (TnyFolder *folder)
index 6f2ec64..9526a3c 100644 (file)
@@ -129,6 +129,18 @@ TnyFolderType modest_tny_folder_get_local_or_mmc_folder_type  (TnyFolder *folder
  */
 ModestTnyFolderRules  modest_tny_folder_get_rules   (TnyFolder *folder);
 
+
+/**
+ * modest_tny_folder_get_help_id:
+ * @folder: a valid tnymail folder
+ * 
+ * get the help_id for this folder
+ *  
+ * Returns: get the help_id for this folder, or NULL in case of error
+ */
+const gchar* modest_tny_folder_get_help_id (const TnyFolder *folder);
+
+
 /**
  * modest_tny_folder_is_outbox_for_account:
  * @folder: a valid tnymail folder
index 54fe04d..83687f4 100644 (file)
@@ -4607,33 +4607,11 @@ modest_ui_actions_on_help (GtkAction *action,
 
                /* Switch help_id */
                if (TNY_IS_FOLDER (folder_store)) {
-                       switch (modest_tny_folder_guess_folder_type (TNY_FOLDER (folder_store))) {
-                       case TNY_FOLDER_TYPE_NORMAL:
-                               help_id = "applications_email_managefolders";
-                               break;
-                       case TNY_FOLDER_TYPE_INBOX:
-                               help_id = "applications_email_inbox";
-                               break;
-                       case TNY_FOLDER_TYPE_OUTBOX:
-                               help_id = "applications_email_outbox";
-                               break;
-                       case TNY_FOLDER_TYPE_SENT:
-                               help_id = "applications_email_sent";
-                               break;
-                       case TNY_FOLDER_TYPE_DRAFTS:
-                               help_id = "applications_email_drafts";
-                               break;
-                       case TNY_FOLDER_TYPE_ARCHIVE:
-                               help_id = "applications_email_managefolders";
-                               break;
-                       case TNY_FOLDER_TYPE_INVALID:
-                               g_warning ("%s: BUG: TNY_FOLDER_TYPE_INVALID", __FUNCTION__);
-                               break;
-                       default:
-                               help_id = "applications_email_managefolders";
+                       help_id = modest_tny_folder_get_help_id (TNY_FOLDER (folder_store));
+                       if (!help_id) {
+                               g_warning ("%s: BUG: did not get a valid help_id", __FUNCTION__);
+                               help_id = "applications_email_mainview";
                        }
-               } else {
-                       help_id = "applications_email_mainview";
                }
                g_object_unref (folder_store);
        } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {