mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-10-08 15:19:20 +00:00
Merge branch 'master' into xirvik
This commit is contained in:
+13
-2
@@ -287,6 +287,16 @@ apply_log_open_file(const torrent::Object::list_type& args) {
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_log_open_gz_file(const torrent::Object::list_type& args) {
|
||||
if (args.size() != 2)
|
||||
throw torrent::input_error("Invalid number of arguments.");
|
||||
|
||||
torrent::log_open_gz_file_output(args.front().as_string().c_str(),
|
||||
rak::path_expand(args.back().as_string()).c_str());
|
||||
return torrent::Object();
|
||||
}
|
||||
|
||||
torrent::Object
|
||||
apply_log_add_output(const torrent::Object::list_type& args) {
|
||||
if (args.size() != 2)
|
||||
@@ -391,8 +401,9 @@ initialize_command_local() {
|
||||
CMD2_EXECUTE ("execute.capture", rpc::ExecFile::flag_throw | rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
|
||||
CMD2_EXECUTE ("execute.capture_nothrow", rpc::ExecFile::flag_expand_tilde | rpc::ExecFile::flag_capture);
|
||||
|
||||
CMD2_ANY_LIST ("log.open_file", tr1::bind(&apply_log_open_file, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.add_output", tr1::bind(&apply_log_add_output, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.open_file", tr1::bind(&apply_log_open_file, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.open_gz_file", tr1::bind(&apply_log_open_gz_file, tr1::placeholders::_2));
|
||||
CMD2_ANY_LIST ("log.add_output", tr1::bind(&apply_log_add_output, tr1::placeholders::_2));
|
||||
|
||||
CMD2_ANY_STRING ("log.execute", tr1::bind(&apply_log, tr1::placeholders::_2, 0));
|
||||
CMD2_ANY_STRING ("log.vmmap.dump", tr1::bind(&log_vmmap_dump, tr1::placeholders::_2));
|
||||
|
||||
@@ -247,7 +247,9 @@ initialize_command_network() {
|
||||
CMD2_VAR_BOOL ("network.port_random", true);
|
||||
CMD2_VAR_STRING ("network.port_range", "6881-6999");
|
||||
|
||||
CMD2_ANY ("network.listen.port", tr1::bind(&torrent::ConnectionManager::listen_port, cm));
|
||||
CMD2_ANY ("network.listen.port", tr1::bind(&torrent::ConnectionManager::listen_port, cm));
|
||||
CMD2_ANY ("network.listen.backlog", tr1::bind(&torrent::ConnectionManager::listen_backlog, cm));
|
||||
CMD2_ANY_VALUE_V ("network.listen.backlog.set", tr1::bind(&torrent::ConnectionManager::set_listen_backlog, cm, tr1::placeholders::_2));
|
||||
|
||||
CMD2_VAR_BOOL ("protocol.pex", true);
|
||||
CMD2_ANY_LIST ("protocol.encryption.set", tr1::bind(&apply_encryption, tr1::placeholders::_2));
|
||||
|
||||
+40
-13
@@ -86,34 +86,44 @@ CurlStack::new_socket(int fd) {
|
||||
|
||||
void
|
||||
CurlStack::receive_action(CurlSocket* socket, int events) {
|
||||
if (this <= (CurlStack*)0x100)
|
||||
throw torrent::internal_error("CurlStack::receive_action(...) called with shit == NULL");
|
||||
|
||||
if (this >= (CurlStack*)0x00007fff00000000)
|
||||
throw torrent::internal_error("CurlStack::receive_action(...) called with this == 0x00007fff00000002");
|
||||
|
||||
if (socket != NULL && socket <= (CurlSocket*)0x100)
|
||||
throw torrent::internal_error("CurlStack::receive_action(...) called with socket == NULL");
|
||||
|
||||
if (socket >= (CurlSocket*)0x00007fff00000000)
|
||||
throw torrent::internal_error("CurlStack::receive_action(...) called with socket == 0x00007fff00000002");
|
||||
|
||||
CURLMcode code;
|
||||
|
||||
do {
|
||||
int count;
|
||||
#if (LIBCURL_VERSION_NUM >= 0x071003)
|
||||
code = curl_multi_socket_action((CURLM*)m_handle, socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT, events, &count);
|
||||
code = curl_multi_socket_action((CURLM*)m_handle,
|
||||
socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT,
|
||||
events,
|
||||
&count);
|
||||
#else
|
||||
code = curl_multi_socket((CURLM*)m_handle, socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT, &count);
|
||||
code = curl_multi_socket((CURLM*)m_handle,
|
||||
socket != NULL ? socket->file_descriptor() : CURL_SOCKET_TIMEOUT,
|
||||
&count);
|
||||
#endif
|
||||
|
||||
if (code > 0)
|
||||
throw torrent::internal_error("Error calling curl_multi_socket_action.");
|
||||
|
||||
// Socket might be removed when cleaning handles below, future calls should not use it.
|
||||
// Socket might be removed when cleaning handles below, future
|
||||
// calls should not use it.
|
||||
socket = NULL;
|
||||
events = 0;
|
||||
|
||||
if ((unsigned int)count != size()) {
|
||||
// Done with some handles.
|
||||
int t;
|
||||
CURLMsg* msg;
|
||||
|
||||
while ((msg = curl_multi_info_read((CURLM*)m_handle, &t)) != NULL) {
|
||||
if (msg->msg != CURLMSG_DONE)
|
||||
throw torrent::internal_error("CurlStack::receive_action() msg->msg != CURLMSG_DONE.");
|
||||
|
||||
transfer_done(msg->easy_handle, msg->data.result == CURLE_OK ? NULL : curl_easy_strerror(msg->data.result));
|
||||
}
|
||||
while (process_done_handle())
|
||||
; // Do nothing.
|
||||
|
||||
if (empty())
|
||||
priority_queue_erase(&taskScheduler, &m_taskTimeout);
|
||||
@@ -122,6 +132,23 @@ CurlStack::receive_action(CurlSocket* socket, int events) {
|
||||
} while (code == CURLM_CALL_MULTI_PERFORM);
|
||||
}
|
||||
|
||||
bool
|
||||
CurlStack::process_done_handle() {
|
||||
int remaining_msgs = 0;
|
||||
CURLMsg* msg = curl_multi_info_read((CURLM*)m_handle, &remaining_msgs);
|
||||
|
||||
if (msg == NULL)
|
||||
return false;
|
||||
|
||||
if (msg->msg != CURLMSG_DONE)
|
||||
throw torrent::internal_error("CurlStack::receive_action() msg->msg != CURLMSG_DONE.");
|
||||
|
||||
transfer_done(msg->easy_handle,
|
||||
msg->data.result == CURLE_OK ? NULL : curl_easy_strerror(msg->data.result));
|
||||
|
||||
return remaining_msgs != 0;
|
||||
}
|
||||
|
||||
void
|
||||
CurlStack::transfer_done(void* handle, const char* msg) {
|
||||
iterator itr = std::find_if(begin(), end(), rak::equal(handle, std::mem_fun(&CurlGet::handle)));
|
||||
|
||||
@@ -125,6 +125,8 @@ class CurlStack : std::deque<CurlGet*> {
|
||||
|
||||
void receive_timeout();
|
||||
|
||||
bool process_done_handle();
|
||||
|
||||
void* m_handle;
|
||||
|
||||
unsigned int m_active;
|
||||
|
||||
+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;
|
||||
};
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/termios.h>
|
||||
#include <termios.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#include "canvas.h"
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+16
-17
@@ -41,14 +41,10 @@
|
||||
#include <rak/functional.h>
|
||||
#include <rak/path.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef __sun__
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#else
|
||||
#include <sys/dir.h>
|
||||
#endif
|
||||
#include <torrent/utils/log.h>
|
||||
|
||||
#include "path_input.h"
|
||||
|
||||
@@ -67,7 +63,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();
|
||||
@@ -78,17 +75,15 @@ PathInput::pressed(int key) {
|
||||
|
||||
struct _transform_filename {
|
||||
void operator () (utils::directory_entry& entry) {
|
||||
#ifdef __sun__
|
||||
if (entry.d_type & S_IFDIR)
|
||||
#else
|
||||
if (entry.d_type == DT_DIR)
|
||||
#endif
|
||||
entry.d_name += '/';
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
PathInput::receive_do_complete() {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: received completion");
|
||||
|
||||
size_type dirEnd = find_last_delim();
|
||||
|
||||
utils::Directory dir(dirEnd != 0 ? str().substr(0, dirEnd) : "./");
|
||||
@@ -101,7 +96,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 +116,12 @@ 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) {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "path_input: show next page");
|
||||
|
||||
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 +146,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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#ifndef RTORRENT_SIGNAL_HANDLER_H
|
||||
#define RTORRENT_SIGNAL_HANDLER_H
|
||||
|
||||
#include <sys/signal.h>
|
||||
#include <signal.h>
|
||||
#include <tr1/functional>
|
||||
|
||||
class SignalHandler {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -55,6 +55,8 @@ ElementStringList::activate(display::Frame* frame, bool focus) {
|
||||
if (is_active())
|
||||
throw torrent::internal_error("ui::ElementStringList::activate(...) is_active().");
|
||||
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: activate");
|
||||
|
||||
control->input()->push_back(&m_bindings);
|
||||
|
||||
m_window = new WStringList();
|
||||
@@ -69,6 +71,8 @@ ElementStringList::disable() {
|
||||
if (!is_active())
|
||||
throw torrent::internal_error("ui::ElementStringList::disable(...) !is_active().");
|
||||
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: deactivate");
|
||||
|
||||
control->input()->erase(&m_bindings);
|
||||
|
||||
m_frame->clear();
|
||||
@@ -80,6 +84,9 @@ ElementStringList::disable() {
|
||||
|
||||
void
|
||||
ElementStringList::next_screen() {
|
||||
if (m_window == NULL)
|
||||
return;
|
||||
|
||||
if (m_window->get_draw_end() != m_list.end())
|
||||
m_window->set_range(m_window->get_draw_end(), m_list.end());
|
||||
else
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <torrent/utils/log.h>
|
||||
|
||||
#include "element_base.h"
|
||||
|
||||
@@ -69,8 +70,14 @@ public:
|
||||
while (first != last)
|
||||
m_list.push_back(*(first++));
|
||||
|
||||
m_window->set_range(m_list.begin(), m_list.end());
|
||||
m_window->mark_dirty();
|
||||
if (m_window != NULL) {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set range (visible)");
|
||||
|
||||
m_window->set_range(m_list.begin(), m_list.end());
|
||||
m_window->mark_dirty();
|
||||
} else {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set range (hidden)");
|
||||
}
|
||||
}
|
||||
|
||||
// A hack, clean this up.
|
||||
@@ -81,8 +88,14 @@ public:
|
||||
while (first != last)
|
||||
m_list.push_back((first++)->d_name);
|
||||
|
||||
m_window->set_range(m_list.begin(), m_list.end());
|
||||
m_window->mark_dirty();
|
||||
if (m_window != NULL) {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set dirent range (visible)");
|
||||
|
||||
m_window->set_range(m_list.begin(), m_list.end());
|
||||
m_window->mark_dirty();
|
||||
} else {
|
||||
lt_log_print(torrent::LOG_UI_EVENTS, "element_string_list: set dirent range (hidden)");
|
||||
}
|
||||
}
|
||||
|
||||
void next_screen();
|
||||
|
||||
@@ -38,14 +38,12 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include <rak/path.h>
|
||||
#include <torrent/exceptions.h>
|
||||
|
||||
#ifdef __sun__
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include "directory.h"
|
||||
|
||||
namespace utils {
|
||||
|
||||
+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