* UI refactoring, added display::Frame and started cleaning up the

code.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@747 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2006-07-26 21:41:09 +00:00
parent ef90f0f51e
commit fc76a11d71
41 changed files with 889 additions and 471 deletions
+30 -31
View File
@@ -50,6 +50,7 @@
#include "control.h"
#include "download.h"
#include "root.h"
#include "element_file_list.h"
#include "element_peer_info.h"
#include "element_peer_list.h"
@@ -63,11 +64,8 @@ Download::Download(DPtr d, Control* c) :
m_download(d),
m_state(DISPLAY_MAX_SIZE),
m_windowTitle(new WTitle(d->download()->name())),
m_windowDownloadStatus(new WDownloadStatus(d)),
m_window(c->display()->end()),
m_control(c),
m_bindings(new input::Bindings) {
@@ -89,8 +87,8 @@ Download::Download(DPtr d, Control* c) :
}
Download::~Download() {
if (m_window != m_control->display()->end())
throw std::logic_error("ui::Download::~Download() called on an active object");
// if (m_window != m_control->display()->end())
// throw std::logic_error("ui::Download::~Download() called on an active object");
m_connPeerConnected.disconnect();
m_connPeerDisconnected.disconnect();
@@ -99,18 +97,19 @@ Download::~Download() {
std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, rak::call_delete<ElementBase>());
delete m_windowTitle;
delete m_windowDownloadStatus;
}
void
Download::activate() {
if (m_window != m_control->display()->end())
throw std::logic_error("ui::Download::activate() called on an already activated object");
// if (m_window != m_control->display()->end())
// throw std::logic_error("ui::Download::activate() called on an already activated object");
m_control->display()->push_front(m_windowDownloadStatus);
m_window = m_control->display()->insert(m_control->display()->begin(), NULL);
m_control->display()->push_front(m_windowTitle);
m_control->ui()->window_title()->set_title(m_download->download()->name());
// m_control->display()->push_front(m_windowDownloadStatus);
// m_window = m_control->display()->insert(m_control->display()->begin(), NULL);
// m_control->display()->push_front(m_control->ui()->window_title());
m_control->input()->push_front(m_bindings);
@@ -119,30 +118,30 @@ Download::activate() {
void
Download::disable() {
if (m_window == m_control->display()->end())
throw std::logic_error("ui::Download::disable() called on an already disabled object");
// if (m_window == m_control->display()->end())
// throw std::logic_error("ui::Download::disable() called on an already disabled object");
disable_display();
m_control->display()->erase(m_window);
m_control->display()->erase(m_windowTitle);
m_control->display()->erase(m_windowDownloadStatus);
// m_control->display()->erase(m_window);
// m_control->display()->erase(m_control->ui()->window_title());
// m_control->display()->erase(m_windowDownloadStatus);
m_window = m_control->display()->end();
// m_window = m_control->display()->end();
m_control->input()->erase(m_bindings);
}
void
Download::activate_display(Display d) {
if (m_window == m_control->display()->end())
throw std::logic_error("ui::Download::activate_display(...) could not find previous display iterator");
// if (m_window == m_control->display()->end())
// throw std::logic_error("ui::Download::activate_display(...) could not find previous display iterator");
if (d >= DISPLAY_MAX_SIZE)
throw std::logic_error("ui::Download::activate_display(...) out of bounds");
m_state = d;
m_uiArray[d]->activate(m_control, m_window);
// m_uiArray[d]->activate(m_control, m_window);
m_control->display()->adjust_layout();
}
@@ -150,10 +149,10 @@ Download::activate_display(Display d) {
// Does not delete disabled window.
void
Download::disable_display() {
m_uiArray[m_state]->disable(m_control);
m_uiArray[m_state]->disable();
m_state = DISPLAY_MAX_SIZE;
*m_window = NULL;
// *m_window = NULL;
}
void
@@ -279,21 +278,21 @@ Download::bind_keys() {
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(this, &Download::receive_next);
// Key bindings for sub-ui's.
m_uiArray[DISPLAY_PEER_LIST]->get_bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_FILE_LIST);
m_uiArray[DISPLAY_PEER_INFO]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_FILE_LIST]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_TRACKER_LIST]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_CHUNKS_SEEN]->get_bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_TRANSFER_LIST]->get_bindings()[KEY_LEFT]= sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_PEER_LIST]->bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_FILE_LIST);
m_uiArray[DISPLAY_PEER_INFO]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_FILE_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_TRACKER_LIST]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_CHUNKS_SEEN]->bindings()[KEY_LEFT] = sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
m_uiArray[DISPLAY_TRANSFER_LIST]->bindings()[KEY_LEFT]= sigc::bind(sigc::mem_fun(this, &Download::receive_change), DISPLAY_PEER_LIST);
// Doesn't belong here.
m_uiArray[DISPLAY_PEER_LIST]->get_bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
m_uiArray[DISPLAY_PEER_INFO]->get_bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
m_uiArray[DISPLAY_PEER_LIST]->bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
m_uiArray[DISPLAY_PEER_INFO]->bindings()['*'] = sigc::mem_fun(this, &Download::receive_snub_peer);
}
void
Download::mark_dirty() {
(*m_window)->mark_dirty();
// (*m_window)->mark_dirty();
}
}
+2 -5
View File
@@ -47,6 +47,7 @@
class Control;
namespace display {
class Frame;
class WindowTitle;
class WindowStatusbar;
class WindowDownloadStatusbar;
@@ -62,12 +63,10 @@ class ElementBase;
class Download {
public:
typedef display::WindowTitle WTitle;
typedef display::WindowDownloadStatusbar WDownloadStatus;
typedef core::Download* DPtr;
typedef std::list<torrent::Peer> PList;
typedef display::Manager::iterator MItr;
typedef enum {
DISPLAY_PEER_LIST,
@@ -122,13 +121,11 @@ private:
Display m_state;
display::Frame* m_frame;
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
WTitle* m_windowTitle;
WDownloadStatus* m_windowDownloadStatus;
MItr m_window;
Control* m_control;
input::Bindings* m_bindings;
+156 -163
View File
@@ -36,7 +36,6 @@
#include "config.h"
#include <stdexcept>
#include <rak/functional.h>
#include <rak/string_manip.h>
#include <sigc++/bind.h>
@@ -54,8 +53,6 @@
#include "input/manager.h"
#include "input/path_input.h"
#include "display/window_http_queue.h"
#include "display/window_input.h"
#include "display/window_log.h"
#include "display/window_title.h"
#include "display/window_statusbar.h"
@@ -70,22 +67,16 @@
namespace ui {
DownloadList::DownloadList(Control* c) :
m_state(DISPLAY_MAX_SIZE),
DownloadList::DownloadList() :
m_state(DISPLAY_NONE),
m_window(c->display()->end()),
m_uiDownload(NULL) {
m_windowTitle(new WTitle("rTorrent " VERSION " - libTorrent " + std::string(torrent::version()))),
m_windowHttpQueue(new WHttp(c->core()->http_queue())),
m_uiDownload(NULL),
m_control(c),
m_bindings(new input::Bindings)
{
m_uiArray[DISPLAY_DOWNLOAD_LIST] = new ElementDownloadList();
m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&m_control->core()->get_log_complete());
m_windowLog = new WLog(&m_control->core()->get_log_important());
m_uiArray[DISPLAY_LOG] = new ElementLogComplete(&control->core()->get_log_complete());
m_uiArray[DISPLAY_STRING_LIST] = new ElementStringList();
m_windowLog = new WLog(&control->core()->get_log_important());
receive_change_view("main");
@@ -95,7 +86,6 @@ DownloadList::DownloadList(Control* c) :
m_taskUpdate.set_slot(rak::mem_fn(this, &DownloadList::task_update)),
setup_keys();
setup_input();
}
DownloadList::~DownloadList() {
@@ -104,33 +94,20 @@ DownloadList::~DownloadList() {
std::for_each(m_uiArray, m_uiArray + DISPLAY_MAX_SIZE, rak::call_delete<ElementBase>());
delete m_windowTitle;
delete m_bindings;
delete m_windowLog;
delete m_windowTextInput->get_input();
delete m_windowTextInput;
delete m_windowHttpQueue;
}
void
DownloadList::activate() {
DownloadList::activate(display::Frame* frame) {
if (is_active())
throw std::logic_error("ui::Download::activate() called on an already activated object");
throw torrent::client_error("ui::DownloadList::activate() called on an already activated object");
priority_queue_insert(&taskScheduler, &m_taskUpdate, cachedTime);
m_windowTextInput->set_active(false);
m_frame = frame;
m_control->display()->push_front(m_windowTextInput);
m_control->display()->push_front(m_windowHttpQueue);
m_control->display()->push_front(m_windowLog);
m_window = m_control->display()->insert(m_control->display()->begin(), NULL);
m_control->display()->push_front(m_windowTitle);
m_control->input()->push_front(m_bindings);
m_control->core()->download_list()->slot_map_erase()["0_download_list"] = sigc::mem_fun(this, &DownloadList::receive_download_erased);
control->input()->push_front(&m_bindings);
control->core()->download_list()->slot_map_erase()["0_download_list"] = sigc::mem_fun(this, &DownloadList::receive_download_erased);
activate_display(DISPLAY_DOWNLOAD_LIST);
}
@@ -138,49 +115,74 @@ DownloadList::activate() {
void
DownloadList::disable() {
if (!is_active())
throw std::logic_error("ui::Download::disable() called on an already disabled object");
throw std::logic_error("ui::DownloadList::disable() called on an already disabled object");
if (m_windowTextInput->is_active()) {
m_windowTextInput->get_input()->clear();
receive_exit_input(INPUT_NONE);
}
// if (m_windowTextInput->is_active()) {
// m_windowTextInput->get_input()->clear();
// receive_exit_input(INPUT_NONE);
// }
disable_display();
activate_display(DISPLAY_NONE);
m_frame = NULL;
priority_queue_erase(&taskScheduler, &m_taskUpdate);
m_control->display()->erase(m_window);
m_control->display()->erase(m_windowTitle);
m_control->display()->erase(m_windowTextInput);
m_control->display()->erase(m_windowLog);
m_control->display()->erase(m_windowHttpQueue);
m_window = m_control->display()->end();
m_control->input()->erase(m_bindings);
control->input()->erase(&m_bindings);
}
void
DownloadList::activate_display(Display d) {
DownloadList::activate_display(Display displayType) {
if (!is_active())
throw std::logic_error("ui::DownloadList::activate_display(...) could not find previous display iterator");
throw std::logic_error("ui::DownloadList::activate_display(...) !is_active().");
if (d >= DISPLAY_MAX_SIZE)
if (displayType >= DISPLAY_MAX_SIZE)
throw std::logic_error("ui::DownloadList::activate_display(...) out of bounds");
m_state = d;
m_uiArray[d]->activate(m_control, m_window);
if (displayType == m_state)
return;
m_control->display()->adjust_layout();
// Don't use default.
// Cleanup previous state.
switch (m_state) {
case DISPLAY_DOWNLOAD_LIST:
case DISPLAY_LOG:
m_uiArray[m_state]->disable();
break;
default:
break;
}
m_state = displayType;
// Initialize new state.
switch (displayType) {
case DISPLAY_NONE:
break;
case DISPLAY_DOWNLOAD_LIST:
control->ui()->window_title()->set_title("rTorrent " VERSION " - libTorrent " + std::string(torrent::version()));
m_uiArray[displayType]->activate(m_frame);
break;
case DISPLAY_LOG:
control->ui()->window_title()->set_title("Log");
m_uiArray[displayType]->activate(m_frame);
break;
default:
break;
}
control->display()->adjust_layout();
}
// Does not delete disabled window.
void
DownloadList::disable_display() {
m_uiArray[m_state]->disable(m_control);
m_state = DISPLAY_MAX_SIZE;
*m_window = NULL;
display::Window*
DownloadList::window() {
return NULL;
}
void
@@ -200,7 +202,7 @@ DownloadList::receive_start_download() {
if (m_view->focus() == m_view->end_visible())
return;
m_control->core()->download_list()->start_normal(*m_view->focus());
control->core()->download_list()->start_normal(*m_view->focus());
m_view->set_last_changed();
}
@@ -210,9 +212,9 @@ DownloadList::receive_stop_download() {
return;
if ((*m_view->focus())->variable()->get_value("state") == 1)
m_control->core()->download_list()->stop_normal(*m_view->focus());
control->core()->download_list()->stop_normal(*m_view->focus());
else
m_control->core()->download_list()->erase(*m_view->focus());
control->core()->download_list()->erase(*m_view->focus());
m_view->set_last_changed();
}
@@ -222,8 +224,8 @@ DownloadList::receive_close_download() {
if (m_view->focus() == m_view->end_visible())
return;
m_control->core()->download_list()->stop_normal(*m_view->focus());
m_control->core()->download_list()->close(*m_view->focus());
control->core()->download_list()->stop_normal(*m_view->focus());
control->core()->download_list()->close(*m_view->focus());
m_view->set_last_changed();
}
@@ -237,7 +239,7 @@ DownloadList::receive_view_download() {
disable();
m_uiDownload = new Download(*m_view->focus(), m_control);
m_uiDownload = new Download(*m_view->focus(), control);
m_uiDownload->activate();
m_uiDownload->get_bindings()[KEY_LEFT] = sigc::mem_fun(*this, &DownloadList::receive_exit_download);
@@ -253,9 +255,9 @@ DownloadList::receive_exit_download() {
m_uiDownload = NULL;
m_view->set_last_changed();
activate();
activate(m_frame);
m_control->display()->adjust_layout();
control->display()->adjust_layout();
}
void
@@ -264,7 +266,7 @@ DownloadList::receive_next_priority() {
return;
(*m_view->focus())->set_priority(((*m_view->focus())->priority() + 1) % 4);
(*m_window)->mark_dirty();
// (*m_window)->mark_dirty();
}
void
@@ -273,7 +275,7 @@ DownloadList::receive_prev_priority() {
return;
(*m_view->focus())->set_priority(((*m_view->focus())->priority() - 1) % 4);
(*m_window)->mark_dirty();
// (*m_window)->mark_dirty();
}
void
@@ -282,7 +284,7 @@ DownloadList::receive_check_hash() {
return;
// Catch here?
m_control->core()->download_list()->check_hash(*m_view->focus());
control->core()->download_list()->check_hash(*m_view->focus());
}
void
@@ -292,10 +294,10 @@ DownloadList::receive_ignore_ratio() {
if ((*m_view->focus())->variable()->get_value("ignore_commands") != 0) {
(*m_view->focus())->variable()->set("ignore_commands", (int64_t)0);
m_control->core()->push_log("Torrent set to heed commands.");
control->core()->push_log("Torrent set to heed commands.");
} else {
(*m_view->focus())->variable()->set("ignore_commands", (int64_t)1);
m_control->core()->push_log("Torrent set to ignore commands");
control->core()->push_log("Torrent set to ignore commands.");
}
}
@@ -308,44 +310,56 @@ DownloadList::receive_clear_tied() {
if (!tiedFile.empty()) {
// Move this into core?
m_control->core()->delete_tied(*m_view->focus());
control->core()->delete_tied(*m_view->focus());
m_control->core()->push_log("Cleared tied to file association for download.");
control->core()->push_log("Cleared tied to file association for download.");
}
}
void
DownloadList::receive_view_input(Input type) {
if (m_windowTextInput->get_active())
if (control->ui()->current_input() != NULL)
return;
m_control->ui()->window_statusbar()->set_active(false);
m_windowTextInput->set_active(true);
m_control->display()->adjust_layout();
input::PathInput* input = new input::PathInput;
m_control->input()->set_text_input(m_windowTextInput->get_input());
switch (type) {
case INPUT_CHANGE_DIRECTORY:
input->str() = control->variable()->get_string("directory");
input->set_pos(input->str().length());
m_windowTextInput->set_focus(true);
break;
if (type == INPUT_CHANGE_DIRECTORY) {
m_windowTextInput->get_input()->str() = m_control->variable()->get_string("directory");
m_windowTextInput->get_input()->set_pos(m_windowTextInput->get_input()->str().length());
default:
break;
}
(*m_bindings)['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
(*m_bindings)[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
(*m_bindings)['\x07'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), INPUT_NONE);
control->ui()->enable_input(input);
// These bindings should be moved to f.ex TextInput?
m_bindings['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
m_bindings[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), type);
m_bindings['\x07'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_exit_input), INPUT_NONE);
}
void
DownloadList::receive_exit_input(Input type) {
if (!m_windowTextInput->get_active())
input::TextInput* input = control->ui()->current_input();
// We should check that this object is the one holding the input.
if (input == NULL)
return;
m_control->ui()->window_statusbar()->set_active(true);
m_windowTextInput->set_active(false);
m_control->input()->set_text_input();
control->ui()->disable_input();
// Urgh... this is ugly...
m_bindings.erase('\n');
m_bindings.erase(KEY_ENTER);
m_bindings.erase('\x07');
m_bindings['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
m_bindings[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
try {
switch (type) {
@@ -354,47 +368,27 @@ DownloadList::receive_exit_input(Input type) {
case INPUT_LOAD_DEFAULT:
case INPUT_LOAD_MODIFIED:
m_control->core()->try_create_download_expand(m_windowTextInput->get_input()->str(), type == INPUT_LOAD_DEFAULT);
control->core()->try_create_download_expand(input->str(), type == INPUT_LOAD_DEFAULT);
break;
case INPUT_CHANGE_DIRECTORY:
if (m_view->focus() == m_view->end_visible())
throw torrent::input_error("No download in focus to change root directory.");
(*m_view->focus())->variable()->set("directory", rak::trim(m_windowTextInput->get_input()->str()));
m_control->core()->push_log("New root dir \"" + (*m_view->focus())->variable()->get_string("directory") + "\" for torrent.");
(*m_view->focus())->variable()->set("directory", rak::trim(input->str()));
control->core()->push_log("New root directory \"" + (*m_view->focus())->variable()->get_string("directory") + "\" for torrent.");
break;
case INPUT_COMMAND:
m_control->variable()->process_command(m_windowTextInput->get_input()->str());
control->variable()->process_command(input->str());
break;
}
} catch (torrent::input_error& e) {
m_control->core()->push_log(e.what());
control->core()->push_log(e.what());
}
// Clean up.
m_windowTextInput->get_input()->clear();
m_windowTextInput->set_focus(false);
m_bindings->erase('\n');
m_bindings->erase(KEY_ENTER);
// Urgh... this is ugly...
(*m_bindings)['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
(*m_bindings)[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
receive_change(DISPLAY_DOWNLOAD_LIST);
}
void
DownloadList::receive_change(Display d) {
if (d == m_state)
return;
disable_display();
activate_display(d);
delete input;
}
void
@@ -410,10 +404,10 @@ DownloadList::receive_download_erased(core::Download* d) {
void
DownloadList::receive_change_view(const std::string& name) {
core::ViewManager::iterator itr = m_control->view_manager()->find(name);
core::ViewManager::iterator itr = control->view_manager()->find(name);
if (itr == m_control->view_manager()->end()) {
m_control->core()->push_log("Could not find view \"" + name + "\".");
if (itr == control->view_manager()->end()) {
control->core()->push_log("Could not find view \"" + name + "\".");
return;
}
@@ -437,53 +431,52 @@ DownloadList::task_update() {
void
DownloadList::setup_keys() {
(*m_bindings)['\x13'] = sigc::mem_fun(*this, &DownloadList::receive_start_download);
(*m_bindings)['\x04'] = sigc::mem_fun(*this, &DownloadList::receive_stop_download);
(*m_bindings)['\x0B'] = sigc::mem_fun(*this, &DownloadList::receive_close_download);
(*m_bindings)['\x12'] = sigc::mem_fun(*this, &DownloadList::receive_check_hash);
(*m_bindings)['+'] = sigc::mem_fun(*this, &DownloadList::receive_next_priority);
(*m_bindings)['-'] = sigc::mem_fun(*this, &DownloadList::receive_prev_priority);
(*m_bindings)['I'] = sigc::mem_fun(*this, &DownloadList::receive_ignore_ratio);
(*m_bindings)['U'] = sigc::mem_fun(*this, &DownloadList::receive_clear_tied);
m_bindings['\x13'] = sigc::mem_fun(*this, &DownloadList::receive_start_download);
m_bindings['\x04'] = sigc::mem_fun(*this, &DownloadList::receive_stop_download);
m_bindings['\x0B'] = sigc::mem_fun(*this, &DownloadList::receive_close_download);
m_bindings['\x12'] = sigc::mem_fun(*this, &DownloadList::receive_check_hash);
m_bindings['+'] = sigc::mem_fun(*this, &DownloadList::receive_next_priority);
m_bindings['-'] = sigc::mem_fun(*this, &DownloadList::receive_prev_priority);
m_bindings['I'] = sigc::mem_fun(*this, &DownloadList::receive_ignore_ratio);
m_bindings['U'] = sigc::mem_fun(*this, &DownloadList::receive_clear_tied);
(*m_bindings)['\x7f'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_DEFAULT);
(*m_bindings)[KEY_BACKSPACE] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_DEFAULT);
(*m_bindings)['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
(*m_bindings)[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
(*m_bindings)['\x0F'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_CHANGE_DIRECTORY);
(*m_bindings)['\x10'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_COMMAND);
m_bindings['\x7f'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_DEFAULT);
m_bindings[KEY_BACKSPACE] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_DEFAULT);
m_bindings['\n'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
m_bindings[KEY_ENTER] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_LOAD_MODIFIED);
m_bindings['\x0F'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_CHANGE_DIRECTORY);
m_bindings['\x10'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_view_input), INPUT_COMMAND);
(*m_bindings)[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
(*m_bindings)[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
(*m_bindings)[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
(*m_bindings)['l'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_LOG);
m_bindings[KEY_UP] = sigc::mem_fun(*this, &DownloadList::receive_prev);
m_bindings[KEY_DOWN] = sigc::mem_fun(*this, &DownloadList::receive_next);
m_bindings[KEY_RIGHT] = sigc::mem_fun(*this, &DownloadList::receive_view_download);
m_bindings['l'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_LOG);
(*m_bindings)['1'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "main");
(*m_bindings)['2'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "name");
(*m_bindings)['3'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "started");
(*m_bindings)['4'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "stopped");
(*m_bindings)['5'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "complete");
(*m_bindings)['6'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "incomplete");
(*m_bindings)['7'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "hashing");
m_bindings['1'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "main");
m_bindings['2'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "name");
m_bindings['3'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "started");
m_bindings['4'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "stopped");
m_bindings['5'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "complete");
m_bindings['6'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "incomplete");
m_bindings['7'] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change_view), "hashing");
m_uiArray[DISPLAY_LOG]->get_bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_DOWNLOAD_LIST);
m_uiArray[DISPLAY_LOG]->bindings()[' '] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
m_uiArray[DISPLAY_LOG]->bindings()[KEY_RIGHT] = sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_DOWNLOAD_LIST);
}
void
DownloadList::setup_input() {
input::PathInput* p = new input::PathInput;
ElementStringList* esl = new ElementStringList();
m_windowTextInput = new WInput(p);
// void
// DownloadList::setup_input() {
// input::PathInput* p = new input::PathInput;
// m_windowTextInput = new WInput(p);
p->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
// p->slot_dirty(sigc::mem_fun(*m_windowTextInput, &WInput::mark_dirty));
p->signal_show_next().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_STRING_LIST));
p->signal_show_next().connect(sigc::mem_fun(*esl, &ElementStringList::next_screen));
// p->signal_show_next().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_STRING_LIST));
// p->signal_show_next().connect(sigc::mem_fun(*esl, &ElementStringList::next_screen));
p->signal_show_range().connect(sigc::hide(sigc::hide(sigc::bind(sigc::mem_fun(*this, &DownloadList::receive_change), DISPLAY_STRING_LIST))));
p->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range<utils::Directory::iterator>));
// p->signal_show_range().connect(sigc::hide(sigc::hide(sigc::bind(sigc::mem_fun(*this, &DownloadList::activate_display), DISPLAY_STRING_LIST))));
// p->signal_show_range().connect(sigc::mem_fun(*esl, &ElementStringList::set_range<utils::Directory::iterator>));
m_uiArray[DISPLAY_STRING_LIST] = esl;
}
// }
}
+8 -25
View File
@@ -41,6 +41,7 @@
#include "display/manager.h"
#include "element_base.h"
#include "globals.h"
class Control;
@@ -55,33 +56,28 @@ namespace input {
}
namespace display {
class Frame;
class WindowDownloadList;
class WindowHttpQueue;
class WindowInput;
class WindowLog;
class WindowLogComplete;
class WindowTitle;
}
namespace ui {
class Download;
class ElementBase;
class DownloadList {
class DownloadList : public ElementBase {
public:
typedef display::WindowDownloadList WList;
typedef display::WindowHttpQueue WHttp;
typedef display::WindowInput WInput;
typedef display::WindowLog WLog;
typedef display::WindowLogComplete WLogComplete;
typedef display::WindowTitle WTitle;
typedef sigc::slot1<void, const std::string&> SlotOpenUri;
typedef display::Manager::iterator MItr;
typedef enum {
DISPLAY_NONE,
DISPLAY_DOWNLOAD_LIST,
DISPLAY_LOG,
DISPLAY_STRING_LIST,
@@ -96,18 +92,15 @@ public:
INPUT_COMMAND
} Input;
DownloadList(Control* c);
DownloadList();
~DownloadList();
input::Bindings& get_bindings() { return *m_bindings; }
bool is_active() const { return m_window != m_control->display()->end(); }
void activate();
void activate(display::Frame* frame);
void disable();
void activate_display(Display d);
void disable_display();
display::Window* window();
void slot_open_uri(SlotOpenUri s) { m_slotOpenUri = s; }
@@ -136,8 +129,6 @@ private:
void receive_view_input(Input type);
void receive_exit_input(Input type);
void receive_change(Display d);
void receive_download_erased(core::Download* d);
void receive_change_view(const std::string& name);
@@ -151,12 +142,7 @@ private:
ElementBase* m_uiArray[DISPLAY_MAX_SIZE];
MItr m_window;
WTitle* m_windowTitle;
WLog* m_windowLog;
WInput* m_windowTextInput;
WHttp* m_windowHttpQueue;
rak::priority_item m_taskUpdate;
@@ -164,9 +150,6 @@ private:
core::View* m_view;
Control* m_control;
input::Bindings* m_bindings;
SlotOpenUri m_slotOpenUri;
};
+15 -6
View File
@@ -37,23 +37,32 @@
#ifndef RTORRENT_UI_ELEMENT_BASE_H
#define RTORRENT_UI_ELEMENT_BASE_H
#include "display/manager.h"
#include "input/bindings.h"
namespace display {
class Frame;
class Window;
}
namespace ui {
class ElementBase {
public:
typedef display::Manager::iterator MItr;
ElementBase() : m_frame(NULL) {}
virtual ~ElementBase() {}
virtual void activate(Control* c, MItr mItr) = 0;
virtual void disable(Control* c) = 0;
bool is_active() const { return m_frame != NULL; }
input::Bindings& get_bindings() { return m_bindings; }
input::Bindings& bindings() { return m_bindings; }
virtual void activate(display::Frame* frame) = 0;
virtual void disable() = 0;
virtual display::Window* window() = 0;
protected:
display::Frame* m_frame;
input::Bindings m_bindings;
};
+16 -10
View File
@@ -36,7 +36,7 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "display/window_download_chunks_seen.h"
#include "input/manager.h"
@@ -60,26 +60,32 @@ ElementChunksSeen::ElementChunksSeen(core::Download* d) :
}
void
ElementChunksSeen::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementChunksSeen::activate(...) called on an object in the wrong state");
ElementChunksSeen::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementChunksSeen::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WChunksSeen(m_download, &m_focus);
m_window = new WChunksSeen(m_download, &m_focus);
m_frame = frame;
}
void
ElementChunksSeen::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementChunksSeen::disable(...) called on an object in the wrong state");
ElementChunksSeen::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementChunksSeen::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
}
display::Window*
ElementChunksSeen::window() {
return m_window;
}
// void
// ElementChunksSeen::receive_disable() {
// if (m_window == NULL)
+4 -2
View File
@@ -55,8 +55,10 @@ public:
ElementChunksSeen(core::Download* d);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
// void receive_disable();
+18 -10
View File
@@ -36,8 +36,10 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "display/frame.h"
#include "display/manager.h"
#include "input/manager.h"
#include "control.h"
@@ -46,24 +48,30 @@
namespace ui {
void
ElementDownloadList::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementDownloadList::activate(...) called on an object in the wrong state");
ElementDownloadList::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementDownloadList::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
m_window = new WDownloadList();
m_window->set_view(m_view);
*mItr = m_window;
m_frame = frame;
m_frame->initialize_window(m_window);
control->display()->schedule(m_window, cachedTime);
}
void
ElementDownloadList::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementDownloadList::disable(...) called on an object in the wrong state");
ElementDownloadList::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementDownloadList::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
m_frame->clear();
m_frame = NULL;
delete m_window;
m_window = NULL;
+4 -2
View File
@@ -56,8 +56,10 @@ public:
ElementDownloadList() : m_window(NULL), m_view(NULL) {}
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window() { return m_window; }
void set_view(core::View* l);
+13 -7
View File
@@ -61,26 +61,32 @@ ElementFileList::ElementFileList(core::Download* d) :
}
void
ElementFileList::activate(Control* c, MItr mItr) {
ElementFileList::activate(display::Frame* frame) {
if (m_window != NULL)
throw torrent::client_error("ui::ElementFileList::activate(...) called on an object in the wrong state");
throw torrent::client_error("ui::ElementFileList::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WFileList(m_download, &m_focus);
// *mItr = m_window = new WFileList(m_download, &m_focus);
m_frame = frame;
}
void
ElementFileList::disable(Control* c) {
ElementFileList::disable() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementFileList::disable(...) called on an object in the wrong state");
throw torrent::client_error("ui::ElementFileList::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
}
display::Window*
ElementFileList::window() {
return m_window;
}
void
ElementFileList::receive_next() {
if (m_window == NULL)
+4 -2
View File
@@ -58,8 +58,10 @@ public:
ElementFileList(core::Download* d);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
void receive_next();
+25 -10
View File
@@ -36,8 +36,10 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "display/frame.h"
#include "display/manager.h"
#include "display/window_log_complete.h"
#include "input/manager.h"
@@ -52,24 +54,37 @@ ElementLogComplete::ElementLogComplete(core::Log* l) :
}
void
ElementLogComplete::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementLogComplete::activate(...) called on an object in the wrong state");
ElementLogComplete::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementLogComplete::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WLogComplete(m_log);
m_window = new WLogComplete(m_log);
m_frame = frame;
m_frame->initialize_window(m_window);
control->display()->schedule(m_window, cachedTime);
}
void
ElementLogComplete::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementLogComplete::disable(...) called on an object in the wrong state");
ElementLogComplete::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementLogComplete::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
m_frame->clear();
m_frame = NULL;
delete m_window;
m_window = NULL;
}
display::Window*
ElementLogComplete::window() {
return m_window;
}
}
+4 -2
View File
@@ -55,8 +55,10 @@ public:
ElementLogComplete(core::Log* l);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
WLogComplete* m_window;
+16 -10
View File
@@ -36,7 +36,7 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "display/window_peer_info.h"
#include "input/manager.h"
@@ -55,24 +55,30 @@ ElementPeerInfo::ElementPeerInfo(core::Download* d, PList* l, PList::iterator* f
}
void
ElementPeerInfo::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementPeerInfo::activate(...) called on an object in the wrong state");
ElementPeerInfo::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementPeerInfo::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WPeerInfo(m_download, m_list, m_focus);
m_window = new WPeerInfo(m_download, m_list, m_focus);
m_frame = frame;
}
void
ElementPeerInfo::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementPeerInfo::disable(...) called on an object in the wrong state");
ElementPeerInfo::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementPeerInfo::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
}
display::Window*
ElementPeerInfo::window() {
return m_window;
}
}
+4 -2
View File
@@ -56,8 +56,10 @@ public:
ElementPeerInfo(core::Download* d, PList* l, PList::iterator* f);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
core::Download* m_download;
+16 -10
View File
@@ -36,7 +36,7 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "display/window_peer_list.h"
#include "input/manager.h"
@@ -55,24 +55,30 @@ ElementPeerList::ElementPeerList(core::Download* d, PList* l, PList::iterator* f
}
void
ElementPeerList::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementPeerList::activate(...) called on an object in the wrong state");
ElementPeerList::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementPeerList::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WPeerList(m_download, m_list, m_focus);
m_window = new WPeerList(m_download, m_list, m_focus);
m_frame = frame;
}
void
ElementPeerList::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementPeerList::disable(...) called on an object in the wrong state");
ElementPeerList::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementPeerList::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
}
display::Window*
ElementPeerList::window() {
return m_window;
}
}
+4 -2
View File
@@ -56,8 +56,10 @@ public:
ElementPeerList(core::Download* d, PList* l, PList::iterator* f);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
core::Download* m_download;
+11 -10
View File
@@ -36,7 +36,7 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "input/manager.h"
@@ -50,23 +50,24 @@ ElementStringList::ElementStringList() :
}
void
ElementStringList::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementStringList::activate(...) called on an object in the wrong state");
ElementStringList::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementStringList::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WStringList();
m_window = new WStringList();
m_frame = frame;
m_window->set_range(m_list.begin(), m_list.end());
}
void
ElementStringList::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementStringList::disable(...) called on an object in the wrong state");
ElementStringList::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementStringList::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
+4 -2
View File
@@ -57,8 +57,10 @@ public:
ElementStringList();
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window() { return m_window; }
template <typename InputIter>
void set_range(InputIter first, InputIter last) {
+13 -7
View File
@@ -60,26 +60,32 @@ ElementTrackerList::ElementTrackerList(core::Download* d) :
}
void
ElementTrackerList::activate(Control* c, MItr mItr) {
ElementTrackerList::activate(display::Frame* frame) {
if (m_window != NULL)
throw torrent::client_error("ui::ElementTrackerList::activate(...) called on an object in the wrong state");
throw torrent::client_error("ui::ElementTrackerList::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WTrackerList(m_download, &m_focus);
m_window = new WTrackerList(m_download, &m_focus);
m_frame = frame;
}
void
ElementTrackerList::disable(Control* c) {
ElementTrackerList::disable() {
if (m_window == NULL)
throw torrent::client_error("ui::ElementTrackerList::disable(...) called on an object in the wrong state");
throw torrent::client_error("ui::ElementTrackerList::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
}
display::Window*
ElementTrackerList::window() {
return m_window;
}
void
ElementTrackerList::receive_disable() {
if (m_window == NULL)
+4 -2
View File
@@ -55,8 +55,10 @@ public:
ElementTrackerList(core::Download* d);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
void receive_next();
+16 -10
View File
@@ -36,7 +36,7 @@
#include "config.h"
#include <stdexcept>
#include <torrent/exceptions.h>
#include "display/window_download_transfer_list.h"
#include "input/manager.h"
@@ -60,26 +60,32 @@ ElementTransferList::ElementTransferList(core::Download* d) :
}
void
ElementTransferList::activate(Control* c, MItr mItr) {
if (m_window != NULL)
throw std::logic_error("ui::ElementTransferList::activate(...) called on an object in the wrong state");
ElementTransferList::activate(display::Frame* frame) {
if (is_active())
throw torrent::client_error("ui::ElementTransferList::activate(...) is_active().");
c->input()->push_front(&m_bindings);
control->input()->push_front(&m_bindings);
*mItr = m_window = new WTransferList(m_download, &m_focus);
m_window = new WTransferList(m_download, &m_focus);
m_frame = frame;
}
void
ElementTransferList::disable(Control* c) {
if (m_window == NULL)
throw std::logic_error("ui::ElementTransferList::disable(...) called on an object in the wrong state");
ElementTransferList::disable() {
if (!is_active())
throw torrent::client_error("ui::ElementTransferList::disable(...) !is_active().");
c->input()->erase(&m_bindings);
control->input()->erase(&m_bindings);
delete m_window;
m_window = NULL;
}
display::Window*
ElementTransferList::window() {
return m_window;
}
// void
// ElementTransferList::receive_disable() {
// if (m_window == NULL)
+4 -2
View File
@@ -55,8 +55,10 @@ public:
ElementTransferList(core::Download* d);
void activate(Control* c, MItr mItr);
void disable(Control* c);
void activate(display::Frame* frame);
void disable();
display::Window* window();
private:
// void receive_disable();
+75 -8
View File
@@ -41,8 +41,14 @@
#include <sigc++/bind.h>
#include <torrent/torrent.h>
#include "core/manager.h"
#include "display/frame.h"
#include "display/window_http_queue.h"
#include "display/window_title.h"
#include "display/window_input.h"
#include "display/window_statusbar.h"
#include "input/manager.h"
#include "input/text_input.h"
#include "utils/variable_map.h"
#include "control.h"
@@ -55,6 +61,9 @@ namespace ui {
Root::Root() :
m_control(NULL),
m_downloadList(NULL),
m_windowTitle(NULL),
m_windowHttpQueue(NULL),
m_windowInput(NULL),
m_windowStatusbar(NULL) {
}
@@ -64,15 +73,30 @@ Root::init(Control* c) {
throw std::logic_error("Root::init() called twice on the same object");
m_control = c;
m_windowTitle = new WTitle();
m_windowHttpQueue = new WHttpQueue(control->core()->http_queue());
m_windowInput = new WInput();
m_windowStatusbar = new WStatusbar();
m_downloadList = new DownloadList();
display::Frame* rootFrame = m_control->display()->root_frame();
rootFrame->initialize_container(display::Frame::TYPE_ROW, 5);
rootFrame->frame(0)->initialize_window(m_windowTitle);
rootFrame->frame(2)->initialize_window(m_windowHttpQueue);
rootFrame->frame(3)->initialize_window(m_windowInput);
rootFrame->frame(4)->initialize_window(m_windowStatusbar);
m_control->display()->schedule(m_windowTitle, cachedTime);
m_control->display()->schedule(m_windowStatusbar, cachedTime);
m_windowInput->set_active(false);
setup_keys();
m_windowStatusbar = new WStatusbar(m_control);
m_downloadList = new DownloadList(m_control);
m_control->display()->push_back(m_windowStatusbar);
m_downloadList->activate();
// m_downloadList->slot_open_uri(sigc::mem_fun(m_control->get_core(), &core::Manager::insert));
m_downloadList->activate(rootFrame->frame(1));
}
void
@@ -83,9 +107,13 @@ Root::cleanup() {
if (m_downloadList->is_active())
m_downloadList->disable();
m_control->display()->erase(m_windowStatusbar);
m_control->display()->root_frame()->clear();
delete m_downloadList;
delete m_windowTitle;
delete m_windowHttpQueue;
delete m_windowInput;
delete m_windowStatusbar;
m_control->input()->erase(&m_bindings);
@@ -158,4 +186,43 @@ Root::adjust_up_throttle(int throttle) {
set_up_throttle(std::max<int>(torrent::up_throttle() / 1024 + throttle, 0));
}
void
Root::enable_input(input::TextInput* input) {
if (m_windowInput->input() != NULL)
throw torrent::client_error("Root::enable_input(...) m_windowInput->input() != NULL.");
input->slot_dirty(sigc::mem_fun(m_windowInput, &WInput::mark_dirty));
m_windowStatusbar->set_active(false);
m_windowInput->set_active(true);
m_windowInput->set_focus(true);
m_windowInput->set_input(input);
control->input()->set_text_input(input);
control->display()->adjust_layout();
}
void
Root::disable_input() {
if (m_windowInput->input() == NULL)
throw torrent::client_error("Root::disable_input() m_windowInput->input() == NULL.");
m_windowInput->input()->slot_dirty(sigc::slot0<void>());
m_windowStatusbar->set_active(true);
m_windowInput->set_active(false);
m_windowInput->set_focus(false);
m_windowInput->set_input(NULL);
control->input()->set_text_input(NULL);
control->display()->adjust_layout();
}
input::TextInput*
Root::current_input() {
return m_windowInput->input();
}
}
+22 -1
View File
@@ -43,15 +43,26 @@
class Control;
namespace display {
class Frame;
class WindowTitle;
class WindowHttpQueue;
class WindowInput;
class WindowStatusbar;
}
namespace input {
class TextInput;
}
namespace ui {
class DownloadList;
class Root {
public:
typedef display::WindowTitle WTitle;
typedef display::WindowHttpQueue WHttpQueue;
typedef display::WindowInput WInput;
typedef display::WindowStatusbar WStatusbar;
Root();
@@ -59,7 +70,9 @@ public:
void init(Control* c);
void cleanup();
WStatusbar* window_statusbar() { return m_windowStatusbar; }
WTitle* window_title() { return m_windowTitle; }
WStatusbar* window_statusbar() { return m_windowStatusbar; }
WInput* window_input() { return m_windowInput; }
void set_down_throttle(unsigned int throttle);
void set_up_throttle(unsigned int throttle);
@@ -71,12 +84,20 @@ public:
void adjust_down_throttle(int throttle);
void adjust_up_throttle(int throttle);
void enable_input(input::TextInput* input);
void disable_input();
input::TextInput* current_input();
private:
void setup_keys();
Control* m_control;
DownloadList* m_downloadList;
WTitle* m_windowTitle;
WHttpQueue* m_windowHttpQueue;
WInput* m_windowInput;
WStatusbar* m_windowStatusbar;
input::Bindings m_bindings;