Internet radio browser GUI for music/video streams from various directory services.

⌈⌋ ⎇ branch:  streamtuner2


Check-in [185e42f185]

Overview
Comment:Experimental drag and drop code snippets. (Not going to work well with other apps, only VLC tested, everything else depends on text/uri-list temp file:// URLs. Internal row dragging not implemented / no bookmarks subcats yet.)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 185e42f185afe4db7356f7c802c465a48ca8d7d5
User & Date: mario on 2015-04-18 17:15:45
Other Links: manifest | tags
Context
2015-04-18
17:16
Removed dnd code snippets. check-in: 1e268b6422 user: mario tags: trunk
17:15
Experimental drag and drop code snippets. (Not going to work well with other apps, only VLC tested, everything else depends on text/uri-list temp file:// URLs. Internal row dragging not implemented / no bookmarks subcats yet.) check-in: 185e42f185 user: mario tags: trunk
2015-04-17
22:15
Move PYZ shebang prefixing into `xpm` codebase. Simplifies local Makefile. Renamed PKG_PYZ into PKG_ZIP, and added extra target rules to Packfile. check-in: 9b93393d5e user: mario tags: trunk
Changes

Added channels/dnd.py version [fc493ef928].



















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# encoding: UTF-8
# api: streamtuner2
# title: Drag and Drop
# description: Move streams/stations from and to other applications.
# depends: uikit
# version: 0.1
# type: interface
# category: ui
#
# Implements Gtk/X11 drag and drop support for station lists.
# Should allow to export either just stream URLs, or complete
# PLS, XSPF collections.
#
# Also used by the bookmarks tab to move favourites around.


from config import *
from uikit import *


# Drag and Drop support
class dnd(object):

    module = "dnd"
    meta = plugin_meta()

    # Keeps selected row on starting DND event
    current_row = None

    # Supported type map
    drag_types = [
      ("audio/x-mpegurl", 0, 20),
      ("application/x-scpls", 0, 21),
      ("application/xspf+xml", 0, 22),
      ("text/uri-list", 0, 4),
#      ("TEXT", 0, 5),
#      ("STRING", 0, 5),
#      ("text/plain", 0, 5),
#      ("UTF8_STRING", 0, 5),
    ]


    # Hook to main, and extend channel tabs
    def __init__(self, parent):
        self.parent = parent
        parent.hooks["init"].append(self.add_dnd)

    # Attach drag and drop functionality to each TreeView
    def add_dnd(self, parent):

        # visit each module
        for cn,module in parent.channels.items():
            w = module.gtk_list
            # as source
            w.enable_model_drag_source(gtk.gdk.BUTTON1_MASK, self.drag_types, gtk.gdk.ACTION_DEFAULT|gtk.gdk.ACTION_COPY|gtk.gdk.ACTION_MOVE)
            w.connect('drag-begin', self.begin)
            w.connect('drag-data-get', self.data_get)
            # as target
            w.enable_model_drag_dest(self.drag_types, gtk.gdk.ACTION_DEFAULT|gtk.gdk.ACTION_COPY)
            w.connect('drag-drop', self.drop)
            w.connect('drag-data-received', self.data_received)


    # --SOURCE--
    def begin(self, tv, context):
        print "begin-dragging"
        context.set_icon_stock("gtk-add", 2, 2)
        self.current_row = self.treelist_row(tv)
        return True
    # src testing
    def data_get(self, tv, context, selection, info, *time):
        print "data-get→send", context.targets, selection, info, time
        selection.set_uris([self.current_row["url"]])
        return True
    # Get selected row
    def treelist_row(self, tv):
        return self.parent.channel().row()

                
    # --DESTINATION--
    def drop(self, tv, context, x, y, time, *e):
        print "drop→probing", context.targets, x, y, time, context.drag_get_selection()
        tv.drag_get_data(context, context.targets[-1], time)
        return True
    # dest testing
    def data_received(self, tv, context, x, y, selection, info, time, *e):
        print "data-received", x,y,selection, info, time, selection.get_uris()
        context.finish(True, True, time)
        return True