~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-dialog-manager.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
 
 
21
#ifndef __CAIRO_DIALOG_MANAGER__
 
22
#define  __CAIRO_DIALOG_MANAGER__
 
23
 
 
24
#include "cairo-dock-container.h"
 
25
#include "cairo-dock-dialog-factory.h"
 
26
G_BEGIN_DECLS
 
27
 
 
28
/** @file cairo-dock-dialog-manager.h This class manages the Dialogs, that are useful to bring interaction with the user.
 
29
 
30
* With dialogs, you can pop-up messages, ask for question, etc. Any GTK widget can be embedded inside a dialog, giving you any possible interaction with the user.
 
31
 
32
* Dialogs are constructed with a set of attributes grouped inside a _CairoDialogAttribute. See \ref cairo-dock-dialog-factory.h for the list of available attributes.
 
33
 
34
* The most generic way to build a Dialog is to fill a _CairoDialogAttribute and pass it to \ref cairo_dock_build_dialog.
 
35
 
36
* But in most of case, you can just use one of the following convenient functions, that will do the job for you.
 
37
* - to show a message, you can use \ref cairo_dock_show_temporary_dialog_with_icon
 
38
* - to ask the user a choice, a value or a text, you can use \ref cairo_dock_show_dialog_with_question, \ref cairo_dock_show_dialog_with_value or \ref cairo_dock_show_dialog_with_entry.
 
39
* - if you need to block while waiting for the user, use the xxx_and_wait version of these functions.
 
40
* - if you want to pop up only 1 dialog at once on a given icon, use \ref cairo_dock_remove_dialog_if_any before you pop up your dialog.
 
41
*/
 
42
 
 
43
struct _CairoDialogManager {
 
44
        CairoDockManager mgr;
 
45
        CairoDialog* (*build_dialog) (CairoDialogAttribute *pAttribute, Icon *pIcon, CairoContainer *pContainer);
 
46
        void (*destroy_desklet) (CairoDesklet *pDesklet);
 
47
        
 
48
        void (*place_dialog) (CairoDialog *pDialog);
 
49
        void (*set_icon) (CairoDialog *pDialog, const gchar *cImageFilePath);
 
50
        void (*set_icon_surface) (CairoDialog *pDialog, cairo_surface_t *pNewIconSurface, int iNewIconSize);
 
51
        void (*free) (CairoDialog *pDialog);
 
52
        GList *pDialogList;  // sinon il faut les fonctions ci-dessous.
 
53
        void (*replace_all) (void);
 
54
        void (*unreference) (CairoDialog *pDialog);  // a ce moment-la, free() n'est plus utile.
 
55
        void (*icon_has_dialog) (Icon *pIcon);
 
56
        gboolean (*remove_dialog_if_any_full) (Icon *icon, gboolean bAll);
 
57
        } ;
 
58
 
 
59
void cairo_dock_init_dialog_manager (void);
 
60
void cairo_dock_load_dialog_buttons (gchar *cButtonOkImage, gchar *cButtonCancelImage);
 
61
void cairo_dock_unload_dialog_buttons (void);
 
62
 
 
63
/** Increase by 1 the reference of a dialog. Use #cairo_dock_dialog_unreference when you're done, so that the dialog can be destroyed.
 
64
*@param pDialog the dialog.
 
65
*@return TRUE if the reference was not nul, otherwise you must not use it.
 
66
*/
 
67
gboolean cairo_dock_dialog_reference (CairoDialog *pDialog);
 
68
 
 
69
/** Decrease by 1 the reference of a dialog. If the reference becomes nul, the dialog is destroyed.
 
70
*@param pDialog the dialog.
 
71
*@return TRUE if the reference became nul, in which case the dialog must not be used anymore.
 
72
*/
 
73
gboolean cairo_dock_dialog_unreference (CairoDialog *pDialog);
 
74
 
 
75
/** Unreference the dialogs pointing on an icon.
 
76
*@param icon the icon you want to delete all dialogs from.
 
77
*@param bAll whether all dialogs should be removed or only the one that don't have interaction with the user.
 
78
*@returns TRUE if at least one dialog has been unreferenced.
 
79
*/
 
80
gboolean cairo_dock_remove_dialog_if_any_full (Icon *icon, gboolean bAll);
 
