public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* gtk-clist-append does not work with shared substrings
@ 2000-01-16 15:19 Greg J. Badros
  2000-01-19 11:10 ` Marius Vollmer
  0 siblings, 1 reply; 7+ messages in thread
From: Greg J. Badros @ 2000-01-16 15:19 UTC (permalink / raw)
  To: guile-gtk

Whereas this works:
;; (gtk-clist-append clist (list "foo" "bar"))

This does not:

;; (gtk-clist-append clist (list (make-shared-substring "foo") "bar"))

Also, I don't think there's any way to tell which version of guile-gtk
you're linked against.  `guile-gtk-version' is a nice primitive to add.

Thanks,
Greg

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

* Re: gtk-clist-append does not work with shared substrings
  2000-01-16 15:19 gtk-clist-append does not work with shared substrings Greg J. Badros
@ 2000-01-19 11:10 ` Marius Vollmer
  2000-01-19 11:37   ` Greg J. Badros
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 2000-01-19 11:10 UTC (permalink / raw)
  To: Greg J. Badros; +Cc: guile-gtk

"Greg J. Badros" <gjb@cs.washington.edu> writes:

> Whereas this works:
> ;; (gtk-clist-append clist (list "foo" "bar"))
> 
> This does not:
> 
> ;; (gtk-clist-append clist (list (make-shared-substring "foo") "bar"))

Hmm, I get:

    guile> (use-modules (gtk gtk))
    guile> (define clist (gtk-clist-new 2))
    guile> (gtk-clist-append clist (list "foo" "bar"))
    0
    guile> (gtk-clist-append clist (list (make-shared-substring "foo") "bar"))
    1
    guile>

Maybe I'm using the wrong Guile version.  Shared substrings should be
converted to normal strings via the `sgtk_string_conversion' function.
It has this definition:

    SCM
    sgtk_string_conversion (SCM str)
    {
      if (SCM_NIMP (str) && SCM_STRINGP (str))
        SCM_COERCE_SUBSTR (str);
      return str;
    }

There is likely something wrong with the way conversions are handled
for composite types, like the list you are using.

> Also, I don't think there's any way to tell which version of guile-gtk
> you're linked against.  `guile-gtk-version' is a nice primitive to add.

There is the (gtk config) module which contains config information.
It even has a `gtkconf-version' entry but that reflects the version of
Gtk+ that this guile-gtk is build for.  I think we should change that
to be the guile-gtk version and add explicit support for the Gtk+
version in use.  This should come from (gtk dynlink) as that module
knows which library has been dynlinked (guile-gtk-1.2 or
guile-gtk-1.3).  Ariel?

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

* Re: gtk-clist-append does not work with shared substrings
  2000-01-19 11:10 ` Marius Vollmer
@ 2000-01-19 11:37   ` Greg J. Badros
  2000-01-20 22:13     ` Marius Vollmer
  0 siblings, 1 reply; 7+ messages in thread
From: Greg J. Badros @ 2000-01-19 11:37 UTC (permalink / raw)
  To: Marius Vollmer; +Cc: guile-gtk

Marius Vollmer <mvo@zagadka.ping.de> writes:

