applications.py: Fix dnd for re-ordering/adding favorites.

Fixes https://github.com/linuxmint/mint20-beta/issues/22
This commit is contained in:
Michael Webster 2020-06-17 10:45:10 -04:00 committed by Clement Lefebvre
parent 77476ded54
commit d7f650b79f

View File

@ -174,11 +174,11 @@ class pluginclass(object):
toButton = (Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT), toButton = (Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT),
Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT)) Gtk.TargetEntry.new("text/uri-list", 0, TARGET_TYPE_TEXT))
TARGET_TYPE_FAV = 81 TARGET_TYPE_FAV = 81
toFav = (Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), toFav = (Gtk.TargetEntry.new("text/plain", Gtk.TargetFlags.SAME_APP, 81),
Gtk.TargetEntry.new("text/plain", 0, 100), Gtk.TargetEntry.new("text/plain", 0, 100),
Gtk.TargetEntry.new("text/uri-list", 0, 101)) Gtk.TargetEntry.new("text/uri-list", 0, 101))
fromFav = (Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81), fromFav = (Gtk.TargetEntry.new("text/plain", Gtk.TargetFlags.SAME_APP, 81),
Gtk.TargetEntry.new("FAVORITES", Gtk.TargetFlags.SAME_APP, 81)) Gtk.TargetEntry.new("text/plain", Gtk.TargetFlags.SAME_APP, 81))
#@print_timing #@print_timing
def __init__(self, mintMenuWin, toggleButton, de): def __init__(self, mintMenuWin, toggleButton, de):
@ -1413,12 +1413,11 @@ class pluginclass(object):
def on_drag_data_get(self, widget, context, selection, info, time): def on_drag_data_get(self, widget, context, selection, info, time):
if info == self.TARGET_TYPE_FAV: if info == self.TARGET_TYPE_FAV:
self.drag_origin = widget.position self.drag_origin = widget.position
# FIXME: This fails in python3: selection.set_text(str(widget.position), -1)
selection.set(selection.get_target(), 8, str(widget.position))
def on_drag_data_received(self, widget, context, x, y, selection, info, time): def on_drag_data_received(self, widget, context, x, y, selection, info, time):
if info == self.TARGET_TYPE_FAV: if info == self.TARGET_TYPE_FAV:
self.favoritesReorder(int(selection.get_data()), widget.position) self.favoritesReorder(int(selection.get_data().decode()), widget.position)
# def on_icon_theme_changed(self, theme): # def on_icon_theme_changed(self, theme):
# print("on_icon_theme_changed") # print("on_icon_theme_changed")