aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-callbacks.c
diff options
context:
space:
mode:
authorPeter Williams <peterw@ximian.com>2001-06-28 05:22:37 +0800
committerPeter Williams <peterw@src.gnome.org>2001-06-28 05:22:37 +0800
commit4cbcd49a8bed07221be190b80e84e23f0ad7d449 (patch)
tree29eac92a416e1ccd54694bc79183f6025003af08 /mail/mail-callbacks.c
parent6fa46ef11d80a615733338bfe1f76acaef5eab48 (diff)
downloadgsoc2013-evolution-4cbcd49a8bed07221be190b80e84e23f0ad7d449.tar.gz
gsoc2013-evolution-4cbcd49a8bed07221be190b80e84e23f0ad7d449.tar.zst
gsoc2013-evolution-4cbcd49a8bed07221be190b80e84e23f0ad7d449.zip
Bump required gal version for new accessors in ETree.
2001-06-27 Peter Williams <peterw@ximian.com> * configure.in (gal): Bump required gal version for new accessors in ETree. mail: 2001-06-27 Peter Williams <peterw@ximian.com> * folder-browser-ui.c: Uncomment EditSelectThread. Yaay! * mail-callbacks.c (select_thread): New function. Self-explanatory name. Implementation is a little hairy. * mail-callbacks.h: Prototype it here. * mail-callbacks.c (invert_selection): Here too. (select_all): Here too. * subscribe-dialog.c (subscribe_select_all): Update to use new ETree accessors. (subscribe_invert_selection): Here too. calendar: 2001-06-27 Peter Williams <peterw@ximian.com> * conduits/*/Makefile.am (INCLUDES): More srcdir != builddir fixes. svn path=/trunk/; revision=10544
Diffstat (limited to 'mail/mail-callbacks.c')
-rw-r--r--mail/mail-callbacks.c79
1 files changed, 77 insertions, 2 deletions
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c
index 7c3db7b418..a51f573482 100644
--- a/mail/mail-callbacks.c
+++ b/mail/mail-callbacks.c
@@ -979,11 +979,85 @@ select_all (BonoboUIComponent *uih, void *user_data, const char *path)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
MessageList *ml = fb->message_list;
+ ESelectionModel *etsm = e_tree_get_selection_model (ml->tree);
if (ml->folder == NULL)
return;
- e_tree_select_all (ml->tree);
+ e_selection_model_select_all (etsm);
+}
+
+/* Thread selection */
+
+typedef struct thread_select_info {
+ MessageList *ml;
+ GPtrArray *paths;
+} thread_select_info_t;
+
+static gboolean
+select_node (ETreeModel *tm, ETreePath path, gpointer user_data)
+{
+ thread_select_info_t *tsi = (thread_select_info_t *) user_data;
+
+ g_ptr_array_add (tsi->paths, path);
+ return FALSE; /*not done yet*/
+}
+
+static void
+thread_select_foreach (ETreePath path, gpointer user_data)
+{
+ thread_select_info_t *tsi = (thread_select_info_t *) user_data;
+ ETreeModel *tm = tsi->ml->model;
+ ETreePath node;
+
+ /* @path part of the initial selection. If it has children,
+ * we select them as well. If it doesn't, we select its siblings and
+ * their children (ie, the current node must be inside the thread
+ * that the user wants to mark.
+ */
+
+ if (e_tree_model_node_get_first_child (tm, path))
+ node = path;
+ else {
+ node = e_tree_model_node_get_parent (tm, path);
+
+ /* Let's make an exception: if no parent, then we're about
+ * to mark the whole tree. No. */
+ if (e_tree_model_node_is_root (tm, node))
+ node = path;
+ }
+
+ e_tree_model_node_traverse (tm, node, select_node, tsi);
+}
+
+void
+select_thread (BonoboUIComponent *uih, void *user_data, const char *path)
+{
+ FolderBrowser *fb = FOLDER_BROWSER (user_data);
+ MessageList *ml = fb->message_list;
+ ETreeSelectionModel *selection_model;
+ thread_select_info_t tsi;
+ int i;
+
+ if (ml->folder == NULL)
+ return;
+
+ /* For every selected item, select the thread containing it.
+ * We can't alter the selection while iterating through it,
+ * so build up a list of paths.
+ */
+
+ tsi.ml = ml;
+ tsi.paths = g_ptr_array_new ();
+
+ e_tree_selected_path_foreach (ml->tree, thread_select_foreach, &tsi);
+
+ selection_model = E_TREE_SELECTION_MODEL (e_tree_get_selection_model (ml->tree));
+
+ for (i = 0; i < tsi.paths->len; i++)
+ e_tree_selection_model_add_to_selection (selection_model,
+ tsi.paths->pdata[i]);
+ g_ptr_array_free (tsi.paths, TRUE);
}
void
@@ -991,11 +1065,12 @@ invert_selection (BonoboUIComponent *uih, void *user_data, const char *path)
{
FolderBrowser *fb = FOLDER_BROWSER (user_data);
MessageList *ml = fb->message_list;
+ ESelectionModel *etsm = e_tree_get_selection_model (ml->tree);
if (ml->folder == NULL)
return;
- e_tree_invert_selection (ml->tree);
+ e_selection_model_invert_selection (etsm);
}
/* flag all selected messages. Return number flagged */