From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: David Pirotte Newsgroups: gmane.lisp.guile.user Subject: Re: G-Golf - Help with ListView needed Date: Mon, 6 Mar 2023 01:07:58 -0300 Message-ID: <20230306010758.454a9bb1@aicha> References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/jIYY40rOaSMy2djyYUaN+TT"; protocol="application/pgp-signature"; micalg=pgp-sha512 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7860"; mail-complaints-to="usenet@ciao.gmane.io" To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Mon Mar 06 05:09:04 2023 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pZ29o-0001rj-2Y for guile-user@m.gmane-mx.org; Mon, 06 Mar 2023 05:09:04 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ29E-0005zd-Ln; Sun, 05 Mar 2023 23:08:28 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ29C-0005yr-Sm for guile-user@gnu.org; Sun, 05 Mar 2023 23:08:26 -0500 Original-Received: from mail.all2all.org ([79.99.200.14] helo=moses.all2all.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ29B-00086c-1x for guile-user@gnu.org; Sun, 05 Mar 2023 23:08:26 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by moses.all2all.org (Postfix) with ESMTP id C5B5067C007A for ; Mon, 6 Mar 2023 05:08:17 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at moses.all2all.org Original-Received: from moses.all2all.org ([127.0.0.1]) by localhost (moses.all2all.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BsaBAaN3KxJR for ; Mon, 6 Mar 2023 05:08:06 +0100 (CET) Original-Received: from aicha (unknown [179.210.48.245]) by moses.all2all.org (Postfix) with ESMTPSA id DDBB367C0078 for ; Mon, 6 Mar 2023 05:08:05 +0100 (CET) In-Reply-To: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.36; x86_64-pc-linux-gnu) Received-SPF: pass client-ip=79.99.200.14; envelope-from=david@altosw.be; helo=moses.all2all.org X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.user:18924 Archived-At: --Sig_/jIYY40rOaSMy2djyYUaN+TT Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello Michele, > I'm trying to learn g-golf. It has been a blast, great technology! > However, the last few days I've tried to get ListView working and now > I'm stuck. Below a working version. In the C code, you should: app =3D gtk_application_new (APPLICATION_ID, G_APPLICATION_DEFAULT_FLAGS); =09 /* so, not G_APPLICATION_FLAGS_NONE *? In the scheme code, there were three problems 1. you need to import "ListItem" 2. you must call the constructor gtk-string-list-new (gtk-string-list-new '("one" "two" "three" "four")) and not (make #:strings '("one" "two" "three" "four")) the later does not fail, but (get-n-items ...) =3D> 0, instead of 4, and then, the factory signal are never triggered ... It is not obvious when you may and when you may not, but in the doc, you'll see 'Readable no, ..., Construct no', Construct-only yes', then try the constructor instead of the scheme idiomatic 'way' ... [of course always prefer the scheme idiomatic way when allowed ...]. 3. in your factory 'bind signal callback, you called=20 ...=20 (get-child (item)) (get-item (item)) ... =09 instead of, it should be ... (get-child item) (get-item item) ... Thanks, David #! /bin/sh # -*- mode: scheme; coding: utf-8 -*- exec guile -e main -s "$0" "$@" !# (eval-when (expand load eval) (use-modules (oop goops)) (default-duplicate-binding-handler '(merge-generics replace warn-override-core warn last)) (use-modules (g-golf)) (g-irepository-require "Gtk" #:version "4.0") #;(for-each (lambda (name) (gi-import-by-name "Gdk" name)) '("Display")) (for-each (lambda (name) (gi-import-by-name "Gtk" name)) '("Application" "ApplicationWindow" "Label" "ListView" "ListItem" "NoSelection" "ScrolledWindow" "SignalListItemFactory" "StringList" "StringObject")) #;(for-each (lambda (name) (gi-import-by-name "Gio" name)) '("ListStore"))) (define (activate app) (let* (#;(display (gdk-display-get-default)) (window (make #:default-width 600 #:default-height 400 #:application app)) (scr (make )) (lst '("one" "two" "three" "four")) #;(sl (make #:strings lst)) (sl (gtk-string-list-new lst)) (ns (make #:model sl)) (factory (make )) (lv (make #:model ns #:factory factory))) (connect factory 'setup (lambda (factory item) (set-child item (make )))) (connect factory 'bind (lambda (factory item) (let* ((lb (get-child item)) (obj (get-item item))) (set-label lb (get-string obj))))) (set-child window scr) (set-child scr lv) (show window))) (define (main args) (let ((app (make #:application-id "keele.g-golf.gtk-signal-list-item-factory"= ))) (connect app 'activate activate) (let ((status (g-application-run app args))) (exit status)))) --Sig_/jIYY40rOaSMy2djyYUaN+TT Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhCJlRZtBM3furJHe83T9k6MFetcFAmQFZx4ACgkQ83T9k6MF eteMKQgAmGlpWKXlSO5qsc443Rwm9Sey/T04XSs/aTfP8Ek4yXwRMoXllcqO3Yv0 kJDIIxavL6PnXT94vrqszoZ38fEKYN11Xvk/otTZALYx3c7Gd75P5VG0dZM/D6MZ 2Hb0mZIy0oHL7zL+W68yTJalwE8v1QHXUaHrhExvRgYbXPwMTAA1sLx7gvsT+BEN +eLv5dlAYrGcpqQdSeIEHsURi5R2XJ8zi2LJ3fcsOW1F96iMDlakxjWZm9aUbGJD Vprm8lPVeWLX5XF+o+2FRXqhoBCN+YcRk+37d+UVdaR4Jg/VjQW5UKBsfM30D2Pk RoM5Kt8pfB6VTtfdlq+R/IRSQkAmDA== =UEg9 -----END PGP SIGNATURE----- --Sig_/jIYY40rOaSMy2djyYUaN+TT--