1414# GtkFontSelectionDialog — A dialog box for selecting fonts
1515# GtkInputDialog — Configure devices for the XInput extension
1616
17- push! (widget:: GtkDialog , text:: String , response:: Integer ) =
17+ function push! (widget:: GtkDialog , text:: String , response:: Integer )
1818 ccall ((:gtk_dialog_add_button ,libgtk), Ptr{GObject},
1919 (Ptr{GObject},Ptr{Uint8},Cint), widget, text, response)
20+ widget
21+ end
2022
21- function GtkFileChooserDialogLeaf (title :: String , parent :: GtkContainer , action :: Integer , button_text_response ... )
22- n = length (button_text_response)
23- if ! iseven (n )
24- error ( " button_text_response must consist of text/response pairs " )
25- end
23+ # if VERSION >= v"0.4-"
24+ # GtkFileChooserDialogLeaf(title::String, parent::GtkContainer, action::Integer, button_text_response::=>...; kwargs...) =
25+ # GtkFileChooserDialogLeaf(title::String, parent, action, button_text_response; kwargs... )
26+ # end
27+ function GtkFileChooserDialogLeaf (title :: String , parent :: GtkContainer , action :: Integer , button_text_response; kwargs ... )
2628 w = GtkFileChooserDialogLeaf (ccall ((:gtk_file_chooser_dialog_new ,libgtk), Ptr{GObject},
2729 (Ptr{Uint8},Ptr{GObject},Cint,Ptr{Void}),
28- title, parent, action, C_NULL ))
29- for i = 1 : 2 : n
30- push! (w, button_text_response[i], button_text_response[i + 1 ] )
30+ title, parent, action, C_NULL ); kwargs ... )
31+ for (k,v) in button_text_response
32+ push! (w, k, v )
3133 end
3234 w
3335end
@@ -36,7 +38,7 @@ run(widget::GtkDialog) = ccall((:gtk_dialog_run,libgtk), Cint, (Ptr{GObject},),
3638
3739const SingleComma = r" (?<!,),(?!,)"
3840function GtkFileFilterLeaf (; name:: Union(ByteString,Nothing) = nothing , pattern:: ByteString = " " , mimetype:: ByteString = " " )
39- filt = ccall ((:gtk_file_filter_new ,libgtk), Ptr{GObject}, ())
41+ filt = GtkFileFilterLeaf ( ccall ((:gtk_file_filter_new ,libgtk), Ptr{GObject}, () ))
4042 if ! isempty (pattern)
4143 name == nothing && (name = pattern)
4244 for p in split (pattern, SingleComma)
@@ -57,24 +59,24 @@ function GtkFileFilterLeaf(; name::Union(ByteString,Nothing) = nothing, pattern:
5759end
5860GtkFileFilterLeaf (pattern:: ByteString ; name:: Union(ByteString,Nothing) = nothing ) = GtkFileFilterLeaf (; name= name, pattern= pattern)
5961
60- GtkFileFilterLeaf (filter:: GtkFileFilterLeaf ) = filter
62+ GtkFileFilterLeaf (filter:: GtkFileFilter ) = filter
6163
62- function makefilters (dlgp:: GtkFileChooser , filters:: Union(AbstractVector,Tuple) )
64+ function makefilters! (dlgp:: GtkFileChooser , filters:: Union(AbstractVector,Tuple) )
6365 for f in filters
6466 ccall ((:gtk_file_chooser_add_filter ,libgtk), Void, (Ptr{GObject}, Ptr{GObject}), dlgp, @GtkFileFilter (f))
6567 end
6668end
6769
68- function open_dialog (title:: String ; parent = GtkNullContainer (), filters:: Union(AbstractVector,Tuple) = ASCIIString[], multiple :: Bool = false )
70+ function open_dialog (title:: String , parent = GtkNullContainer (), filters:: Union(AbstractVector,Tuple) = ASCIIString[]; kwargs ... )
6971 dlg = @GtkFileChooserDialog (title, parent, GConstants. GtkFileChooserAction. OPEN,
70- " _Cancel" , GConstants. GtkResponseType. CANCEL,
71- " _Open" , GConstants. GtkResponseType. ACCEPT)
72- setproperty! (dlg, :select_multiple , multiple)
72+ ((" _Cancel" , GConstants. GtkResponseType. CANCEL),
73+ (" _Open" , GConstants. GtkResponseType. ACCEPT)); kwargs... )
7374 dlgp = GtkFileChooser (dlg)
7475 if ! isempty (filters)
75- makefilters (dlgp, filters)
76+ makefilters! (dlgp, filters)
7677 end
7778 response = run (dlg)
79+ multiple = getproperty (dlg, :select_multiple , Bool)
7880 local selection
7981 if response == GConstants. GtkResponseType. ACCEPT
8082 if multiple
@@ -96,13 +98,13 @@ function open_dialog(title::String; parent = GtkNullContainer(), filters::Union(
9698 selection
9799end
98100
99- function save_dialog (title:: String ; parent = GtkNullContainer (), filters:: Union(AbstractVector,Tuple) = ASCIIString[])
101+ function save_dialog (title:: String , parent = GtkNullContainer (), filters:: Union(AbstractVector,Tuple) = ASCIIString[]; kwargs ... )
100102 dlg = @GtkFileChooserDialog (title, parent, GConstants. GtkFileChooserAction. SAVE,
101- " _Cancel" , GConstants. GtkResponseType. CANCEL,
102- " _Save" , GConstants. GtkResponseType. ACCEPT)
103+ (( " _Cancel" , GConstants. GtkResponseType. CANCEL) ,
104+ ( " _Save" , GConstants. GtkResponseType. ACCEPT)), kwargs ... )
103105 dlgp = GtkFileChooser (dlg)
104106 if ! isempty (filters)
105- makefilters (dlgp, filters)
107+ makefilters! (dlgp, filters)
106108 end
107109 ccall ((:gtk_file_chooser_set_do_overwrite_confirmation ,libgtk), Void, (Ptr{GObject}, Cint), dlg, true )
108110 response = run (dlg)
0 commit comments