diff options
author | Lars Kruse <[email protected]> | 2011-08-22 21:05:48 +0200 |
---|---|---|
committer | Alexei Sorokin <[email protected]> | 2016-08-22 23:03:31 +0300 |
commit | 2d90080dcec1decf459c8e7d676b987f33aea316 (patch) | |
tree | a356fdb9a129eaa23abeaf3d0d71037a0e39b712 /Mozo/MainWindow.py | |
parent | 35c489c60bb9f7d608ad770c5902cf35d1ffb8df (diff) | |
download | mozo-2d90080dcec1decf459c8e7d676b987f33aea316.tar.bz2 mozo-2d90080dcec1decf459c8e7d676b987f33aea316.tar.xz |
fix several drag-and-drop usability issues
1) drag and drop of an item from the item pane "into" a menu item of the
item pane
2) moving a separator item from the item pane "into" a menu item of the
"menu pane"
3) dragging an item from the item pane to another position in the item
pane (between two other items)
https://bugzilla.gnome.org/show_bug.cgi?id=611278
Diffstat (limited to 'Mozo/MainWindow.py')
-rw-r--r-- | Mozo/MainWindow.py | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Mozo/MainWindow.py b/Mozo/MainWindow.py index c6fa109..b7c1ab6 100644 --- a/Mozo/MainWindow.py +++ b/Mozo/MainWindow.py @@ -431,6 +431,8 @@ class MainWindow: elif item.get_type() == matemenu.TYPE_DIRECTORY: if self.editor.moveMenu(item, new_parent) == False: self.loadUpdates() + elif item.get_type() == matemenu.TYPE_SEPARATOR: + self.editor.moveSeparator(item, new_parent) else: context.finish(False, False, etime) context.finish(True, True, etime) @@ -507,7 +509,9 @@ class MainWindow: def on_item_tree_drag_data_received(self, treeview, context, x, y, selection, info, etime): items = treeview.get_model() - types = (Gtk.TreeViewDropPosition.BEFORE, Gtk.TreeViewDropPosition.INTO_OR_BEFORE) + types_before = (Gtk.TreeViewDropPosition.BEFORE, Gtk.TreeViewDropPosition.INTO_OR_BEFORE) + types_into = (Gtk.TreeViewDropPosition.INTO_OR_BEFORE, Gtk.TreeViewDropPosition.INTO_OR_AFTER) + types_after = (Gtk.TreeViewDropPosition.AFTER, Gtk.TreeViewDropPosition.INTO_OR_AFTER) if str(selection.get_target()) == 'MOZO_ITEM_ROW': drop_info = treeview.get_dest_row_at_pos(x, y) before = None @@ -515,22 +519,32 @@ class MainWindow: if self.drag_data == None: return False item = self.drag_data + # by default we assume, that the items stays in the same menu + destination = item.get_parent() if drop_info: path, position = drop_info - if position in types: - before = items[path][3] + target = items[path][3] + # move the item to the directory, if the item was dropped into it + if (target.get_type() == matemenu.TYPE_DIRECTORY) and (position in types_into): + # append the selected item to the choosen menu + destination = target + elif position in types_before: + before = target + elif position in types_after: + after = target else: - after = items[path][3] + # this does not happen + pass else: path = (len(items) - 1,) after = items[path][3] if item.get_type() == matemenu.TYPE_ENTRY: - self.editor.moveItem(item, item.get_parent(), before, after) + self.editor.moveItem(item, destination, before, after) elif item.get_type() == matemenu.TYPE_DIRECTORY: - if self.editor.moveMenu(item, item.get_parent(), before, after) == False: + if self.editor.moveMenu(item, destination, before, after) == False: self.loadUpdates() elif item.get_type() == matemenu.TYPE_SEPARATOR: - self.editor.moveSeparator(item, item.get_parent(), before, after) + self.editor.moveSeparator(item, destination, before, after) context.finish(True, True, etime) elif str(selection.get_target()) == 'text/plain': if selection.data == None: |