*: update all clients of the `CString::to_s` services
[nit.git] / lib / gtk / v3_4 / gtk_dialogs.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
4 # Copyright 2013 Nathan Heu <heu.nathan@courrier.uqam.ca>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 module gtk_dialogs is pkgconfig("gtk+-3.0")
19
20 import gtk_core
21
22 in "C Header" `{
23 #include <gtk/gtk.h>
24 `}
25
26 # Create popup windows
27 # See: https://developer.gnome.org/gtk3/stable/GtkDialog.html
28 extern class GtkDialog `{GtkDialog *`}
29 super GtkWindow
30
31 new `{
32 return (GtkDialog *)gtk_dialog_new();
33 `}
34
35 new with_buttons(title: String, parent: GtkWindow, flags: GtkDialogFlags)
36 import String.to_cstring `{
37 return (GtkDialog *)gtk_dialog_new_with_buttons(
38 String_to_cstring(title), parent, flags, "", NULL);
39 `}
40
41 fun run `{
42 gtk_dialog_run(self);
43 `}
44 end
45
46 # Display information about an application
47 # See: https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html
48 extern class GtkAboutDialog `{GtkAboutDialog *`}
49 super GtkDialog
50
51 new `{
52 return (GtkAboutDialog *)gtk_about_dialog_new();
53 `}
54
55 fun program_name: String import CString.to_s `{
56 return CString_to_s((char *)gtk_about_dialog_get_program_name(self));
57 `}
58
59 fun program_name=(name: String) import String.to_cstring `{
60 gtk_about_dialog_set_program_name(self, String_to_cstring(name));
61 `}
62
63 fun version: String import CString.to_s `{
64 return CString_to_s((char *)gtk_about_dialog_get_version(self));
65 `}
66
67 fun version=(v: String) import String.to_cstring `{
68 gtk_about_dialog_set_version(self, String_to_cstring(v));
69 `}
70
71 fun copyright: String import CString.to_s `{
72 return CString_to_s((char *)gtk_about_dialog_get_copyright(self));
73 `}
74
75 fun copyright=(c: String) import String.to_cstring `{
76 gtk_about_dialog_set_copyright(self, String_to_cstring(c));
77 `}
78
79 fun comments: String import CString.to_s `{
80 return CString_to_s((char *)gtk_about_dialog_get_comments(self));
81 `}
82
83 fun comments=(com: String) import String.to_cstring `{
84 gtk_about_dialog_set_comments(self, String_to_cstring(com));
85 `}
86
87 fun license: String import CString.to_s `{
88 return CString_to_s((char *)gtk_about_dialog_get_license(self));
89 `}
90
91 fun license=(li: String) import String.to_cstring `{
92 gtk_about_dialog_set_license(self, String_to_cstring(li));
93 `}
94
95 # license_type
96
97 fun website: String import CString.to_s `{
98 return CString_to_s((char *)gtk_about_dialog_get_website(self));
99 `}
100
101 fun website=(link: String) import String.to_cstring `{
102 gtk_about_dialog_set_website(self, String_to_cstring(link));
103 `}
104
105 fun website_label: String import CString.to_s `{
106 return CString_to_s((char *) gtk_about_dialog_get_website_label(self));
107 `}
108
109 fun website_label=(link_label: String) import String.to_cstring `{
110 gtk_about_dialog_set_website_label(self, String_to_cstring(link_label));
111 `}
112
113 # TODO
114 # fun authors: String import CString.to_s `{
115 # return CString_to_s(gtk_about_dialog_get_authors(self));
116 # `}
117
118 # TODO
119 # fun authors=(authors_list: String) import String.to_cstring`{
120 # gtk_about_dialog_set_authors(self, String_to_cstring(authors_list));
121 # `}
122
123 fun show_about_dialog(parent: GtkWindow, params: String)
124 import String.to_cstring `{
125 gtk_show_about_dialog(parent, String_to_cstring(params), NULL);
126 `}
127 end
128
129 # An application chooser dialog
130 # See: https://developer.gnome.org/gtk3/stable/GtkAppChooserDialog.html
131 extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
132 super GtkDialog
133
134 # TODO - GFile
135 # new (parent: GtkWindow, flags: GtkDialogFlags, file: GFile) `{
136 # return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new(parent, flags, file);
137 # `}
138
139 new for_content_type (parent: GtkWindow, flags: GtkDialogFlags, content_type: String)
140 import String.to_cstring `{
141 return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new_for_content_type(
142 parent, flags, String_to_cstring(content_type));
143 `}
144
145 fun widget: GtkWidget `{ return gtk_app_chooser_dialog_get_widget(self); `}
146
147 fun heading: String import CString.to_s `{
148 return CString_to_s((char *)gtk_app_chooser_dialog_get_heading(self));
149 `}
150
151 fun heading=(text: String) import String.to_cstring `{
152 gtk_app_chooser_dialog_set_heading(self, String_to_cstring(text));
153 `}
154
155 end
156
157 # A dialog for choosing colors
158 # See: https://developer.gnome.org/gtk3/stable/GtkColorChooserDialog.html
159 extern class GtkColorChooserDialog `{GtkColorChooserDialog *`}
160 super GtkDialog
161
162 new (title: String, parent: GtkWindow) import String.to_cstring `{
163 return (GtkColorChooserDialog *)gtk_color_chooser_dialog_new(
164 String_to_cstring(title), parent);
165 `}
166 end
167
168 # A file chooser dialog, suitable for "File/Open" or "File/Save" commands
169 # See: https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html
170 extern class GtkFileChooserDialog `{GtkFileChooserDialog *`}
171 super GtkDialog
172
173 new (title: String, parent: GtkWindow, action: GtkFileChooserAction)
174 import String.to_cstring `{
175 return (GtkFileChooserDialog *)gtk_file_chooser_dialog_new(
176 String_to_cstring(title), parent, action, "", NULL);
177 `}
178 end
179
180 # enum GtkFileChooserAction
181 #
182 # Describes whether a GtkFileChooser is being used to open existing files or to save to a possibly new file.
183 # See: https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#GtkFileChooserAction
184 extern class GtkFileChooserAction `{GtkFileChooserAction`}
185 # Open file mode
186 #
187 # The file chooser will only let the user pick an existing file.
188 new open `{ return GTK_FILE_CHOOSER_ACTION_OPEN; `}
189
190 # Save file mode
191 #
192 # The file chooser will let the user pick an existing file, or type in a new filename.
193 new save `{ return GTK_FILE_CHOOSER_ACTION_SAVE; `}
194
195 # Select folder mode
196 #
197 # The file chooser will let the user pick an existing folder.
198 new select_folder `{ return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; `}
199
200 # Create a new folder mode
201 #
202 # The file chooser will let the user name an existing or new folder.
203 new create_folder `{ return GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; `}
204 end
205
206 # A dialog for selecting fonts
207 # See: https://developer.gnome.org/gtk3/stable/GtkFontChooserDialog.html
208 extern class GtkFontChooserDialog `{GtkFontChooserDialog *`}
209 super GtkDialog
210
211 new (title: String, parent: GtkWindow) `{
212 return (GtkFontChooserDialog *)gtk_font_chooser_dialog_new(String_to_cstring(title), parent);
213 `}
214 end
215
216 # A convenient message window
217 # See: https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
218 extern class GtkMessageDialog `{GtkMessageDialog *`}
219 super GtkDialog
220
221 new (parent: GtkWindow, flags: GtkDialogFlags, msg_type: GtkMessageType, btn_type: GtkButtonsType, format: String) import String.to_cstring `{
222 return (GtkMessageDialog *)gtk_message_dialog_new(parent, flags, msg_type, btn_type, String_to_cstring(format), NULL);
223 `}
224 end
225
226 # enum GtkButtonsType
227 # Prebuilt sets of buttons for the dialog. If none of these choices are appropriate, simply use GTK_BUTTONS_NONE then call gtk_dialog_add_buttons().
228 # See: https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkButtonsType
229 extern class GtkButtonsType `{GtkButtonsType`}
230 # No buttons at all
231 new none `{ return GTK_BUTTONS_NONE; `}
232
233 # An OK button.
234 new ok `{ return GTK_BUTTONS_OK; `}
235
236 # A Close button.
237 new close `{ return GTK_BUTTONS_CLOSE; `}
238
239 # A Cancel button.
240 new cancel `{ return GTK_BUTTONS_CANCEL; `}
241
242 # Yes and No buttons.
243 new yes_no `{ return GTK_BUTTONS_YES_NO; `}
244
245 # OK and Cancel buttons.
246 new ok_cancel `{ return GTK_BUTTONS_OK_CANCEL; `}
247 end
248
249 # enum GtkMessageType
250 # The type of message being displayed in the dialog.
251 # See: https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkMessageType
252 extern class GtkMessageType `{GtkMessageType`}
253 # Informational message
254 new info `{ return GTK_MESSAGE_INFO; `}
255
256 # Non-fatal warning message.
257 new warning `{ return GTK_MESSAGE_WARNING; `}
258
259 # Question requiring a choice.
260 new question `{ return GTK_MESSAGE_QUESTION; `}
261
262 # Fatal error message.
263 new error `{ return GTK_MESSAGE_ERROR; `}
264
265 # None of the above, doesn't get an icon.
266 new other `{ return GTK_MESSAGE_OTHER; `}
267 end
268
269 # A page setup dialog
270 # See: https://developer.gnome.org/gtk3/stable/GtkPageSetupUnixDialog.html
271 # extern class GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
272 # super GtkDialog
273 #
274 # end
275
276 # A print dialog
277 # See: https://developer.gnome.org/gtk3/stable/GtkPrintUnixDialog.html
278 # extern class GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
279 # super GtkDialog
280 #
281 # end
282
283 # Displays recently used files in a dialog
284 # See: https://developer.gnome.org/gtk3/stable/GtkRecentChooserDialog.html
285 extern class GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
286 super GtkDialog
287
288 end
289
290
291 # enum GtkDialogFlags
292 # Flags used to influence dialog construction.
293 # See: https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkDialogFlags
294 extern class GtkDialogFlags `{GtkDialogFlags`}
295 # Make the constructed dialog modal.
296 new modal `{ return GTK_DIALOG_MODAL; `}
297
298 # Destroy the dialog when its parent is destroyed.
299 new destroy_with_parent `{ return GTK_DIALOG_DESTROY_WITH_PARENT; `}
300 end
301
302 # enum GtkResponseType
303 # Predefined values for use as response ids in gtk_dialog_add_button().
304 # See: https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkResponseType
305 extern class GtkResponseType `{GtkResponseType`}
306 # Returned if an action widget has no response id, or if the dialog gets programmatically hidden or destroyed.
307 new none `{ return GTK_RESPONSE_NONE; `}
308
309 # Generic response id, not used by GTK+ dialogs.
310 new reject `{ return GTK_RESPONSE_REJECT; `}
311
312 # Generic response id, not used by GTK+ dialogs
313 new accept `{ return GTK_RESPONSE_ACCEPT; `}
314
315 # Returned if the dialog is deleted
316 new delete_event `{ return GTK_RESPONSE_DELETE_EVENT; `}
317 # Returned by OK buttons in GTK+ dialogs.
318 new ok `{ return GTK_RESPONSE_OK; `}
319
320 # Returned by Cancel buttons in GTK+ dialogs.
321 new cancel `{ return GTK_RESPONSE_CANCEL; `}
322
323 # Returned by OK Close in GTK+ dialogs.
324 new close `{ return GTK_RESPONSE_CLOSE; `}
325
326 # Returned by OK Yes in GTK+ dialogs.
327 new yes `{ return GTK_RESPONSE_YES; `}
328
329 # Returned by OK No in GTK+ dialogs.
330 new no `{ return GTK_RESPONSE_NO; `}
331
332 # Returned by OK Apply in GTK+ dialogs.
333 new apply `{ return GTK_RESPONSE_APPLY; `}
334
335 # Returned by OK Help in GTK+ dialogs.
336 new help `{ return GTK_RESPONSE_HELP; `}
337 end