Cleaned up ui::Root, fixed updating and hiding status bar.

Using displayScheduler for updating windows, much more efficient.

Added saving of some parts of the state of torrents.


git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@482 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
rakshasa
2005-06-30 16:42:22 +00:00
parent 52884c3c39
commit 98ad8e8791
29 changed files with 221 additions and 95 deletions
+16 -7
View File
@@ -27,23 +27,32 @@
#include "display/manager.h"
#include "input/manager.h"
#include "root.h"
namespace ui {
class Control {
public:
Control() {}
Control() : m_shutdownReceived(false) {}
core::Manager& get_core() { return m_core; }
display::Manager& get_display() { return m_display; }
input::Manager& get_input() { return m_input; }
bool get_shutdown_received() { return m_shutdownReceived; }
void set_shutdown_received(bool v) { m_shutdownReceived = v; }
Root& get_ui() { return m_ui; }
core::Manager& get_core() { return m_core; }
display::Manager& get_display() { return m_display; }
input::Manager& get_input() { return m_input; }
private:
Control(const Control&);
void operator = (const Control&);
core::Manager m_core;
display::Manager m_display;
input::Manager m_input;
bool m_shutdownReceived;
Root m_ui;
core::Manager m_core;
display::Manager m_display;
input::Manager m_input;
};
}
+7 -6
View File
@@ -37,6 +37,7 @@
#include "display/window_input.h"
#include "display/window_log.h"
#include "display/window_title.h"
#include "display/window_statusbar.h"
#include "control.h"
#include "download.h"
@@ -113,15 +114,15 @@ DownloadList::disable() {
if (!is_active())
throw std::logic_error("ui::Download::disable() called on an already disabled object");
disable_display();
utils::taskScheduler.erase(&m_taskUpdate);
if (m_windowTextInput->is_active()) {
m_windowTextInput->get_input()->clear();
receive_exit_input();
}
disable_display();
utils::taskScheduler.erase(&m_taskUpdate);
m_control->get_display().erase(m_window);
m_control->get_display().erase(m_windowTitle);
m_control->get_display().erase(m_windowTextInput);
@@ -225,7 +226,7 @@ DownloadList::receive_check_hash() {
void
DownloadList::receive_view_input() {
//m_windowStatus->set_active(false);
m_control->get_ui().window_statusbar()->set_active(false);
m_windowTextInput->set_active(true);
m_control->get_display().adjust_layout();
@@ -239,7 +240,7 @@ DownloadList::receive_view_input() {
void
DownloadList::receive_exit_input() {
//m_windowStatus->set_active(true);
m_control->get_ui().window_statusbar()->set_active(true);
m_windowTextInput->set_active(false);
m_control->get_input().set_text_input();
+18 -14
View File
@@ -34,24 +34,24 @@
namespace ui {
Root::Root(Control* c) :
m_shutdownReceived(false),
m_control(c),
Root::Root() :
m_control(NULL),
m_downloadList(NULL),
m_windowStatus(NULL) {
m_windowStatusbar(NULL) {
}
void
Root::init() {
if (m_downloadList != NULL)
Root::init(Control* c) {
if (m_control != NULL)
throw std::logic_error("Root::init() called twice on the same object");
m_control = c;
setup_keys();
m_windowStatus = new WStatus(&m_control->get_core());
m_downloadList = new DownloadList(m_control);
m_windowStatusbar = new WStatusbar(&m_control->get_core());
m_downloadList = new DownloadList(m_control);
m_control->get_display().push_back(m_windowStatus);
m_control->get_display().push_back(m_windowStatusbar);
m_downloadList->activate();
m_downloadList->slot_open_uri(sigc::mem_fun(m_control->get_core(), &core::Manager::insert));
@@ -59,15 +59,19 @@ Root::init() {
void
Root::cleanup() {
if (m_control == NULL)
throw std::logic_error("Root::cleanup() called twice on the same object");
if (m_downloadList->is_active())
m_downloadList->disable();
m_control->get_display().erase(m_windowStatus);
m_control->get_display().erase(m_windowStatusbar);
delete m_downloadList;
delete m_windowStatus;
delete m_windowStatusbar;
m_control->get_input().erase(&m_bindings);
m_control = NULL;
}
void
@@ -89,19 +93,19 @@ Root::setup_keys() {
m_bindings['C'] = sigc::bind(sigc::mem_fun(*this, &Root::receive_read_throttle), -50);
m_bindings[KEY_RESIZE] = sigc::mem_fun(m_control->get_display(), &display::Manager::adjust_layout);
m_bindings['\x11'] = sigc::bind(sigc::mem_fun(*this, &Root::set_shutdown_received), true);
m_bindings['\x11'] = sigc::bind(sigc::mem_fun(*m_control, &Control::set_shutdown_received), true);
}
void
Root::receive_read_throttle(int t) {
//m_downloadList->mark_dirty();
m_windowStatusbar->mark_dirty();
torrent::set_read_throttle(torrent::get_read_throttle() + t * 1024);
}
void
Root::receive_write_throttle(int t) {
//m_downloadList->mark_dirty();
m_windowStatusbar->mark_dirty();
torrent::set_write_throttle(torrent::get_write_throttle() + t * 1024);
}
+6 -8
View File
@@ -32,18 +32,18 @@ namespace display {
namespace ui {
class DownloadList;
class Control;
class Root {
public:
typedef display::WindowStatusbar WStatus;
typedef display::WindowStatusbar WStatusbar;
Root(Control* c);
Root();
void init();
void init(Control* c);
void cleanup();
bool get_shutdown_received() { return m_shutdownReceived; }
void set_shutdown_received(bool v) { m_shutdownReceived = v; }
WStatusbar* window_statusbar() { return m_windowStatusbar; }
private:
void setup_keys();
@@ -51,12 +51,10 @@ private:
void receive_read_throttle(int t);
void receive_write_throttle(int t);
bool m_shutdownReceived;
Control* m_control;
DownloadList* m_downloadList;
WStatus* m_windowStatus;
WStatusbar* m_windowStatusbar;
input::Bindings m_bindings;
};