gtk: add basic dialog widget and derived dialog windows : about, appChooser, fileChoo...
authornheu <heu.nathan@courrier.uqam.ca>
Tue, 7 May 2013 20:39:05 +0000 (16:39 -0400)
committernathan.heu <heu.nathan@courrier.uqam.ca>
Wed, 15 May 2013 20:19:14 +0000 (16:19 -0400)
Signed-off-by: Nathan Heu <heu.nathan@courrier.uqam.ca>

lib/gtk/gtk.nit
lib/gtk/gtk_dialogs.nit [new file with mode: 0644]

index 74b41de..9e8a64b 100644 (file)
@@ -1,4 +1,5 @@
 module gtk
 
 import gtk_widgets_ext
+import gtk_dialogs
 import gtk_assistant
diff --git a/lib/gtk/gtk_dialogs.nit b/lib/gtk/gtk_dialogs.nit
new file mode 100644 (file)
index 0000000..24abb40
--- /dev/null
@@ -0,0 +1,303 @@
+module gtk_dialogs
+import gtk_core
+
+in "C Header" `{
+       #include <gtk/gtk.h>
+`}
+
+#Create popup windows
+#@https://developer.gnome.org/gtk3/stable/GtkDialog.html
+extern GtkDialog `{GtkDialog *`}
+       super GtkWindow
+
+       new is extern `{
+               return (GtkDialog *)gtk_dialog_new( );
+       `}
+
+       new with_buttons( title : String, parent : GtkWindow, flags : GtkDialogFlags) is extern import String::to_cstring`{
+               return (GtkDialog *)gtk_dialog_new_with_buttons( String_to_cstring( title ), parent, flags, "", NULL );
+       `}
+
+       fun run is extern `{
+               gtk_dialog_run( recv );
+       `}
+
+end
+
+#Display information about an application
+#@https://developer.gnome.org/gtk3/stable/GtkAboutDialog.html
+extern GtkAboutDialog `{GtkAboutDialog *`}
+       super GtkDialog
+
+       new is extern `{
+               return (GtkAboutDialog *)gtk_about_dialog_new( );
+       `}
+
+       fun program_name : String is extern`{
+               return new_String_from_cstring( (char *)gtk_about_dialog_get_program_name( recv ) );
+       `}
+
+       fun program_name=( name : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_program_name( recv, String_to_cstring( name ) );
+       `}
+
+       fun version : String is extern`{
+               return new_String_from_cstring( (char *)gtk_about_dialog_get_version( recv ) );
+       `}
+
+       fun version=( v : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_version( recv, String_to_cstring( v ) );
+       `}
+
+       fun copyright : String is extern`{
+               return new_String_from_cstring( (char *)gtk_about_dialog_get_copyright( recv ) );
+       `}
+
+       fun copyright=( c : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_copyright( recv, String_to_cstring( c ) );
+       `}
+
+       fun comments : String is extern`{
+               return new_String_from_cstring( (char *)gtk_about_dialog_get_comments( recv ) );
+       `}
+
+       fun comments=( com : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_comments( recv, String_to_cstring( com ) );
+       `}
+
+       fun license : String is extern`{
+               return new_String_from_cstring( (char *)gtk_about_dialog_get_license( recv ) );
+       `}
+
+       fun license=( li : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_license( recv, String_to_cstring( li ) );
+       `}
+
+       #license_type
+
+       fun website : String is extern`{
+               return new_String_from_cstring( (char *)gtk_about_dialog_get_website( recv ) );
+       `}
+
+       fun website=( link : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_website( recv, String_to_cstring( link ) );
+       `}
+
+       fun website_label : String is extern`{
+               return new_String_from_cstring( (char *) gtk_about_dialog_get_website_label( recv ) );
+       `}
+
+       fun website_label=( link_label : String ) is extern import String::to_cstring`{
+               gtk_about_dialog_set_website_label( recv, String_to_cstring( link_label ) );
+       `}
+
+       #TODO
+       #fun authors : String is extern`{
+       #               return new_String_from_cstring( gtk_about_dialog_get_authors( recv ) );
+       #`}
+
+       #TODO
+       #fun authors=( authors_list : String ) is extern import String::to_cstring`{
+       #       gtk_about_dialog_set_authors( recv, String_to_cstring( authors_list ) );
+       #`}
+
+       fun show ( parent : GtkWindow, params : String ) is extern import String::to_cstring`{
+               gtk_show_about_dialog( parent, String_to_cstring( params ), NULL);
+       `}
+end
+
+#An application chooser dialog
+#@https://developer.gnome.org/gtk3/stable/GtkAppChooserDialog.html
+extern GtkAppChooserDialog `{GtkAppChooserDialog *`}
+       super GtkDialog
+
+       #TODO - GFile
+       #new ( parent : GtkWindow, flags : GtkDialogFlags, file : GFile ) is extern `{
+       #       return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new( parent, flags, file );
+       #`}
+
+       new for_content_type ( parent : GtkWindow, flags : GtkDialogFlags, content_type : String ) is extern  import String::to_cstring `{
+               return (GtkAppChooserDialog *)gtk_app_chooser_dialog_new_for_content_type( parent, flags,                                                                                                                                                                                       String_to_cstring( content_type ) );
+       `}
+
+       fun widget : GtkWidget is extern `{ return gtk_app_chooser_dialog_get_widget( recv ); `}
+
+       fun heading : String is extern `{ 
+               return new_String_from_cstring( (char *)gtk_app_chooser_dialog_get_heading( recv ) ); 
+       `}
+
+       fun heading=( text : String ) is extern import String::to_cstring `{ 
+               gtk_app_chooser_dialog_set_heading( recv, String_to_cstring( text ) ); 
+       `}
+
+end
+
+#A dialog for choosing colors
+#@https://developer.gnome.org/gtk3/stable/GtkColorChooserDialog.html
+extern GtkColorChooserDialog `{GtkColorChooserDialog *`}
+       super GtkDialog
+
+       new ( title : String, parent : GtkWindow ) is extern import String::to_cstring `{
+               return (GtkColorChooserDialog *)gtk_color_chooser_dialog_new( String_to_cstring( title ), parent );
+       `}
+end
+
+#A file chooser dialog, suitable for "File/Open" or "File/Save" commands
+#@https://developer.gnome.org/gtk3/stable/GtkFileChooserDialog.html
+extern GtkFileChooserDialog `{GtkFileChooserDialog *`}
+       super GtkDialog
+
+       new ( title : String, parent : GtkWindow, action : GtkFileChooserAction ) is extern import String::to_cstring `{
+               return (GtkFileChooserDialog *)gtk_file_chooser_dialog_new( String_to_cstring( title ), parent, action, "", NULL );
+       `}
+end
+
+#enum GtkFileChooserAction
+#Describes whether a GtkFileChooser is being used to open existing files or to save to a possibly new file.
+#@https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#GtkFileChooserAction
+extern GtkFileChooserAction `{GtkFileChooserAction`}
+       #Indicates open mode. The file chooser will only let the user pick an existing file.
+       new open `{ return GTK_FILE_CHOOSER_ACTION_OPEN; `} 
+
+       #Indicates save mode. The file chooser will let the user pick an existing file, or type in a new filename.
+       new save `{ return GTK_FILE_CHOOSER_ACTION_SAVE; `}     
+
+       #Indicates an Open mode for selecting folders. The file chooser will let the user pick an existing folder.
+       new select_folder `{ return GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; `}   
+
+       #Indicates a mode for creating a new folder. The file chooser will let the user name an existing or new folder.
+       new create_folder `{ return GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; `}   
+end
+
+#A dialog for selecting fonts
+#@https://developer.gnome.org/gtk3/stable/GtkFontChooserDialog.html
+extern GtkFontChooserDialog `{GtkFontChooserDialog *`}
+       super GtkDialog
+
+       new ( title : String, parent : GtkWindow ) is extern `{
+               return (GtkFontChooserDialog *)gtk_font_chooser_dialog_new( String_to_cstring( title ), parent );
+       `}
+end
+
+#A convenient message window
+#@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html
+extern GtkMessageDialog `{GtkMessageDialog *`}
+       super GtkDialog
+
+       new ( parent : GtkWindow, flags : GtkDialogFlags, msg_type : GtkMessageType, btn_type : GtkButtonsType, format : String ) is extern import String::to_cstring `{
+               return (GtkMessageDialog *)gtk_message_dialog_new( parent, flags, msg_type, btn_type, String_to_cstring( format ), NULL );
+       `}
+end
+
+#enum GtkButtonsType
+#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().
+#@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkButtonsType
+extern GtkButtonsType `{GtkButtonsType`}
+       #No buttons at all
+       new none `{ return GTK_BUTTONS_NONE; `} 
+
+       #An OK button.
+       new ok `{ return GTK_BUTTONS_OK; `}     
+
+       #A Close button.
+       new close `{ return GTK_BUTTONS_CLOSE; `}       
+
+       #A Cancel button.
+       new cancel `{ return GTK_BUTTONS_CANCEL; `}     
+
+       #Yes and No buttons.
+       new yes_no `{ return GTK_BUTTONS_YES_NO; `}     
+
+       #OK and Cancel buttons.
+       new ok_cancel `{ return GTK_BUTTONS_OK_CANCEL; `}       
+end
+
+#enum GtkMessageType
+#The type of message being displayed in the dialog.
+#@https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#GtkMessageType
+extern GtkMessageType `{GtkMessageType`}
+       #Informational message
+       new info `{ return GTK_MESSAGE_INFO; `} 
+
+       #Non-fatal warning message.
+       new warning `{ return GTK_MESSAGE_WARNING; `}   
+
+       #Question requiring a choice.
+       new question `{ return GTK_MESSAGE_QUESTION; `}         
+
+       #Fatal error message.
+       new error `{ return GTK_MESSAGE_ERROR; `}       
+
+       #None of the above, doesn't get an icon.
+       new other `{ return GTK_MESSAGE_OTHER; `}       
+end
+
+#A page setup dialog
+#@https://developer.gnome.org/gtk3/stable/GtkPageSetupUnixDialog.html
+#extern GtkPageSetupUnixDialog `{GtkPageSetupUnixDialog *`}
+#      super GtkDialog
+#
+#end
+
+#A print dialog
+#@https://developer.gnome.org/gtk3/stable/GtkPrintUnixDialog.html
+#extern GtkPrintUnixDialog `{GtkPrintUnixDialog *`}
+#      super GtkDialog
+#
+#end
+
+#Displays recently used files in a dialog
+#@https://developer.gnome.org/gtk3/stable/GtkRecentChooserDialog.html
+extern GtkRecentChooserDialog `{GtkRecentChooserDialog *`}
+       super GtkDialog
+
+end
+
+
+#enum GtkDialogFlags
+#Flags used to influence dialog construction.
+#@https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkDialogFlags
+extern GtkDialogFlags `{GtkDialogFlags`}
+       #Make the constructed dialog modal.
+       new modal `{ return GTK_DIALOG_MODAL; `} 
+
+       #Destroy the dialog when its parent is destroyed.       
+       new destroy_with_parent `{ return GTK_DIALOG_DESTROY_WITH_PARENT; `}    
+end
+
+#enum GtkResponseType
+#Predefined values for use as response ids in gtk_dialog_add_button().
+#@https://developer.gnome.org/gtk3/stable/GtkDialog.html#GtkResponseType
+extern GtkResponseType `{GtkResponseType`}
+       #Returned if an action widget has no response id, or if the dialog gets programmatically hidden or destroyed.
+       new none `{ return GTK_RESPONSE_NONE; `} 
+
+       #Generic response id, not used by GTK+ dialogs.
+       new reject `{ return GTK_RESPONSE_REJECT; `}    
+
+       #Generic response id, not used by GTK+ dialogs  
+       new accept `{ return GTK_RESPONSE_ACCEPT; `}    
+
+       #Returned if the dialog is deleted
+       new delete_event `{ return GTK_RESPONSE_DELETE_EVENT; `}        
+       #Returned by OK buttons in GTK+ dialogs.        
+       new ok `{ return GTK_RESPONSE_OK; `}    
+
+       #Returned by Cancel buttons in GTK+ dialogs.    
+       new cancel `{ return GTK_RESPONSE_CANCEL; `}    
+
+       #Returned by OK Close in GTK+ dialogs.  
+       new close `{ return GTK_RESPONSE_CLOSE; `}      
+
+       #Returned by OK Yes in GTK+ dialogs.    
+       new yes `{ return GTK_RESPONSE_YES; `} 
+
+       #Returned by OK No in GTK+ dialogs.     
+       new no `{ return GTK_RESPONSE_NO; `} 
+
+       #Returned by OK Apply in GTK+ dialogs.  
+       new apply `{ return GTK_RESPONSE_APPLY; `} 
+
+       #Returned by OK Help in GTK+ dialogs.   
+       new help `{ return GTK_RESPONSE_HELP; `} 
+end