The Battle for Wesnoth  1.15.12+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 <functional>
27 
28 namespace gui2::dialogs
29 {
30 
31 REGISTER_DIALOG(addon_connect)
32 
33 addon_connect::addon_connect(std::string& host_name,
34  const bool allow_remove)
35  : allow_remove_(allow_remove)
36 {
37  set_restore(true);
38  register_text("host_name", false, host_name, true);
39 }
40 
42 {
43  help::show_help("installing_addons");
44 }
45 
47 {
48  find_widget<button>(&window, "remove_addons", false)
49  .set_active(allow_remove_);
50 
52  find_widget<button>(&window, "show_help", false),
53  std::bind(&addon_connect::help_button_callback, this));
54 }
55 
57 {
58  if(get_retval() == retval::OK) {
59  text_box& host_widget
60  = find_widget<text_box>(&window, "host_name", false);
61 
62  host_widget.save_to_history();
63  }
64 }
65 
66 } // 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:112
This shows the dialog for managing addons and connecting to the addon server.
Definition: connect.hpp:32
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:148
STL namespace.
Class for a single line text area.
Definition: text_box.hpp:140
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:50
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: connect.cpp:46
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:171
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: connect.cpp:56
int get_retval() const
Returns the cached window exit code.
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:64