Skip to content

Commit

Permalink
gui2/tchat_log: Use a separate proper label for the page number text
Browse files Browse the repository at this point in the history
This replaces the page number slider with a "minimal" variant slider and
an adjacent label widget whose text we enter manually.

The label format is "<PAGE>/<COUNT>" and it's untranslatable. Hopefully
this shouldn't cause any localization issues since it's all numbers and
we currently can't use alternative numeral systems anyway.

I'm leaving the page slider's maximum_value_label attribute intact just
in case this needs to be reverted later, since it's going into the 1.12
branch too.
  • Loading branch information
irydacea committed Jun 19, 2014
1 parent 2ffdcb7 commit eee57af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
14 changes: 13 additions & 1 deletion data/gui/default/window/chat_log.cfg
Expand Up @@ -65,13 +65,25 @@
border_size = 5
[slider]
id = "page_number"
definition = "default"
definition = "minimal"
minimum_value = 1
maximum_value = 100
step_size = 1
# Unused, kept for 1.12 i18n in case the default slider
# variant with a label needs to be restored.
maximum_value_label = _"Last"
[/slider]
[/column]
[column]
grow_factor = 0
border = "all"
border_size = 5
[label]
id = "page_label"
definition = "default"
label = ""
[/label]
[/column]
[column]
grow_factor = 0
border = "all"
Expand Down
9 changes: 9 additions & 0 deletions src/gui/dialogs/chat_log.cpp
Expand Up @@ -75,6 +75,7 @@ class tchat_log::model
, chat_log_history(r->build_chat_log())
, page(0)
, page_number()
, page_label()
, previous_page()
, next_page()
, filter()
Expand All @@ -90,6 +91,7 @@ class tchat_log::model
int page;
static const int COUNT_PER_PAGE = 100;
tslider* page_number;
tcontrol* page_label;
tbutton* previous_page;
tbutton* next_page;
ttext_box* filter;
Expand Down Expand Up @@ -311,6 +313,11 @@ class tchat_log::controller
LOG_CHAT_LOG << "Maximum value of page number slider: "
<< count_of_pages << std::endl;
model_.page_number->set_value(page + 1);

std::ostringstream cur_page_text;
cur_page_text << (page + 1) << '/' << std::max(1, count_of_pages);
model_.page_label->set_label(cur_page_text.str());

LOG_CHAT_LOG << "Exiting tchat_log::controller::update_view_from_model"
<< std::endl;
}
Expand Down Expand Up @@ -405,6 +412,8 @@ class tchat_log::view
this,
boost::ref(window)));

model_.page_label = &find_widget<tcontrol>(&window, "page_label", false);

LOG_CHAT_LOG << "Exiting tchat_log::view::bind" << std::endl;
}

Expand Down

0 comments on commit eee57af

Please sign in to comment.