aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-01-19 16:41:11 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-01-19 16:41:11 +0800
commit35243289664c9e672b2802ffdd1408294a53b4a4 (patch)
treedf7113e172f5333abbf7320e93f02f1b1e064274 /mail
parent3f3cb88b8e27d8926701bac89ec8773f4bf99d83 (diff)
downloadgsoc2013-evolution-35243289664c9e672b2802ffdd1408294a53b4a4.tar.gz
gsoc2013-evolution-35243289664c9e672b2802ffdd1408294a53b4a4.tar.zst
gsoc2013-evolution-35243289664c9e672b2802ffdd1408294a53b4a4.zip
removed this like i asked radek to ages ago, just call the parent
2004-01-19 Not Zed <NotZed@Ximian.com> * mail-ops.c (add_vjunk_info, add_vtrash_info): removed this like i asked radek to ages ago, just call the parent directly. (add_vtrash_or_vjunk_info): renamed to something saner. add_special_info. (add_special_info): removed the 'unread count' parameter & return the added info. ** See bug #52854. * em-folder-tree.c (emft_tree_button_press): setup a FOLDER target for the popup menu. * em-popup.c (em_popup_target_free): implement free for TARGET_FOLDER, changed the target options somewhat. (em_popup_target_new_folder): implement folder selection target. Total Hack(tm) alert. (emp_standard_menu_factory): removed the stupid g_assert_if_not_reached() call. * message-list.c (message_list_destroy): NULL out the uid_nodemap when we destroy it. svn path=/trunk/; revision=24302
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog24
-rw-r--r--mail/em-folder-tree.c35
-rw-r--r--mail/em-popup.c65
-rw-r--r--mail/em-popup.h9
-rw-r--r--mail/mail-ops.c31
-rw-r--r--mail/message-list.c1
6 files changed, 131 insertions, 34 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 4abe8e72bb..2de489db80 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,5 +1,29 @@
2004-01-19 Not Zed <NotZed@Ximian.com>
+ * mail-ops.c (add_vjunk_info, add_vtrash_info): removed this like
+ i asked radek to ages ago, just call the parent directly.
+ (add_vtrash_or_vjunk_info): renamed to something saner.
+ add_special_info.
+ (add_special_info): removed the 'unread count' parameter & return
+ the added info.
+
+ ** See bug #52854.
+
+ * em-folder-tree.c (emft_tree_button_press): setup a FOLDER target
+ for the popup menu.
+
+ * em-popup.c (em_popup_target_free): implement free for
+ TARGET_FOLDER, changed the target options somewhat.
+ (em_popup_target_new_folder): implement folder selection target.
+ Total Hack(tm) alert.
+ (emp_standard_menu_factory): removed the stupid
+ g_assert_if_not_reached() call.
+
+ * message-list.c (message_list_destroy): NULL out the uid_nodemap
+ when we destroy it.
+
+2004-01-19 Not Zed <NotZed@Ximian.com>
+
* em-folder-browser.c (emfb_folder_expunge): get the toplevel
widget here too, similar to bug 52161.
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index bc04551593..d13be53b79 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -1641,29 +1641,38 @@ emft_popup_properties (GtkWidget *item, EMFolderTree *emft)
static EMPopupItem emft_popup_menu[] = {
#if 0
- { EM_POPUP_ITEM, "00.emc.00", N_("_View"), G_CALLBACK (emft_popup_view), NULL, NULL, 0 },
- { EM_POPUP_ITEM, "00.emc.01", N_("Open in _New Window"), G_CALLBACK (emft_popup_open_new), NULL, NULL, 0 },
+ { EM_POPUP_ITEM, "00.emc.00", N_("_View"), G_CALLBACK (emft_popup_view), NULL, NULL, EM_POPUP_FOLDER_SELECT },
+ { EM_POPUP_ITEM, "00.emc.01", N_("Open in _New Window"), G_CALLBACK (emft_popup_open_new), NULL, NULL, EM_POPUP_FOLDER_SELECT },
{ EM_POPUP_BAR, "10.emc" },
#endif
- { EM_POPUP_ITEM, "10.emc.00", N_("_Copy"), G_CALLBACK (emft_popup_copy), NULL, "folder-copy-16.png", 0 },
- { EM_POPUP_ITEM, "10.emc.01", N_("_Move"), G_CALLBACK (emft_popup_move), NULL, "folder-move-16.png", 0 },
+ { EM_POPUP_ITEM, "10.emc.00", N_("_Copy"), G_CALLBACK (emft_popup_copy), NULL, "folder-copy-16.png", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT },
+ { EM_POPUP_ITEM, "10.emc.01", N_("_Move"), G_CALLBACK (emft_popup_move), NULL, "folder-move-16.png", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE },
{ EM_POPUP_BAR, "20.emc" },
- { EM_POPUP_ITEM, "20.emc.00", N_("_New Folder..."), G_CALLBACK (emft_popup_new_folder), NULL, "folder-mini.png", 0 },
- { EM_POPUP_ITEM, "20.emc.01", N_("_Delete"), G_CALLBACK (emft_popup_delete_folder), NULL, "evolution-trash-mini.png", 0 },
- { EM_POPUP_ITEM, "20.emc.01", N_("_Rename"), G_CALLBACK (emft_popup_rename_folder), NULL, NULL, 0 },
+ /* FIXME: need to disable for nochildren folders */
+ { EM_POPUP_ITEM, "20.emc.00", N_("_New Folder..."), G_CALLBACK (emft_popup_new_folder), NULL, "folder-mini.png", EM_POPUP_FOLDER_INFERIORS },
+ /* FIXME: need to disable for undeletable folders */
+ { EM_POPUP_ITEM, "20.emc.01", N_("_Delete"), G_CALLBACK (emft_popup_delete_folder), NULL, "evolution-trash-mini.png", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE },
+ { EM_POPUP_ITEM, "20.emc.01", N_("_Rename"), G_CALLBACK (emft_popup_rename_folder), NULL, NULL, EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_DELETE },
{ EM_POPUP_BAR, "80.emc" },
- { EM_POPUP_ITEM, "80.emc.00", N_("_Properties..."), G_CALLBACK (emft_popup_properties), NULL, "configure_16_folder.xpm", 0 },
+ { EM_POPUP_ITEM, "80.emc.00", N_("_Properties..."), G_CALLBACK (emft_popup_properties), NULL, "configure_16_folder.xpm", EM_POPUP_FOLDER_FOLDER|EM_POPUP_FOLDER_SELECT },
};
static gboolean
emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree *emft)
{
+ struct _EMFolderTreePrivate *priv = emft->priv;
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
GSList *menus = NULL;
GtkMenu *menu;
EMPopup *emp;
+ EMPopupTarget *target;
+ char *uri;
+ gboolean isstore;
int i;
if (event->button != 3)
@@ -1671,6 +1680,12 @@ emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree
/* 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);
+ target = em_popup_target_new_folder(uri, isstore);
for (i = 0; i < sizeof (emft_popup_menu) / sizeof (emft_popup_menu[0]); i++) {
EMPopupItem *item = &emft_popup_menu[i];
@@ -1680,8 +1695,8 @@ emft_tree_button_press (GtkWidget *treeview, GdkEventButton *event, EMFolderTree
}
em_popup_add_items (emp, menus, (GDestroyNotify) g_slist_free);
-
- menu = em_popup_create_menu_once (emp, NULL, 0, 0);
+
+ menu = em_popup_create_menu_once (emp, target, 0, target->mask);
if (event == NULL || event->type == GDK_KEY_PRESS) {
/* FIXME: menu pos function */
diff --git a/mail/em-popup.c b/mail/em-popup.c
index e1efd4f268..128db12d12 100644
--- a/mail/em-popup.c
+++ b/mail/em-popup.c
@@ -26,6 +26,9 @@
#include <camel/camel-mime-part.h>
#include <camel/camel-url.h>
+#include <camel/camel-vee-folder.h>
+#include <camel/camel-vtrash-folder.h>
+
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
@@ -544,6 +547,62 @@ em_popup_target_new_part(struct _CamelMimePart *part, const char *mime_type)
return t;
}
+/* 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, int isstore)
+{
+ EMPopupTarget *t = g_malloc0(sizeof(*t));
+ guint32 mask = ~0;
+ CamelURL *url;
+
+ t->type = EM_POPUP_TARGET_FOLDER;
+ t->data.folder.folder_uri = g_strdup(uri);
+
+ if (isstore)
+ 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) {
+ 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;
+
+ /* since vtrash/vjunk currently make scarily bogus
+ * url's, we have to check this too */
+ if (strcmp(url->protocol, "vtrash") == 0
+ || strcmp(url->protocol, "vjunk") == 0)
+ mask |= EM_POPUP_FOLDER_DELETE|EM_POPUP_FOLDER_INFERIORS;
+ /* end hack bit */
+
+ if (camel_url_get_param(url, "noselect") == NULL)
+ mask &= ~EM_POPUP_FOLDER_SELECT;
+ }
+
+ camel_url_free(url);
+done:
+ t->mask = mask;
+
+ return t;
+}
+
void
em_popup_target_free(EMPopupTarget *t)
{
@@ -561,6 +620,9 @@ em_popup_target_free(EMPopupTarget *t)
camel_object_unref(t->data.part.part);
g_free(t->data.part.mime_type);
break;
+ case EM_POPUP_TARGET_FOLDER:
+ g_free(t->data.folder.folder_uri);
+ break;
}
g_free(t);
@@ -820,9 +882,9 @@ emp_standard_menu_factory(EMPopup *emp, EMPopupTarget *target, void *data)
GSList *menus = NULL;
switch (target->type) {
+#if 0
case EM_POPUP_TARGET_SELECT:
return;
-#if 0
items = emp_standard_select_popups;
len = LEN(emp_standard_select_popups);
break;
@@ -890,7 +952,6 @@ emp_standard_menu_factory(EMPopup *emp, EMPopupTarget *target, void *data)
default:
items = NULL;
len = 0;
- g_assert_not_reached ();
}
for (i=0;i<len;i++) {
diff --git a/mail/em-popup.h b/mail/em-popup.h
index 831d586efe..f71d312b90 100644
--- a/mail/em-popup.h
+++ b/mail/em-popup.h
@@ -108,9 +108,11 @@ enum {
/* Flags that describe TARGET_FOLDER */
enum {
- EM_POPUP_FOLDER_LOCAL = 1<<0,
- EM_POPUP_FOLDER_REMOTE = 1<<1,
- EM_POPUP_FOLDER_VFOLDER = 1<<2,
+ EM_POPUP_FOLDER_FOLDER = 1<<0, /* normal folder */
+ EM_POPUP_FOLDER_STORE = 1<<1, /* root/nonselectable folder, i.e. store */
+ EM_POPUP_FOLDER_INFERIORS = 1<<2, /* folder can have children */
+ EM_POPUP_FOLDER_DELETE = 1<<3, /* folder can be deleted/renamed */
+ EM_POPUP_FOLDER_SELECT = 1<<4, /* folder can be selected/opened */
};
struct _EMPopupTarget {
@@ -162,6 +164,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, int isstore);
void em_popup_target_free(EMPopupTarget *target);
#ifdef __cplusplus
diff --git a/mail/mail-ops.c b/mail/mail-ops.c
index 380ba24d30..9804584bc1 100644
--- a/mail/mail-ops.c
+++ b/mail/mail-ops.c
@@ -1042,14 +1042,14 @@ get_folderinfo_desc (struct _mail_msg *mm, int done)
return ret;
}
-static void
-add_vtrash_or_vjunk_info (CamelStore *store, CamelFolderInfo *info, gchar *name, gchar *full_name, gchar *url_base, gboolean unread_count)
+static CamelFolderInfo *
+add_special_info(CamelStore *store, CamelFolderInfo *info, char *name, char *full_name, char *url_base)
{
CamelFolderInfo *fi, *vinfo, *parent;
char *uri, *path;
CamelURL *url;
- g_return_if_fail (info != NULL);
+ g_return_val_if_fail (info != NULL, NULL);
parent = NULL;
for (fi = info; fi; fi = fi->sibling) {
@@ -1090,22 +1090,10 @@ add_vtrash_or_vjunk_info (CamelStore *store, CamelFolderInfo *info, gchar *name,
vinfo->full_name = g_strdup (full_name);
vinfo->name = g_strdup(vinfo->full_name);
vinfo->url = g_strdup_printf ("%s:%s", url_base, uri);
- if (!unread_count)
- vinfo->unread_message_count = -1;
vinfo->path = g_strdup_printf("/%s", vinfo->name);
g_free (uri);
-}
-static void
-add_vtrash_info (CamelStore *store, CamelFolderInfo *info)
-{
- add_vtrash_or_vjunk_info (store, info, CAMEL_VTRASH_NAME, _("Trash"), "vtrash", FALSE);
-}
-
-static void
-add_vjunk_info (CamelStore *store, CamelFolderInfo *info)
-{
- add_vtrash_or_vjunk_info (store, info, CAMEL_VJUNK_NAME, _("Junk"), "vjunk", TRUE);
+ return vinfo;
}
static void
@@ -1134,9 +1122,14 @@ get_folderinfo_get (struct _mail_msg *mm)
m->info = camel_store_get_folder_info (m->store, NULL, flags, &mm->ex);
if (m->info) {
if (m->info->url && (m->store->flags & CAMEL_STORE_VTRASH))
- add_vtrash_info(m->store, m->info);
- if (m->info->url && (m->store->flags & CAMEL_STORE_VJUNK))
- add_vjunk_info(m->store, m->info);
+ add_special_info(m->store, m->info, CAMEL_VTRASH_NAME, _("Trash"), "vtrash");
+ if (m->info->url && (m->store->flags & CAMEL_STORE_VJUNK)) {
+ CamelFolderInfo *info;
+
+ info = add_special_info(m->store, m->info, CAMEL_VJUNK_NAME, _("Junk"), "vjunk");
+ info->unread_message_count = -1;
+ }
+
if (CAMEL_IS_VEE_STORE(m->store))
add_unmatched_info(m->info);
}
diff --git a/mail/message-list.c b/mail/message-list.c
index 8130f20e8d..601a617ac1 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -1623,6 +1623,7 @@ message_list_destroy(GtkObject *object)
if (message_list->uid_nodemap) {
g_hash_table_foreach(message_list->uid_nodemap, (GHFunc)clear_info, message_list);
g_hash_table_destroy (message_list->uid_nodemap);
+ message_list->uid_nodemap = NULL;
}
save_tree_state(message_list);