guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

G-Golf - <g-simple-action> with custom parameter type


From: Alptekin SANLI
Subject: G-Golf - <g-simple-action> with custom parameter type
Date: Fri, 17 Nov 2023 19:44:17 +0300
User-agent: Mozilla Thunderbird

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ı




reply via email to

[Prev in Thread] Current Thread [Next in Thread]