Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/buttons.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,7 @@ function GtkVolumeButtonLeaf(value::Real) # 0 <= value <= 1
end

GtkFontButtonLeaf() = GtkFontButtonLeaf(ccall((:gtk_font_button_new, libgtk), Ptr{GObject}, ()))

GtkColorButtonLeaf() = GtkColorButtonLeaf(ccall((:gtk_color_button_new, libgtk), Ptr{GObject}, ()))
GtkColorButtonLeaf(color::GdkRGBA) = GtkColorButtonLeaf(ccall((:gtk_color_button_new_with_rgba, libgtk), Ptr{GObject},
(Ref{GdkRGBA},), color))
10 changes: 10 additions & 0 deletions src/gdk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ struct GdkPoint
end
# GdkPoint is not a GBoxed type

struct GdkRGBA
r::Cdouble
g::Cdouble
b::Cdouble
a::Cdouble
GdkRGBA(r, g, b, a) = new(r, g, b, a)
end
@make_gvalue(GdkRGBA, Ptr{GdkRGBA}, :boxed, (:gdk_rgba,:libgdk))
convert(::Type{GdkRGBA}, rgba::Ptr{GdkRGBA}) = unsafe_load(rgba)

baremodule GdkKeySyms
const VoidSymbol = 0xffffff
const BackSpace = 0xff08
Expand Down
2 changes: 2 additions & 0 deletions src/gtktypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ end
@gtktype GtkScrolledWindow
@gtktype GtkAboutDialog
@gtktype GtkMessageDialog
@gtktype GtkColorChooserDialog
@gtktype GtkColorButton
@Gtype GApplication libgio g_application
@Gtype GdkPixbuf libgdkpixbuf gdk_pixbuf
#TODO: @gtktype GtkScaleButton
Expand Down
4 changes: 3 additions & 1 deletion src/long_exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export GObject,
GtkToggleToolButton,
GtkTreeIter,
GtkWindow,
GtkEventBox
GtkEventBox,
GtkColorChooserDialog,
GtkColorButton

# Gtk interfaces
export GTypePlugin,
Expand Down
8 changes: 6 additions & 2 deletions src/long_leaf_exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export
@GtkTextBuffer,
@GtkToggleButton,
@GtkToggleToolButton,
@GtkWindow
@GtkWindow,
@GtkColorChooserDialog,
@GtkColorButton

# Gtk objects
export
Expand Down Expand Up @@ -152,7 +154,9 @@ export
GtkToggleButtonLeaf,
GtkToggleToolButtonLeaf,
GtkWindowLeaf,
GtkEventBoxLeaf
GtkEventBoxLeaf,
GtkColorChooserDialogLeaf,
GtkColorButtonLeaf


# Gtk3 objects
Expand Down
18 changes: 18 additions & 0 deletions src/selectors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,21 @@ function save_dialog_native(title::AbstractString, parent = GtkNullContainer(),
GLib.gc_unref(dlg) #destroy(dlg)
return selection
end

function GtkColorChooserDialogLeaf(title::AbstractString, parent::GtkContainer; kwargs...)
return GtkColorChooserDialogLeaf(ccall((:gtk_color_chooser_dialog_new, libgtk), Ptr{GObject},
(Ptr{UInt8}, Ptr{GObject}),
title, parent); kwargs...)
end

function color_chooser_dialog(title::AbstractString, parent = GtkNullContainer(); kwargs...)
dlg = GtkColorChooserDialog(title, parent; kwargs...)
response = run(dlg)
if response == GConstants.GtkResponseType.OK
selection = GAccessor.rgba(dlg)
else
selection = nothing
end
destroy(dlg)
return selection
end
6 changes: 5 additions & 1 deletion src/short_exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ const TreeViewColumn = GtkTreeViewColumn
const VolumeButton = GtkVolumeButton
const Window = GtkWindow
const EventBox = GtkEventBox
const ColorChooserDialog = GtkColorChooserDialog
const ColorButton = GtkColorButton

export G_, GObject,
AboutDialog,
Expand Down Expand Up @@ -156,7 +158,9 @@ export G_, GObject,
TreeViewColumn,
VolumeButton,
Window,
EventBox
EventBox,
ColorChooserDialog,
ColorButton

const TypePlugin = GTypePlugin
const Buildable = GtkBuildable
Expand Down
10 changes: 8 additions & 2 deletions src/short_leaf_exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
@g_type_delegate TreeViewColumn = GtkTreeViewColumn
@g_type_delegate VolumeButton = GtkVolumeButton
@g_type_delegate Window = GtkWindow
@g_type_delegate ColorChooserDialog = GtkColorChooserDialog
@g_type_delegate ColorButton = GtkColorButton

export @G_,
@AboutDialog,
Expand Down Expand Up @@ -149,7 +151,9 @@ export @G_,
@TreeView,
@TreeViewColumn,
@VolumeButton,
@Window
@Window,
@ColorChooserDialog,
@ColorButton

export G_Leaf,
AboutDialogLeaf,
Expand Down Expand Up @@ -222,7 +226,9 @@ export G_Leaf,
TreeViewLeaf,
TreeViewColumnLeaf,
VolumeButtonLeaf,
WindowLeaf
WindowLeaf,
ColorChooserDialog,
ColorButton

# Gtk 3
@g_type_delegate Grid = GtkGrid
Expand Down
14 changes: 13 additions & 1 deletion test/gui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ w = Window(b, "VolumeButton", 50, 50)|>showall
destroy(w)
end

@testset "ColorButton" begin
b = ColorButton(Gtk.GdkRGBA(0, 0.8, 1.0, 0.3))
w = Window(b, "ColorButton", 50, 50)|>showall
GAccessor.rgba(ColorChooser(b), GLib.mutable(Gtk.GdkRGBA(0, 0, 0, 0)))
destroy(w)
end

@testset "combobox" begin
combo = ComboBoxText()
choices = ["Strawberry", "Vanilla", "Chocolate"]
Expand Down Expand Up @@ -615,13 +622,18 @@ end
#@test get_value(tr)[1] == choices[2]
#destroy(w)

@testset "Selectors" begin
@testset "File Chooser" begin
dlg = FileChooserDialog("Select file", Null(), GtkFileChooserAction.OPEN,
(("_Cancel", GtkResponseType.CANCEL),
("_Open", GtkResponseType.ACCEPT)))
destroy(dlg)
end

@testset "Color Chooser" begin
dlg = ColorChooserDialog("Select color", Null())
destroy(dlg)
end

@testset "List view" begin
ls=ListStore(Int32,Bool)
push!(ls,(44,true))
Expand Down