gui2/tgame_cache_options: Disable Clean/Purge buttons if cache is empty

This commit is contained in:
Ignacio R. Morelle 2016-02-14 01:04:30 -03:00
parent f5ba6a0e9e
commit 85688780c5
2 changed files with 16 additions and 4 deletions

View File

@ -76,13 +76,18 @@ REGISTER_DIALOG(game_cache_options)
tgame_cache_options::tgame_cache_options()
: cache_path_(filesystem::get_cache_dir())
, clean_button_(NULL)
, purge_button_(NULL)
, size_label_(NULL)
{
}
void tgame_cache_options::pre_show(CVideo& video, twindow& window)
{
clean_button_ = &find_widget<tbutton>(&window, "clean", false);
purge_button_ = &find_widget<tbutton>(&window, "purge", false);
size_label_ = &find_widget<tlabel>(&window, "size", false);
update_cache_size_display();
ttext_& path_box = find_widget<ttext_>(&window, "path", false);
@ -103,14 +108,12 @@ void tgame_cache_options::pre_show(CVideo& video, twindow& window)
boost::bind(&tgame_cache_options::browse_cache_callback,
this));
tbutton& clean = find_widget<tbutton>(&window, "clean", false);
connect_signal_mouse_left_click(clean,
connect_signal_mouse_left_click(*clean_button_,
boost::bind(&tgame_cache_options::clean_cache_callback,
this,
boost::ref(video)));
tbutton& purge = find_widget<tbutton>(&window, "purge", false);
connect_signal_mouse_left_click(purge,
connect_signal_mouse_left_click(*purge_button_,
boost::bind(&tgame_cache_options::purge_cache_callback,
this,
boost::ref(video)));
@ -134,6 +137,11 @@ void tgame_cache_options::update_cache_size_display()
} else {
size_label_->set_label(utils::si_string(size, true, _("unit_byte^B")));
}
if(size == 0) {
clean_button_->set_active(false);
purge_button_->set_active(false);
}
}
void tgame_cache_options::copy_to_clipboard_callback()

View File

@ -20,6 +20,7 @@
namespace gui2
{
class tlabel;
class tbutton;
class tgame_cache_options : public tdialog
{
@ -39,6 +40,9 @@ public:
private:
std::string cache_path_;
tbutton* clean_button_;
tbutton* purge_button_;
tlabel* size_label_;
void clean_cache_callback(CVideo& video);