From 7856f67309e6a0d3a5768a403ab124110a6227b7 Mon Sep 17 00:00:00 2001 From: Sergio Villar Senin Date: Tue, 20 Jan 2009 15:28:13 +0000 Subject: [PATCH] * Fixes NB#98294, archive is now displayed in New folder dialog * Fixes NB#98310, user folders are now listed in New folder dialog * Fixes NB#98608, local folders account is now listed in New folder dialog * Added a new filter to filter accounts * Modified set_filter. Added unset_filter * Set the proper icon in the new folder dialog pmo-trunk-r7200 --- src/hildon2/modest-folder-window.c | 2 ++ src/hildon2/modest-platform.c | 41 ++++++++++++++++++++++++---- src/widgets/modest-folder-view.c | 53 ++++++++++++++++++++++++------------ src/widgets/modest-folder-view.h | 15 +++++++++- 4 files changed, 87 insertions(+), 24 deletions(-) diff --git a/src/hildon2/modest-folder-window.c b/src/hildon2/modest-folder-window.c index df924f1..869b5ed 100644 --- a/src/hildon2/modest-folder-window.c +++ b/src/hildon2/modest-folder-window.c @@ -224,6 +224,8 @@ modest_folder_window_new (TnyFolderStoreQuery *query) priv->folder_view = modest_platform_create_folder_view (query); modest_folder_view_set_cell_style (MODEST_FOLDER_VIEW (priv->folder_view), MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT); + modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view), + MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS); g_signal_connect (G_OBJECT (self), "edit-mode-changed", G_CALLBACK (edit_mode_changed), (gpointer) self); diff --git a/src/hildon2/modest-platform.c b/src/hildon2/modest-platform.c index 3ed719f..9ac3e67 100644 --- a/src/hildon2/modest-platform.c +++ b/src/hildon2/modest-platform.c @@ -756,12 +756,48 @@ folder_picker_set_store (GtkButton *button, TnyFolderStore *store) if (store == NULL) { g_object_set_data (G_OBJECT (button), FOLDER_PICKER_CURRENT_FOLDER, NULL); } else { + GdkPixbuf *pixbuf; + const gchar *icon_name = NULL; + g_object_ref (store); g_object_set_data_full (G_OBJECT (button), FOLDER_PICKER_CURRENT_FOLDER, store, (GDestroyNotify) g_object_unref); name = folder_store_get_display_name (store); hildon_button_set_value (HILDON_BUTTON (button), name); g_free (name); + + /* Select icon */ + if (TNY_IS_ACCOUNT (store)) { + if (modest_tny_account_is_virtual_local_folders (TNY_ACCOUNT (store))) + icon_name = MODEST_FOLDER_ICON_LOCAL_FOLDERS; + else if (modest_tny_account_is_memory_card_account (TNY_ACCOUNT (store))) + icon_name = MODEST_FOLDER_ICON_MMC; + else + icon_name = MODEST_FOLDER_ICON_ACCOUNT; + } else { + if (modest_tny_folder_is_remote_folder (TNY_FOLDER (store))) { + TnyFolderType type = modest_tny_folder_guess_folder_type (TNY_FOLDER (store)); + switch (type) { + case TNY_FOLDER_TYPE_INBOX: + icon_name = MODEST_FOLDER_ICON_INBOX; + break; + default: + icon_name = MODEST_FOLDER_ICON_ACCOUNT; + } + } else if (modest_tny_folder_is_local_folder (TNY_FOLDER (store))) + icon_name = MODEST_FOLDER_ICON_NORMAL; + else if (modest_tny_folder_is_memory_card_folder (TNY_FOLDER (store))) + icon_name = MODEST_FOLDER_ICON_MMC_FOLDER; + } + + /* Set icon */ + pixbuf = modest_platform_get_icon (icon_name, MODEST_ICON_SIZE_SMALL); + + if (pixbuf) { + hildon_button_set_image (HILDON_BUTTON (button), + gtk_image_new_from_pixbuf (pixbuf)); + g_object_unref (pixbuf); + } } } @@ -781,15 +817,10 @@ static GtkWidget * folder_picker_new (ModestFolderView *folder_view, TnyFolderStore *suggested) { GtkWidget *button; - GdkPixbuf *pixbuf; button = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL); - pixbuf = modest_platform_get_icon (MODEST_FOLDER_ICON_NORMAL, - MODEST_ICON_SIZE_SMALL); - hildon_button_set_image (HILDON_BUTTON (button), - gtk_image_new_from_pixbuf (pixbuf)); hildon_button_set_alignment (HILDON_BUTTON (button), 0.0, 0.5, 1.0, 1.0); if (suggested) { diff --git a/src/widgets/modest-folder-view.c b/src/widgets/modest-folder-view.c index 6f29b8f..868a6b1 100644 --- a/src/widgets/modest-folder-view.c +++ b/src/widgets/modest-folder-view.c @@ -1189,7 +1189,7 @@ modest_folder_view_finalize (GObject *obj) } local_account = (TnyAccount *) - modest_tny_account_store_get_local_folders_account ((ModestTnyAccountStore *)priv->account_store); + modest_tny_account_store_get_local_folders_account (modest_runtime_get_account_store ()); if (local_account) { if (g_signal_handler_is_connected (local_account, priv->outbox_deleted_handler)) @@ -1688,10 +1688,6 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) return FALSE; if (TNY_IS_ACCOUNT (instance)) { -#ifdef MODEST_TOOLKIT_HILDON2 - /* In hildon 2.2 we don't show the account rows */ - return FALSE; -#else TnyAccount *acc = TNY_ACCOUNT (instance); const gchar *account_id = tny_account_get_id (acc); @@ -1714,7 +1710,6 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) * in the local-folders account instead: */ if (retval && MODEST_IS_TNY_OUTBOX_ACCOUNT (acc)) retval = FALSE; -#endif } else { if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE) { /* Only show special folders for current account if needed */ @@ -1779,27 +1774,31 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) } /* apply special filters */ + if (retval && (priv->filter & MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS)) { + if (TNY_IS_ACCOUNT (instance)) + return FALSE; + } + if (retval && (priv->filter & MODEST_FOLDER_VIEW_FILTER_CAN_HAVE_FOLDERS)) { if (TNY_IS_FOLDER (instance)) { - TnyFolderCaps capabilities; + /* Check folder rules */ + ModestTnyFolderRules rules; - capabilities = tny_folder_get_caps (TNY_FOLDER (instance)); - retval = !(capabilities & TNY_FOLDER_CAPS_NOCHILDREN); - - if (retval) { - retval = ((type != TNY_FOLDER_TYPE_DRAFTS) && - (type != TNY_FOLDER_TYPE_OUTBOX) && - (type != TNY_FOLDER_TYPE_SENT)); - } + rules = modest_tny_folder_get_rules (TNY_FOLDER (instance)); + retval = !(rules & MODEST_FOLDER_RULES_FOLDER_NON_WRITEABLE); } else if (TNY_IS_ACCOUNT (instance)) { - retval = FALSE; + if (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (instance))) { + retval = FALSE; + } else { + retval = TRUE; + } } } if (retval && (priv->filter & MODEST_FOLDER_VIEW_FILTER_HIDE_MANDATORY_FOLDERS)) { if (TNY_IS_FOLDER (instance)) { TnyFolderType guess_type; - + if (TNY_FOLDER_TYPE_NORMAL) { guess_type = modest_tny_folder_guess_folder_type (TNY_FOLDER (instance)); } else { @@ -1820,7 +1819,7 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) default: break; } - + } else if (TNY_IS_ACCOUNT (instance)) { retval = FALSE; } @@ -3530,3 +3529,21 @@ modest_folder_view_set_filter (ModestFolderView *self, gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model)); } } + +void +modest_folder_view_unset_filter (ModestFolderView *self, + ModestFolderViewFilter filter) +{ + ModestFolderViewPrivate *priv; + GtkTreeModel *filter_model; + + g_return_if_fail (MODEST_IS_FOLDER_VIEW (self)); + priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self); + + priv->filter &= ~filter; + + filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (self)); + if (GTK_IS_TREE_MODEL_FILTER(filter_model)) { + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (filter_model)); + } +} diff --git a/src/widgets/modest-folder-view.h b/src/widgets/modest-folder-view.h index 2748512..b1cb67d 100644 --- a/src/widgets/modest-folder-view.h +++ b/src/widgets/modest-folder-view.h @@ -62,6 +62,7 @@ typedef enum _ModestFolderViewFilter { MODEST_FOLDER_VIEW_FILTER_RENAMEABLE = 1 << 2, MODEST_FOLDER_VIEW_FILTER_MOVEABLE = 1 << 3, MODEST_FOLDER_VIEW_FILTER_DELETABLE = 1 << 4, + MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS = 1 << 5, } ModestFolderViewFilter; typedef struct _ModestFolderView ModestFolderView; @@ -271,7 +272,7 @@ void modest_folder_view_set_cell_style (ModestFolderView *self, ModestFolderViewCellStyle cell_style); /** - * modest_folder_view_filter: + * modest_folder_view_set_filter: * @self: a #ModestFolderView * @filter: a filter mask to be applied to files * @@ -281,6 +282,18 @@ void modest_folder_view_set_cell_style (ModestFolderView *self, void modest_folder_view_set_filter (ModestFolderView *self, ModestFolderViewFilter filter); +/** + * modest_folder_view_unset_filter: + * @self: a #ModestFolderView + * @filter: a filter mask to be unapplied to files + * + * Unsets the special filter to be applied (affects visibility of + * items). It's a mask, and filters applied are applied with an AND. + */ +void modest_folder_view_unset_filter (ModestFolderView *self, + ModestFolderViewFilter filter); + + G_END_DECLS #endif /* __MODEST_FOLDER_VIEW_H__ */ -- 1.7.9.5