unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* guimax and guile-gi
@ 2019-07-05 13:14 Mike Gran
  2019-07-05 19:40 ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Gran @ 2019-07-05 13:14 UTC (permalink / raw)
  To: Guile User

Hi Jan,

The GNOME-suggested API for gobject-introspection is to use 'send' and
'connect', which are already Guile procedures.  In guile-gi, we're
thinking about moving away from 'send' to use 'with-object' or perhaps
'using'.  Also, we're changing how to connect GObject signals.

It would change all the work you've done on guimax, so I forked and
re-wrote guimax using the guile-gi API that we expect to push today.

You can find the fork at the location below, and I can pull that into a
patchset if you want me to.

https://gitlab.com/spk121/guimax/tree/master

Feel free to let me know if this API change is for the better or
worse. ;-)

Thanks,
Mike Gran



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

* Re: guimax and guile-gi
  2019-07-05 13:14 guimax and guile-gi Mike Gran
@ 2019-07-05 19:40 ` Jan Nieuwenhuizen
  2019-07-10  6:32   ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Nieuwenhuizen @ 2019-07-05 19:40 UTC (permalink / raw)
  To: Mike Gran; +Cc: Guile User

Mike Gran writes:

Hi Mike,

> The GNOME-suggested API for gobject-introspection is to use 'send' and
> 'connect', which are already Guile procedures.  In guile-gi, we're
> thinking about moving away from 'send' to use 'with-object' or perhaps
> 'using'.  Also, we're changing how to connect GObject signals.

Yes, I saw `with-object' on a syntax branch and was about to ask you if
I could already commit to that...it seems now it's `using'

with-object' feels Guily'er in a way, but `object' is maybe a bit vague?
`with-gobject' is longer than `with-g', and both mainly add more
crypticness over `object'.  `using' is shorter and better than send, I
like it :)

> It would change all the work you've done on guimax, so I forked and
> re-wrote guimax using the guile-gi API that we expect to push today.

Ohh, wow -- thanks!!

> You can find the fork at the location below, and I can pull that into a
> patchset if you want me to.
>
> https://gitlab.com/spk121/guimax/tree/master

> Feel free to let me know if this API change is for the better or
> worse. ;-)

This works for me, definately better.  I'm working on some silly guimax
bugs while finishing up the GTK C backend first and then come back to
Guile-GI wich is the preferred UI backend for Guimax, eventually ;)  So
timing is perfect.

On Guix, Guile-GI now needs glib and glib-bin to build, you can pull
from

    https://gitlab.com/janneke/guile-gi.git

(and some tests still fail, i'm sure you got that).

Thanks again,
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] 3+ messages in thread

