Debian Codegraph @

src/modules/frontend/gtk/cdebconf_gtk.h

raw
1 /*****************************************************************************
2 *
3 * cdebconf - An implementation of the Debian Configuration Management
4 * System
5 *
6 * cdebconf is (c) 2000-2007 Randolph Chung and others under the following
7 * license.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 *****************************************************************************/
33
34 /** @file cdebconf_gtk.h
35 * Public interface of the GTK+ frontend of cdebconf.
36 *
37 * You should find everything needed to write a plugin here.
38 */
39
40 #ifndef _CDEBCONF_GTK_H_
41 #define _CDEBCONF_GTK_H_
42
43 #include <gtk/gtk.h>
44
45 #include "frontend.h"
46 #include "question.h"
47
48 /** Horizontal padding between a question and the question box frame. */
49 #define QUESTIONBOX_HPADDING 6
50 /** Vertical padding between two adjacent questions inside the question box. */
51 #define QUESTIONBOX_VPADDING 3
52 /** Default padding used troughout the GTK+ frontend. */
53 #define DEFAULT_PADDING 6
54
55 /* Unused area between "aligned" columns in pango units. */
56 #define COLUMN_SPACING 20000
57
58 #ifdef DI_UDEB
59 /** Paths to the directory containing images used by the GTK+ frontend. */
60 # define BASE_IMAGE_PATH \
61 "/usr/share/graphics"
62 #else /* !DI_UDEB */
63 /* XXX: we need to ship the relevant images in the package */
64 # define BASE_IMAGE_PATH \
65 "/usr/share/debconf/graphics"
66 #endif /* DI_UDEB */
67
68 /** Full path to the logo that will be displayed in the banner.
69 *
70 * @see create_banner()
71 */
72 #define LOGO_IMAGE_PATH \
73 BASE_IMAGE_PATH "/logo_installer.png"
74 #define LOGO_DARK_IMAGE_PATH \
75 BASE_IMAGE_PATH "/logo_installer_dark.png"
76 #define LOGO_CONFIG_PATH \
77 BASE_IMAGE_PATH "/logo_installer.ini"
78
79 /** Can the progress be canceled within the current frontend run? */
80 #define CAN_CANCEL_PROGRESS(Frontend) \
81 (Frontend->methods.can_cancel_progress(Frontend))
82
83 /** Can the user "go back" in the current frontend run? */
84 #define CAN_GO_BACK(Frontend) \
85 (Frontend->methods.can_go_back(Frontend, Frontend->questions))
86
87 /** Should tab separated fields be aligned in select and multiselect? */
88 #define CAN_ALIGN(Frontend) \
89 (Frontend->methods.can_align(Frontend, Frontend->questions))
90
91 /** Is the question the only one in the current GO? */
92 #define IS_QUESTION_SINGLE(Question) \
93 (NULL == Question->prev && NULL == Question->next)
94
95 /** A function that will "set" the question to the value entered by the user.
96 *
97 * @param question question being set
98 * @param user_data data given to cdebconf_gtk_register_setter()
99 */
100 typedef void (* setter_function)(struct question * question,
101 void * user_data);
102
103 /** Cast a function into a setter_function. */
104 #define SETTER_FUNCTION(X) ((setter_function) X)
105
106 void cdebconf_gtk_register_setter(struct frontend * fe, setter_function func,
107 struct question * question,
108 void * user_data);
109
110 gboolean cdebconf_gtk_is_first_question(struct question * question);
111
112 char * cdebconf_gtk_get_text(struct frontend * fe, const char * template,
113 const char * fallback);
114
115 /** A question handler.
116 * XXX
117 */
118 typedef int (* cdebconf_gtk_handler)(struct frontend * fe,
119 struct question * question,
120 GtkWidget * question_box);
121
122 /** Value of answer field when there no answer have been set. */
123 #define DC_NO_ANSWER (-1)
124
125 /** Get the pending debconf answer in a thread-safe way.
126 *
127 * @param fe cdebconf frontend
128 * @return the current answer
129 */
130 int cdebconf_gtk_get_answer(struct frontend * fe);
131
132 /** Set the pending debconf answer in a thread-safe way.
133 *
134 * @param fe cdebconf frontend
135 * @param answer the new answer value
136 */
137 void cdebconf_gtk_set_answer(struct frontend * fe, int answer);
138
139 /** Set the pending debconf answer to DC_OK.
140 *
141 * This function is provided by convenience as a possible argument
142 * for g_signal_connect_swapped().
143 *
144 * @param fe cdebconf frontend
145 */
146 void cdebconf_gtk_set_answer_ok(struct frontend * fe);
147
148 /** Set the pending debconf answer to DC_NOTOK.
149 *
150 * This function is provided by convenience as a possible argument
151 * for g_signal_connect_swapped().
152 *
153 * @param fe cdebconf frontend
154 */
155 void cdebconf_gtk_set_answer_notok(struct frontend * fe);
156
157 /** Set the pending debconf answer to DC_GOBACK.
158 *
159 * This function is provided by convenience as a possible argument
160 * for g_signal_connect_swapped().
161 *
162 * @param fe cdebconf frontend
163 */
164 void cdebconf_gtk_set_answer_goback(struct frontend * fe);
165
166 /** Display help for the current question.
167 *
168 * @param fe cdebconf frontend
169 */
170 void cdebconf_gtk_help(struct frontend * fe);
171
172 /** Force cdebconf to quit.
173 *
174 * This function is currently used when the main window is closed.
175 *
176 * It is implemented by sending a TERM signal to the current process,
177 *
178 * @param fe cdebconf frontend
179 */
180 void cdebconf_gtk_force_quit(struct frontend * fe);
181
182 /** Add common question layout around a given widget and add it to the given
183 * container.
184 *
185 * The common layout include the description and extended description of the
186 * question as well as any icons that has been associated with the question
187 * type.
188 *
189 * @param fe cdebconf frontend
190 * @param question question being handled
191 * @param container container in which the widgets will be added
192 * @param widget question widgets
193 */
194 void cdebconf_gtk_add_common_layout(struct frontend * fe,
195 struct question * question,
196 GtkWidget * container,
197 GtkWidget * widget);
198
199 /** Pack the widget inside a vbox inside a hbox to center it.
200 *
201 * The given widget needs to be parentless before calling this function.
202 *
203 * The given pointer is updated to point to the surrounding box.
204 *
205 * @param widget pointer to the widget to be centered
206 * @param horizontal_padding horizontal padding around the widget
207 * @param vertical_padding vertical padding around the widget
208 */
209 void cdebconf_gtk_center_widget(GtkWidget ** widget, guint horizontal_padding,
210 guint vertical_padding);
211
212 /** Pop-up a informational dialog to the user.
213 *
214 * @todo
215 * This function should just wrap around a standard GtkDialog when used outside
216 * the debian-installer.
217 *
218 * @param fe cdebconf frontend
219 * @param title title of the dialog window
220 * @param message message of the dialog window
221 * @return FALSE if an error happened, TRUE otherwise
222 */
223 gboolean cdebconf_gtk_run_message_dialog(struct frontend * fe,
224 const gchar * title,
225 const gchar * message);
226
227 /** Add a keyboard shortcut to the main window.
228 *
229 * The added keyboard shortcut is tied to a specific widget
230 * (usually a button), and will be removed when the widget is destroyed.
231 *
232 * @param fe cdebconf frontend
233 * @param widget a widget which "carries" the signal
234 * @param key_event_handler a shortcut handler
235 */
236 void cdebconf_gtk_add_global_key_handler(struct frontend * fe,
237 GtkWidget * widget,
238 GCallback key_event_handler);
239
240 /** Set sensitivity for all buttons in the main window.
241 *
242 * @param fe cdebconf frontend
243 * @param sensitive FALSE for insensitive buttons, TRUE for sensitive ones
244 */
245 void cdebconf_gtk_set_buttons_sensitive(struct frontend * fe,
246 gboolean sensitive);
247
248 /** Add the given button to the main window.
249 *
250 * Buttons will be added to the action box with the same order than
251 * calls to this functions. The focus chain will be updated as well on
252 * the same basis.
253 *
254 * @param fe cdebconf frontend
255 * @param button the button to add
256 */
257 void cdebconf_gtk_add_button(struct frontend * fe, GtkWidget * button);
258
259 /** Set the "secondary" propriety for the given button.
260 *
261 * A "secondary" button will be displayed at the other end of the action
262 * box. This is currently the case for the "Go Back" button.
263 *
264 * This is basically a wrapper around gtk_button_set_secondary().
265 *
266 * @param fe cdebconf frontend
267 * @param button the button that will set
268 * @param secondary TRUE if the button is "secondary", FALSE otherwise
269 */
270 void cdebconf_gtk_set_button_secondary(struct frontend * fe,
271 GtkWidget * button,
272 gboolean secondary);
273
274 /** Create the "Continue" button.
275 *
276 * The button will be added to the main action box on top of being
277 * returned. This also a specific question handler to have more
278 * control over the button during the input.
279 *
280 * To ease navigation, the "Continue" button will be first in the action box
281 * focus chain.
282 *
283 * @param fe cdebconf frontend
284 * @return the newly created "Continue" button
285 */
286 GtkWidget * cdebconf_gtk_create_continue_button(struct frontend * fe);
287
288 #ifdef DI_UDEB
289 /* Workaround for #882804, GTK 2 only
290 *
291 * @param ce cdebconf frontend
292 */
293 void cdebconf_gtk_update_frontend_info(struct frontend * fe);
294 #endif
295
296
297 #endif /* !_CDEBCONF_GTK_H_ */
298
299 /* vim: et sw=4 si
300 */