81
 
 
82
/** Unreference all the dialogs pointing on an icon.
 
83
*@param icon the icon you want to delete all dialogs from.
 
84
*@returns TRUE if at least one dialog has been unreferenced.
 
85
*/
 
86
#define cairo_dock_remove_dialog_if_any(icon) cairo_dock_remove_dialog_if_any_full (icon, TRUE)
 
87
 
 
88
 
 
89
 
 
90
/** Generic function to pop up a dialog.
 
91
*@param pAttribute attributes of the dialog.
 
92
*@param pIcon the icon that will hold the dialog.
 
93
*@param pContainer the container of the icon.
 
94
*@return a newly created dialog, visible, with a reference of 1.
 
95
*/
 
96
CairoDialog *cairo_dock_build_dialog (CairoDialogAttribute *pAttribute, Icon *pIcon, CairoContainer *pContainer);
 
97
 
 
98
 
 
99
void cairo_dock_replace_all_dialogs (void);
 
100
 
 
101
/** Pop up a dialog with a message, a widget, 2 buttons ok/cancel and an icon, all optionnal.
 
102
*@param cText the message to display.
 
103
*@param pIcon the icon that will hold the dialog.
 
104
*@param pContainer the container of the icon.
 
105
*@param fTimeLength the duration of the dialog (in ms), or 0 for an unlimited dialog.
 
106
*@param cIconPath path to an icon to display in the margin.
 
107
*@param pInteractiveWidget a GTK widget; It is destroyed with the dialog. Use 'gtk_widget_reparent()' before if you want to keep it alive, or use #cairo_dock_show_dialog_and_wait.
 
108
*@param pActionFunc the callback called when the user makes its choice. NULL means there will be no buttons.
 
109
*@param data data passed as a parameter of the callback.
 
110
*@param pFreeDataFunc function used to free the data when the dialog is destroyed, or NULL if unnecessary.
 
111
*@return the newly created dialog, visible, with a reference of 1.
 
112
*/
 
113
CairoDialog *cairo_dock_show_dialog_full (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, double fTimeLength, const gchar *cIconPath, GtkWidget *pInteractiveWidget, CairoDockActionOnAnswerFunc pActionFunc, gpointer data, GFreeFunc pFreeDataFunc);
 
114
 
 
115
/** Pop up a dialog with a message, and a limited duration, and an icon in the margin.
 
116
*@param cText the message to display.
 
117
*@param pIcon the icon that will hold the dialog.
 
118
*@param pContainer the container of the icon.
 
119
*@param fTimeLength the duration of the dialog (in ms), or 0 for an unlimited dialog.
 
120
*@param cIconPath path to an icon.
 
121
*@param ... arguments to insert in the message, in a printf way.
 
122
*@return the newly created dialog, visible, with a reference of 1.
 
123
*/
 
124
CairoDialog *cairo_dock_show_temporary_dialog_with_icon_printf (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, double fTimeLength, const gchar *cIconPath, ...) G_GNUC_PRINTF (1, 6);
 
125
 
 
126
/** Pop up a dialog with a message, and a limited duration, and an icon in the margin.
 
127
*@param cText the message to display.
 
128
*@param pIcon the icon that will hold the dialog.
 
129
*@param pContainer the container of the icon.
 
130
*@param fTimeLength the duration of the dialog (in ms), or 0 for an unlimited dialog.
 
131
*@param cIconPath path to an icon.
 
132
*@return the newly created dialog, visible, with a reference of 1.
 
133
*/
 
134
CairoDialog *cairo_dock_show_temporary_dialog_with_icon (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, double fTimeLength, const gchar *cIconPath);
 
135
 
 
136
/** Pop up a dialog with a message, and a limited duration, with no icon.
 
137
*@param cText the message to display.
 
138
*@param pIcon the icon that will hold the dialog.
 
139
*@param pContainer the container of the icon.
 
140
*@param fTimeLength the duration of the dialog (in ms), or 0 for an unlimited dialog.
 
141
*@return the newly created dialog, visible, with a reference of 1 et visible, avec une reference a 1.
 
142
*/
 
143
CairoDialog *cairo_dock_show_temporary_dialog (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, double fTimeLength);
 
144
 
 
145
/** Pop up a dialog with a message, and a limited duration, and a default icon.
 
146
*@param cText the format of the message to display.
 
147
*@param pIcon the icon that will hold the dialog.
 
148
*@param pContainer the container of the icon.
 
149
*@param fTimeLength the duration of the dialog (in ms), or 0 for an unlimited dialog.
 
150
*@return the newly created dialog, visible, with a reference of 1 et visible, avec une reference a 1.
 
151
*/
 