* Re: guimax and guile-gi
  2019-07-05 19:40 ` Jan Nieuwenhuizen
@ 2019-07-10  6:32   ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Nieuwenhuizen @ 2019-07-10  6:32 UTC (permalink / raw)
  To: Mike Gran; +Cc: Guile User

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

Jan Nieuwenhuizen writes:

Hello Mike,

I have isolated a Guile-GI crash in Guimax and put it into the
editor example.

When I run the editor and press split, I get

--8<---------------cut here---------------start------------->8---
$ tools/uninstalled-env tools/guile-gi examples/editor.scm
...
buffer-window #<<GtkBox> 22c3f00>
key: 65507
key: 65507
key: 65505
buffer-window #<<GtkBox> 22c3a50>

;;; WARNING (make-box children (#<<user-data> widget: #<<GtkBox> 22c3f00> window: #<<GtkScrolledWindow> 22c3d70> view: #<<GtkTextView> 22c3d20> mode-line: #<<GtkLabel> 22c3dc0>> #<<user-data> widget: #<<GtkBox> 22c3a50> window: #<<GtkScrolledWindow> 22c38c0> view: #<<GtkTextView> 22c3870> mode-line: #<<GtkLabel> 22c3910>>))
ui-data #<<user-data> widget: #<<GtkBox> 22c3f00> window: #<<GtkScrolledWindow> 22c3d70> view: #<<GtkTextView> 22c3d20> mode-line: #<<GtkLabel> 22c3dc0>>
w= #<<GtkBox> 22c3f00>

(editor.scm:14686): Gtk-CRITICAL **: 08:19:03.500: gtk_box_pack: assertion 'GTK_IS_WIDGET (child)' failed
ui-data #<<user-data> widget: #<<GtkBox> 22c3a50> window: #<<GtkScrolledWindow> 22c38c0> view: #<<GtkTextView> 22c3870> mode-line: #<<GtkLabel> 22c3910>>
w= #<<GtkBox> 22c3a50>

(editor.scm:14686): Gtk-CRITICAL **: 08:19:03.500: gtk_container_remove: assertion 'GTK_IS_WIDGET (widget)' failed
--8<---------------cut here---------------end--------------->8---

I'm pretty sure this works in the other UI backends, but I could be
doing something wrong, of course.

Can you help me with this?  See attached patch or https://gitlab.com/janneke/guile-gi.git

Greetings,
janneke



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-editor-Add-window-split.patch --]
[-- Type: text/x-patch, Size: 6218 bytes --]

From d7a94f9282202fa63acc4a9ea6b5a832d58a93d7 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 10 Jul 2019 08:22:08 +0200
Subject: [PATCH] editor: Add window split.

---
 examples/editor.scm | 107 ++++++++++++++++++++++++++++++++++++++------
 1 file changed, 94 insertions(+), 13 deletions(-)

diff --git a/examples/editor.scm b/examples/editor.scm
index 4ddf437..cd1b569 100644
--- a/examples/editor.scm
+++ b/examples/editor.scm
@@ -14,46 +14,118 @@
 ;; You should have received a copy of the GNU General Public License
 ;; along with this program.  If not, see <https:;;www.gnu.org/licenses/>.
 (use-modules (gi)
-             (ice-9 receive))
+             (ice-9 receive)
+             (srfi srfi-9))
 
 (typelib-load "Gio" "2.0")
 (typelib-load "Gdk" "3.0")
 (typelib-load "Gtk" "3.0")
 (typelib-load "GLib" "2.0")
-(typelib-load "WebKit2" "4.0")
+(typelib-load "Pango" "1.0")
 
 ;; Oddly, the introspection information does not provide a constructor
 ;; for GtkTextIter.
 (define (text-iter:new)
   (make-gstruct <GtkTextIter>))
 
+(define (rgba:new)
+  (make-gstruct <GdkRGBA>))
+
 (define (print-goodbye widget)
   (display "Goodbye World\n"))
 
 (define (key-press widget event)
   (receive (ok keyval)
-      (with-object event (get-keyval?))
+      (with-object event (get-keyval))
       (format #t "key: ~s\n" keyval)
       #f))
 
+(define-record-type <user-data>
+  (make-user-data widget window view mode-line)
+  user-data?
+  (widget user-data-widget)
+  (window user-data-window)             ; GI: avoid `children'
+  (view user-data-view set-user-data-view)
+  (mode-line user-data-mode-line))
+
+(define (make-box children orientation)
+  (warn 'make-box 'children children)
+  (let ((box (create <GtkBox>
+               (orientation (if (eq? orientation 'vertical)
+                                ORIENTATION_VERTICAL
+                                ORIENTATION_HORIZONTAL))
+               (spacing 0))))
+    (with-object box (set-homogeneous #t))
+    (for-each
+     (lambda (ui-data)
+       (format (current-error-port) "ui-data ~a\n" ui-data)
+       (let* ((w (if (user-data? ui-data) (user-data-widget ui-data) ui-data))
+              (parent (with-object w (get-parent))))
+         (format (current-error-port) "w= ~a\n" w)
+         (when w
+           (when parent
+             (let ((parent (cast parent <GtkBox>)))
+               (with-object parent (remove w))))
+           (with-object box (pack-start w #t #t 0)))))
+     children)
+    (with-object box (show-all))
+    box))
+
+(define (make-buffer-window)
+  (let ((vbox (create <GtkBox>
+                (orientation ORIENTATION_VERTICAL)
+                (spacing 0)))
+        (ebox (create <GtkEventBox>))
+        (bgc (cast (rgba:new) <GdkRGBA>))
+        (mode-line (create <GtkLabel>))
+        (window (create <GtkScrolledWindow>))
+        (view (create <GtkTextView>)))
+
+    (using mode-line
+      (set-halign ALIGN_START)
+      (set-markup " :--- guimax")
+      (set-line-wrap #f))
+    (using window (set-policy POLICY_AUTOMATIC POLICY_AUTOMATIC))
+    (using bgc (parse? "lightgray"))
+    (using ebox (override-background-color STATE_NORMAL bgc))
+
+    (using view (modify-font (font-description-from-string "monospace 18")))
+
+    (using vbox
+      (pack-start window #t #t 0)
+      (pack-start ebox #f #f 0))
+    (using ebox (add mode-line))
+    (using window (add view))
+
+    (format (current-error-port) "buffer-window ~a\n" vbox)
+    (make-user-data vbox window view mode-line)))
+
 (define (activate app)
-  (let ((window (cast (application-window:new app) <GtkApplicationWindow>))
-        (vbox (cast (vbox:new 0 0) <GtkVBox>))
-        (editor (cast (text-view:new) <GtkTextView>))
-        (button-box (cast (button-box:new 0) <GtkButtonBox>))
-        (button (button:new-with-label "Quit"))
-        (button2 (button:new-with-label "Hello")))
+  (let* ((window (cast (application-window:new app) <GtkApplicationWindow>))
+         (vbox (cast (vbox:new 0 0) <GtkVBox>))
+         (button-box (cast (button-box:new 0) <GtkButtonBox>))
+         (button-hello (button:new-with-label "Hello"))
+         (button-split (button:new-with-label "Split"))
+         (button-quit (button:new-with-label "Quit"))
+         (buffer-window (make-buffer-window))
+         (editor (user-data-view buffer-window))
+         (container (user-data-widget buffer-window)))
     (with-object editor
       (add-events EVENT_MASK_KEY_PRESS_MASK)
       (connect! key-press-event key-press))
-    (with-object button-box (add button2) (add button))
-    (with-object vbox (add editor) (add button-box))
+    (with-object button-box
+      (add button-hello)
+      (add button-split)
+      (add button-quit))
+    (with-object vbox
+      (add container)
+      (add button-box))
     (with-object window
       (set-title "Window")
       (set-default-size 200 200)
       (add vbox))
 
-    (with-object button
+    (with-object button-quit
       (connect! clicked print-goodbye)
       (connect! clicked (lambda x
                          (with-object window (destroy)))))
@@ -61,7 +133,7 @@
     ;; When the 'hello' button is clicked, write the current contents
     ;; of the editor to the console, and replace the buffer contents
     ;; with 'Hello, world'.
-    (with-object button2
+    (with-object button-hello
       (connect! clicked (lambda x
                          (let ((buffer (with-object editor (get-buffer)))
                                (iter1 (text-iter:new))
@@ -71,6 +143,15 @@
                              (write txt) (newline))
                            (with-object buffer (set-text "Hello, world" 12))))))
 
+    (with-object button-split
+      (connect! clicked (lambda x
+                          (let* ((children (list buffer-window (make-buffer-window)))
+                                 (container' (make-box children 'horizontal)))
+                            (with-object vbox
+                              (remove container)
+                              (add container')
+                              (show-all))))))
+
     (with-object editor (grab-focus))
     (with-object 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] 3+ messages in thread

end of thread, other threads:[~2019-07-10  6:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-05 13:14 guimax and guile-gi Mike Gran
2019-07-05 19:40 ` Jan Nieuwenhuizen
2019-07-10  6:32   ` Jan Nieuwenhuizen

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