[Xfce4-commits] <postler:master> Implement dragging messages to other folders
Christian Dywan
noreply at xfce.org
Thu Feb 10 00:44:02 CET 2011
Updating branch refs/heads/master
to 4ba480278d5f22b094916197a02068435d261f72 (commit)
from 51fce9eadbe58992d3c7054553a76d394e024621 (commit)
commit 4ba480278d5f22b094916197a02068435d261f72
Author: Sergio Spinatelli <spinatelli.sergio at gmail.com>
Date: Wed Feb 9 23:34:55 2011 +0100
Implement dragging messages to other folders
Multiple messages can be selected with Control or
Shift respectively.
Fixes: https://bugs.launchpad.net/postler/+bug/672871
postler/postler-folders.vala | 36 ++++++++++++++++++++++++++++++++++++
postler/postler-messages.vala | 28 ++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/postler/postler-folders.vala b/postler/postler-folders.vala
index 4250ea1..f72e242 100644
--- a/postler/postler-folders.vala
+++ b/postler/postler-folders.vala
@@ -41,7 +41,43 @@ public class Postler.Folders : Gtk.TreeView {
FOLDER_TYPE
}
+ void on_drag_data_received (Gdk.DragContext context, int x, int y,
+ Gtk.SelectionData selection_data, uint info, uint time_) {
+
+ Gtk.TreePath path;
+ Gtk.TreeViewDropPosition pos;
+ if (get_dest_row_at_pos (x, y, out path, out pos)) {
+ Gtk.TreeIter iter;
+ var tree_model = get_model ();
+ string new_location;
+ tree_model.get_iter_from_string (out iter, path.to_string ());
+ tree_model.get (iter, Columns.LOCATION, out new_location);
+ new_location += "/cur/";
+ foreach (string uri in selection_data.get_uris ()) {
+ try {
+ string old_location = Filename.from_uri (uri, null);
+ if (old_location.has_prefix (new_location))
+ return;
+
+ string filename = old_location.rstr ("/").replace ("/","");
+ var source = GLib.File.new_for_path (old_location);
+ var destination = GLib.File.new_for_path (new_location + filename);
+ source.move (destination, GLib.FileCopyFlags.NONE);
+ }
+ catch (Error error) {
+ GLib.critical ("Dropping failed: %s", error.message);
+ return;
+ }
+ }
+ }
+ }
+
public Folders (Accounts accounts) {
+ /* Drag and Drop */
+ Gtk.drag_dest_set (this, Gtk.DestDefaults.ALL, {}, Gdk.DragAction.MOVE);
+ Gtk.drag_dest_add_uri_targets (this);
+ drag_data_received.connect (on_drag_data_received);
+
this.accounts = accounts;
/* Local folders */
diff --git a/postler/postler-messages.vala b/postler/postler-messages.vala
index 8a6bfa0..5c2cd8b 100644
--- a/postler/postler-messages.vala
+++ b/postler/postler-messages.vala
@@ -222,7 +222,35 @@ public class Postler.Messages : Gtk.TreeView {
toggle_message_flag (sort_iter, ref location, 'S');
}
+ void on_drag_data_get (Gdk.DragContext context,
+ Gtk.SelectionData selection_data, uint info, uint time_) {
+
+ Gtk.TreeIter iter;
+ Gtk.TreeModel model;
+ var rows = get_selection ().get_selected_rows (out model);
+ string[] uris = null;
+ foreach (Gtk.TreePath path in rows) {
+ model.get_iter_from_string (out iter, path.to_string ());
+ string? location;
+ model.get (iter, Columns.LOCATION, out location);
+ string bare_filename;
+ string flags = flags_from_filename (location, out bare_filename);
+ string filename;
+ if ("S" in flags)
+ filename = Path.get_basename (bare_filename) + ":" + flags;
+ else
+ filename = Path.get_basename (toggle_flag (location, 'S'));
+ uris += ("file://" + location);
+ }
+ selection_data.set_uris (uris);
+ }
+
public Messages (Accounts accounts) {
+ /* Drag and Drop */
+ Gtk.drag_source_set (this, Gdk.ModifierType.BUTTON1_MASK, {}, Gdk.DragAction.MOVE);
+ Gtk.drag_source_add_uri_targets (this);
+ drag_data_get.connect (on_drag_data_get);
+
this.accounts = accounts;
store = new Gtk.TreeStore (9, typeof (bool), typeof (string),
typeof (string), typeof (string), typeof (int), typeof (string),
More information about the Xfce4-commits
mailing list