lib/gtk: add `GtkWidget::destroy|show|hide` and avoid conflicts
[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 #@https://developer.gnome.org/gtk3/stable/GtkDialog.html
28 extern class GtkDialog `{GtkDialog *`}
29 super GtkWindow
30
31 new is extern `{
32 return (GtkDialog *)gtk_dialog_new( );
33 `}
34
35 new with_buttons( title : String, parent : GtkWindow, flags : GtkDialogFlags) is extern import String.to_cstring`{
36 return (GtkDialog *)gtk_dialog_new_with_buttons( String_to_cstring( title ), parent, flags, "", NULL );
37 `}
38
39 fun run is extern `{
40 gtk_dialog_run( recv );
41 `}
42
43 end
44
45 #Display information about an application
46 #@https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html
47 extern class GtkAboutDialog `{GtkAboutDialog *`}
48 super GtkDialog
49
50 new is extern `{
51 return (GtkAboutDialog *)gtk_about_dialog_new( );
52 `}
53
54 fun program_name : String import NativeString.to_s `{
55 return NativeString_to_s( (char *)gtk_about_dialog_get_program_name( recv ) );
56 `}
57
58 fun program_name=( name : String ) is extern import String.to_cstring`{
59 gtk_about_dialog_set_program_name( recv, String_to_cstring( name ) );
60 `}
61
62 fun version : String import NativeString.to_s `{
63 return NativeString_to_s( (char *)gtk_about_dialog_get_version( recv ) );
64 `}
65
66 fun version=( v : String ) is extern import String.to_cstring`{
67 gtk_about_dialog_set_version( recv, String_to_cstring( v ) );
68 `}
69
70 fun copyright : String import NativeString.to_s `{
71 return NativeString_to_s( (char *)gtk_about_dialog_get_copyright( recv ) );
72 `}
73
74 fun copyright=( c : String ) is extern import String.to_cstring`{
75 gtk_about_dialog_set_copyright( recv, String_to_cstring( c ) );
76 `}
77
78 fun comments : String import NativeString.to_s `{
79 return NativeString_to_s( (char *)gtk_about_dialog_get_comments( recv ) );
80 `}
81
82 fun comments=( com : String ) is extern import String.to_cstring`{
83 gtk_about_dialog_set_comments( recv, String_to_cstring( com ) );
84 `}
85
86 fun license : String import NativeString.to_s `{
87 return NativeString_to_s( (char *)gtk_about_dialog_get_license( recv ) );
88 `}
89
90 fun license=( li : String ) is extern import String.to_cstring`{
91 gtk_about_dialog_set_license( recv, String_to_cstring( li ) );
92 `}
93
94 #license_type
95
96 fun website : String import NativeString.to_s `{
97 return NativeString_to_s( (char *)gtk_about_dialog_get_website( recv ) );
98 `}
99
100 fun website=( link : String ) is extern import String.to_cstring`{
101 gtk_about_dialog_set_website( recv, String_to_cstring( link ) );
102 `}
103
104 fun website_label : String import NativeString.to_s `{
105 return NativeString_to_s( (char *) gtk_about_dialog_get_website_label( recv ) );
106 `}
107
108 fun website_label=( link_label : String ) is extern import String.to_cstring`{
109 gtk_about_dialog_set_website_label( recv, String_to_cstring( link_label ) );
110 `}
111
112 #TODO
113 #fun authors : String is extern`{
114 # return NativeString_to_s( gtk_about_dialog_get_authors( recv ) );
115 #`}
116
117 #TODO
118 #fun authors=( authors_list : String ) is extern import String.to_cstring`{
119 # gtk_about_dialog_set_authors( recv, String_to_cstring( authors_list ) );
120 #`}
121
122 fun show_about_dialog(parent: GtkWindow, params: String) import String.to_cstring `{
123 gtk_show_about_dialog(parent, String_to_cstring(params), NULL);
124 `}
125 end
126
127 #An application chooser dialog
128 #@https://developer.gnome.org/gtk3/stable/GtkAppChooserDialog.html
129 extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
130 super GtkDialog
131
132 #TODO - GFile
133 #new ( parent : GtkWindow, flags : GtkDialogFlags, file : GFile ) is extern `{
134 # return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new( parent, flags, file );
135 #`}
136
137 new for_content_type ( parent : GtkWindow, flags : GtkDialogFlags, content_type : String ) is extern import String.to_cstring `{
138 return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new_for_content_type( parent, flags, String_to_cstring( content_type ) );
139 `}
140
141 fun widget : GtkWidget is extern `{ return gtk_app_chooser_dialog_get_widget( recv ); `}
142
143 fun heading : String import NativeString.to_s `{
144 return NativeString_to_s( (char *)gtk_app_chooser_dialog_get_heading( recv ) );
145 `}
146
147 fun heading=( text : String ) is extern import String.to_cstring `{
148 gtk_app_chooser_dialog_set_heading( recv, String_to_cstring( text ) );
149 `}
150
151 end
152
153 #A dialog for choosing colors
154 #@https://developer.gnome.org/gtk3/stable/GtkColorChooserDialog.html
155 extern class GtkColorChooserDialog `{GtkColorChooserDialog *`}
156 super GtkDialog
157
158 new ( title : String, parent : GtkWindow ) is extern import String.to_cstring `{
159 return (GtkColorChooserDialog *)gtk_color_chooser_dialog_new( String_to_cstring( title ), parent );
160 `}
161 end
162
163 #A file chooser dialog, suitable for "File/Open" or "File/Save" commands
164 #@https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html
165 extern class GtkFileChooserDialog `{GtkFileChooserDialog *`}
166 super GtkDialog
167
168 new ( title : String, parent : GtkWindow, action : GtkFileChooserAction ) is extern import String.to_cstring `{
169 return (GtkFileChooserDialog *)gtk_file_chooser_dialog_new( String_to_cstring( title ), parent, action, "", NULL );
170 `}
171 end
172
173 #enum GtkFileChooserAction
174 #Describes whether a GtkFileChooser is being used to open existing files or to save to a possibly new file.
175 #@https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#GtkFileChooserAction
176 extern class GtkFileChooserAction `{GtkFileChooserAction`}
177 #Indicates open mode. The file chooser will only let the user pick an existing file.
178 new open `{ return GTK_FILE_CHOOSER_ACTION_OPEN; `}
179
180 #Indicates save mode. The file chooser will let the user pick an existing file, or type in a new filename.
181 new save `{ return GTK_FILE_CHOOSER_ACTION_SAVE; `}
182
183 #Indicates an Open mode for selecting folders. The file chooser will let the user pick an existing folder.
184 new select_folder `{ return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; `}
185
186 #Indicates a mode for creating a new folder. The file chooser will let the user name an existing or new folder.
187 new create_folder `{ return GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; `}
188 end
189
190 #A dialog for selecting fonts
191 #@https://developer.gnome.org/gtk3/stable/GtkFontChooserDialog.html
192 extern class GtkFontChooserDialog `{GtkFontChooserDialog *`}
193 super GtkDialog
194
195 new ( title : String, parent : GtkWindow ) is extern `{
196 return (GtkFontChooserDialog *)gtk_font_chooser_dialog_new( String_to_cstring( title ), parent );
197 `}
198 end
199
200 #A convenient message window
201 #@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
202 extern class GtkMessageDialog `{GtkMessageDialog *`}
203 super GtkDialog
204
205 new ( parent : GtkWindow, flags : GtkDialogFlags, msg_type : GtkMessageType, btn_type : GtkButtonsType, format : String ) is extern import String.to_cstring `{
206 return (GtkMessageDialog *)gtk_message_dialog_new( parent, flags, msg_type, btn_type, String_to_cstring( format ), NULL );
207 `}
208 end
209
210 #enum GtkButtonsType
211 #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().
212 #@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkButtonsType
213 extern class GtkButtonsType `{GtkButtonsType`}
214 #No buttons at all
215 new none `{ return GTK_BUTTONS_NONE; `}
216
217 #An OK button.
218 new ok `{ return GTK_BUTTONS_OK; `}
219
220 #A Close button.
221 new close `{ return GTK_BUTTONS_CLOSE; `}
222
223 #A Cancel button.
224 new cancel `{ return GTK_BUTTONS_CANCEL; `}
225
226 #Yes and No buttons.
227 new yes_no `{ return GTK_BUTTONS_YES_NO; `}
228
229 #OK and Cancel buttons.
230 new ok_cancel `{ return GTK_BUTTONS_OK_CANCEL; `}
231 end
232
233 #enum GtkMessageType
234 #The type of message being displayed in the dialog.
235 #@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkMessageType
236 extern class GtkMessageType `{GtkMessageType`}
237 #Informational message
238 new info `{ return GTK_MESSAGE_INFO; `}
239
240 #Non-fatal warning message.
241 new warning `{ return GTK_MESSAGE_WARNING; `}
242
243 #Question requiring a choice.
244 new question `{ return GTK_MESSAGE_QUESTION; `}
245
246 #Fatal error message.
247 new error `{ return GTK_MESSAGE_ERROR; `}
248
249 #None of the above, doesn't get an icon.
250 new other `{ return GTK_MESSAGE_OTHER; `}
251 end
252
253 #A page setup dialog
254 #@https://developer.gnome.org/gtk3/stable/GtkPageSetupUnixDialog.html
255 #extern class GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
256 # super GtkDialog
257 #
258 #end
259
260 #A print dialog
261 #@https://developer.gnome.org/gtk3/stable/GtkPrintUnixDialog.html
262 #extern class GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
263 # super GtkDialog
264 #
265 #end
266
267 #Displays recently used files in a dialog
268 #@https://developer.gnome.org/gtk3/stable/GtkRecentChooserDialog.html
269 extern class GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
270 super GtkDialog
271
272 end
273
274
275 #enum GtkDialogFlags
276 #Flags used to influence dialog construction.
277 #@https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkDialogFlags
278 extern class GtkDialogFlags `{GtkDialogFlags`}
279 #Make the constructed dialog modal.
280 new modal `{ return GTK_DIALOG_MODAL; `}
281
282 #Destroy the dialog when its parent is destroyed.
283 new destroy_with_parent `{ return GTK_DIALOG_DESTROY_WITH_PARENT; `}
284 end
285
286 #enum GtkResponseType
287 #Predefined values for use as response ids in gtk_dialog_add_button().
288 #@https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkResponseType
289 extern class GtkResponseType `{GtkResponseType`}
290 #Returned if an action widget has no response id, or if the dialog gets programmatically hidden or destroyed.
291 new none `{ return GTK_RESPONSE_NONE; `}
292
293 #Generic response id, not used by GTK+ dialogs.
294 new reject `{ return GTK_RESPONSE_REJECT; `}
295
296 #Generic response id, not used by GTK+ dialogs
297 new accept `{ return GTK_RESPONSE_ACCEPT; `}
298
299 #Returned if the dialog is deleted
300 new delete_event `{ return GTK_RESPONSE_DELETE_EVENT; `}
301 #Returned by OK buttons in GTK+ dialogs.
302 new ok `{ return GTK_RESPONSE_OK; `}
303
304 #Returned by Cancel buttons in GTK+ dialogs.
305 new cancel `{ return GTK_RESPONSE_CANCEL; `}
306
307 #Returned by OK Close in GTK+ dialogs.
308 new close `{ return GTK_RESPONSE_CLOSE; `}
309
310 #Returned by OK Yes in GTK+ dialogs.
311 new yes `{ return GTK_RESPONSE_YES; `}
312
313 #Returned by OK No in GTK+ dialogs.
314 new no `{ return GTK_RESPONSE_NO; `}
315
316 #Returned by OK Apply in GTK+ dialogs.
317 new apply `{ return GTK_RESPONSE_APPLY; `}
318
319 #Returned by OK Help in GTK+ dialogs.
320 new help `{ return GTK_RESPONSE_HELP; `}
321 end