Skip to content

Commit

Permalink
Merge pull request #236 from JuliaGraphics/tk/use_call_syntax
Browse files Browse the repository at this point in the history
WIP: Fix #134
  • Loading branch information
tknopp committed Jan 5, 2017
2 parents beb29b0 + adfb2fd commit d25c711
Show file tree
Hide file tree
Showing 12 changed files with 170 additions and 179 deletions.
20 changes: 0 additions & 20 deletions gen/gbox3
Expand Up @@ -15,9 +15,6 @@ $(Expr(:toplevel, :(module GAccessor
ccall((:g_object_set_property,Gtk.GLib.libgobject),Void,(Ptr{Gtk.GObject},Ptr{UInt8},Ptr{Void}),object,property_name,value)
return object
end
function property(object::Gtk.GObject,property_name,value)
return ccall((:g_object_get_property,Gtk.GLib.libgobject),Void,(Ptr{Gtk.GObject},Ptr{UInt8},Ptr{Void}),object,property_name,value)
end
function qdata(object::Gtk.GObject,quark)
return ccall((:g_object_get_qdata,Gtk.GLib.libgobject),Ptr{Void},(Ptr{Gtk.GObject},UInt32),object,quark)
end
Expand Down Expand Up @@ -596,9 +593,6 @@ $(Expr(:toplevel, :(module GAccessor
ccall((:gtk_container_child_set_property,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GObject},Ptr{UInt8},Ptr{Void}),container,child,property_name,value)
return container
end
function property(container::Gtk.GtkContainer,child,property_name,value)
return ccall((:gtk_container_child_get_property,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GObject},Ptr{UInt8},Ptr{Void}),container,child,property_name,value)
end
function path_for_child(container::Gtk.GtkContainer,child)
return convert(Gtk.GtkWidgetPath,ccall((:gtk_container_get_path_for_child,Gtk.libgtk),Ptr{Gtk.GtkWidgetPath},(Ptr{Gtk.GObject},Ptr{Gtk.GObject}),container,child))
end
Expand Down Expand Up @@ -1546,9 +1540,6 @@ $(Expr(:toplevel, :(module GAccessor
ccall((:gtk_cell_area_cell_set_property,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GObject},Ptr{UInt8},Ptr{Void}),area,renderer,property_name,value)
return area
end
function property(area::Gtk.GtkCellArea,renderer,property_name,value)
return ccall((:gtk_cell_area_cell_get_property,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GObject},Ptr{UInt8},Ptr{Void}),area,renderer,property_name,value)
end
function focus_cell(area::Gtk.GtkCellArea,renderer)
ccall((:gtk_cell_area_set_focus_cell,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GObject}),area,renderer)
return area
Expand Down Expand Up @@ -1797,13 +1788,6 @@ $(Expr(:toplevel, :(module GAccessor
function track_motion(widget::Gtk.GtkWidget)
return convert(Bool,ccall((:gtk_drag_dest_get_track_motion,Gtk.libgtk),Cint,(Ptr{Gtk.GObject},),widget))
end
function target_list(widget::Gtk.GtkWidget)
return convert(Gtk.GtkTargetList,ccall((:gtk_drag_source_get_target_list,Gtk.libgtk),Ptr{Gtk.GtkTargetList},(Ptr{Gtk.GObject},),widget))
end
function target_list(widget::Gtk.GtkWidget,target_list_)
ccall((:gtk_drag_source_set_target_list,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GtkTargetList}),widget,target_list_)
return widget
end
function icon_pixbuf(widget::Gtk.GtkWidget,pixbuf)
ccall((:gtk_drag_source_set_icon_pixbuf,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Gtk.GObject}),widget,pixbuf)
return widget
Expand Down Expand Up @@ -2843,10 +2827,6 @@ $(Expr(:toplevel, :(module GAccessor
function rgba(chooser::Gtk.GtkColorChooser,color)
return ccall((:gtk_color_chooser_get_rgba,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Void}),chooser,color)
end
function rgba(chooser::Gtk.GtkColorChooser,color)
ccall((:gtk_color_chooser_set_rgba,Gtk.libgtk),Void,(Ptr{Gtk.GObject},Ptr{Void}),chooser,color)
return chooser
end
function use_alpha(chooser::Gtk.GtkColorChooser)
return convert(Bool,ccall((:gtk_color_chooser_get_use_alpha,Gtk.libgtk),Cint,(Ptr{Gtk.GObject},),chooser))
end
Expand Down
4 changes: 4 additions & 0 deletions src/GLib/gtype.jl
Expand Up @@ -219,8 +219,12 @@ function get_type_decl(name,iname,gtyp,gtype_decl)
end
gtype_wrappers[$(QuoteNode(iname))] = $ename
macro $einame(args...)
Base.depwarn(string("\@",$einame," is deprecated, use ", $einame, " instead."), :Gtk)
Expr(:call, $ename, map(esc,args)...)
end
function $einame(args...; kwargs...)
$ename(args...; kwargs...)
end
$gtype_decl
nothing
end
Expand Down
4 changes: 1 addition & 3 deletions src/gl_area.jl
Expand Up @@ -7,8 +7,6 @@ if libgtk_version >= v"3.16.0"
#TODO: gtk_gl_area_get_error
alpha(w::GtkGLArea, value::Bool) =
(ccall((:gtk_gl_area_set_has_alpha,libgtk),Void,(Ptr{GObject},Cint),w, value); w)
depth_buffer(w::GtkGLArea, value::Bool) =
(ccall((:gtk_gl_area_set_has_depth_buffer,libgtk),Void,(Ptr{GObject},Cint),w, value); w)
alpha(w::GtkGLArea) =
Bool(ccall((:gtk_gl_area_set_has_alpha,libgtk),Cint,(Ptr{GObject},),w))
depth_buffer(w::GtkGLArea, value::Bool) =
Expand All @@ -19,7 +17,7 @@ if libgtk_version >= v"3.16.0"
Bool(ccall((:gtk_gl_area_get_has_stencil_buffer,libgtk),Cint,(Ptr{GObject},),w))
auto_render(w::GtkGLArea, value::Bool) =
(ccall((:gtk_gl_area_set_auto_render,libgtk),Void,(Ptr{GObject},Cint),w, value); w)
stencil_buffer(w::GtkGLArea) =
auto_render(w::GtkGLArea) =
Bool(ccall((:gtk_gl_area_get_auto_render,libgtk),Cint,(Ptr{GObject},),w))
#TODO: gtk_gl_area_get_required_version
#TODO: gtk_gl_area_set_required_version
Expand Down
1 change: 1 addition & 0 deletions src/long_exports.jl
Expand Up @@ -46,6 +46,7 @@ export GObject,
GtkPaned,
GtkProgressBar,
GtkRadioButton,
GtkRadioButtonGroup,
GtkScale,
GtkScrolledWindow,
GtkSeparatorMenuItem,
Expand Down
4 changes: 2 additions & 2 deletions src/long_leaf_exports.jl
Expand Up @@ -152,9 +152,9 @@ export


# Gtk3 objects
export @GtkGrid, @GtkGLArea
export GtkGrid, GtkGLArea
export GtkGridLeaf, GtkGLAreaLeaf

# Gtk2 objects
export @GtkTable, @GtkAlignment
export GtkTable, GtkAlignment
export GtkTableLeaf, GtkAlignmentLeaf
7 changes: 3 additions & 4 deletions src/selectors.jl
Expand Up @@ -67,12 +67,12 @@ if libgtk_version >= v"3" ### should work with v >= 2.4, but there is a bug

function makefilters!(dlgp::GtkFileChooser, filters::Union{AbstractVector,Tuple})
for f in filters
ccall((:gtk_file_chooser_add_filter,libgtk), Void, (Ptr{GObject}, Ptr{GObject}), dlgp, @GtkFileFilter(f))
ccall((:gtk_file_chooser_add_filter,libgtk), Void, (Ptr{GObject}, Ptr{GObject}), dlgp, GtkFileFilter(f))
end
end

function open_dialog(title::AbstractString, parent = GtkNullContainer(), filters::Union{AbstractVector,Tuple} = String[]; kwargs...)
dlg = @GtkFileChooserDialog(title, parent, GConstants.GtkFileChooserAction.OPEN,
dlg = GtkFileChooserDialog(title, parent, GConstants.GtkFileChooserAction.OPEN,
(("_Cancel", GConstants.GtkResponseType.CANCEL),
("_Open", GConstants.GtkResponseType.ACCEPT)); kwargs...)
dlgp = GtkFileChooser(dlg)
Expand Down Expand Up @@ -103,7 +103,7 @@ if libgtk_version >= v"3" ### should work with v >= 2.4, but there is a bug
end

function save_dialog(title::AbstractString, parent = GtkNullContainer(), filters::Union{AbstractVector,Tuple} = String[]; kwargs...)
dlg = @GtkFileChooserDialog(title, parent, GConstants.GtkFileChooserAction.SAVE,
dlg = GtkFileChooserDialog(title, parent, GConstants.GtkFileChooserAction.SAVE,
(("_Cancel", GConstants.GtkResponseType.CANCEL),
("_Save", GConstants.GtkResponseType.ACCEPT)), kwargs...)
dlgp = GtkFileChooser(dlg)
Expand All @@ -120,5 +120,4 @@ if libgtk_version >= v"3" ### should work with v >= 2.4, but there is a bug
destroy(dlg)
selection
end

end
2 changes: 2 additions & 0 deletions src/short_exports.jl
Expand Up @@ -46,6 +46,7 @@ const Paned = GtkPaned
const Pixbuf = GdkPixbuf
const ProgressBar = GtkProgressBar
const RadioButton = GtkRadioButton
const RadioButtonGroup = GtkRadioButtonGroup
const Scale = GtkScale
const ScrolledWindow = GtkScrolledWindow
const SeparatorMenuItem = GtkSeparatorMenuItem
Expand Down Expand Up @@ -122,6 +123,7 @@ export G_, GObject,
Pixbuf,
ProgressBar,
RadioButton,
RadioButtonGroup,
Scale,
ScrolledWindow,
SeparatorMenuItem,
Expand Down
4 changes: 2 additions & 2 deletions src/short_leaf_exports.jl
Expand Up @@ -225,11 +225,11 @@ export G_Leaf,
# Gtk 3
@g_type_delegate Grid = GtkGrid
@g_type_delegate GLArea = GtkGLArea
export @Grid, @GLArea
export Grid, GLArea
export GridLeaf, GLAreaLeaf

# Gtk 2
@g_type_delegate Table = GtkTable
@g_type_delegate Alignment = GtkAlignment
export @Table, @Aligment
export Table, Aligment
export TableLeaf, AligmentLeaf
4 changes: 2 additions & 2 deletions src/text.jl
Expand Up @@ -19,7 +19,7 @@ GtkLabelLeaf(title) = GtkLabelLeaf(
GtkTextBufferLeaf() = GtkTextBufferLeaf(
ccall((:gtk_text_buffer_new,libgtk),Ptr{GObject},(Ptr{GObject},),C_NULL))

GtkTextViewLeaf(buffer::GtkTextBuffer=@GtkTextBuffer()) = GtkTextViewLeaf(
GtkTextViewLeaf(buffer::GtkTextBuffer=GtkTextBuffer()) = GtkTextViewLeaf(
ccall((:gtk_text_view_new_with_buffer,libgtk),Ptr{GObject},(Ptr{GObject},),buffer))

GtkTextMarkLeaf(left_gravity::Bool=false) = GtkTextMarkLeaf(
Expand Down Expand Up @@ -353,7 +353,7 @@ function user_action(f::Function, buffer::GtkTextBuffer)
end

function create_tag(buffer::GtkTextBuffer, tag_name::AbstractString; properties...)
tag = @GtkTextTag(ccall((:gtk_text_buffer_create_tag,libgtk), Ptr{GObject},
tag = GtkTextTag(ccall((:gtk_text_buffer_create_tag,libgtk), Ptr{GObject},
(Ptr{GObject},Ptr{UInt8},Ptr{Void}),
buffer, bytestring(tag_name), C_NULL))
for (k,v) in properties
Expand Down
6 changes: 3 additions & 3 deletions src/windows.jl
Expand Up @@ -71,7 +71,7 @@ ask_dialog(message::AbstractString, parent = GtkNullContainer()) =
ask_dialog(message, "No", "Yes", parent)

function ask_dialog(message::AbstractString, no_text, yes_text, parent = GtkNullContainer())
dlg = @GtkMessageDialog(message, ((no_text,0), (yes_text,1)),
dlg = GtkMessageDialog(message, ((no_text,0), (yes_text,1)),
GtkDialogFlags.DESTROY_WITH_PARENT, GtkMessageType.QUESTION, parent)
response = run(dlg)
destroy(dlg)
Expand All @@ -94,9 +94,9 @@ for (func, flag) in (
end

function input_dialog(message::AbstractString, entry_default::AbstractString, buttons=(("Cancel",0), ("Accept",1)), parent = GtkNullContainer())
widget = @GtkMessageDialog(message, buttons, GtkDialogFlags.DESTROY_WITH_PARENT, GtkMessageType.INFO, parent)
widget = GtkMessageDialog(message, buttons, GtkDialogFlags.DESTROY_WITH_PARENT, GtkMessageType.INFO, parent)
box = content_area(widget)
entry = @GtkEntry(;text=entry_default)
entry = GtkEntry(;text=entry_default)
push!(box, entry)
showall(widget)
resp = run(widget)
Expand Down

0 comments on commit d25c711

Please sign in to comment.