> "Greg J. Badros" <gjb@cs.washington.edu> writes:
> 
> > Whereas this works:
> > ;; (gtk-clist-append clist (list "foo" "bar"))
> > 
> > This does not:
> > 
> > ;; (gtk-clist-append clist (list (make-shared-substring "foo") "bar"))
> 
> Hmm, I get:
> 
>     guile> (use-modules (gtk gtk))
>     guile> (define clist (gtk-clist-new 2))
>     guile> (gtk-clist-append clist (list "foo" "bar"))
>     0
>     guile> (gtk-clist-append clist (list (make-shared-substring "foo") "bar"))
>     1
>     guile>
> 
> Maybe I'm using the wrong Guile version.  Shared substrings should be
> converted to normal strings via the `sgtk_string_conversion' function.
> It has this definition:
> 
>     SCM
>     sgtk_string_conversion (SCM str)
>     {
>       if (SCM_NIMP (str) && SCM_STRINGP (str))
>         SCM_COERCE_SUBSTR (str);
>       return str;
>     }

That's the same as mine.  I get the same *responses* as you, but the
CLIST is not populated with the correct strings.  Try this:

#!/usr/bin/guile -s 
!#
(use-modules (gtk gtk))
(define w (gtk-window-new 'dialog))
(define clist (gtk-clist-new-with-titles (list "first" "second")))
(define vbox (gtk-vbox-new #f 5))
(gtk-box-pack-start vbox clist)
(gtk-container-add w vbox)
(gtk-clist-append clist (list "foo" "bar"))
(gtk-clist-append clist (list (make-shared-substring "foo") "bar"))
(gtk-widget-show-all w)
(gtk-standalone-main w)

I get the second row, first column being empty, when I expect it should
have "foo" in it.

> There is likely something wrong with the way conversions are handled
> for composite types, like the list you are using.

I get both columns empty when I use make-shared-substring on both
elements of the list.

> > Also, I don't think there's any way to tell which version of guile-gtk
> > you're linked against.  `guile-gtk-version' is a nice primitive to add.
> 
> There is the (gtk config) module which contains config information.
> It even has a `gtkconf-version' entry but that reflects the version of
> Gtk+ that this guile-gtk is build for.  I think we should change that
> to be the guile-gtk version and add explicit support for the Gtk+
> version in use.  This should come from (gtk dynlink) as that module
> knows which library has been dynlinked (guile-gtk-1.2 or
> guile-gtk-1.3).  Ariel?

Right-- I may care about which GTk+, but I'm more likely to care about
which guile-gtk.  We need both, and only the former is available.

Greg

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

* Re: gtk-clist-append does not work with shared substrings
  2000-01-20 22:13     ` Marius Vollmer
@ 2000-01-20 21:22       ` Greg J. Badros
  2000-01-23  8:04         ` Marius Vollmer
  0 siblings, 1 reply; 7+ messages in thread
From: Greg J. Badros @ 2000-01-20 21:22 UTC (permalink / raw)
  To: Marius Vollmer; +Cc: guile-gtk

Marius Vollmer <mvo@zagadka.ping.de> writes:

> "Greg J. Badros" <gjb@cs.washington.edu> writes:
> 
> > That's the same as mine.  I get the same *responses* as you, but the
> > CLIST is not populated with the correct strings.  Try this:
> 
> Ahh, I see.  There are two bugs in guile-gtk that prevent it from
> working.  The first is that no automatic type conversion used for
> composite objects (including the one that takes substrings to normal
> strings), and the second is that guile-gtk accepts substrings as valid
> types but can't deal with them then.
> 
> I have fixed the second bug, so now your example will produce a "Wrong
> type argument" error.  The first bug needs more work and more thought,
> because of memory management issues and of mode `out' parameters.  You
> can work around the first bug by explicitely using string-copy to get
> from a substring to an equal normal string.

Right, that's roughly what I did in Scwm's gtk-table-display.scm.
Fixing the first problem definitely is helpful as it's better than just
failing silently.

> My current thinking is to convert a composite of mode `in' by copying
> it, and one of mode `out' or `inout' by modifying it in place.  Any
> thoughts about this?

I've never achieved a deep understanding of the guile-gtk interface
description stuff, but my naive take on this stuff is that that would be 
sufficient.  You definitely don't want to side-effect an in parameter. 

> > Right-- I may care about which GTk+, but I'm more likely to care about
> > which guile-gtk.  We need both, and only the former is available.
> 
> You can now use gtkconf-guile-gtk-version to get at the guile-gtk
> version.  gtkconf-version will now reflect the version of Gtk+ that is
> actually active.

Great, thanks!

Greg

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

* Re: gtk-clist-append does not work with shared substrings
  2000-01-19 11:37   ` Greg J. Badros
@ 2000-01-20 22:13     ` Marius Vollmer
  2000-01-20 21:22       ` Greg J. Badros
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 2000-01-20 22:13 UTC (permalink / raw)
  To: Greg J. Badros; +Cc: guile-gtk

"Greg J. Badros" <gjb@cs.washington.edu> writes:

> That's the same as mine.  I get the same *responses* as you, but the
> CLIST is not populated with the correct strings.  Try this:

Ahh, I see.  There are two bugs in guile-gtk that prevent it from
working.  The first is that no automatic type conversion used for
composite objects (including the one that takes substrings to normal
strings), and the second is that guile-gtk accepts substrings as valid
types but can't deal with them then.

I have fixed the second bug, so now your example will produce a "Wrong
type argument" error.  The first bug needs more work and more thought,
because of memory management issues and of mode `out' parameters.  You
can work around the first bug by explicitely using string-copy to get
from a substring to an equal normal string.

