aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/em-folder-tree.c37
-rw-r--r--mail/em-popup.c42
-rw-r--r--mail/em-popup.h2
4 files changed, 58 insertions, 33 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index a0a2d6f903..a2bae13be6 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,13 @@
+2004-02-18 Jeffrey Stedfast <fejj@ximian.com>
+
+ * em-folder-tree.c (emft_tree_button_press): Pass flags to
+ em_popup_target_new_folder() instead of just an isstore arg.
+
+ * em-popup.c (em_popup_target_new_folder): Instead of taking an
+ isstore argument, take a flags argument so that our caller can
+ give us hints about the selected folder/store. Also fixed a logic
+ bug from my previous commit.
+
2004-02-12 Jeffrey Stedfast <fejj@ximian.com>
* em-folder-tree.c (emft_tree_button_press): Updated for em-popup
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index 0e1c6c4357..bdab24952f 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -2204,29 +2204,50 @@ emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree
/* FIXME: need to disable Rename/Move for Outbox and possibly other special folders */
struct _EMFolderTreePrivate *priv = emft->priv;
GtkTreeSelection *selection;
+ CamelStore *local, *store;
+ const char *folder_name;
+ EMPopupTarget *target;
GtkTreeModel *model;
GtkTreeIter iter;
GSList *menus = NULL;
+ guint32 flags = 0;
+ gboolean isstore;
+ char *uri, *path;
GtkMenu *menu;
EMPopup *emp;
- EMPopupTarget *target;
- char *uri;
- gboolean isstore;
int i;
if (event->button != 3)
return FALSE;
- /* handle right-click by opening a context menu */
- emp = em_popup_new ("com.ximian.mail.storageset.popup.select");
-
/* FIXME: we really need the folderinfo to build a proper menu */
selection = gtk_tree_view_get_selection (priv->treeview);
emft_selection_get_selected (selection, &model, &iter);
- gtk_tree_model_get (model, &iter, COL_STRING_URI, &uri, COL_BOOL_IS_STORE, &isstore, -1);
+ gtk_tree_model_get (model, &iter, COL_POINTER_CAMEL_STORE, &store,
+ COL_STRING_URI, &uri, COL_STRING_FOLDER_PATH, &path,
+ COL_BOOL_IS_STORE, &isstore, -1);
+
+ if (path == NULL)
+ return FALSE;
+
+ if (isstore)
+ flags |= EM_POPUP_FOLDER_STORE;
+ else
+ flags |= EM_POPUP_FOLDER_FOLDER;
+
+ local = mail_component_peek_local_store (NULL);
+
+ folder_name = path[0] == '/' ? path + 1 : path;
+
+ /* don't allow deletion of special local folders */
+ if (!(store == local && is_special_local_folder (folder_name)))
+ flags |= EM_POPUP_FOLDER_DELETE;
+
+ /* handle right-click by opening a context menu */
+ emp = em_popup_new ("com.ximian.mail.storageset.popup.select");
/* FIXME: pass valid fi->flags here */
- target = em_popup_target_new_folder(uri, 0, isstore);
+ target = em_popup_target_new_folder (uri, /* fi->flags */ 0, flags);
for (i = 0; i < sizeof (emft_popup_menu) / sizeof (emft_popup_menu[0]); i++) {
EMPopupItem *item = &emft_popup_menu[i];
diff --git a/mail/em-popup.c b/mail/em-popup.c
index 8f154ade93..60f10dbb04 100644
--- a/mail/em-popup.c
+++ b/mail/em-popup.c
@@ -585,7 +585,7 @@ em_popup_target_new_part(struct _CamelMimePart *part, const char *mime_type)
/* TODO: This should be based on the CamelFolderInfo, but ... em-folder-tree doesn't keep it? */
EMPopupTarget *
-em_popup_target_new_folder(const char *uri, guint32 info_flags, int isstore)
+em_popup_target_new_folder (const char *uri, guint32 info_flags, guint32 popup_flags)
{
EMPopupTarget *t = g_malloc0(sizeof(*t));
guint32 mask = ~0;
@@ -594,43 +594,37 @@ em_popup_target_new_folder(const char *uri, guint32 info_flags, int isstore)
t->type = EM_POPUP_TARGET_FOLDER;
t->data.folder.folder_uri = g_strdup(uri);
- if (isstore)
+ if (popup_flags & EM_POPUP_FOLDER_STORE)
mask &= ~(EM_POPUP_FOLDER_STORE|EM_POPUP_FOLDER_INFERIORS);
else
mask &= ~EM_POPUP_FOLDER_FOLDER;
-
+
url = camel_url_new(uri, NULL);
if (url == NULL)
goto done;
- if (!isstore) {
+ if (!(popup_flags & EM_POPUP_FOLDER_STORE)) {
const char *path;
-
- /* We have no way to find out FOLDER_INFERIORS without
- * the FolderInfo, so turn it on always (except vtrash/junk below) */
- mask &= ~EM_POPUP_FOLDER_INFERIORS;
-
- /* FIXME: this is a total hack, but i think all we can do at present */
- path = url->fragment?url->fragment:url->path;
- mask &= ~EM_POPUP_FOLDER_DELETE;
- if (path && path[0]
- && (strcmp(path, CAMEL_VTRASH_NAME) == 0
- || strcmp(path, CAMEL_VJUNK_NAME) == 0
- || strcmp(path, CAMEL_UNMATCHED_NAME) == 0
- /* more hack, for maildir root */
- || strcmp(path, ".") == 0))
- mask |= EM_POPUP_FOLDER_DELETE|EM_POPUP_FOLDER_INFERIORS;
- /* end hack bit */
+ if (popup_flags & EM_POPUP_FOLDER_DELETE)
+ mask &= ~EM_POPUP_FOLDER_DELETE;
+
+ if (!(info_flags & CAMEL_FOLDER_NOINFERIORS))
+ mask &= ~EM_POPUP_FOLDER_INFERIORS;
+
+ if (!(info_flags & CAMEL_FOLDER_NOSELECT))
+ mask &= ~EM_POPUP_FOLDER_SELECT;
- /* check for vTrash/vJunk */
if (info_flags & CAMEL_FOLDER_VIRTUAL)
mask |= EM_POPUP_FOLDER_DELETE|EM_POPUP_FOLDER_INFERIORS;
- if (info_flags & CAMEL_FOLDER_NOSELECT)
- mask &= ~EM_POPUP_FOLDER_SELECT;
+ if ((path = url->fragment ? url->fragment : url->path)) {
+ if ((!strcmp (url->protocol, "vfolder") && !strcmp (path, CAMEL_UNMATCHED_NAME))
+ || (!strcmp (url->protocol, "maildir") && !strcmp (path, "."))) /* hack for maildir toplevel folder */
+ mask |= EM_POPUP_FOLDER_DELETE|EM_POPUP_FOLDER_INFERIORS;
+ }
}
-
+
camel_url_free(url);
done:
t->mask = mask;
diff --git a/mail/em-popup.h b/mail/em-popup.h
index 3cc82840f4..f0e7de3782 100644
--- a/mail/em-popup.h
+++ b/mail/em-popup.h
@@ -165,7 +165,7 @@ struct _GtkMenu *em_popup_create_menu_once(EMPopup *emp, EMPopupTarget *, guint3
EMPopupTarget *em_popup_target_new_uri(const char *uri);
EMPopupTarget *em_popup_target_new_select(struct _CamelFolder *folder, const char *folder_uri, GPtrArray *uids);
EMPopupTarget *em_popup_target_new_part(struct _CamelMimePart *part, const char *mime_type);
-EMPopupTarget *em_popup_target_new_folder(const char *uri, guint32 info_flags, int isstore);
+EMPopupTarget *em_popup_target_new_folder(const char *uri, guint32 info_flags, guint32 popup_flags);
void em_popup_target_free(EMPopupTarget *target);
#ifdef __cplusplus