The Battle for Wesnoth  1.17.0-dev
connect.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2021
3  by Mark de Wever <koraq@xs4all.nl>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
21 #include "gui/widgets/button.hpp"
22 #include "gui/widgets/window.hpp"
23 #include "gui/widgets/settings.hpp"
24 #include "gui/widgets/text_box.hpp"
25 #include "help/help.hpp"
26 
27 #include <functional>
28 
29 namespace gui2::dialogs
30 {
31 
32 REGISTER_DIALOG(addon_connect)
33 
34 addon_connect::addon_connect(std::string& host_name,
35  const bool allow_remove)
36  : allow_remove_(allow_remove)
37 {
38  set_restore(true);
39  register_text("host_name", false, host_name, true);
40 }
41 
43 {
44  help::show_help("installing_addons");
45 }
46 
48 {
49  find_widget<button>(&window, "remove_addons", false)
50  .set_active(allow_remove_);
51 
53  find_widget<button>(&window, "show_help", false),
54  std::bind(&addon_connect::help_button_callback, this));
55 }
56 
58 {
59  if(get_retval() == retval::OK) {
60  text_box& host_widget
61  = find_widget<text_box>(&window, "host_name", false);
62 
63  host_widget.save_to_history();
64  }
65 }
66 
67 } // namespace dialogs
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:144
This shows the dialog for managing addons and connecting to the addon server.
Definition: connect.hpp:33
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:149
STL namespace.
Class for a single line text area.
Definition: text_box.hpp:141
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:51
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: connect.cpp:47
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:172
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: connect.cpp:57
int get_retval() const
Returns the cached window exit code.
Dialog was closed with the OK button.
Definition: retval.hpp:35
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65