The Battle for Wesnoth  1.15.0+dev
connect.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2018 by Mark de Wever <koraq@xs4all.nl>
3  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY.
11 
12  See the COPYING file for more details.
13 */
14 
15 #define GETTEXT_DOMAIN "wesnoth-lib"
16 
18 
20 #include "gui/widgets/button.hpp"
21 #include "gui/widgets/window.hpp"
22 #include "gui/widgets/settings.hpp"
23 #include "gui/widgets/text_box.hpp"
24 #include "help/help.hpp"
25 
26 #include "utils/functional.hpp"
27 
28 namespace gui2
29 {
30 namespace dialogs
31 {
32 
33 /*WIKI
34  * @page = GUIWindowDefinitionWML
35  * @order = 2_addon_connect
36  *
37  * == Addon connect ==
38  *
39  * This shows the dialog for managing addons and connecting to the addon server.
40  *
41  * @begin{table}{dialog_widgets}
42  * hostname & & text_box & m &
43  * This text contains the name of the server to connect to. $
44  *
45  * show_help & & button & m &
46  * Thus button shows the in-game help about add-ons management when
47  * triggered. $
48  *
49  * & 2 & button & o &
50  * This button closes the dialog to display a dialog for removing
51  * installed add-ons. $
52  *
53  * @end{table}
54  */
55 
57 
58 addon_connect::addon_connect(std::string& host_name,
59  const bool allow_remove)
60  : allow_remove_(allow_remove)
61 {
62  set_restore(true);
63  register_text("host_name", false, host_name, true);
64 }
65 
67 {
68  help::show_help("installing_addons");
69 }
70 
72 {
73  find_widget<button>(&window, "remove_addons", false)
74  .set_active(allow_remove_);
75 
77  find_widget<button>(&window, "show_help", false),
79  this,
80  std::ref(window)));
81 }
82 
84 {
85  if(get_retval() == retval::OK) {
86  text_box& host_widget
87  = find_widget<text_box>(&window, "host_name", false);
88 
89  host_widget.save_to_history();
90  }
91 }
92 
93 } // namespace dialogs
94 } // namespace gui2
void show_help(const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:116
void help_button_callback(window &window)
Definition: connect.cpp:66
Addon connect dialog.
Definition: connect.hpp:25
This file contains the window object, this object is a top level container which has the event manage...
void save_to_history()
Saves the text in the widget to the history.
Definition: text_box.hpp:129
STL namespace.
Class for a single line text area.
Definition: text_box.hpp:121
Generic file dialog.
Definition: field-fwd.hpp:22
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:43
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: connect.cpp:71
This file contains the settings handling of the widget library.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal_function &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:233
Various uncategorised dialogs.
virtual void post_show(window &window) override
Inherited from modal_dialog.
Definition: connect.cpp:83
Dialog was closed with the OK button.
Definition: retval.hpp:34
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:63