gui2/taddon_description: Use a [stacked_widget] so URL controls may be hidden

The URL controls overlay a placeholder "None" label using the
[stacked_widget]. When there's no URL to show, the URL controls are
hidden. When there is a URL to show, the placeholder is hidden instead.
This commit is contained in:
Ignacio R. Morelle 2014-01-04 12:02:37 -03:00
parent 9894a36cb6
commit a5ac4d06c6
2 changed files with 76 additions and 36 deletions

View file

@ -325,54 +325,82 @@
[column]
horizontal_alignment = "left"
[grid]
[stacked_widget]
[row]
[stack]
[column]
border = "all"
border_size = 5
horizontal_grow = "true"
[layer]
[text_box]
id = "url"
definition = "default"
label = ""
[/text_box]
[row]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "left"
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[label]
id = "url_none"
label = _ "url^None"
[/label]
[button]
id = "url_copy"
definition = "action_copy"
label = _ "url^Copy"
tooltip = _ "Copy this URL to clipboard"
[/button]
[/column]
[/column]
[/row]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[/layer]
[button]
id = "url_go"
definition = "action_go"
label = _ "url^Go"
tooltip = _ "Visit this URL with a web browser"
[/button]
[layer]
[/column]
[row]
[/row]
[column]
border = "all"
border_size = 5
horizontal_grow = "true"
[/grid]
[text_box]
id = "url"
definition = "default"
label = ""
[/text_box]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "url_copy"
definition = "action_copy"
label = _ "url^Copy"
tooltip = _ "Copy this URL to clipboard"
[/button]
[/column]
[column]
border = "all"
border_size = 5
horizontal_alignment = "right"
[button]
id = "url_go"
definition = "action_go"
label = _ "url^Go"
tooltip = _ "Visit this URL with a web browser"
[/button]
[/column]
[/row]
[/layer]
[/stack]
[/stacked_widget]
[/column]

View file

@ -255,6 +255,10 @@ namespace gui2 {
* Button for copying the add-on's feedback page URL to clipboard if
* provided by the server. $
*
* url_none & & control & m &
* Label displayed instead of the other url_* widgets when no URL is
* provided by the server.
*
* @end{table}
*/
@ -314,6 +318,8 @@ void taddon_description::copy_url_callback()
void taddon_description::pre_show(CVideo& /*video*/, twindow& window)
{
tcontrol& url_none =
find_widget<tcontrol>(&window, "url_none", false);
tbutton& url_go_button =
find_widget<tbutton>(&window, "url_go", false);
tbutton& url_copy_button =
@ -325,6 +331,8 @@ void taddon_description::pre_show(CVideo& /*video*/, twindow& window)
url_textbox.set_active(false);
if(!feedback_url_.empty()) {
url_none.set_visible(tcontrol::tvisible::invisible);
connect_signal_mouse_left_click(url_go_button,
boost::bind(&taddon_description::browse_url_callback, this));
connect_signal_mouse_left_click(url_copy_button,
@ -332,6 +340,10 @@ void taddon_description::pre_show(CVideo& /*video*/, twindow& window)
} else {
url_go_button.set_active(false);
url_copy_button.set_active(false);
url_go_button.set_visible(tcontrol::tvisible::invisible);
url_copy_button.set_visible(tcontrol::tvisible::invisible);
url_textbox.set_visible(tcontrol::tvisible::invisible);
}
}