* G-Golf - <g-simple-action> with custom parameter type
@ 2023-11-17 16:44 Alptekin SANLI
2023-11-20 4:07 ` David Pirotte
0 siblings, 1 reply; 2+ messages in thread
From: Alptekin SANLI @ 2023-11-17 16:44 UTC (permalink / raw)
To: guile-user
I'd like to ask a question regarding composite parameter types in
<g-simple-action>.
I'm trying to port my simple pygobject/gtk4 app into g-golf; & it's
been going pretty well; however, I've hit a roadblock. In the python
version, I define several `Gio.SimpleAction`s to attach to my
`Gtk.Application` with explicitly specified GVariantTypes, so that I
can activate them with arguments over D-Bus. The following works just
fine, allowing me to activate this action over the CLI via gdbus:
``` python
class OwnGtkApplication(Gtk.Application):
def __init__(self, **kwargs):
## etc.
new_simple_action = Gio.SimpleAction.new(
"the_name", GLib.VariantType.new("(uus)")
)
self.add_action(new_simple_action)
## etc.
## later on
def do_activate(self):
## etc.
self.lookup_action("new_simple_action").connect(
"activate", self.the_callback)
## etc.
## later on
def the_callback(self, the_obj, the_param):
one_uint32 = the_param.get_child_value(0).get_uint32()
one_more = the_param.get_child_value(1).get_uint32()
a_string = the_param.get_child_value(2).get_string()
## -- now use the extracted values
```
Under g-golf, however, I can't define a <g-simple-action> with
parameters. So the following runs:
``` guile
(define (activate app)
(let* ;; etc., etc.,
((a-new-simple (make <g-simple-action> #:name "the_name")))
(add-action app a-new-simple)
(connect a-new-simple 'activate (lambda (s-action g-variant)
(log-msg 'WARN g-variant)))
)
)
```
& the log message just prints `#f`; but whenever I try to add the
`#:parameter_type` keyword to `(make <g-simple-action>)`, I get an
unbound variable error. `glib-variant-type-new` doesn't seem to exist;
and I don't understand what `g-type-param-variant` does -- or whether
it's relevant to my case.
I've tried:
```
#:parameter-type `(,g-type-param-uint ,g-type-param-uint
,g-type-param-string)
```
But this gives me:
```
In procedure primitive-call-ip: Wrong type argument in position 1
(expecting PRIMITIVE_P): #<procedure 7f5412336940 (_ _ _ _ _ _ _)>
ERROR: In procedure foreign-call: Wrong type argument in position 1
(expecting POINTER_P): (#<procedure 7f5412e5b280 ()> #<procedure
7f5412e5b280 ()> #<procedure 7f5412e5b160 ()>)
```
... but then I'm back to square one; because I don't know how to
package a '(uus)' type, and return only the pointer to it.
I really hope that it's possible to do what I'm trying to do under
Guile, because
I've really been enjoying my learning experience so far.
Thanks,
Alptekin Sanlı
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: G-Golf - <g-simple-action> with custom parameter type
2023-11-17 16:44 G-Golf - <g-simple-action> with custom parameter type Alptekin SANLI
@ 2023-11-20 4:07 ` David Pirotte
0 siblings, 0 replies; 2+ messages in thread
From: David Pirotte @ 2023-11-20 4:07 UTC (permalink / raw)
To: Alptekin SANLI; +Cc: guile-user
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
Hello Alptekin
> ...
> Under g-golf, however, I can't define a <g-simple-action> with
> parameters.
Right, currently you can't - GVariant are not (yet) supported, and
it's not a high priority item in my list, so don't hold your breath ...
What you can do, currently, is what you do as in your 'simpler' example,
also shown in the adw1-demo example that comes with g-golf, see the
(adw1-demo window) module, the install-actions procedures.
Regards,
David
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-11-20 4:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-17 16:44 G-Golf - <g-simple-action> with custom parameter type Alptekin SANLI
2023-11-20 4:07 ` David Pirotte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).