This is the mail archive of the guile-gtk@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: obtaining the selection: gtk_selection_convert?


From: Marius Vollmer <mvo@zagadka.ping.de>
Subject: Re: obtaining the selection: gtk_selection_convert?
Date: 16 Apr 2000 22:12:03 +0200
Message-ID: <874s91st4c.fsf@zagadka.ping.de>

> > gtk-selection-convert itself seems to work
> 
> Really? ;-) 

oops, i meant, i didn't find anything obviously wrong with it yet ;-)

> There is a bug in the way I use scm_intern.  I'll fix this `asap'.

> > -- the problem now appears to be that when you register a callback
> > for "selection_received", one of the arguments to the callback is
> > GtkSelectionData.  when the callback call is attempted, there appear
> > to be problems because GtkSelectionData doesn't seem to have a
> > guile-gtk manifestation 
> 
> Can you show a short test program so that I can play with it?

i'll attach what i was using to test to this message (the callback
doesn't have any arguments yet).

when i ran the script, what i got as an error was:

  unknown type 'GtkSelectionData'

> What is the meaning of format, data and length?

well, i can quote what i saw in the gtk tutorial ('Managing Selection"):

  format gives the length of the units (for instance characters) in
  bits. Usually, you don't care about this when receiving data. data is
  a pointer to the returned data, and length gives the length of the
  returned data, in bytes. If length is negative, then an error occurred
  and the selection could not be retrieved. This might happen if no
  application owned the selection, or if you requested a target that the
  application didn't support. The buffer is actually guaranteed to be
  one byte longer than length; the extra byte will always be zero, so it
  isn't necessary to make a copy of strings just to null terminate them.

> > (define-object GtkSelectionData ()
> 
> We need to use `define-boxed' for this.

ok.

> >   (fields
> >     (atom selection)
> >     (atom target)
> >     (atom type)
> >     (uint format)
> >     (pointer data)
> 
> and `pointer' should not be used.

what should be used instead?  "pointer" was a blind guess -- the type in
gtkwidget.h is guchar*

> Hmm, OK, I wont be able to really work on this very soon.  Any takers?

i wish i could say that i had the skill, but alas...

#! /bin/sh
exec guile-gtk -s $0 $*
!#

(use-modules (gtk gtk))

(let ((window (gtk-window-new 'toplevel))
      (button (gtk-button-new-with-label "Press Me"))
      (selection nil)
      (target nil)
      (time nil))
  (gtk-container-add window button)
  (gtk-signal-connect button "clicked"
		      (lambda () 
			(display "I've been pressed")
			(newline)
			(gtk-widget-destroy window)))
  (gtk-selection-convert button
			 selection
			 target
			 time)
  (gtk-signal-connect button
		      "selection_received"
		      (lambda ()
			(display "a")
			))
  (gtk-widget-show-all window)
  (gtk-standalone-main window))

; Local Variables:
; mode: scheme
; End:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]