some more refactoring
This commit is contained in:
parent
932be3d827
commit
aa740fe757
|
@ -54,7 +54,7 @@ using namespace LiveSupport::GLiveSupport;
|
|||
* Set up the D'n'D callbacks.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
DndMethods :: setupDndCallbacks (void) throw ()
|
||||
DndMethods :: setupDndCallbacks (DndType type) throw ()
|
||||
{
|
||||
Gtk::TreeView * treeView = getTreeViewForDnd();
|
||||
|
||||
|
@ -62,15 +62,17 @@ DndMethods :: setupDndCallbacks (void) throw ()
|
|||
targets.push_back(Gtk::TargetEntry("STRING",
|
||||
Gtk::TARGET_SAME_APP));
|
||||
|
||||
// set up the tree view as a d'n'd source
|
||||
treeView->enable_model_drag_source(targets);
|
||||
treeView->signal_drag_data_get().connect(sigc::mem_fun(*this,
|
||||
if (type | DND_SOURCE) {
|
||||
treeView->enable_model_drag_source(targets);
|
||||
treeView->signal_drag_data_get().connect(sigc::mem_fun(*this,
|
||||
&DndMethods::onTreeViewDragDataGet));
|
||||
}
|
||||
|
||||
// set up the tree view as a d'n'd target
|
||||
treeView->enable_model_drag_dest(targets);
|
||||
treeView->signal_drag_data_received().connect(sigc::mem_fun(*this,
|
||||
if (type | DND_DEST) {
|
||||
treeView->enable_model_drag_dest(targets);
|
||||
treeView->signal_drag_data_received().connect(sigc::mem_fun(*this,
|
||||
&DndMethods::onTreeViewDragDataReceived));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -124,10 +124,21 @@ class DndMethods
|
|||
int y) throw ();
|
||||
|
||||
/**
|
||||
* Set up the D'n'D callbacks.
|
||||
* Types of d'n'd.
|
||||
*/
|
||||
typedef enum { DND_SOURCE = 1,
|
||||
DND_DEST = 2
|
||||
} DndType;
|
||||
|
||||
/**
|
||||
* Set up the d'n'd callbacks.
|
||||
*
|
||||
* @param type set up callbacks for d'n'd source or destination
|
||||
* (default: both).
|
||||
*/
|
||||
void
|
||||
setupDndCallbacks (void) throw ();
|
||||
setupDndCallbacks (DndType type = DndType(DND_SOURCE | DND_DEST))
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* The callback for supplying the data for the drag and drop.
|
||||
|
|
|
@ -237,7 +237,7 @@ SearchWindow :: constructSearchResultsView(void) throw ()
|
|||
false /* call this first */);
|
||||
searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onDoubleClick));
|
||||
setupDndCallbacks();
|
||||
setupDndCallbacks(DND_SOURCE);
|
||||
|
||||
audioClipContextMenu = constructAudioClipContextMenu();
|
||||
playlistContextMenu = constructPlaylistContextMenu();
|
||||
|
@ -1123,44 +1123,12 @@ SearchWindow :: updatePagingToolbar(void) throw ()
|
|||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Set up the D'n'D callbacks.
|
||||
* The name of the window for the d'n'd methods.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SearchWindow :: setupDndCallbacks (void) throw ()
|
||||
Glib::ustring
|
||||
SearchWindow :: getWindowNameForDnd (void) throw ()
|
||||
{
|
||||
std::list<Gtk::TargetEntry> targets;
|
||||
targets.push_back(Gtk::TargetEntry("STRING",
|
||||
Gtk::TARGET_SAME_APP));
|
||||
|
||||
// set up the tree view as a d'n'd source
|
||||
searchResultsTreeView->enable_model_drag_source(targets);
|
||||
searchResultsTreeView->signal_drag_data_get().connect(sigc::mem_fun(*this,
|
||||
&SearchWindow::onTreeViewDragDataGet));
|
||||
return bundleName;
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* The callback for supplying the data for the drag and drop.
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
SearchWindow :: onTreeViewDragDataGet(
|
||||
const Glib::RefPtr<Gdk::DragContext> & context,
|
||||
Gtk::SelectionData & selectionData,
|
||||
guint info,
|
||||
guint time)
|
||||
throw ()
|
||||
{
|
||||
Glib::ustring dropString = bundleName;
|
||||
Ptr<Playable>::Ref playable = getFirstSelectedPlayable();
|
||||
|
||||
while ((playable = getNextSelectedPlayable())) {
|
||||
dropString += " ";
|
||||
dropString += std::string(*playable->getId());
|
||||
}
|
||||
|
||||
selectionData.set(selectionData.get_target(),
|
||||
8 /* 8 bits format*/,
|
||||
(const guchar *) dropString.c_str(),
|
||||
dropString.bytes());
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#endif
|
||||
|
||||
#include "GuiWindow.h"
|
||||
#include "DndMethods.h"
|
||||
#include "LiveSupport/Core/NumericTools.h"
|
||||
|
||||
#include "LiveSupport/Core/Ptr.h"
|
||||
|
@ -75,6 +76,7 @@ using namespace LiveSupport::Widgets;
|
|||
* @version $Revision$
|
||||
*/
|
||||
class SearchWindow : public GuiWindow,
|
||||
public DndMethods,
|
||||
private NumericTools
|
||||
{
|
||||
private:
|
||||
|
@ -399,32 +401,6 @@ class SearchWindow : public GuiWindow,
|
|||
void
|
||||
displayRemoteSearchError(const XmlRpcException & error)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Return the topmost selected row.
|
||||
* Sets selectedPaths and selectedIter; does not increment it.
|
||||
*
|
||||
* @return the first selected playable item.
|
||||
*/
|
||||
Ptr<Playable>::Ref
|
||||
getFirstSelectedPlayable(void) throw ();
|
||||
|
||||
/**
|
||||
* Used to iterate over the selected rows.
|
||||
* Reset to the first row by onEntryClicked().
|
||||
* Returns a 0 pointer if nothing is selected or we have reached
|
||||
* the end of the list of selected rows.
|
||||
*
|
||||
* @return the next selected playable item.
|
||||
*/
|
||||
Ptr<Playable>::Ref
|
||||
getNextSelectedPlayable(void) throw ();
|
||||
|
||||
/**
|
||||
* Set up the D'n'D callbacks.
|
||||
*/
|
||||
void
|
||||
setupDndCallbacks (void) throw ();
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -625,20 +601,52 @@ class SearchWindow : public GuiWindow,
|
|||
onForwardButtonClicked(void) throw ();
|
||||
|
||||
/**
|
||||
* The callback for supplying the data for the drag and drop.
|
||||
*
|
||||
* @param context the drag context.
|
||||
* @param selectionData the data (filled in by this function).
|
||||
* @param info not used.
|
||||
* @param time timestamp for the d'n'd operation.
|
||||
* The tree view we want to implement d'n'd on.
|
||||
*/
|
||||
void
|
||||
onTreeViewDragDataGet(
|
||||
const Glib::RefPtr<Gdk::DragContext> & context,
|
||||
Gtk::SelectionData & selectionData,
|
||||
guint info,
|
||||
guint time)
|
||||
throw ();
|
||||
virtual Gtk::TreeView *
|
||||
getTreeViewForDnd (void) throw ()
|
||||
{
|
||||
return searchResultsTreeView;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the window for the d'n'd methods.
|
||||
*/
|
||||
virtual Glib::ustring
|
||||
getWindowNameForDnd (void) throw ();
|
||||
|
||||
/**
|
||||
* Return the topmost selected row.
|
||||
* Sets selectedPaths and selectedIter; does not increment it.
|
||||
*
|
||||
* @return the first selected playable item.
|
||||
*/
|
||||
virtual Ptr<Playable>::Ref
|
||||
getFirstSelectedPlayable(void) throw ();
|
||||
|
||||
/**
|
||||
* Used to iterate over the selected rows.
|
||||
* Reset to the first row by onEntryClicked().
|
||||
* Returns a 0 pointer if nothing is selected or we have reached
|
||||
* the end of the list of selected rows.
|
||||
*
|
||||
* @return the next selected playable item.
|
||||
*/
|
||||
virtual Ptr<Playable>::Ref
|
||||
getNextSelectedPlayable(void) throw ();
|
||||
|
||||
/**
|
||||
* Add an item to the tree view at the given position.
|
||||
* Required to implement by DndMethods, does not do anything here.
|
||||
*
|
||||
* @param iter the iterator pointing to the row to be filled in.
|
||||
* @param id the ID of the item to add.
|
||||
*/
|
||||
virtual void
|
||||
addItem(Gtk::TreeIter iter,
|
||||
Ptr<const UniqueId>::Ref id) throw ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue