From 4917dae327fb275f620961d4009762cd22b7e71e Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Fri, 2 Nov 2007 10:35:55 +0000 Subject: [PATCH] * cleanup: added modest_tny_folder_get_help_id, and let modest-ui-actions use that pmo-trunk-r3615 --- src/modest-tny-folder.c | 30 +++++++++++++++++++++++++++++- src/modest-tny-folder.h | 12 ++++++++++++ src/modest-ui-actions.c | 30 ++++-------------------------- 3 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/modest-tny-folder.c b/src/modest-tny-folder.c index f9227e1..ff32e0e 100644 --- a/src/modest-tny-folder.c +++ b/src/modest-tny-folder.c @@ -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) diff --git a/src/modest-tny-folder.h b/src/modest-tny-folder.h index 6f2ec64..9526a3c 100644 --- a/src/modest-tny-folder.h +++ b/src/modest-tny-folder.h @@ -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 diff --git a/src/modest-ui-actions.c b/src/modest-ui-actions.c index 54fe04d..83687f4 100644 --- a/src/modest-ui-actions.c +++ b/src/modest-ui-actions.c @@ -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)) { -- 1.7.9.5