Giter Club home page Giter Club logo

Comments (10)

bohonghuang avatar bohonghuang commented on July 19, 2024 1

isn't it possible to use this type of keyboard handling ?

The signal is available in GTK3 (https://docs.gtk.org/gtk3/signal.Widget.key-press-event.html), while it got removed in GTK4 (https://docs.gtk.org/gtk4/class.Window.html).

also don't know if it is related but when i am using slime i get

Try evaluating this:

https://github.com/bohonghuang/cl-gtk4/blob/99772034ff299978f58d37840a03ac2adfce82c6/cl-gdk4.asd#LL1-L3C48

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

Thank you for discovering and pointing out my oversight in the API conversion. This is an issue with the wrapper, which I will fix in the near future.

from cl-gtk4.

vrx avatar vrx commented on July 19, 2024

thanks for your quick reply !

concerning the second problem, i found a way to do it
main trick is to directly call the gir-property function like so (setf (gir:property tag 'foreground) fg-color)

example :

(defun get-iter-at-line (buffer line)
  (multiple-value-bind (ok? iter) (text-buffer-get-iter-at-line buffer line)
    (when ok? iter)
    ))

(defun tag-create (table name &optional (fg-color "green") (bg-color "yellow"))
  (let ((tag (text-tag-table-lookup table name)))
    (if tag
        (text-tag-table-remove table tag)
        (setf tag (make-text-tag :name name))
        )
    (setf (gir:property tag 'foreground) fg-color)
    (setf (gir:property tag 'background) bg-color)
    (text-tag-table-add table tag)
    
    (text-buffer-apply-tag b tag (get-iter-at-line b 0) (get-iter-at-line b 1))
    )
  )

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

concerning the second problem, i found a way to do it main trick is to directly call the gir-property function like so (setf (gir:property tag 'foreground) fg-color)

This is currently one alternative approach, but further exploration is needed on whether and how to convert GObject properties to constructor parameters and accessors in Lisp while preserving the existing interface.

from cl-gtk4.

vrx avatar vrx commented on July 19, 2024

thx, still i have difficulties to deal with keyboard inputs
i did not find a way to use usual connection signals (see my first post above) so i am using

(key-controller (make-event-controller-key))
(connect key-controller "key-pressed" (lambda (event &rest args) ))

but it is somehow inconvenient and instable, as it throws at times messages like
gtk_event_controller_get_propagation_phase: assertion 'GTK_IS_EVENT_CONTROLLER (controller)' failed

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

but it is somehow inconvenient and instable, as it throws at times messages like

Sorry, I can't reproduce the issue. Here is my code, which works stably for me:

(ql:quickload :cl-gdk4)

(in-package #:gtk4)

(defun main ()
  (let ((application (make-application :application-id "org.bohonghuang.gtk4-event-test" :flags gio:+application-flags-flags-none+)))
    (connect application "activate" (lambda (app)
                                      (let ((window (make-application-window :application app))
                                            (controller (make-event-controller-key)))
                                        (connect controller "key-pressed" (lambda (&rest args)
                                                                            (print args)
                                                                            (values gdk:+event-propagate+)))
                                        (widget-add-controller window controller)
                                        (window-present window))))
    (application-run application nil)))

from cl-gtk4.

vrx avatar vrx commented on July 19, 2024

it seems to be related to threading

sorry i did not mention it but i am willing to develop interactively so whenever i am setting a swank server i end up with this problem

isn't it possible to use this type of keyboard handling ?
g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (gkeypress), NULL);

also don't know if it is related but when i am using slime i get

arithmetic error FLOATING-POINT-INVALID-OPERATION signalled
[Condition of type FLOATING-POINT-INVALID-OPERATION]

Restarts:
0: [ABORT] Abort compilation.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "worker" RUNNING {1004538BF3}>)

Backtrace:
0: ((FLET SB-UNIX::RUN-HANDLER :IN SB-UNIX::%INSTALL-HANDLER) 8 #.(SB-SYS:INT-SAP #X7F5F7A60CA70) #.(SB-SYS:INT-SAP #X7F5F7A60C940))
1: ("foreign function: call_into_lisp_")
2: ("foreign function: funcall3")
3: ("foreign function: interrupt_handle_now_handler")
4: ((LAMBDA (&REST GIR::ARGS-IN) :IN GIR::BUILD-FUNCTION) #.(SB-SYS:INT-SAP #X7F5F7408F180) NIL)
5: (GIO:APPLICATION-RUN #<GIR::OBJECT-INSTANCE {1004DA1A23}> NIL)

from cl-gtk4.

vrx avatar vrx commented on July 19, 2024

thanks, it solved my pb !

from cl-gtk4.

vrx avatar vrx commented on July 19, 2024

and as for the instability problem when using other threads (like swank)

setting event propagation phase not to bubble up seems to solve the mysterious error message :
gtk_event_controller_get_propagation_phase: assertion 'GTK_IS_EVENT_CONTROLLER (controller)' failed

(setf (gtk4:event-controller-propagation-phase key-controller) gtk4:+propagation-phase-capture+)

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

and as for the instability problem when using other threads (like swank)

Unfortunately, I have never encountered this issue in my use case. If it is an error caused by multithreading, you should make sure that the code interacting with GTK is executed within (gtk:run-in-main-event-loop () ...).

from cl-gtk4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.