Skip to content

Commit

Permalink
Removed all dependencies on sigc++.
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshasa committed Aug 26, 2013
1 parent aa93404 commit 370bae4
Show file tree
Hide file tree
Showing 11 changed files with 101 additions and 70 deletions.
4 changes: 0 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 1 addition & 3 deletions src/core/manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions src/core/view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions src/core/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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;
Expand Down Expand Up @@ -101,7 +102,7 @@ class View : private std::vector<Download*> {

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);
Expand Down Expand Up @@ -143,7 +144,7 @@ class View : private std::vector<Download*> {

// 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&);
Expand All @@ -154,7 +155,8 @@ class View : private std::vector<Download*> {
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(); }

Expand All @@ -176,7 +178,7 @@ class View : private std::vector<Download*> {

rak::timer m_lastChanged;

signal_type m_signalChanged;
signal_void m_signal_changed;
rak::priority_item m_delayChanged;
};

Expand Down
17 changes: 13 additions & 4 deletions src/display/window_download_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
m_view = l;
if (m_view != NULL)
m_view->signal_changed().erase(m_changed_itr);

m_connChanged.disconnect();
m_view = l;

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
Expand Down
15 changes: 5 additions & 10 deletions src/display/window_download_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -63,7 +58,7 @@ class WindowDownloadList : public Window {
private:
core::View* m_view;

sigc::connection m_connChanged;
signal_void_itr m_changed_itr;
};

}
Expand Down
15 changes: 9 additions & 6 deletions src/input/path_input.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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));
Expand Down
23 changes: 14 additions & 9 deletions src/input/path_input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,28 +47,32 @@ 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);

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;
};

}
Expand Down
1 change: 0 additions & 1 deletion src/ui/download.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#include <list>
#include <torrent/peer/peer.h>
#include <sigc++/connection.h>

#include "display/manager.h"
#include "utils/list_focus.h"
Expand Down
13 changes: 7 additions & 6 deletions src/ui/download_list.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 370bae4

Please sign in to comment.