gboolean e_mail_store_create_folder_sync (CamelStore *store, const gchar *full_name, GCancellable *cancellable, GError **error) { CamelFolderInfo *folder_info; gchar *copied_full_name; gchar *display_name; const gchar *parent; gboolean success = TRUE; g_return_val_if_fail (CAMEL_IS_STORE (store), FALSE); g_return_val_if_fail (full_name != NULL, FALSE); copied_full_name = g_strdup (full_name); display_name = strrchr (copied_full_name, '/'); if (display_name == NULL) { display_name = copied_full_name; parent = ""; } else { *display_name++ = '\0'; parent = copied_full_name; } folder_info = camel_store_create_folder_sync ( store, parent, display_name, cancellable, error); g_free (copied_full_name); if (folder_info == NULL) return FALSE; if (CAMEL_IS_SUBSCRIBABLE (store)) success = camel_subscribable_subscribe_folder_sync ( CAMEL_SUBSCRIBABLE (store), full_name, cancellable, error); camel_store_free_folder_info (store, folder_info); return success; }
static void mail_shell_view_update_actions (EShellView *shell_view) { EMailShellView *mail_shell_view; EMailShellContent *mail_shell_content; EMailShellSidebar *mail_shell_sidebar; EShellSidebar *shell_sidebar; EShellWindow *shell_window; EMFolderTree *folder_tree; EMFolderTreeModel *model; EMailReader *reader; EMailView *mail_view; GtkAction *action; CamelStore *store = NULL; GList *list, *link; gchar *folder_name = NULL; gboolean sensitive; guint32 state; /* Be descriptive. */ gboolean folder_allows_children; gboolean folder_can_be_deleted; gboolean folder_is_outbox; gboolean folder_is_selected = FALSE; gboolean folder_is_store; gboolean folder_is_trash; gboolean folder_is_virtual; gboolean folder_has_unread = FALSE; gboolean folder_has_unread_rec = FALSE; gboolean folder_tree_and_message_list_agree = TRUE; gboolean store_is_builtin; gboolean store_is_subscribable; gboolean store_can_be_disabled; gboolean any_store_is_subscribable = FALSE; /* Chain up to parent's update_actions() method. */ E_SHELL_VIEW_CLASS (e_mail_shell_view_parent_class)-> update_actions (shell_view); shell_window = e_shell_view_get_shell_window (shell_view); mail_shell_view = E_MAIL_SHELL_VIEW (shell_view); mail_shell_content = mail_shell_view->priv->mail_shell_content; mail_view = e_mail_shell_content_get_mail_view (mail_shell_content); reader = E_MAIL_READER (mail_view); state = e_mail_reader_check_state (reader); e_mail_reader_update_actions (reader, state); mail_shell_sidebar = mail_shell_view->priv->mail_shell_sidebar; folder_tree = e_mail_shell_sidebar_get_folder_tree (mail_shell_sidebar); shell_sidebar = e_shell_view_get_shell_sidebar (shell_view); state = e_shell_sidebar_check_state (shell_sidebar); model = em_folder_tree_model_get_default (); folder_allows_children = (state & E_MAIL_SIDEBAR_FOLDER_ALLOWS_CHILDREN); folder_can_be_deleted = (state & E_MAIL_SIDEBAR_FOLDER_CAN_DELETE); folder_is_outbox = (state & E_MAIL_SIDEBAR_FOLDER_IS_OUTBOX); folder_is_store = (state & E_MAIL_SIDEBAR_FOLDER_IS_STORE); folder_is_trash = (state & E_MAIL_SIDEBAR_FOLDER_IS_TRASH); folder_is_virtual = (state & E_MAIL_SIDEBAR_FOLDER_IS_VIRTUAL); store_is_builtin = (state & E_MAIL_SIDEBAR_STORE_IS_BUILTIN); store_is_subscribable = (state & E_MAIL_SIDEBAR_STORE_IS_SUBSCRIBABLE); store_can_be_disabled = (state & E_MAIL_SIDEBAR_STORE_CAN_BE_DISABLED); if (em_folder_tree_get_selected (folder_tree, &store, &folder_name)) { GtkTreeRowReference *reference; CamelFolder *folder; folder_is_selected = TRUE; folder = e_mail_reader_ref_folder (reader); /* XXX If the user right-clicks on a folder other than what * the message list is showing, disable folder rename. * Between fetching the CamelFolder asynchronously and * knowing when NOT to move the folder tree selection * back to where it was to avoid cancelling the inline * folder tree editing, it's just too hairy to try to * get right. So we're punting. */ if (folder != NULL) { gchar *uri1, *uri2; uri1 = e_mail_folder_uri_from_folder (folder); uri2 = e_mail_folder_uri_build (store, folder_name); folder_tree_and_message_list_agree = (g_strcmp0 (uri1, uri2) == 0); g_free (uri1); g_free (uri2); g_object_unref (folder); } reference = em_folder_tree_model_get_row_reference ( model, store, folder_name); if (reference != NULL) { GtkTreePath *path; GtkTreeIter iter; path = gtk_tree_row_reference_get_path (reference); gtk_tree_model_get_iter ( GTK_TREE_MODEL (model), &iter, path); has_unread_mail ( GTK_TREE_MODEL (model), &iter, TRUE, &folder_has_unread, &folder_has_unread_rec); gtk_tree_path_free (path); } g_clear_object (&store); g_free (folder_name); folder_name = NULL; } /* Look for a CamelStore that supports subscriptions. */ list = em_folder_tree_model_list_stores (model); for (link = list; link != NULL; link = g_list_next (link)) { CamelStore *store = CAMEL_STORE (link->data); if (CAMEL_IS_SUBSCRIBABLE (store)) { any_store_is_subscribable = TRUE; break; } } g_list_free (list); action = ACTION (MAIL_ACCOUNT_DISABLE); sensitive = folder_is_store && store_can_be_disabled; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_ACCOUNT_EXPUNGE); sensitive = folder_is_trash; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_ACCOUNT_PROPERTIES); sensitive = folder_is_store && !store_is_builtin; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_ACCOUNT_REFRESH); sensitive = folder_is_store; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FLUSH_OUTBOX); sensitive = folder_is_outbox; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_COPY); sensitive = folder_is_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_DELETE); sensitive = folder_is_selected && folder_can_be_deleted; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_EXPUNGE); sensitive = folder_is_selected && !folder_is_virtual; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_MOVE); sensitive = folder_is_selected && folder_can_be_deleted; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_NEW); sensitive = folder_allows_children; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_PROPERTIES); sensitive = folder_is_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_REFRESH); sensitive = folder_is_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_RENAME); sensitive = folder_is_selected && folder_can_be_deleted && folder_tree_and_message_list_agree; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_SELECT_THREAD); sensitive = folder_is_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_SELECT_SUBTHREAD); sensitive = folder_is_selected; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_UNSUBSCRIBE); sensitive = folder_is_selected && store_is_subscribable && !folder_is_virtual; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_FOLDER_MARK_ALL_AS_READ); sensitive = folder_is_selected && folder_has_unread; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_POPUP_FOLDER_MARK_ALL_AS_READ); sensitive = folder_is_selected && folder_has_unread_rec; gtk_action_set_visible (action, sensitive); action = ACTION (MAIL_MANAGE_SUBSCRIPTIONS); sensitive = folder_is_store && store_is_subscribable; gtk_action_set_sensitive (action, sensitive); action = ACTION (MAIL_TOOLS_SUBSCRIPTIONS); sensitive = any_store_is_subscribable; gtk_action_set_sensitive (action, sensitive); /* folder_is_store + folder_is_virtual == "Search Folders" */ action = ACTION (MAIL_VFOLDER_UNMATCHED_ENABLE); gtk_action_set_visible (action, folder_is_store && folder_is_virtual); e_mail_shell_view_update_popup_labels (mail_shell_view); }