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 - how to access gtk APIS that take lists of arguments ending with null ptr Date: Tue, 19 Jul 2022 14:48:50 -0300 Message-ID: <20220719144850.623ae092@aicha> References: Mime-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/B/gfN5W5Q5bd1=fThmCk/LQ"; protocol="application/pgp-signature"; micalg=pgp-sha512 Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38847"; mail-complaints-to="usenet@ciao.gmane.io" Cc: guile-user@gnu.org To: Andy Tai Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Tue Jul 19 19:49:30 2022 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 1oDrLd-0009wa-99 for guile-user@m.gmane-mx.org; Tue, 19 Jul 2022 19:49:29 +0200 Original-Received: from localhost ([::1]:39382 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oDrLa-0005IE-Qe for guile-user@m.gmane-mx.org; Tue, 19 Jul 2022 13:49:28 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53474) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrLE-0005Gn-3I for guile-user@gnu.org; Tue, 19 Jul 2022 13:49:04 -0400 Original-Received: from maximusconfessor.all2all.org ([79.99.200.102]:35344) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oDrLB-00014Z-M3 for guile-user@gnu.org; Tue, 19 Jul 2022 13:49:03 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by maximusconfessor.all2all.org (Postfix) with ESMTP id 6D06F1BE02CC; Tue, 19 Jul 2022 19:48:57 +0200 (CEST) Original-Received: from maximusconfessor.all2all.org ([127.0.0.1]) by localhost (maximusconfessor.all2all.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sGdb-s9HubLl; Tue, 19 Jul 2022 19:48:57 +0200 (CEST) Original-Received: from aicha (unknown [179.210.48.225]) by maximusconfessor.all2all.org (Postfix) with ESMTPSA id 7F8F11BE02CA; Tue, 19 Jul 2022 19:48:56 +0200 (CEST) In-Reply-To: X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; x86_64-pc-linux-gnu) Received-SPF: pass client-ip=79.99.200.102; envelope-from=david@altosw.be; helo=maximusconfessor.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, T_SCC_BODY_TEXT_LINE=-0.01 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" Xref: news.gmane.io gmane.lisp.guile.user:18435 Archived-At: --Sig_/B/gfN5W5Q5bd1=fThmCk/LQ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hello, > How to call gtk APIs such as > (gtk+ 3) > gint > gtk_tree_view_insert_column_with_attributes > (GtkTreeView *tree_view, > gint position, > const gchar *title, > GtkCellRenderer *cell, > ...); You don't. Rather, you define the column(s) and call add-attribute, below, a quick example (no 'style', and in a real an large application code, you'd separate the making and 'populating' of the store ... David ;; drop this in a 'tree-store' or 'tree-store.scm' file ;; chmod a+x tree-store[.scm] ;; ./tree-store[.scm] #! /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 "3.0") (for-each (lambda (item) (gi-import-by-name "Gtk" item)) '("Window" "VBox" "TreeStore" "TreeView" "TreeViewColumn" "CellRendererText" "init" "main" "main_quit"))) ;; This example also shows the use of a none rendered 'object column type. (define (main args) (gtk-init 0 #f) (let* ((window (make )) (vbox (make )) (store (gtk-tree-store-new 3 '(int string object))) (treeview (make #:model store)) (column1 (make #:title "Column 1")) (renderer1 (make )) (column2 (make #:title "Column 2")) (renderer2 (make ))) (connect window 'delete-event (lambda (window event) (gtk-widget-destroy window) #f)) ;; do not stop the event propagation (connect window 'destroy (lambda (window) (gtk-main-quit) #f)) ;; do not stop the event propagation (pack-start column1 renderer1 #f) (add-attribute column1 renderer1 "text" 0) (append-column treeview column1) (pack-start column2 renderer2 #f) (add-attribute column2 renderer2 "text" 1) (append-column treeview column2) (let ((iter1 (append store #f)) (iter2 (append store #f))) (set-value store iter1 0 1) (set-value store iter1 1 "Hello ...") (set-value store iter1 2 column1) =20 (set-value store iter2 0 2) (set-value store iter2 1 "... world!") (set-value store iter2 2 column2)) (add window vbox) (add vbox treeview) (show-all window) (gtk-main))) --Sig_/B/gfN5W5Q5bd1=fThmCk/LQ Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhCJlRZtBM3furJHe83T9k6MFetcFAmLW7oIACgkQ83T9k6MF eteOuwf/fAOUNseVG2SKNFnwseDwkyfioek8G2uSAcsMLlxxFWWICVxk7ECE5up0 AMZF37gnyi/nhj82gajyO9I6KQl5X5TfAZG+aMV5autRZdzNwNw6kFjwonL6Zzv3 J5EvxN1yJx/imkkGtR5UNC+QXuO0JomOtJ9sZnrPYT+kqLhIDXFuUbQvVN0FiKZ4 wIDGvcyZ/4NlquTJ3/8c9f3zdXbWy0ew35DnngcR+eVeCFyjbWWvHG5sBoyzG28Z L4R5adylgdhlXEqau/4yWBHfZCmyFLLGqFiim+T9V0ozKOp7vm1w7ItZTn6AMBWe Xvhw6qz4zT9+eL7Nh3AkHMaG1qR1mw== =clt5 -----END PGP SIGNATURE----- --Sig_/B/gfN5W5Q5bd1=fThmCk/LQ--