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")
27 #@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) is extern import String.to_cstring`{
36 return (GtkDialog *)gtk_dialog_new_with_buttons
( String_to_cstring( title
), parent
, flags
, "", NULL );
40 gtk_dialog_run
( recv
);
45 #Display information about an application
46 #@https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html
47 extern class GtkAboutDialog `{GtkAboutDialog *`}
51 return (GtkAboutDialog *)gtk_about_dialog_new( );
54 fun program_name
: String import NativeString.to_s
`{
55 return NativeString_to_s( (char *)gtk_about_dialog_get_program_name( recv ) );
58 fun program_name
=( name
: String ) is extern import String.to_cstring
`{
59 gtk_about_dialog_set_program_name( recv, String_to_cstring( name ) );
62 fun version
: String import NativeString.to_s
`{
63 return NativeString_to_s( (char *)gtk_about_dialog_get_version( recv ) );
66 fun version
=( v
: String ) is extern import String.to_cstring
`{
67 gtk_about_dialog_set_version( recv, String_to_cstring( v ) );
70 fun copyright
: String import NativeString.to_s
`{
71 return NativeString_to_s( (char *)gtk_about_dialog_get_copyright( recv ) );
74 fun copyright
=( c
: String ) is extern import String.to_cstring
`{
75 gtk_about_dialog_set_copyright( recv, String_to_cstring( c ) );
78 fun comments
: String import NativeString.to_s
`{
79 return NativeString_to_s( (char *)gtk_about_dialog_get_comments( recv ) );
82 fun comments
=( com
: String ) is extern import String.to_cstring
`{
83 gtk_about_dialog_set_comments( recv, String_to_cstring( com ) );
86 fun license
: String import NativeString.to_s
`{
87 return NativeString_to_s( (char *)gtk_about_dialog_get_license( recv ) );
90 fun license
=( li
: String ) is extern import String.to_cstring
`{
91 gtk_about_dialog_set_license( recv, String_to_cstring( li ) );
96 fun website
: String import NativeString.to_s
`{
97 return NativeString_to_s( (char *)gtk_about_dialog_get_website( recv ) );
100 fun website
=( link
: String ) is extern import String.to_cstring
`{
101 gtk_about_dialog_set_website( recv, String_to_cstring( link ) );
104 fun website_label
: String import NativeString.to_s
`{
105 return NativeString_to_s( (char *) gtk_about_dialog_get_website_label( recv ) );
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 ) );
113 #fun authors : String is extern`{
114 # return NativeString_to_s( gtk_about_dialog_get_authors( recv ) );
118 #fun authors=( authors_list : String ) is extern import String.to_cstring`{
119 # gtk_about_dialog_set_authors( recv, String_to_cstring( authors_list ) );
122 fun show_about_dialog
(parent
: GtkWindow, params
: String) import String.to_cstring
`{
123 gtk_show_about_dialog(parent, String_to_cstring(params), NULL);
127 #An application chooser dialog
128 #@https://developer.gnome.org/gtk3/stable/GtkAppChooserDialog.html
129 extern class GtkAppChooserDialog `{GtkAppChooserDialog *`}
133 #new ( parent : GtkWindow, flags : GtkDialogFlags, file : GFile ) is extern `{
134 # return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new( parent, flags, file );
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 ) );
141 fun widget
: GtkWidget is extern `{ return gtk_app_chooser_dialog_get_widget( recv ); `}
143 fun heading : String import NativeString.to_s `{
144 return NativeString_to_s( (char
*)gtk_app_chooser_dialog_get_heading
( recv
) );
147 fun heading=( text : String ) is extern import String.to_cstring `{
148 gtk_app_chooser_dialog_set_heading
( recv
, String_to_cstring( text
) );
153 #A dialog for choosing colors
154 #@https://developer.gnome.org/gtk3/stable/GtkColorChooserDialog.html
155 extern class GtkColorChooserDialog `{GtkColorChooserDialog *`}
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 );
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 *`}
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 );
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; `}
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; `}
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; `}
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; `}
190 #A dialog for selecting fonts
191 #@https://developer.gnome.org/gtk3/stable/GtkFontChooserDialog.html
192 extern class GtkFontChooserDialog `{GtkFontChooserDialog *`}
195 new ( title : String, parent : GtkWindow ) is extern `{
196 return (GtkFontChooserDialog *)gtk_font_chooser_dialog_new
( String_to_cstring( title
), parent
);
200 #A convenient message window
201 #@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
202 extern class GtkMessageDialog `{GtkMessageDialog *`}
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 );
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`}
215 new none `{ return GTK_BUTTONS_NONE; `}
218 new ok
`{ return GTK_BUTTONS_OK; `}
221 new close `{ return GTK_BUTTONS_CLOSE; `}
224 new cancel
`{ return GTK_BUTTONS_CANCEL; `}
227 new yes_no `{ return GTK_BUTTONS_YES_NO; `}
229 #OK and Cancel buttons.
230 new ok_cancel
`{ return GTK_BUTTONS_OK_CANCEL; `}
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; `}
240 #Non-fatal warning message.
241 new warning `{ return GTK_MESSAGE_WARNING; `}
243 #Question requiring a choice.
244 new question
`{ return GTK_MESSAGE_QUESTION; `}
246 #Fatal error message.
247 new error `{ return GTK_MESSAGE_ERROR; `}
249 #None of the above, doesn't get an icon.
250 new other
`{ return GTK_MESSAGE_OTHER; `}
254 #@https://developer.gnome.org/gtk3/stable/GtkPageSetupUnixDialog.html
255 #extern class GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
261 #@https://developer.gnome.org/gtk3/stable/GtkPrintUnixDialog.html
262 #extern class GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
267 #Displays recently used files in a dialog
268 #@https://developer.gnome.org/gtk3/stable/GtkRecentChooserDialog.html
269 extern class GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
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; `}
282 #Destroy the dialog when its parent is destroyed.
283 new destroy_with_parent `{ return GTK_DIALOG_DESTROY_WITH_PARENT; `}
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; `}
293 #Generic response id, not used by GTK+ dialogs.
294 new reject
`{ return GTK_RESPONSE_REJECT; `}
296 #Generic response id, not used by GTK+ dialogs
297 new accept `{ return GTK_RESPONSE_ACCEPT; `}
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; `}
304 #Returned by Cancel buttons in GTK+ dialogs.
305 new cancel
`{ return GTK_RESPONSE_CANCEL; `}
307 #Returned by OK Close in GTK+ dialogs.
308 new close `{ return GTK_RESPONSE_CLOSE; `}
310 #Returned by OK Yes in GTK+ dialogs.
311 new yes
`{ return GTK_RESPONSE_YES; `}
313 #Returned by OK No in GTK+ dialogs.
314 new no `{ return GTK_RESPONSE_NO; `}
316 #Returned by OK Apply in GTK+ dialogs.
317 new apply
`{ return GTK_RESPONSE_APPLY; `}
319 #Returned by OK Help in GTK+ dialogs.
320 new help `{ return GTK_RESPONSE_HELP; `}