some more refactoring
This commit is contained in:
parent
932be3d827
commit
aa740fe757
4 changed files with 74 additions and 85 deletions
|
@ -54,7 +54,7 @@ using namespace LiveSupport::GLiveSupport;
|
||||||
* Set up the D'n'D callbacks.
|
* Set up the D'n'D callbacks.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
DndMethods :: setupDndCallbacks (void) throw ()
|
DndMethods :: setupDndCallbacks (DndType type) throw ()
|
||||||
{
|
{
|
||||||
Gtk::TreeView * treeView = getTreeViewForDnd();
|
Gtk::TreeView * treeView = getTreeViewForDnd();
|
||||||
|
|
||||||
|
@ -62,16 +62,18 @@ DndMethods :: setupDndCallbacks (void) throw ()
|
||||||
targets.push_back(Gtk::TargetEntry("STRING",
|
targets.push_back(Gtk::TargetEntry("STRING",
|
||||||
Gtk::TARGET_SAME_APP));
|
Gtk::TARGET_SAME_APP));
|
||||||
|
|
||||||
// set up the tree view as a d'n'd source
|
if (type | DND_SOURCE) {
|
||||||
treeView->enable_model_drag_source(targets);
|
treeView->enable_model_drag_source(targets);
|
||||||
treeView->signal_drag_data_get().connect(sigc::mem_fun(*this,
|
treeView->signal_drag_data_get().connect(sigc::mem_fun(*this,
|
||||||
&DndMethods::onTreeViewDragDataGet));
|
&DndMethods::onTreeViewDragDataGet));
|
||||||
|
}
|
||||||
|
|
||||||
// set up the tree view as a d'n'd target
|
if (type | DND_DEST) {
|
||||||
treeView->enable_model_drag_dest(targets);
|
treeView->enable_model_drag_dest(targets);
|
||||||
treeView->signal_drag_data_received().connect(sigc::mem_fun(*this,
|
treeView->signal_drag_data_received().connect(sigc::mem_fun(*this,
|
||||||
&DndMethods::onTreeViewDragDataReceived));
|
&DndMethods::onTreeViewDragDataReceived));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
|
|
@ -124,10 +124,21 @@ class DndMethods
|
||||||
int y) throw ();
|
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
|
void
|
||||||
setupDndCallbacks (void) throw ();
|
setupDndCallbacks (DndType type = DndType(DND_SOURCE | DND_DEST))
|
||||||
|
throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The callback for supplying the data for the drag and drop.
|
* The callback for supplying the data for the drag and drop.
|
||||||
|
|
|
@ -237,7 +237,7 @@ SearchWindow :: constructSearchResultsView(void) throw ()
|
||||||
false /* call this first */);
|
false /* call this first */);
|
||||||
searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
searchResultsTreeView->signal_row_activated().connect(sigc::mem_fun(*this,
|
||||||
&SearchWindow::onDoubleClick));
|
&SearchWindow::onDoubleClick));
|
||||||
setupDndCallbacks();
|
setupDndCallbacks(DND_SOURCE);
|
||||||
|
|
||||||
audioClipContextMenu = constructAudioClipContextMenu();
|
audioClipContextMenu = constructAudioClipContextMenu();
|
||||||
playlistContextMenu = constructPlaylistContextMenu();
|
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
|
Glib::ustring
|
||||||
SearchWindow :: setupDndCallbacks (void) throw ()
|
SearchWindow :: getWindowNameForDnd (void) throw ()
|
||||||
{
|
{
|
||||||
std::list<Gtk::TargetEntry> targets;
|
return bundleName;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
|
||||||
* 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
|
#endif
|
||||||
|
|
||||||
#include "GuiWindow.h"
|
#include "GuiWindow.h"
|
||||||
|
#include "DndMethods.h"
|
||||||
#include "LiveSupport/Core/NumericTools.h"
|
#include "LiveSupport/Core/NumericTools.h"
|
||||||
|
|
||||||
#include "LiveSupport/Core/Ptr.h"
|
#include "LiveSupport/Core/Ptr.h"
|
||||||
|
@ -75,6 +76,7 @@ using namespace LiveSupport::Widgets;
|
||||||
* @version $Revision$
|
* @version $Revision$
|
||||||
*/
|
*/
|
||||||
class SearchWindow : public GuiWindow,
|
class SearchWindow : public GuiWindow,
|
||||||
|
public DndMethods,
|
||||||
private NumericTools
|
private NumericTools
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -400,32 +402,6 @@ class SearchWindow : public GuiWindow,
|
||||||
displayRemoteSearchError(const XmlRpcException & error)
|
displayRemoteSearchError(const XmlRpcException & error)
|
||||||
throw ();
|
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:
|
protected:
|
||||||
|
|
||||||
|
@ -625,20 +601,52 @@ class SearchWindow : public GuiWindow,
|
||||||
onForwardButtonClicked(void) throw ();
|
onForwardButtonClicked(void) throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The callback for supplying the data for the drag and drop.
|
* The tree view we want to implement d'n'd on.
|
||||||
*
|
|
||||||
* @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.
|
|
||||||
*/
|
*/
|
||||||
void
|
virtual Gtk::TreeView *
|
||||||
onTreeViewDragDataGet(
|
getTreeViewForDnd (void) throw ()
|
||||||
const Glib::RefPtr<Gdk::DragContext> & context,
|
{
|
||||||
Gtk::SelectionData & selectionData,
|
return searchResultsTreeView;
|
||||||
guint info,
|
}
|
||||||
guint time)
|
|
||||||
throw ();
|
/**
|
||||||
|
* 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:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue