1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * This gob file provides a hack, so rows in a gtk_list_store can be moved, (with gtk_tree_reorderable enabled)
22 * While the gtk_tree_row_reference stays in tracked.
31 public class ListstoreSort
: Gtk
.ListStore
, Gtk
.TreeDragSource
,Gtk
.TreeDragDest
33 private const bool use_transition
= Gmpc
.use_transition
;
36 bool row_draggable (Gtk
.TreePath path
)
41 bool drag_data_get (Gtk
.TreePath path
, Gtk
.SelectionData selection_data
)
47 bool drag_data_delete (Gtk
.TreePath path
)
52 bool drag_data_received(Gtk
.TreePath dest
, Gtk
.SelectionData selection_data
)
55 Gtk
.TreePath path
= null;
61 if(Gtk
.tree_get_row_drag_data(selection_data
, out model
, out path
))
63 Gtk
.TreeIter dest_iter
, source_iter
;
64 var dest_v
= model
.get_iter(out dest_iter
, dest
);
65 var source_v
= model
.get_iter(out source_iter
, path
);
69 this
.move_before(ref source_iter
, dest_iter
);
71 this
.move_before(ref source_iter
, null);
78 bool row_drop_possible (Gtk
.TreePath dest_path
, Gtk
.SelectionData data
)
82 Gtk
.TreePath path
= null;
83 Gtk
.TreeModel model
= null;
84 if(Gtk
.tree_get_row_drag_data(data
, out model
, out path
))
89 if(model
.get_iter(out iter
, path
))
91 model
.get(iter
, 4, out source
);
92 if(model
.get_iter(out iter
, dest_path
))
94 model
.get(iter
, 4, out dest
);
95 // only in current category, and not above the separator!!!
96 if(source
/1000 == dest
/1000 && dest
%1000 != 0)