152
CairoDialog *cairo_dock_show_temporary_dialog_with_default_icon (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, double fTimeLength);
 
153
 
 
154
/** Pop up a dialog with a question and 2 buttons ok/cancel.
 
155
* The dialog is unreferenced after the user has answered, so if you want to keep it alive, you have to reference it in the callback.
 
156
*@param cText the message to display.
 
157
*@param pIcon the icon that will hold the dialog.
 
158
*@param pContainer the container of the icon.
 
159
*@param cIconPath path to an icon to display in the margin.
 
160
*@param pActionFunc the callback.
 
161
*@param data data passed as a parameter of the callback.
 
162
*@param pFreeDataFunc function used to free the data.
 
163
*@return the newly created dialog, visible, with a reference of 1 et visible, avec une reference a 1.
 
164
*/
 
165
CairoDialog *cairo_dock_show_dialog_with_question (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, const gchar *cIconPath, CairoDockActionOnAnswerFunc pActionFunc, gpointer data, GFreeFunc pFreeDataFunc);
 
166
 
 
167
/** Pop up a dialog with a text entry and 2 buttons ok/cancel.
 
168
* The dialog is unreferenced after the user has answered, so if you want to keep it alive, you have to reference it in the callback.
 
169
*@param cText the message to display.
 
170
*@param pIcon the icon that will hold the dialog.
 
171
*@param pContainer the container of the icon.
 
172
*@param cIconPath path to an icon to display in the margin.
 
173
*@param cTextForEntry text to display initially in the entry.
 
174
*@param pActionFunc the callback.
 
175
*@param data data passed as a parameter of the callback.
 
176
*@param pFreeDataFunc function used to free the data.
 
177
*@return the newly created dialog, visible, with a reference of 1.
 
178
*/
 
179
CairoDialog *cairo_dock_show_dialog_with_entry (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, const gchar *cIconPath, const gchar *cTextForEntry, CairoDockActionOnAnswerFunc pActionFunc, gpointer data, GFreeFunc pFreeDataFunc);
 
180
 
 
181
/** Pop up a dialog with an horizontal scale between 0 and fMaxValue and 2 buttons ok/cancel.
 
182
* The dialog is unreferenced after the user has answered, so if you want to keep it alive, you have to reference it in the callback.
 
183
*@param cText the message to display.
 
184
*@param pIcon the icon that will hold the dialog.
 
185
*@param pContainer the container of the icon.
 
186
*@param cIconPath path to an icon to display in the margin.
 
187
*@param fValue initial value of the scale.
 
188
*@param fMaxValue maximum value of the scale.
 
189
*@param pActionFunc the callback.
 
190
*@param data data passed as a parameter of the callback.
 
191
*@param pFreeDataFunc function used to free the data.
 
192
*@return the newly created dialog, visible, with a reference of 1.
 
193
*/
 
194
CairoDialog *cairo_dock_show_dialog_with_value (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, const gchar *cIconPath, double fValue, double fMaxValue, CairoDockActionOnAnswerFunc pActionFunc, gpointer data, GFreeFunc pFreeDataFunc);
 
195
 
 
196
 
 
197
 
 
198
/** Pop up a dialog with GTK widget and 2 buttons ok/cancel, and block until the user makes its choice.
 
199
*@param cText the message to display.
 
200
*@param pIcon the icon that will hold the dialog.
 
201
*@param pContainer the container of the icon.
 
202
*@param fTimeLength time length of the dialog, or 0 for an unlimited dialog.
 
203
*@param cIconPath path to an icon to display in the margin.
 
204
*@param pInteractiveWidget an interactive widget.
 
205
*@return the number of the button that was clicked : 0 or -1 for OK, 1 or -2 for CANCEL, -3 if the dialog has been destroyed before. The dialog is destroyed after the user choosed, but the interactive widget is not destroyed, which allows to retrieve the changes made by the user. Destroy it with 'gtk_widget_destroy' when you're done with it.
 
206
*/
 
207
int cairo_dock_show_dialog_and_wait (const gchar *cText, Icon *pIcon, CairoContainer *pContainer, double fTimeLength, const gchar *cIconPath, GtkWidget *pInteractiveWidget);
 
