diff --git a/configure.ac b/configure.ac index 2e6a9eb5..d5a9e6f6 100644 --- a/configure.ac +++ b/configure.ac @@ -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") diff --git a/src/core/manager.cc b/src/core/manager.cc index 7cd58b76..c7373e22 100644 --- a/src/core/manager.cc +++ b/src/core/manager.cc @@ -47,8 +47,6 @@ #include #include #include -#include -#include #include #include #include @@ -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 diff --git a/src/core/view.cc b/src/core/view.cc index 871f98ee..1b5fc09c 100644 --- a/src/core/view.cc +++ b/src/core/view.cc @@ -138,12 +138,18 @@ struct view_downloads_filter : std::unary_function { 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 diff --git a/src/core/view.h b/src/core/view.h index 98d366d3..69d9fb79 100644 --- a/src/core/view.h +++ b/src/core/view.h @@ -52,8 +52,8 @@ #include #include #include -#include #include +#include #include "globals.h" @@ -63,8 +63,9 @@ class Download; class View : private std::vector { public: - typedef std::vector base_type; - typedef sigc::signal0 signal_type; + typedef std::vector base_type; + typedef std::tr1::function slot_void; + typedef std::list 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; }; diff --git a/src/display/window_download_list.cc b/src/display/window_download_list.cc index 0b407138..ead4ddda 100644 --- a/src/display/window_download_list.cc +++ b/src/display/window_download_list.cc @@ -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 diff --git a/src/display/window_download_list.h b/src/display/window_download_list.h index 0fed0c18..8e15cac9 100644 --- a/src/display/window_download_list.h +++ b/src/display/window_download_list.h @@ -37,23 +37,18 @@ #ifndef RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H #define RTORRENT_DISPLAY_WINDOW_DOWNLOAD_LIST_H -#include - #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; }; } diff --git a/src/input/path_input.cc b/src/input/path_input.cc index 2b951b28..04b22f17 100644 --- a/src/input/path_input.cc +++ b/src/input/path_input.cc @@ -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)); diff --git a/src/input/path_input.h b/src/input/path_input.h index 3564aca2..5134f70f 100644 --- a/src/input/path_input.h +++ b/src/input/path_input.h @@ -37,7 +37,8 @@ #ifndef RTORRENT_INPUT_PATH_INPUT_H #define RTORRENT_INPUT_PATH_INPUT_H -#include +#include +#include #include "utils/directory.h" #include "text_input.h" @@ -46,15 +47,19 @@ namespace input { class PathInput : public TextInput { public: - typedef std::pair Range; - typedef sigc::signal0 Signal; - typedef sigc::signal2 SignalShowRange; + typedef utils::Directory::iterator directory_itr; + typedef std::pair range_type; + + typedef std::tr1::function slot_void; + typedef std::tr1::function slot_itr_itr; + typedef std::list signal_void; + typedef std::list 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; }; } diff --git a/src/ui/download.h b/src/ui/download.h index b00622d6..c896c528 100644 --- a/src/ui/download.h +++ b/src/ui/download.h @@ -39,7 +39,6 @@ #include #include -#include #include "display/manager.h" #include "utils/list_focus.h" diff --git a/src/ui/download_list.cc b/src/ui/download_list.cc index 78227e83..58f4646f 100644 --- a/src/ui/download_list.cc +++ b/src/ui/download_list.cc @@ -38,8 +38,6 @@ #include #include -#include -#include #include #include #include @@ -270,11 +268,14 @@ DownloadList::receive_view_input(Input type) { ElementStringList* esl = dynamic_cast(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)); + 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, + *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); diff --git a/src/utils/list_focus.h b/src/utils/list_focus.h index 5ad3ed4c..25cc0af6 100644 --- a/src/utils/list_focus.h +++ b/src/utils/list_focus.h @@ -37,7 +37,7 @@ #ifndef RTORRENT_UTILS_LIST_FOCUS_H #define RTORRENT_UTILS_LIST_FOCUS_H -#include +#include namespace utils { @@ -46,15 +46,18 @@ namespace utils { template 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 slot_void; + typedef std::list signal_void; - typedef typename Base::value_type value_type; - typedef sigc::signal0 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 +void +ListFocus::set_focus(iterator itr) { + m_focus = itr; + emit_changed(); +} + template typename ListFocus::iterator ListFocus::inc_focus() { @@ -94,8 +106,7 @@ ListFocus::inc_focus() { else m_focus = begin(); - m_signalChanged.emit(); - + emit_changed(); return m_focus; } @@ -107,8 +118,7 @@ ListFocus::dec_focus() { else m_focus = end(); - m_signalChanged.emit(); - + emit_changed(); return m_focus; } @@ -120,7 +130,7 @@ ListFocus::erase(iterator itr) { else return m_base->erase(itr); - m_signalChanged.emit(); + emit_changed(); } template @@ -136,6 +146,13 @@ ListFocus::remove(const value_type& v) { ++first; } +template +void +ListFocus::emit_changed() { + for (signal_void::iterator itr = m_signal_changed.begin(), last = m_signal_changed.end(); itr != last; itr++) + (*itr)(); +} + } #endif