summaryrefslogtreecommitdiff
path: root/src/apt_config_treeitems.h
blob: e2b8b48a4f89c79c33acafe4516cf42ed03d60de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// apt_config_treeitems.h          -*-c++-*-
//
//   Copyright (C) 2007-2008 Daniel Burrows
//
//   This program is free software; you can redistribute it and/or
//   modify it under the terms of the GNU General Public License as
//   published by the Free Software Foundation; either version 2 of
//   the License, or (at your option) any later version.
//
//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//   General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program; see the file COPYING.  If not, write to
//   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
//   Boston, MA 02111-1307, USA.

#ifndef APT_CONFIG_TREEITEMS_H
#define APT_CONFIG_TREEITEMS_H

#include <cwidget/widgets/treeitem.h>

namespace cwidget
{
  class fragment;
}

namespace aptitude
{
  namespace ui
  {
    namespace config
    {
      /** \brief The interface for configuration list-items.
       */
      class config_treeitem : virtual public cwidget::widgets::treeitem
      {
      public:
	/** \brief A signal emitted when the description of this tree-item
	 *  needs to be refreshed.
	 */
	sigc::signal0<void> description_changed;

	/** \brief Option information
	 *
	 *  These methods retrieve information about the option for
	 *  presentation to the user.
	 */
	// @{

	/** \brief Retrieve a long description of this configuration item.
	 */
	virtual cwidget::fragment *get_long_description() const = 0;

	// @}
      };

      /** \brief Generate a configuration item for the given Boolean option.
       *
       *  \param description       A textual description of the configuration item.
       *  \param long_description  A longer description of the configuration item,
       *                           as a fragf-style pattern with no arguments.
       *  \param item    The configuration item that is to be managed.
       *  \param dflt    The default value if the option is not set.
       *
       *  \return a structure describing the new configuration item.
       *  The caller is responsible for destroying the treeitem
       *  object.
       *
       *  Selecting the option and pressing "Confirm" will toggle it on
       *  or off.
       */
      cwidget::widgets::treeitem *make_boolean_item(const std::wstring &description,
				     const std::string   &long_description,
				     const std::string   &item,
				     const bool          dflt);

      /** \brief Generate a tree item for the given string option.
       *
       *  \param description       A textual description of the configuration item.
       *  \param long_description  A longer description of the configuration item,
       *                           as a fragf-style pattern with no arguments.
       *  \param item    The configuration item that is to be managed.
       *  \param dflt    The default value if the option is not set.
       *
       *  \return a structure describing the new configuration item.
       *  The caller is responsible for destroying the treeitem
       *  object.
       *
       *  Selecting the option and pressing "Confirm" will display a
       *  prompt to enter a new value for the option.
       */
      cwidget::widgets::treeitem *make_string_item(const std::wstring &description,
				    const std::string  &long_description,
				    const std::string  &item,
				    const std::string  &dflt);

      /** \brief Information about a single option in a multiple-choice setting. */
      class radio_choice
      {
	std::string value;
	std::string untranslated_description;
	std::string untranslated_long_description;

      public:
	radio_choice()
	{
	}

	radio_choice(const std::string &_value,
		     const std::string &_untranslated_description,
		     const std::string &_untranslated_long_description)
	  : value(_value),
	    untranslated_description(_untranslated_description),
	    untranslated_long_description(_untranslated_long_description)
	{
	}

	const std::string &get_value() const
	{
	  return value;
	}

	const std::string &get_untranslated_description() const
	{
	  return untranslated_description;
	}

	const std::string &get_untranslated_long_description() const
	{
	  return untranslated_long_description;
	}
      };

      /** \brief Generate a tree item for the given multi-choice option.
       *
       *  \param description       A textual description of the configuration item.
       *  \param long_description  A longer description of the configuration item,
       *                           as a fragf-style pattern with no arguments.
       *  \param item    The configuration item that is to be managed.
       *  \param choices The permitted choices for the radio item.
       *  \param dflt    The default value if the option is not set.
       *
       *  \return a structure describing the new configuration item.
       *  The caller is responsible for destroying the treeitem
       *  object.
       *
       *  Selecting the option and pressing "Confirm" will display a
       *  prompt to choose a new value for the option.
       */
      cwidget::widgets::treeitem *make_radio_item(const std::wstring &description,
				   const std::string  &long_description,
				   const std::string  &item,
				   const std::vector<radio_choice> &choices,
				   const std::string  &dflt);
    }
  }
}

#endif // APT_CONFIG_TREEITEMS_H