From b450b3d490ffd2ac46dc47221aabeaf451aac4ed Mon Sep 17 00:00:00 2001 From: Jared Wahlstrand Date: Sun, 24 Sep 2023 08:08:14 -0400 Subject: [PATCH] generate methods for ShortcutTrigger, add another method for add_action --- gen/gen_gtk4.jl | 2 +- src/GLib/actions.jl | 8 ++++++++ src/events.jl | 5 +++++ src/gen/gtk4_methods | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/gen/gen_gtk4.jl b/gen/gen_gtk4.jl index aaf43222..349f6c61 100644 --- a/gen/gen_gtk4.jl +++ b/gen/gen_gtk4.jl @@ -58,7 +58,7 @@ GI.all_struct_methods!(exprs,ns,struct_skiplist=vcat(struct_skiplist,[:Bitset,:B skiplist=[:create_closure,:activate_cell,:event,:start_editing,:filter_keypress,:append_node,:im_context_filter_keypress,:get_backlog,:get,:get_default,:get_for_display,:get_current_event_state,:get_axes] -object_skiplist=vcat(object_skiplist,[:CellRenderer,:MnemonicAction,:NeverTrigger,:NothingAction,:PrintJob,:PrintSettings,:RecentManager,:ShortcutTrigger]) +object_skiplist=vcat(object_skiplist,[:CellRenderer,:MnemonicAction,:NeverTrigger,:NothingAction,:PrintJob,:PrintSettings,:RecentManager]) # skips are to avoid method name collisions GI.all_object_methods!(exprs,ns;skiplist=skiplist,object_skiplist=object_skiplist,exclude_deprecated=false) diff --git a/src/GLib/actions.jl b/src/GLib/actions.jl index aaef6f3b..4a2241b2 100644 --- a/src/GLib/actions.jl +++ b/src/GLib/actions.jl @@ -13,6 +13,14 @@ function add_action(m::GActionMap, name::AbstractString, handler::Function) action end +function add_action(m::GActionMap, name::AbstractString, cb, user_data) + action = GSimpleAction(name) + push!(m,GAction(action)) + signal_connect(cb, action, :activate, Nothing, + (Ptr{GVariant},), false, user_data) + action +end + function add_stateful_action(m::GActionMap, name::AbstractString, initial_state, handler::Function) action = GSimpleAction(name, nothing, GVariant(initial_state)) push!(m,GAction(action)) diff --git a/src/events.jl b/src/events.jl index 60421bdc..c59e94e1 100644 --- a/src/events.jl +++ b/src/events.jl @@ -40,6 +40,11 @@ function GtkEventControllerKey(widget::GtkWidget) push!(widget, g) g end +function GtkShortcutController(widget::GtkWidget) + g = G_.ShortcutController_new() + push!(widget, g) + g +end function GtkGestureClick(widget::GtkWidget,button=1) g = G_.GestureClick_new() diff --git a/src/gen/gtk4_methods b/src/gen/gtk4_methods index 645797ea..00436e8c 100644 --- a/src/gen/gtk4_methods +++ b/src/gen/gtk4_methods @@ -9627,6 +9627,48 @@ $(Expr(:toplevel, quote ret = ccall(("gtk_shortcut_label_set_disabled_text", libgtk4), Nothing, (Ptr{GObject}, Cstring), instance, _disabled_text) nothing end + function ShortcutTrigger_parse_string(_string::Union{AbstractString, Symbol}) + ret = ccall(("gtk_shortcut_trigger_parse_string", libgtk4), Ptr{GObject}, (Cstring,), _string) + ret2 = convert_if_not_null(GtkShortcutTrigger, ret, true) + ret2 + end + function compare(instance::GtkShortcutTrigger, _trigger2::GtkShortcutTrigger) + ret = ccall(("gtk_shortcut_trigger_compare", libgtk4), Int32, (Ptr{GObject}, Ptr{GObject}), instance, _trigger2) + ret + end + function equal(instance::GtkShortcutTrigger, _trigger2::GtkShortcutTrigger) + ret = ccall(("gtk_shortcut_trigger_equal", libgtk4), Cint, (Ptr{GObject}, Ptr{GObject}), instance, _trigger2) + ret2 = convert(Bool, ret) + ret2 + end + function hash(instance::GtkShortcutTrigger) + ret = ccall(("gtk_shortcut_trigger_hash", libgtk4), UInt32, (Ptr{GObject},), instance) + ret + end + function print(instance::GtkShortcutTrigger, _string::Union{GString, Ref{_GString}}) + ret = ccall(("gtk_shortcut_trigger_print", libgtk4), Nothing, (Ptr{GObject}, Ptr{_GString}), instance, _string) + nothing + end + function print_label(instance::GtkShortcutTrigger, _display::GdkDisplay, _string::Union{GString, Ref{_GString}}) + ret = ccall(("gtk_shortcut_trigger_print_label", libgtk4), Cint, (Ptr{GObject}, Ptr{GObject}, Ptr{_GString}), instance, _display, _string) + ret2 = convert(Bool, ret) + ret2 + end + function to_label(instance::GtkShortcutTrigger, _display::GdkDisplay) + ret = ccall(("gtk_shortcut_trigger_to_label", libgtk4), Cstring, (Ptr{GObject}, Ptr{GObject}), instance, _display) + ret2 = string_or_nothing(ret, true) + ret2 + end + function to_string(instance::GtkShortcutTrigger) + ret = ccall(("gtk_shortcut_trigger_to_string", libgtk4), Cstring, (Ptr{GObject},), instance) + ret2 = string_or_nothing(ret, true) + ret2 + end + function trigger(instance::GtkShortcutTrigger, _event::GdkEvent, _enable_mnemonics::Bool) + ret = ccall(("gtk_shortcut_trigger_trigger", libgtk4), UInt32, (Ptr{GObject}, Ptr{GdkEvent}, Cint), instance, _event, _enable_mnemonics) + ret2 = KeyMatch(ret) + ret2 + end function SignalAction_new(_signal_name::Union{AbstractString, Symbol}) ret = ccall(("gtk_signal_action_new", libgtk4), Ptr{GObject}, (Cstring,), _signal_name) ret2 = GtkSignalActionLeaf(ret, true)