My current thinking is to convert a composite of mode `in' by copying
it, and one of mode `out' or `inout' by modifying it in place.  Any
thoughts about this?

> Right-- I may care about which GTk+, but I'm more likely to care about
> which guile-gtk.  We need both, and only the former is available.

You can now use gtkconf-guile-gtk-version to get at the guile-gtk
version.  gtkconf-version will now reflect the version of Gtk+ that is
actually active.

2000-01-20  Marius Vollmer  <mvo@zagadka.ping.de>

	* build-guile-gtk (emit-funcs): The `string' type now only accepts
	non-substrings.
	
	* gdk-1.2.defs, gdk-1.3.defs (gdk_pixmap_create_from_xpm): New.

	* gtk/config.scm.in (gtkconf-libdir): Construct from
	$myexecprefix.
	(gtkconf-default-version): New variable, takes old role of
	gtkconf-version.
	(gtkconf-version): Initialize to `#f', will bet set to the right
	value once the glue code has been loaded.
	(gtkconf-guile-gtk-version): New variable, reflects version of
	guile-gtk package itself.
	* gtk/dynlink.scm (gtk-version-set): Take version number as string
	and construct prefix from it.  Set gtkconf-version.
	Changed all callers.

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

* Re: gtk-clist-append does not work with shared substrings
  2000-01-20 21:22       ` Greg J. Badros
@ 2000-01-23  8:04         ` Marius Vollmer
  2000-01-23  9:26           ` Greg J. Badros
  0 siblings, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 2000-01-23  8:04 UTC (permalink / raw)
  To: Greg J. Badros; +Cc: guile-gtk

"Greg J. Badros" <gjb@cs.washington.edu> writes:

> > My current thinking is to convert a composite of mode `in' by copying
> > it, and one of mode `out' or `inout' by modifying it in place.  Any
> > thoughts about this?
> 
> I've never achieved a deep understanding of the guile-gtk interface
> description stuff, but my naive take on this stuff is that that would be 
> sufficient.  You definitely don't want to side-effect an in parameter. 

Ok, I have now checked in some code for this (also some bug fixes).
Can you give it a try?  I didn't really test it.

- Marius

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

* Re: gtk-clist-append does not work with shared substrings
  2000-01-23  8:04         ` Marius Vollmer
@ 2000-01-23  9:26           ` Greg J. Badros
  0 siblings, 0 replies; 7+ messages in thread
From: Greg J. Badros @ 2000-01-23  9:26 UTC (permalink / raw)
  To: Marius Vollmer; +Cc: guile-gtk

Marius Vollmer <mvo@zagadka.ping.de> writes:

> "Greg J. Badros" <gjb@cs.washington.edu> writes:
> 
> > > My current thinking is to convert a composite of mode `in' by copying
> > > it, and one of mode `out' or `inout' by modifying it in place.  Any
> > > thoughts about this?
> > 
> > I've never achieved a deep understanding of the guile-gtk interface
> > description stuff, but my naive take on this stuff is that that would be 
> > sufficient.  You definitely don't want to side-effect an in parameter. 
> 
> Ok, I have now checked in some code for this (also some bug fixes).
> Can you give it a try?  I didn't really test it.

Just tried, and it succeeds with my simple test case:

#!/usr/bin/guile -s 
!#
(use-modules (gtk gtk))

(define w (gtk-window-new 'dialog))
(define clist (gtk-clist-new-with-titles (list "first" "second")))
(define vbox (gtk-vbox-new #f 5))
(gtk-box-pack-start vbox clist)
(gtk-container-add w vbox)
(gtk-clist-append clist (list "foo" "bar"))
(gtk-clist-append clist (list (make-shared-substring "foo") "bar"))
(gtk-widget-show-all w)
(gtk-standalone-main w)


Thanks!

Greg

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

end of thread, other threads:[~2000-01-23  9:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-16 15:19 gtk-clist-append does not work with shared substrings Greg J. Badros
2000-01-19 11:10 ` Marius Vollmer
2000-01-19 11:37   ` Greg J. Badros
2000-01-20 22:13     ` Marius Vollmer
2000-01-20 21:22       ` Greg J. Badros
2000-01-23  8:04         ` Marius Vollmer
2000-01-23  9:26           ` Greg J. Badros

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