Disobedience, DisOrder's
GUI client, uses
a GtkTreeView
to display its current queue of tracks (and for various other
purposes). It allows rearrangement of the queue by drag and drop.
The high-level support for this in GtkTreeView is rather
unsatisfactory for two reasons:
- You can only drag one track (row) at a time. It should be
possible to drag the whole selection.
- You cannot drag between widgets. Playlist editing in particular
is likely to make this important.
(Actually the model where it reports the effects of the drag and
drop by inserted/deleted signals on the underlying model is also quite
inconvenient for me: Disobedience has to translate it back into a move
which it communicates to the server.)
Fixing this involves doing rather a lot of the drag-and-drop work
yourself, and while the documentation does exist it is not always
clear or even complete. There is existing code out there, and I
referred to it while working some of this out; but describing it in
English online seems worthwhile. In addition, while some of the code
is inextricably mixed with Disobedience's internal workings, a couple
of independent modules are presented, which should be usable in other
C programs.
This articles assumes some familiarity
with GTK+. I have tried as far as
reasonably possible to remove DisOrder-specific issues from the
discussion here, but note that this isn't always possible.
( Read on... )