From: Alptekin SANLI <alptekinsanli@gmail.com>
To: guile-user@gnu.org
Subject: G-Golf - <g-simple-action> with custom parameter type
Date: Fri, 17 Nov 2023 19:44:17 +0300 [thread overview]
Message-ID: <253f3e43-59a6-4119-9aa6-9fbfcf02366e@gmail.com> (raw)
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ı
next reply other threads:[~2023-11-17 16:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-17 16:44 Alptekin SANLI [this message]
2023-11-20 4:07 ` G-Golf - <g-simple-action> with custom parameter type David Pirotte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=253f3e43-59a6-4119-9aa6-9fbfcf02366e@gmail.com \
--to=alptekinsanli@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).