unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* guile-gi: scancode->keyval?
@ 2019-06-06 20:16 Jan Nieuwenhuizen
  2019-06-07  3:45 ` Mike Gran
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2019-06-06 20:16 UTC (permalink / raw)
  To: Mike Gran; +Cc: guile-user

Hi Mike,

I've update the Guix package and started using (send event
(get-scancode)), which works great.  However, scancodes are somewhat
inconvenient, iwbn to get the keyval or character through
gdk-keyval-to-unicode.

I would expect `get-keyval' and `get-keycode' methods on event but only
found predicate-like variants:

   (send event (get-keyval?)) => (#t 0)
   (send event (get-keycode?)) => (#t 0)

Hmm.

Then I went to look for a more low level function using the Keymap

    (let ((keymap (Keymap-get-default)))

also works and then I'm lost again...something like this might work

    (send keymap (translate-keyboard-state? scancode MODIFIER_TYPE_SHIFT_MASK MODIFIER_TYPE_SHIFT_MASK))

=>

    GuileGI:ERROR:gi_giargument.c:1665:convert_interface_arg_to_object: assertion failed: (type_tag == GI_TYPE_TAG_INTERFACE)

Can you help me with this?

Greetings,
janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guile-gi: scancode->keyval?
  2019-06-06 20:16 guile-gi: scancode->keyval? Jan Nieuwenhuizen
@ 2019-06-07  3:45 ` Mike Gran
  2019-06-14 11:14   ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 4+ messages in thread
From: Mike Gran @ 2019-06-07  3:45 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-user

On Thu, Jun 06, 2019 at 10:16:14PM +0200, Jan Nieuwenhuizen wrote:
> Hi Mike,
> 
> I've update the Guix package and started using (send event
> (get-scancode)), which works great.  However, scancodes are somewhat
> inconvenient, iwbn to get the keyval or character through
> gdk-keyval-to-unicode.
> 
> I would expect `get-keyval' and `get-keycode' methods on event but only
> found predicate-like variants:
> 
>    (send event (get-keyval?)) => (#t 0)
>    (send event (get-keycode?)) => (#t 0)

I hadn't implemented automated wrapping of C procedures that return
output via pointer to plain C types, such as

  gboolean gdk_event_get_keyval (const GdkEvent *event,
                                 guint *keyval);

I fixed it, I think.

There are many, many unit tests to be written and memory allocations
to be checked. Sigh.


> 
> Hmm.
> 
> Then I went to look for a more low level function using the Keymap
> 
>     (let ((keymap (Keymap-get-default)))
> 
> also works and then I'm lost again...something like this might work
> 
>     (send keymap (translate-keyboard-state? scancode MODIFIER_TYPE_SHIFT_MASK MODIFIER_TYPE_SHIFT_MASK))
> 
> =>
> 
>     GuileGI:ERROR:gi_giargument.c:1665:convert_interface_arg_to_object: assertion failed: (type_tag == GI_TYPE_TAG_INTERFACE)

I'll look into it.

Thanks,

Mike Gran



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: guile-gi: scancode->keyval?
  2019-06-07  3:45 ` Mike Gran
@ 2019-06-14 11:14   ` Jan Nieuwenhuizen
  2019-06-16 20:02     ` Mike Gran
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Nieuwenhuizen @ 2019-06-14 11:14 UTC (permalink / raw)
  To: Mike Gran; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 715 bytes --]

Mike Gran writes:

Hi!

> I hadn't implemented automated wrapping of C procedures that return
> output via pointer to plain C types, such as
>
>   gboolean gdk_event_get_keyval (const GdkEvent *event,
>                                  guint *keyval);
>
> I fixed it, I think.

Yes, great!

> There are many, many unit tests to be written and memory allocations
> to be checked. Sigh.

...and I found another one, trying to load text in the test/editor.scm example

    (let ((buffer (send editor (get-buffer))))
      (warn 'buffer buffer) ; =>       ;; WARNING (buffer #<<GtkTextBuffer> 22bcc30>)
      ;; BOOM:      => free(): invalid pointer
      (send buffer (set-text "Hello, world!")))

Greetings,
janneke


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-editor-test-load-text.patch --]
[-- Type: text/x-patch, Size: 1053 bytes --]

From 49393b1720e14aac103d9027458327cbe3806661 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Fri, 14 Jun 2019 13:10:26 +0200
Subject: [PATCH] editor test: load text.

---
 test/editor.scm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/editor.scm b/test/editor.scm
index a8f49f2..db12144 100644
--- a/test/editor.scm
+++ b/test/editor.scm
@@ -19,7 +19,6 @@
 (typelib-load "Gdk" "3.0")
 (typelib-load "Gtk" "3.0")
 (typelib-load "GLib" "2.0")
-(typelib-load "WebKit2" "4.0")
 
 (define (print-goodbye widget data)
   (display "Goodbye World\n"))
@@ -47,6 +46,10 @@
                              #f))
     (connect editor (key-press-event key-press #f))
     (send editor (grab-focus))
+    (let ((buffer (send editor (get-buffer))))
+      (warn 'buffer buffer) ; =>       ;; WARNING (buffer #<<GtkTextBuffer> 22bcc30>)
+      ;; BOOM:      => free(): invalid pointer
+      (send buffer (set-text "Hello, world!")))
     (send button-box (add button))
     (send window (show-all))))
 
-- 
2.21.0


[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: guile-gi: scancode->keyval?
  2019-06-14 11:14   ` Jan Nieuwenhuizen
@ 2019-06-16 20:02     ` Mike Gran
  0 siblings, 0 replies; 4+ messages in thread
From: Mike Gran @ 2019-06-16 20:02 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guile-user

On Fri, Jun 14, 2019 at 01:14:29PM +0200, Jan Nieuwenhuizen wrote:
> Mike Gran writes:
> 
> 
> ...and I found another one, trying to load text in the test/editor.scm example
> 
>     (let ((buffer (send editor (get-buffer))))
>       (warn 'buffer buffer) ; =>       ;; WARNING (buffer #<<GtkTextBuffer> 22bcc30>)
>       ;; BOOM:      => free(): invalid pointer
>       (send buffer (set-text "Hello, world!")))

I pushed a new release with an updated test/editor.scm that works, I think.

Thanks,

Mike Gran




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-06-16 20:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-06 20:16 guile-gi: scancode->keyval? Jan Nieuwenhuizen
2019-06-07  3:45 ` Mike Gran
2019-06-14 11:14   ` Jan Nieuwenhuizen
2019-06-16 20:02     ` Mike Gran

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).