14
14
# GtkFontSelectionDialog — A dialog box for selecting fonts
15
15
# GtkInputDialog — Configure devices for the XInput extension
16
16
17
- push! (widget:: GtkDialog , text:: String , response:: Integer ) =
17
+ function push! (widget:: GtkDialog , text:: String , response:: Integer )
18
18
ccall ((:gtk_dialog_add_button ,libgtk), Ptr{GObject},
19
19
(Ptr{GObject},Ptr{Uint8},Cint), widget, text, response)
20
+ widget
21
+ end
20
22
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 ... )
26
28
w = GtkFileChooserDialogLeaf (ccall ((:gtk_file_chooser_dialog_new ,libgtk), Ptr{GObject},
27
29
(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 )
31
33
end
32
34
w
33
35
end
@@ -36,7 +38,7 @@ run(widget::GtkDialog) = ccall((:gtk_dialog_run,libgtk), Cint, (Ptr{GObject},),
36
38
37
39
const SingleComma = r" (?<!,),(?!,)"
38
40
function 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}, () ))
40
42
if ! isempty (pattern)
41
43
name == nothing && (name = pattern)
42
44
for p in split (pattern, SingleComma)
@@ -57,24 +59,24 @@ function GtkFileFilterLeaf(; name::Union(ByteString,Nothing) = nothing, pattern:
57
59
end
58
60
GtkFileFilterLeaf (pattern:: ByteString ; name:: Union(ByteString,Nothing) = nothing ) = GtkFileFilterLeaf (; name= name, pattern= pattern)
59
61
60
- GtkFileFilterLeaf (filter:: GtkFileFilterLeaf ) = filter
62
+ GtkFileFilterLeaf (filter:: GtkFileFilter ) = filter
61
63
62
- function makefilters (dlgp:: GtkFileChooser , filters:: Union(AbstractVector,Tuple) )
64
+ function makefilters! (dlgp:: GtkFileChooser , filters:: Union(AbstractVector,Tuple) )
63
65
for f in filters
64
66
ccall ((:gtk_file_chooser_add_filter ,libgtk), Void, (Ptr{GObject}, Ptr{GObject}), dlgp, @GtkFileFilter (f))
65
67
end
66
68
end
67
69
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 ... )
69
71
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... )
73
74
dlgp = GtkFileChooser (dlg)
74
75
if ! isempty (filters)
75
- makefilters (dlgp, filters)
76
+ makefilters! (dlgp, filters)
76
77
end
77
78
response = run (dlg)
79
+ multiple = getproperty (dlg, :select_multiple , Bool)
78
80
local selection
79
81
if response == GConstants. GtkResponseType. ACCEPT
80
82
if multiple
@@ -96,13 +98,13 @@ function open_dialog(title::String; parent = GtkNullContainer(), filters::Union(
96
98
selection
97
99
end
98
100
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 ... )
100
102
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 ... )
103
105
dlgp = GtkFileChooser (dlg)
104
106
if ! isempty (filters)
105
- makefilters (dlgp, filters)
107
+ makefilters! (dlgp, filters)
106
108
end
107
109
ccall ((:gtk_file_chooser_set_do_overwrite_confirmation ,libgtk), Void, (Ptr{GObject}, Cint), dlg, true )
108
110
response = run (dlg)
0 commit comments