mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-14 22:22:31 +00:00
Removed all dependencies on sigc++.
This commit is contained in:
@@ -41,10 +41,6 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS $CURSES_CFLAGS"
|
||||
LIBS="$PTHREAD_LIBS $CURSES_LIB $LIBS"
|
||||
|
||||
PKG_CHECK_MODULES(sigc, sigc++-2.0,
|
||||
CXXFLAGS="$CXXFLAGS $sigc_CFLAGS";
|
||||
LIBS="$LIBS $sigc_LIBS")
|
||||
|
||||
PKG_CHECK_MODULES(libcurl, libcurl >= 7.15.4,
|
||||
CXXFLAGS="$CXXFLAGS $libcurl_CFLAGS";
|
||||
LIBS="$LIBS $libcurl_LIBS")
|
||||
|
||||
+1
-3
@@ -47,8 +47,6 @@
|
||||
#include <rak/regex.h>
|
||||
#include <rak/path.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
#include <torrent/utils/resume.h>
|
||||
#include <torrent/object.h>
|
||||
#include <torrent/connection_manager.h>
|
||||
@@ -115,7 +113,7 @@ Manager::set_hashing_view(View* v) {
|
||||
throw torrent::internal_error("Manager::set_hashing_view(...) received NULL or is already set.");
|
||||
|
||||
m_hashingView = v;
|
||||
v->signal_changed().connect(sigc::mem_fun(this, &Manager::receive_hashing_changed));
|
||||
m_hashingView->signal_changed().push_back(std::tr1::bind(&Manager::receive_hashing_changed, this));
|
||||
}
|
||||
|
||||
torrent::ThrottlePair
|
||||
|
||||
+8
-2
@@ -138,12 +138,18 @@ struct view_downloads_filter : std::unary_function<Download*, bool> {
|
||||
const torrent::Object& m_command;
|
||||
};
|
||||
|
||||
inline void
|
||||
void
|
||||
View::emit_changed() {
|
||||
priority_queue_erase(&taskScheduler, &m_delayChanged);
|
||||
priority_queue_insert(&taskScheduler, &m_delayChanged, cachedTime);
|
||||
}
|
||||
|
||||
void
|
||||
View::emit_changed_now() {
|
||||
for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++)
|
||||
(*itr)();
|
||||
}
|
||||
|
||||
View::~View() {
|
||||
if (m_name.empty())
|
||||
return;
|
||||
@@ -171,7 +177,7 @@ View::initialize(const std::string& name) {
|
||||
m_focus = 0;
|
||||
|
||||
set_last_changed(rak::timer());
|
||||
m_delayChanged.slot() = std::tr1::bind(&signal_type::operator(), &m_signalChanged);
|
||||
m_delayChanged.slot() = std::tr1::bind(&View::emit_changed_now, this);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
+9
-7
@@ -52,8 +52,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <rak/timer.h>
|
||||
#include <sigc++/signal.h>
|
||||
#include <torrent/object.h>
|
||||
#include <tr1/functional>
|
||||
|
||||
#include "globals.h"
|
||||
|
||||
@@ -63,8 +63,9 @@ class Download;
|
||||
|
||||
class View : private std::vector<Download*> {
|
||||
public:
|
||||
typedef std::vector<Download*> base_type;
|
||||
typedef sigc::signal0<void> signal_type;
|
||||
typedef std::vector<Download*> base_type;
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::list<slot_void> signal_void;
|
||||
|
||||
using base_type::iterator;
|
||||
using base_type::const_iterator;
|
||||
@@ -101,7 +102,7 @@ public:
|
||||
|
||||
iterator focus() { return begin() + m_focus; }
|
||||
const_iterator focus() const { return begin() + m_focus; }
|
||||
void set_focus(iterator itr) { m_focus = position(itr); m_signalChanged.emit(); }
|
||||
void set_focus(iterator itr) { m_focus = position(itr); emit_changed(); }
|
||||
|
||||
void insert(Download* download) { base_type::push_back(download); }
|
||||
void erase(Download* download);
|
||||
@@ -143,7 +144,7 @@ public:
|
||||
|
||||
// Don't connect any slots until after initialize else it get's
|
||||
// triggered when adding the Download's in DownloadList.
|
||||
signal_type& signal_changed() { return m_signalChanged; }
|
||||
signal_void& signal_changed() { return m_signal_changed; }
|
||||
|
||||
private:
|
||||
View(const View&);
|
||||
@@ -154,7 +155,8 @@ private:
|
||||
inline void insert_visible(Download* d);
|
||||
inline void erase_internal(iterator itr);
|
||||
|
||||
inline void emit_changed();
|
||||
void emit_changed();
|
||||
void emit_changed_now();
|
||||
|
||||
size_type position(const_iterator itr) const { return itr - begin(); }
|
||||
|
||||
@@ -176,7 +178,7 @@ private:
|
||||
|
||||
rak::timer m_lastChanged;
|
||||
|
||||
signal_type m_signalChanged;
|
||||
signal_void m_signal_changed;
|
||||
rak::priority_item m_delayChanged;
|
||||
};
|
||||
|
||||
|
||||
@@ -48,18 +48,27 @@
|
||||
|
||||
namespace display {
|
||||
|
||||
WindowDownloadList::WindowDownloadList() :
|
||||
Window(new Canvas, 0, 120, 1, extent_full, extent_full),
|
||||
m_view(NULL) {
|
||||
}
|
||||
|
||||
WindowDownloadList::~WindowDownloadList() {
|
||||
m_connChanged.disconnect();
|
||||
if (m_view != NULL)
|
||||
m_view->signal_changed().erase(m_changed_itr);
|
||||
|
||||
m_view = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
WindowDownloadList::set_view(core::View* l) {
|
||||
if (m_view != NULL)
|
||||
m_view->signal_changed().erase(m_changed_itr);
|
||||
|
||||
m_view = l;
|
||||
|
||||
m_connChanged.disconnect();
|
||||
|
||||
if (m_view != NULL)
|
||||
m_connChanged = m_view->signal_changed().connect(sigc::mem_fun(*this, &Window::mark_dirty));
|
||||
m_changed_itr = m_view->signal_changed().insert(m_view->signal_changed().begin(), std::tr1::bind(&Window::mark_dirty, this));
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -37,23 +37,18 @@
|
||||
#ifndef RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
|
||||
#define RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H
|
||||
|
||||
#include <sigc++/connection.h>
|
||||
|
||||
#include "window.h"
|
||||
|
||||
#include "core/download_list.h"
|
||||
|
||||
namespace core {
|
||||
class View;
|
||||
}
|
||||
#include "core/view.h"
|
||||
|
||||
namespace display {
|
||||
|
||||
class WindowDownloadList : public Window {
|
||||
public:
|
||||
WindowDownloadList() :
|
||||
Window(new Canvas, 0, 120, 1, extent_full, extent_full),
|
||||
m_view(NULL) {}
|
||||
typedef core::View::signal_void::iterator signal_void_itr;
|
||||
|
||||
WindowDownloadList();
|
||||
~WindowDownloadList();
|
||||
|
||||
virtual void redraw();
|
||||
@@ -63,7 +58,7 @@ public:
|
||||
private:
|
||||
core::View* m_view;
|
||||
|
||||
sigc::connection m_connChanged;
|
||||
signal_void_itr m_changed_itr;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ PathInput::pressed(int key) {
|
||||
return TextInput::pressed(key);
|
||||
|
||||
} else if (m_showNext) {
|
||||
m_signalShowNext.emit();
|
||||
for (signal_void::iterator itr = m_signal_show_next.begin(), last = m_signal_show_next.end(); itr != last; itr++)
|
||||
(*itr)();
|
||||
|
||||
} else {
|
||||
receive_do_complete();
|
||||
@@ -101,7 +102,7 @@ PathInput::receive_do_complete() {
|
||||
|
||||
std::for_each(dir.begin(), dir.end(), _transform_filename());
|
||||
|
||||
Range r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
|
||||
range_type r = find_incomplete(dir, str().substr(dirEnd, get_pos()));
|
||||
|
||||
if (r.first == r.second)
|
||||
return; // Show some nice colors here.
|
||||
@@ -121,8 +122,10 @@ PathInput::receive_do_complete() {
|
||||
// Only emit if there are more than one option.
|
||||
m_showNext = ++utils::Directory::iterator(r.first) != r.second;
|
||||
|
||||
if (m_showNext)
|
||||
m_signalShowRange.emit(r.first, r.second);
|
||||
if (m_showNext) {
|
||||
for (signal_itr_itr::iterator itr = m_signal_show_range.begin(), last = m_signal_show_range.end(); itr != last; itr++)
|
||||
(*itr)(r.first, r.second);
|
||||
}
|
||||
}
|
||||
|
||||
PathInput::size_type
|
||||
@@ -147,9 +150,9 @@ find_complete_not_compare(const utils::directory_entry& complete, const std::str
|
||||
return !complete.d_name.compare(0, base.size(), base);
|
||||
}
|
||||
|
||||
PathInput::Range
|
||||
PathInput::range_type
|
||||
PathInput::find_incomplete(utils::Directory& d, const std::string& f) {
|
||||
Range r;
|
||||
range_type r;
|
||||
|
||||
r.first = std::find_if(d.begin(), d.end(), rak::bind2nd(std::ptr_fun(&find_complete_not_compare), f));
|
||||
r.second = std::find_if(r.first, d.end(), rak::bind2nd(std::ptr_fun(&find_complete_compare), f));
|
||||
|
||||
+14
-9
@@ -37,7 +37,8 @@
|
||||
#ifndef RTORRENT_INPUT_PATH_INPUT_H
|
||||
#define RTORRENT_INPUT_PATH_INPUT_H
|
||||
|
||||
#include <sigc++/signal.h>
|
||||
#include <list>
|
||||
#include <tr1/functional>
|
||||
|
||||
#include "utils/directory.h"
|
||||
#include "text_input.h"
|
||||
@@ -46,15 +47,19 @@ namespace input {
|
||||
|
||||
class PathInput : public TextInput {
|
||||
public:
|
||||
typedef std::pair<utils::Directory::iterator, utils::Directory::iterator> Range;
|
||||
typedef sigc::signal0<void> Signal;
|
||||
typedef sigc::signal2<void, utils::Directory::iterator, utils::Directory::iterator> SignalShowRange;
|
||||
typedef utils::Directory::iterator directory_itr;
|
||||
typedef std::pair<directory_itr, directory_itr> range_type;
|
||||
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::tr1::function<void (directory_itr, directory_itr)> slot_itr_itr;
|
||||
typedef std::list<slot_void> signal_void;
|
||||
typedef std::list<slot_itr_itr> signal_itr_itr;
|
||||
|
||||
PathInput();
|
||||
virtual ~PathInput() {}
|
||||
|
||||
Signal& signal_show_next() { return m_signalShowNext; }
|
||||
SignalShowRange& signal_show_range() { return m_signalShowRange; }
|
||||
signal_void& signal_show_next() { return m_signal_show_next; }
|
||||
signal_itr_itr& signal_show_range() { return m_signal_show_range; }
|
||||
|
||||
virtual bool pressed(int key);
|
||||
|
||||
@@ -62,12 +67,12 @@ private:
|
||||
void receive_do_complete();
|
||||
|
||||
size_type find_last_delim();
|
||||
Range find_incomplete(utils::Directory& d, const std::string& f);
|
||||
range_type find_incomplete(utils::Directory& d, const std::string& f);
|
||||
|
||||
bool m_showNext;
|
||||
|
||||
Signal m_signalShowNext;
|
||||
SignalShowRange m_signalShowRange;
|
||||
signal_void m_signal_show_next;
|
||||
signal_itr_itr m_signal_show_range;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@
|
||||
|
||||
#include <list>
|
||||
#include <torrent/peer/peer.h>
|
||||
#include <sigc++/connection.h>
|
||||
|
||||
#include "display/manager.h"
|
||||
#include "utils/list_focus.h"
|
||||
|
||||
@@ -38,8 +38,6 @@
|
||||
|
||||
#include <rak/functional.h>
|
||||
#include <rak/string_manip.h>
|
||||
#include <sigc++/adaptors/bind.h>
|
||||
#include <sigc++/adaptors/hide.h>
|
||||
#include <torrent/exceptions.h>
|
||||
#include <torrent/torrent.h>
|
||||
#include <torrent/utils/log.h>
|
||||
@@ -270,11 +268,14 @@ DownloadList::receive_view_input(Input type) {
|
||||
|
||||
ElementStringList* esl = dynamic_cast<ElementStringList*>(m_uiArray[DISPLAY_STRING_LIST]);
|
||||
|
||||
input->signal_show_next().connect(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST));
|
||||
input->signal_show_next().connect(std::tr1::bind(&ElementStringList::next_screen, *esl));
|
||||
input->signal_show_next().push_back(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST));
|
||||
input->signal_show_next().push_back(std::tr1::bind(&ElementStringList::next_screen, *esl));
|
||||
|
||||
input->signal_show_range().connect(sigc::hide(sigc::hide(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST))));
|
||||
input->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range_dirent<utils::Directory::iterator>));
|
||||
input->signal_show_range().push_back(std::tr1::bind(&DownloadList::activate_display, this, DISPLAY_STRING_LIST));
|
||||
input->signal_show_range().push_back(std::tr1::bind(&ElementStringList::set_range_dirent<utils::Directory::iterator>,
|
||||
*esl,
|
||||
std::tr1::placeholders::_1,
|
||||
std::tr1::placeholders::_2));
|
||||
|
||||
input->bindings()['\n'] = std::tr1::bind(&DownloadList::receive_exit_input, this, type);
|
||||
input->bindings()[KEY_ENTER] = std::tr1::bind(&DownloadList::receive_exit_input, this, type);
|
||||
|
||||
+35
-18
@@ -37,7 +37,7 @@
|
||||
#ifndef RTORRENT_UTILS_LIST_FOCUS_H
|
||||
#define RTORRENT_UTILS_LIST_FOCUS_H
|
||||
|
||||
#include <sigc++/signal.h>
|
||||
#include <tr1/functional>
|
||||
|
||||
namespace utils {
|
||||
|
||||
@@ -46,15 +46,18 @@ namespace utils {
|
||||
template <typename Base>
|
||||
class ListFocus {
|
||||
public:
|
||||
typedef typename Base::iterator iterator;
|
||||
typedef typename Base::const_iterator const_iterator;
|
||||
typedef typename Base::reverse_iterator reverse_iterator;
|
||||
typedef typename Base::const_reverse_iterator const_reverse_iterator;
|
||||
typedef Base base_type;
|
||||
typedef std::tr1::function<void ()> slot_void;
|
||||
typedef std::list<slot_void> signal_void;
|
||||
|
||||
typedef typename Base::value_type value_type;
|
||||
typedef sigc::signal0<void> Signal;
|
||||
typedef typename base_type::iterator iterator;
|
||||
typedef typename base_type::const_iterator const_iterator;
|
||||
typedef typename base_type::reverse_iterator reverse_iterator;
|
||||
typedef typename base_type::const_reverse_iterator const_reverse_iterator;
|
||||
|
||||
ListFocus(Base* b = NULL) : m_base(b) { if (b) m_focus = b->end(); }
|
||||
typedef typename base_type::value_type value_type;
|
||||
|
||||
ListFocus(base_type* b = NULL) : m_base(b) { if (b) m_focus = b->end(); }
|
||||
|
||||
// Convinience functions, would have added more through using, but
|
||||
// can't.
|
||||
@@ -64,10 +67,10 @@ public:
|
||||
reverse_iterator rend() { return m_base->rend(); }
|
||||
|
||||
// Don't do erase on this object without making sure focus is right.
|
||||
Base& base() { return *m_base; }
|
||||
base_type& base() { return *m_base; }
|
||||
|
||||
iterator get_focus() { return m_focus; }
|
||||
void set_focus(iterator itr) { m_focus = itr; m_signalChanged.emit(); }
|
||||
void set_focus(iterator itr);
|
||||
|
||||
// These are looping increment/decrements.
|
||||
iterator inc_focus();
|
||||
@@ -77,15 +80,24 @@ public:
|
||||
void remove(const value_type& v);
|
||||
|
||||
// Be careful with copying signals.
|
||||
Signal& signal_changed() { return m_signalChanged; }
|
||||
signal_void& signal_changed() { return m_signal_changed; }
|
||||
|
||||
private:
|
||||
Base* m_base;
|
||||
void emit_changed();
|
||||
|
||||
base_type* m_base;
|
||||
iterator m_focus;
|
||||
|
||||
Signal m_signalChanged;
|
||||
signal_void m_signal_changed;
|
||||
};
|
||||
|
||||
template <typename Base>
|
||||
void
|
||||
ListFocus<Base>::set_focus(iterator itr) {
|
||||
m_focus = itr;
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
typename ListFocus<Base>::iterator
|
||||
ListFocus<Base>::inc_focus() {
|
||||
@@ -94,8 +106,7 @@ ListFocus<Base>::inc_focus() {
|
||||
else
|
||||
m_focus = begin();
|
||||
|
||||
m_signalChanged.emit();
|
||||
|
||||
emit_changed();
|
||||
return m_focus;
|
||||
}
|
||||
|
||||
@@ -107,8 +118,7 @@ ListFocus<Base>::dec_focus() {
|
||||
else
|
||||
m_focus = end();
|
||||
|
||||
m_signalChanged.emit();
|
||||
|
||||
emit_changed();
|
||||
return m_focus;
|
||||
}
|
||||
|
||||
@@ -120,7 +130,7 @@ ListFocus<Base>::erase(iterator itr) {
|
||||
else
|
||||
return m_base->erase(itr);
|
||||
|
||||
m_signalChanged.emit();
|
||||
emit_changed();
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
@@ -136,6 +146,13 @@ ListFocus<Base>::remove(const value_type& v) {
|
||||
++first;
|
||||
}
|
||||
|
||||
template <typename Base>
|
||||
void
|
||||
ListFocus<Base>::emit_changed() {
|
||||
for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++)
|
||||
(*itr)();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user