208
 
 
209
/** Pop up a dialog with a text entry, and 2 buttons ok/cancel, and block until the user makes its choice.
 
210
*@param cMessage the message to display.
 
211
*@param pIcon the icon that will hold the dialog.
 
212
*@param pContainer the container of the icon.
 
213
*@param cInitialAnswer the initial value of the entry (can be NULL).
 
214
*@return the text entered by the user, or NULL if he cancelled or if the dialog has been destroyed before.
 
215
*/
 
216
gchar *cairo_dock_show_demand_and_wait (const gchar *cMessage, Icon *pIcon, CairoContainer *pContainer, const gchar *cInitialAnswer);
 
217
 
 
218
/** Pop up a dialog with an horizontal scale between 0 and fMaxValue, and 2 buttons ok/cancel, and block until the user makes its choice.
 
219
*@param cMessage the message to display.
 
220
*@param pIcon the icon that will hold the dialog.
 
221
*@param pContainer the container of the icon.
 
222
*@param fInitialValue the initial value of the scale.
 
223
*@param fMaxValue the maximum value of the scale.
 
224
*@return the value choosed by the user, or -1 if he cancelled or if the dialog has been destroyed before.
 
225
*/
 
226
double cairo_dock_show_value_and_wait (const gchar *cMessage, Icon *pIcon, CairoContainer *pContainer, double fInitialValue, double fMaxValue);
 
227
 
 
228
/** Pop up a dialog with a question and 2 buttons yes/no, and block until the user makes its choice.
 
229
*@param cQuestion the question to ask.
 
230
*@param pIcon the icon that will hold the dialog.
 
231
*@param pContainer the container of the icon.
 
232
*@return GTK_RESPONSE_YES ou GTK_RESPONSE_NO according to the user's choice, or GTK_RESPONSE_NONE if the dialog has been destroyed before.
 
233
*/
 
234
int cairo_dock_ask_question_and_wait (const gchar *cQuestion, Icon *pIcon, CairoContainer *pContainer);
 
235
 
 
236
 
 
237
/** Test if an icon has at least one dialog.
 
238
*@param pIcon the icon.
 
239
*@return TRUE if the icon has one or more dialog(s).
 
240
*/
 
241
gboolean cairo_dock_icon_has_dialog (Icon *pIcon);
 
242
 
 
243
/** Search the "the best icon possible" for a Dock to hold a general dialog.
 
244
*@param pDock a dock (NULL to search inside the main dock).
 
245
*@return an Icon, or NULL if the dock is empty.
 
246
*/
 
247
Icon *cairo_dock_get_dialogless_icon_full (CairoDock *pDock);
 
248
 
 
249
#define cairo_dock_get_dialogless_icon(...) cairo_dock_get_dialogless_icon_full (NULL)
 
250
 
 
251
/** Pop up a dialog, pointing on "the best icon possible". This allows to display a general message.
 
252
*@param cMessage the message.
 
253
*@param fTimeLength life time of the dialog, in ms.
 
254
*@return the newly created dialog, visible and with a reference of 1.
 
255
*/
 
256
CairoDialog * cairo_dock_show_general_message (const gchar *cMessage, double fTimeLength);
 
257
 
 
258
/** Pop up a dialog, pointing on "the best icon possible", and wait. This allows to display a general message.
 
259
*@param cQuestion the message.
 
260
*@return GTK_RESPONSE_YES ou GTK_RESPONSE_NO according to the user's choice, or GTK_RESPONSE_NONE if the dialog has been destroyed before.
 
261
*/
 
262
int cairo_dock_ask_general_question_and_wait (const gchar *cQuestion);
 
263
 
 
264
 
 
265
/** Hide a dialog.
 
266
*@param pDialog the dialog.
 
267
*/
 
268
void cairo_dock_hide_dialog (CairoDialog *pDialog);
 
269
/** Show a dialog and give it focus.
 
270
*@param pDialog the dialog.
 
271
*/
 
272
void cairo_dock_unhide_dialog (CairoDialog *pDialog);
 
273
/** Toggle the visibility of a dialog.
 
274
*@param pDialog the dialog.
 
275
*/
 
276
void cairo_dock_toggle_dialog_visibility (CairoDialog *pDialog);
 
277
 
 
278
 
 
279
G_END_DECLS
 
280
#endif