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