The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
connect.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2016 by Mark de Wever <[email protected]>
3  Part of the Battle for Wesnoth Project http://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 
31 /*WIKI
32  * @page = GUIWindowDefinitionWML
33  * @order = 2_addon_connect
34  *
35  * == Addon connect ==
36  *
37  * This shows the dialog for managing addons and connecting to the addon server.
38  *
39  * @begin{table}{dialog_widgets}
40  * hostname & & text_box & m &
41  * This text contains the name of the server to connect to. $
42  *
43  * show_help & & button & m &
44  * Thus button shows the in-game help about add-ons management when
45  * triggered. $
46  *
47  * & 2 & button & o &
48  * This button closes the dialog to display a dialog for removing
49  * installed add-ons. $
50  *
51  * @end{table}
52  */
53 
54 REGISTER_DIALOG(addon_connect)
55 
56 taddon_connect::taddon_connect(std::string& host_name,
57  const bool allow_remove)
58  : allow_remove_(allow_remove)
59 {
60  set_restore(true);
61  register_text("host_name", false, host_name, true);
62 }
63 
65 {
66  help::show_help(window.video(), "installing_addons");
67 }
68 
70 {
71  find_widget<tbutton>(&window, "remove_addons", false)
72  .set_active(allow_remove_);
73 
75  find_widget<tbutton>(&window, "show_help", false),
77  this,
78  std::ref(window)));
79 }
80 
82 {
83  if(get_retval() == twindow::OK) {
84  ttext_box& host_widget
85  = find_widget<ttext_box>(&window, "host_name", false);
86 
87  host_widget.save_to_history();
88  }
89 }
90 
91 } // namespace gui2
void show_help(CVideo &video, const std::string &show_topic, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:117
int get_retval() const
Definition: dialog.hpp:161
CVideo & video()
Definition: window.hpp:411
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(label_settings)
Addon connect dialog.
Definition: connect.hpp:26
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.hpp:710
STL namespace.
Class for a single line text area.
Definition: text_box.hpp:118
base class of top level items, the only item which needs to store the final canvases to draw on ...
Definition: window.hpp:62
A class inherited from ttext_box that displays its input as stars.
Definition: field-fwd.hpp:23
void help_button_callback(twindow &window)
Definition: connect.cpp:64
Dialog is closed with ok button.
Definition: window.hpp:125
This file contains the settings handling of the widget library.
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:46
void save_to_history()
Saves the text in the widget to the history.
Definition: text_box.hpp:124
GLenum GLint ref
Definition: glew.h:1813
void post_show(twindow &window)
Inherited from tdialog.
Definition: connect.cpp:81
void pre_show(twindow &window)
Inherited from tdialog.
Definition: connect.cpp:69