aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2005-02-08 13:07:42 +0800
committerMichael Zucci <zucchi@src.gnome.org>2005-02-08 13:07:42 +0800
commit41d52c7063b47ba2deafa8ca28beae6d0f1cc7f0 (patch)
treeea8225202aefd6ac983ab19d55711bc76d8509f4 /mail
parentc0c618e5a7aeb6d1130760669ee8936e7f896458 (diff)
downloadgsoc2013-evolution-41d52c7063b47ba2deafa8ca28beae6d0f1cc7f0.tar.gz
gsoc2013-evolution-41d52c7063b47ba2deafa8ca28beae6d0f1cc7f0.tar.zst
gsoc2013-evolution-41d52c7063b47ba2deafa8ca28beae6d0f1cc7f0.zip
** See bug #72209
2005-02-07 Not Zed <NotZed@Ximian.com> ** See bug #72209 * em-folder-tree.c (emft_popup_copy_folder_exclude): implement one for copying/moving folders. * em-folder-selection.c (em_select_folder): add an excluded func argument, fix callers. * em-folder-tree.c (em_folder_tree_set_exclude_func): allow custom callback for exclusion. (emft_select_func): handle the custom excluded callback. svn path=/trunk/; revision=28745
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog15
-rw-r--r--mail/em-folder-selection.c6
-rw-r--r--mail/em-folder-selection.h3
-rw-r--r--mail/em-folder-tree.c53
-rw-r--r--mail/em-folder-tree.h3
-rw-r--r--mail/em-folder-view.c4
6 files changed, 76 insertions, 8 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog
index 58d804e2b9..c44b9c7009 100644
--- a/mail/ChangeLog
+++ b/mail/ChangeLog
@@ -1,3 +1,18 @@
+2005-02-07 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #72209
+
+ * em-folder-tree.c (emft_popup_copy_folder_exclude): implement one
+ for copying/moving folders.
+
+ * em-folder-selection.c (em_select_folder): add an excluded func
+ argument, fix callers.
+
+ * em-folder-tree.c
+ (em_folder_tree_set_exclude_func): allow custom callback for
+ exclusion.
+ (emft_select_func): handle the custom excluded callback.
+
2005-02-07 Harry Lu <harry.lu@sun.com>
Fix for 72275.
diff --git a/mail/em-folder-selection.c b/mail/em-folder-selection.c
index acc6ea3a3f..63deb1430a 100644
--- a/mail/em-folder-selection.c
+++ b/mail/em-folder-selection.c
@@ -55,6 +55,7 @@ emfs_selector_response(EMFolderSelector *emfs, int response, struct _select_fold
void
em_select_folder (GtkWindow *parent_window, const char *title, const char *oklabel, const char *default_uri,
+ EMFTExcludeFunc exclude,
void (*done) (const char *uri, void *user_data), void *user_data)
{
struct _select_folder_data *d;
@@ -64,7 +65,10 @@ em_select_folder (GtkWindow *parent_window, const char *title, const char *oklab
model = mail_component_peek_tree_model (mail_component_peek ());
emft = (EMFolderTree *) em_folder_tree_new_with_model (model);
- em_folder_tree_set_excluded (emft, EMFT_EXCLUDE_NOSELECT|EMFT_EXCLUDE_VIRTUAL|EMFT_EXCLUDE_VTRASH);
+ if (exclude)
+ em_folder_tree_set_excluded_func(emft, exclude, user_data);
+ else
+ em_folder_tree_set_excluded (emft, EMFT_EXCLUDE_NOSELECT|EMFT_EXCLUDE_VIRTUAL|EMFT_EXCLUDE_VTRASH);
dialog = em_folder_selector_new(emft, EM_FOLDER_SELECTOR_CAN_CREATE, title, NULL, oklabel);
diff --git a/mail/em-folder-selection.h b/mail/em-folder-selection.h
index 103cf65686..3f646ba76f 100644
--- a/mail/em-folder-selection.h
+++ b/mail/em-folder-selection.h
@@ -29,9 +29,12 @@ extern "C" {
#pragma }
#endif /* __cplusplus */
+#include "em-folder-tree.h"
+
struct _GtkWindow;
void em_select_folder (struct _GtkWindow *parent_window, const char *title, const char *oklabel, const char *default_uri,
+ EMFTExcludeFunc exclude,
void (*done)(const char *uri, void *data),
void *data);
diff --git a/mail/em-folder-tree.c b/mail/em-folder-tree.c
index ad88721c5b..7bc32e5568 100644
--- a/mail/em-folder-tree.c
+++ b/mail/em-folder-tree.c
@@ -88,6 +88,8 @@ struct _EMFolderTreePrivate {
GHashTable *select_uris_table; /*Removed as they're encountered, so use this to find uri's not presnet but selected */
guint32 excluded;
+ gboolean (*excluded_func)(EMFolderTree *emft, GtkTreeModel *model, GtkTreeIter *iter, void *data);
+ void *excluded_data;
int do_multiselect:1; /* multiple select mode */
int cursor_set:1; /* set to TRUE means we or something
@@ -360,12 +362,15 @@ emft_select_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *
GtkTreeIter iter;
/* NB: This will be called with selection==NULL from tree_row_activated */
- if (emft->priv->excluded == 0)
+ if (emft->priv->excluded == 0 && emft->priv->excluded_func == NULL)
return TRUE;
if (!gtk_tree_model_get_iter(model, &iter, path))
return TRUE;
+ if (emft->priv->excluded_func != NULL)
+ return emft->priv->excluded_func(emft, model, &iter, emft->priv->excluded_data);
+
gtk_tree_model_get(model, &iter, COL_UINT_FLAGS, &flags, COL_BOOL_IS_STORE, &is_store, -1);
if (is_store)
flags |= CAMEL_FOLDER_NOSELECT;
@@ -1566,6 +1571,12 @@ void em_folder_tree_set_excluded(EMFolderTree *emft, guint32 flags)
emft->priv->excluded = flags;
}
+void em_folder_tree_set_excluded_func(EMFolderTree *emft, EMFTExcludeFunc exclude, void *data)
+{
+ emft->priv->excluded_func = exclude;
+ emft->priv->excluded_data = data;
+}
+
GList *
em_folder_tree_get_selected_uris (EMFolderTree *emft)
{
@@ -2215,10 +2226,10 @@ emft_popup_copy_folder_selected (const char *uri, void *data)
if (!(tostore = camel_session_get_store (session, uri, &ex))) {
e_error_run((GtkWindow *)gtk_widget_get_toplevel((GtkWidget *) cfd->emft),
- cfd->delete?"mail:no-move-folder-to-notexist":"mail:no-move-folder-to-notexist", frombase, uri, ex.desc, NULL);
+ cfd->delete?"mail:no-move-folder-to-notexist":"mail:no-copy-folder-to-notexist", frombase, uri, ex.desc, NULL);
goto fail;
}
-
+
url = camel_url_new (uri, NULL);
if (((CamelService *)tostore)->provider->url_flags & CAMEL_URL_FRAGMENT_IS_PATH)
tobase = url->fragment;
@@ -2241,6 +2252,38 @@ fail:
g_free (cfd);
}
+/* tree here is the 'destination' selector, not 'self' */
+static gboolean
+emft_popup_copy_folder_exclude(EMFolderTree *tree, GtkTreeModel *model, GtkTreeIter *iter, void *data)
+{
+ struct _copy_folder_data *cfd = data;
+ int fromvfolder, tovfolder;
+ char *fromuri, *touri;
+ guint flags;
+ gboolean is_store;
+
+ /* handles moving to/from vfolders */
+
+ fromuri = em_folder_tree_get_selected_uri(cfd->emft);
+ fromvfolder = strncmp(fromuri, "vfolder:", 8) == 0;
+ gtk_tree_model_get(model, iter, COL_STRING_URI, &touri, COL_UINT_FLAGS, &flags, COL_BOOL_IS_STORE, &is_store, -1);
+ tovfolder = strncmp(touri, "vfolder:", 8) == 0;
+ g_free(fromuri);
+ g_free(touri);
+
+ /* moving from vfolder to normal- not allowed */
+ if (fromvfolder && !tovfolder && cfd->delete)
+ return FALSE;
+ /* copy/move from normal folder to vfolder - not allowed */
+ if (!fromvfolder && tovfolder)
+ return FALSE;
+ /* copying to vfolder - not allowed */
+ if (tovfolder && !cfd->delete)
+ return FALSE;
+
+ return (flags & EMFT_EXCLUDE_NOINFERIORS) == 0;
+}
+
static void
emft_popup_copy(EPopup *ep, EPopupItem *item, void *data)
{
@@ -2252,7 +2295,7 @@ emft_popup_copy(EPopup *ep, EPopupItem *item, void *data)
cfd->delete = FALSE;
em_select_folder (NULL, _("Select folder"), _("C_opy"),
- NULL, emft_popup_copy_folder_selected, cfd);
+ NULL, emft_popup_copy_folder_exclude, emft_popup_copy_folder_selected, cfd);
}
static void
@@ -2266,7 +2309,7 @@ emft_popup_move(EPopup *ep, EPopupItem *item, void *data)
cfd->delete = TRUE;
em_select_folder (NULL, _("Select folder"), _("_Move"),
- NULL, emft_popup_copy_folder_selected, cfd);
+ NULL, emft_popup_copy_folder_exclude, emft_popup_copy_folder_selected, cfd);
}
diff --git a/mail/em-folder-tree.h b/mail/em-folder-tree.h
index 8ce1ad5873..e7c465998b 100644
--- a/mail/em-folder-tree.h
+++ b/mail/em-folder-tree.h
@@ -51,6 +51,8 @@ typedef struct _EMFolderTreeClass EMFolderTreeClass;
#define EMFT_EXCLUDE_SYSTEM CAMEL_FOLDER_SYSTEM
#define EMFT_EXCLUDE_VTRASH CAMEL_FOLDER_VTRASH
+typedef gboolean (*EMFTExcludeFunc)(EMFolderTree *emft, GtkTreeModel *model, GtkTreeIter *iter, void *data);
+
struct _EMFolderTree {
GtkVBox parent_object;
@@ -74,6 +76,7 @@ void em_folder_tree_enable_drag_and_drop (EMFolderTree *emft);
void em_folder_tree_set_multiselect (EMFolderTree *emft, gboolean mode);
void em_folder_tree_set_excluded(EMFolderTree *emft, guint32 flags);
+void em_folder_tree_set_excluded_func(EMFolderTree *emft, EMFTExcludeFunc exclude, void *data);
void em_folder_tree_set_selected_list (EMFolderTree *emft, GList *list);
GList *em_folder_tree_get_selected_uris (EMFolderTree *emft);
diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c
index c0bb8f9cc5..c3273697c0 100644
--- a/mail/em-folder-view.c
+++ b/mail/em-folder-view.c
@@ -857,7 +857,7 @@ emfv_popup_move(EPopup *ep, EPopupItem *pitem, void *data)
d->uids = message_list_get_selected(emfv->list);
d->delete = TRUE;
- em_select_folder ((GtkWindow *) emfv, _("Select folder"), _("_Move"), default_xfer_messages_uri, emfv_popup_move_cb, d);
+ em_select_folder ((GtkWindow *) emfv, _("Select folder"), _("_Move"), default_xfer_messages_uri, NULL, emfv_popup_move_cb, d);
}
static void
@@ -872,7 +872,7 @@ emfv_popup_copy(EPopup *ep, EPopupItem *pitem, void *data)
d->uids = message_list_get_selected(emfv->list);
d->delete = FALSE;
- em_select_folder ((GtkWindow *) emfv, _("Select folder"), _("C_opy"), default_xfer_messages_uri, emfv_popup_move_cb, d);
+ em_select_folder ((GtkWindow *) emfv, _("Select folder"), _("C_opy"), default_xfer_messages_uri, NULL, emfv_popup_move_cb, d);
}
static void