The Battle for Wesnoth  1.15.9+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
29 {
30 namespace dialogs
31 {
32 
34 
35 addon_connect::addon_connect(std::string& host_name,
36  const bool allow_remove)
37  : allow_remove_(allow_remove)
38 {
39  set_restore(true);
40  register_text("host_name", false, host_name, true);
41 }
42 
44 {
45  help::show_help("installing_addons");
46 }
47 
49 {
50  find_widget<button>(&window, "remove_addons", false)
51  .set_active(allow_remove_);
52 
54  find_widget<button>(&window, "show_help", false),
55  std::bind(&addon_connect::help_button_callback, this));
56 }
57 
59 {
60  if(get_retval() == retval::OK) {
61  text_box& host_widget
62  = find_widget<text_box>(&window, "host_name", false);
63 
64  host_widget.save_to_history();
65  }
66 }
67 
68 } // namespace dialogs
69 } // 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:114
This shows the dialog for managing addons and connecting to the addon server.
Definition: connect.hpp:34
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
Generic file dialog.
Definition: field-fwd.hpp:22
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:52
virtual void pre_show(window &window) override
Inherited from modal_dialog.
Definition: connect.cpp:48
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
Various uncategorised dialogs.
virtual void post_show(window &window) override
Inherited from modal_dialog.
Definition: connect.cpp:58
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