1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
4 # Copyright 2013 Nathan Heu <heu.nathan@courrier.uqam.ca>
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
10 # http://www.apache.org/licenses/LICENSE-2.0
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.
18 module gtk_dialogs
is pkgconfig
("gtk+-3.0")
26 # Create popup windows
27 # See: https://developer.gnome.org/gtk3/stable/GtkDialog.html
28 extern class GtkDialog `{GtkDialog *`}
32 return (GtkDialog *)gtk_dialog_new
();
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);
46 # Display information about an application
47 # See: https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html
48 extern class GtkAboutDialog `{GtkAboutDialog *`}
52 return (GtkAboutDialog *)gtk_about_dialog_new();
55 fun program_name
: String import NativeString.to_s
`{
56 return NativeString_to_s((char *)gtk_about_dialog_get_program_name(self));
59 fun program_name
=(name
: String) import String.to_cstring
`{
60 gtk_about_dialog_set_program_name(self, String_to_cstring(name));
63 fun version
: String import NativeString.to_s
`{
64 return NativeString_to_s((char *)gtk_about_dialog_get_version(self));
67 fun version
=(v
: String) import String.to_cstring
`{
68 gtk_about_dialog_set_version(self, String_to_cstring(v));
71 fun copyright
: String import NativeString.to_s
`{
72 return NativeString_to_s((char *)gtk_about_dialog_get_copyright(self));
75 fun copyright
=(c
: String) import String.to_cstring
`{
76 gtk_about_dialog_set_copyright(self, String_to_cstring(c));
79 fun comments
: String import NativeString.to_s
`{
80 return NativeString_to_s((char *)gtk_about_dialog_get_comments(self));
83 fun comments
=(com
: String) import String.to_cstring
`{
84 gtk_about_dialog_set_comments(self, String_to_cstring(com));
87 fun license
: String import NativeString.to_s
`{
88 return NativeString_to_s((char *)gtk_about_dialog_get_license(self));
91 fun license
=(li
: String) import String.to_cstring
`{
92 gtk_about_dialog_set_license(self, String_to_cstring(li));
97 fun website
: String import NativeString.to_s
`{
98 return NativeString_to_s((char *)gtk_about_dialog_get_website(self));
101 fun website
=(link
: String) import String.to_cstring
`{
102 gtk_about_dialog_set_website(self, String_to_cstring(link));
105 fun website_label
: String import NativeString.to_s
`{
106 return NativeString_to_s((char *) gtk_about_dialog_get_website_label(self));
109 fun website_label
=(link_label
: String) import String.to_cstring
`{
110 gtk_about_dialog_set_website_label(self, String_to_cstring(link_label));
114 # fun authors: String`{
115 # return NativeString_to_s(gtk_about_dialog_get_authors(self));
119 # fun authors=(authors_list: String) import String.to_cstring`{
120 # gtk_about_dialog_set_authors(self, String_to_cstring(authors_list));
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);
129 # An application chooser dialog
130 # See: https://developer.gnome.org/gtk3/stable/GtkAppChooserDialog.html
131 extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
135 # new (parent: GtkWindow, flags: GtkDialogFlags, file: GFile) `{
136 # return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new(parent, flags, file);
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));
145 fun widget
: GtkWidget `{ return gtk_app_chooser_dialog_get_widget(self); `}
147 fun heading: String import NativeString.to_s `{
148 return NativeString_to_s((char
*)gtk_app_chooser_dialog_get_heading
(self));
151 fun heading=(text: String) import String.to_cstring `{
152 gtk_app_chooser_dialog_set_heading
(self, String_to_cstring(text
));
157 # A dialog for choosing colors
158 # See: https://developer.gnome.org/gtk3/stable/GtkColorChooserDialog.html
159 extern class GtkColorChooserDialog `{GtkColorChooserDialog *`}
162 new (title
: String, parent
: GtkWindow) import String.to_cstring
`{
163 return (GtkColorChooserDialog *)gtk_color_chooser_dialog_new(
164 String_to_cstring(title), parent);
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 *`}
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);
180 # enum GtkFileChooserAction
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`}
187 # The file chooser will only let the user pick an existing file.
188 new open
`{ return GTK_FILE_CHOOSER_ACTION_OPEN; `}
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; `}
197 # The file chooser will let the user pick an existing folder.
198 new select_folder
`{ return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; `}
200 # Create a new folder mode
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; `}
206 # A dialog for selecting fonts
207 # See: https://developer.gnome.org/gtk3/stable/GtkFontChooserDialog.html
208 extern class GtkFontChooserDialog `{GtkFontChooserDialog *`}
211 new (title: String, parent: GtkWindow) `{
212 return (GtkFontChooserDialog *)gtk_font_chooser_dialog_new
(String_to_cstring(title
), parent
);
216 # A convenient message window
217 # See: https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
218 extern class GtkMessageDialog `{GtkMessageDialog *`}
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);
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`}
231 new none `{ return GTK_BUTTONS_NONE; `}
234 new ok
`{ return GTK_BUTTONS_OK; `}
237 new close `{ return GTK_BUTTONS_CLOSE; `}
240 new cancel
`{ return GTK_BUTTONS_CANCEL; `}
242 # Yes and No buttons.
243 new yes_no `{ return GTK_BUTTONS_YES_NO; `}
245 # OK and Cancel buttons.
246 new ok_cancel
`{ return GTK_BUTTONS_OK_CANCEL; `}
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; `}
256 # Non-fatal warning message.
257 new warning `{ return GTK_MESSAGE_WARNING; `}
259 # Question requiring a choice.
260 new question
`{ return GTK_MESSAGE_QUESTION; `}
262 # Fatal error message.
263 new error `{ return GTK_MESSAGE_ERROR; `}
265 # None of the above, doesn't get an icon.
266 new other
`{ return GTK_MESSAGE_OTHER; `}
269 # A page setup dialog
270 # See: https://developer.gnome.org/gtk3/stable/GtkPageSetupUnixDialog.html
271 # extern class GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
277 # See: https://developer.gnome.org/gtk3/stable/GtkPrintUnixDialog.html
278 # extern class GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
283 # Displays recently used files in a dialog
284 # See: https://developer.gnome.org/gtk3/stable/GtkRecentChooserDialog.html
285 extern class GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
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; `}
298 # Destroy the dialog when its parent is destroyed.
299 new destroy_with_parent `{ return GTK_DIALOG_DESTROY_WITH_PARENT; `}
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; `}
309 # Generic response id, not used by GTK+ dialogs.
310 new reject
`{ return GTK_RESPONSE_REJECT; `}
312 # Generic response id, not used by GTK+ dialogs
313 new accept `{ return GTK_RESPONSE_ACCEPT; `}
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; `}
320 # Returned by Cancel buttons in GTK+ dialogs.
321 new cancel
`{ return GTK_RESPONSE_CANCEL; `}
323 # Returned by OK Close in GTK+ dialogs.
324 new close `{ return GTK_RESPONSE_CLOSE; `}
326 # Returned by OK Yes in GTK+ dialogs.
327 new yes
`{ return GTK_RESPONSE_YES; `}
329 # Returned by OK No in GTK+ dialogs.
330 new no `{ return GTK_RESPONSE_NO; `}
332 # Returned by OK Apply in GTK+ dialogs.
333 new apply
`{ return GTK_RESPONSE_APPLY; `}
335 # Returned by OK Help in GTK+ dialogs.
336 new help `{ return GTK_RESPONSE_HELP; `}