97
97
Gtk.MenuItem popupmenu_mount_item;
98
98
Gtk.MenuItem popupmenu_unmount_item;
99
99
Gtk.MenuItem popupmenu_eject_item;
100
Gtk.MenuItem popupmenu_rescan_item;
101
Gtk.MenuItem popupmenu_format_item;
102
100
Gtk.MenuItem popupmenu_empty_trash_item;
103
101
Gtk.MenuItem popupmenu_drive_property_item;
104
Gtk.MenuItem popupmenu_start_item;
105
Gtk.MenuItem popupmenu_stop_item;
107
103
/* volume mounting - delayed open process */
108
104
bool mounting = false;
397
393
Column.VOLUME, volume,
398
394
Column.MOUNT, mount,
399
395
Column.NAME, converted_name,
400
Column.ICON, (GLib.Icon)pixbuf,
401
397
Column.INDEX, index,
402
398
Column.CAN_EJECT, show_eject_button,
403
399
Column.NO_EJECT, !show_eject_button,
897
893
this.drag_row_ref = null;
898
894
if (selection_data.get_target () != Gdk.Atom.NONE
899
895
&& info == TargetType.TEXT_URI_LIST) {
900
897
string s = (string)(selection_data.get_data ());
901
898
drag_list = EelGFile.list_new_from_string (s);
947
944
Gtk.TreeViewDropPosition drop_pos,
949
946
Marlin.PlaceType type;
947
uint target_position;
951
948
store.@get (iter,
952
949
Column.ROW_TYPE, out type,
953
Column.INDEX, out position);
950
Column.INDEX, out target_position);
955
952
if (type == Marlin.PlaceType.BOOKMARK || type == Marlin.PlaceType.BUILT_IN) {
956
if (type == Marlin.PlaceType.BOOKMARK && drop_pos == Gtk.TreeViewDropPosition.BEFORE)
960
954
case TargetType.TEXT_URI_LIST:
961
drop_drag_list (position);
955
drop_drag_list (target_position, drop_pos);
963
957
case TargetType.GTK_TREE_MODEL_ROW:
964
reorder_bookmarks (position);
958
reorder_bookmarks (target_position, drop_pos);
967
961
assert_not_reached ();
1033
1027
return count > 0 && count <= MAX_BOOKMARKS_DROPPED;
1036
private void drop_drag_list (uint position) {
1030
private void drop_drag_list (uint target_position, Gtk.TreeViewDropPosition drop_pos) {
1037
1031
if (drag_list == null) {
1038
1032
warning ("dropped a null drag list");
1045
1039
uris.prepend (file.get_uri ());
1043
if (target_position > n_builtins_before) {
1044
target_position-= n_builtins_before;
1046
/* The target is a builtin. Always drop at start of bookmarks */
1047
target_position = 0;
1048
drop_pos = Gtk.TreeViewDropPosition.BEFORE; /* We have effectively moved target down */
1050
uint position = (drop_pos == Gtk.TreeViewDropPosition.AFTER) ? ++target_position : target_position;
1049
1051
bookmarks.insert_uris (uris, position);
1052
1055
public void add_uri (string uri, string? label = null) {
1115
1118
out Gtk.TreeViewDropPosition drop_position
1118
int num_rows = store.iter_n_children (null);
1119
1122
if (!tree_view.get_dest_row_at_pos (x, y, out path, out drop_position)) {
1120
warning ("tree_view.get_dest_row_at_pos failed in sidebar");
1126
if (path.get_depth () == 1) { /* On category name */
1124
1130
int row = (path.get_indices ()) [0];
1125
if (row == 1 || row == 2) {
1126
/* Hardcoded shortcuts can only be dragged into */
1131
Gtk.TreeIter? row_iter = null;
1132
store.get_iter_from_string (out row_iter, row.to_string ());
1133
int last_row = store.iter_n_children (row_iter) - 1;
1136
/* On a Device or Network bookmark - these can only be dropped into */
1127
1137
drop_position = Gtk.TreeViewDropPosition.INTO_OR_BEFORE;
1128
} else if (row >= num_rows) {
1129
row = num_rows - 1; /* row not used after this?? */
1130
drop_position = Gtk.TreeViewDropPosition.AFTER;
1131
} else if (drop_position != Gtk.TreeViewDropPosition.BEFORE
1132
&& received_drag_data
1133
&& drag_data_info == TargetType.GTK_TREE_MODEL_ROW)
1138
} else if (row == last_row && drop_position == Gtk.TreeViewDropPosition.AFTER) {
1139
/* Cannot drop after "Trash" */
1141
} else if (received_drag_data && drag_data_info == TargetType.GTK_TREE_MODEL_ROW) {
1134
1142
/* bookmark rows are never dragged into other bookmark rows */
1135
drop_position = Gtk.TreeViewDropPosition.AFTER;
1137
if (path.get_depth () == 1)
1143
if (drop_position == Gtk.TreeViewDropPosition.INTO_OR_BEFORE) {
1144
drop_position = Gtk.TreeViewDropPosition.BEFORE;
1145
} else if (drop_position == Gtk.TreeViewDropPosition.INTO_OR_AFTER) {
1146
drop_position = Gtk.TreeViewDropPosition.AFTER;
1200
1210
var location = mount.get_default_location ();
1201
1211
if (flags == Marlin.OpenFlag.NEW_WINDOW) {
1202
1212
var app = Marlin.Application.get ();
1203
app.create_window (location, window.get_screen ());
1213
app.create_window (location);
1204
1214
} else if (flags == Marlin.OpenFlag.NEW_TAB) {
1205
1215
window.add_tab (location, Marlin.ViewMode.CURRENT);
1273
1283
/* Reorder the selected bookmark to the specified position */
1274
private void reorder_bookmarks (uint new_position) {
1284
private void reorder_bookmarks (uint target_position, Gtk.TreeViewDropPosition drop_pos) {
1275
1285
if (drag_row_ref != null) {
1276
1286
Gtk.TreeIter iter;
1277
1287
store.get_iter (out iter, drag_row_ref.get_path ());
1283
1293
uint old_position;
1284
1294
store.@get (iter, Column.INDEX, out old_position);
1286
if (old_position <= n_builtins_before)
1296
/* Positions are currently indices into the Sidebar TreeView. We need to take account
1297
* of builtin entries like "Home" to convert these positions into indices into the personal
1299
* As we are using uints, take care not to assign negative numbers */
1300
if (old_position > n_builtins_before) {
1301
old_position-= n_builtins_before;
1287
1303
old_position = 0;
1289
old_position-= n_builtins_before;
1291
if (old_position >= bookmarks.length ())
1306
if (target_position > n_builtins_before) {
1307
target_position-= n_builtins_before;
1309
/* The target is a builtin. Always drop at start of bookmarks */
1310
drop_pos = Gtk.TreeViewDropPosition.BEFORE;
1311
target_position = 0;
1313
/* If the row is dropped on the opposite side of the target than it starts from,
1314
* then it replaces the target position. Otherwise it takes one more or less
1315
* than the target position. */
1316
uint new_position = 0;
1317
if (old_position < target_position) {
1318
new_position = (drop_pos == Gtk.TreeViewDropPosition.BEFORE) ? --target_position : target_position;
1319
} else if (old_position > target_position) {
1320
new_position = (drop_pos == Gtk.TreeViewDropPosition.AFTER) ? ++target_position : target_position;
1322
warning ("Dropping before or after self - ignore");
1294
bookmarks.move_item (old_position, new_position);
1326
bookmarks.move_item (old_position, new_position); /* Bookmarklist will validate the positions. */
1304
1336
popupmenu = new Gtk.Menu ();
1305
popupmenu.attach_to_widget ((Gtk.Widget)this, (Gtk.MenuDetachFunc)popup_menu_detach_cb);
1307
1338
var item = new Gtk.ImageMenuItem.with_mnemonic (_("Open"));
1308
1339
var image = new Gtk.Image.from_icon_name ("document-open", Gtk.IconSize.MENU);
1393
/* Callback used when the file list's popup menu is detached */
1394
public void popup_menu_detach_cb (Gtk.Widget attach_widget, Gtk.Menu menu) {
1396
popupmenu_remove_item = null;
1397
popupmenu_rename_item = null;
1398
popupmenu_separator_item1 = null;
1399
popupmenu_separator_item2 = null;
1400
popupmenu_mount_item = null;
1401
popupmenu_unmount_item = null;
1402
popupmenu_eject_item = null;
1403
popupmenu_rescan_item = null;
1404
popupmenu_format_item = null;
1405
popupmenu_start_item = null;
1406
popupmenu_stop_item = null;
1407
popupmenu_empty_trash_item = null;
1408
popupmenu_drive_property_item = null;
1411
1424
/* Callback used for the GtkWidget::popup-menu signal of the shortcuts list */
1412
1425
private bool popup_menu_cb (Gtk.Widget widget) {
1413
1426
popup_menu (null);