public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* obtaining the selection: gtk_selection_convert?
@ 2000-04-10  3:12 sen_ml
  2000-04-10 23:19 ` sen_ml
  0 siblings, 1 reply; 7+ messages in thread
From: sen_ml @ 2000-04-10  3:12 UTC (permalink / raw)
  To: guile-gtk

hi-

  i'd like to be able to obtain the primary selection.  reading:

    file:/usr/doc/libgtk-doc/tutorial-html/gtk_tut-20.html

suggested to me that i'd want to use the equivalent of
gtk_selection_convert.  however, i was unable to find bindings for
this in guile-gtk.  am i missing something?  is there some other way
to obtain the selection through guile-gtk.

  thanks for any help.

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

* Re: obtaining the selection: gtk_selection_convert?
  2000-04-10  3:12 obtaining the selection: gtk_selection_convert? sen_ml
@ 2000-04-10 23:19 ` sen_ml
  2000-04-12 12:09   ` Marius Vollmer
  2000-04-12 12:55   ` Marius Vollmer
  0 siblings, 2 replies; 7+ messages in thread
From: sen_ml @ 2000-04-10 23:19 UTC (permalink / raw)
  To: guile-gtk

the developer of rep-gtk suggested that it might be possible to add
support for gtk_selection_convert by adding appropriate information to
gtk-1.2.defs and recompiling.

my guess would have been to add:

  (define-func gtk_selection_convert
    int
    ((GtkWidget widget)
     (GdkAtom selection)
     (GdkAtom target)
     (uint time)))

but, there does not appear to be a relevant defintion of GdkAtom.
would that be difficult to add?  GdkAtom is typedef-ed as gulong,
right?

any help would be appreciated.

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

* Re: obtaining the selection: gtk_selection_convert?
  2000-04-10 23:19 ` sen_ml
@ 2000-04-12 12:09   ` Marius Vollmer
  2000-04-12 12:55   ` Marius Vollmer
  1 sibling, 0 replies; 7+ messages in thread
From: Marius Vollmer @ 2000-04-12 12:09 UTC (permalink / raw)
  To: sen_ml; +Cc: guile-gtk

sen_ml@eccosys.com writes:

> my guess would have been to add:
> 
>   (define-func gtk_selection_convert
>     int
>     ((GtkWidget widget)
>      (GdkAtom selection)
>      (GdkAtom target)
>      (uint time)))
> 
> but, there does not appear to be a relevant defintion of GdkAtom.
> would that be difficult to add?

I think GdkAtom is Gdk's idea of what Scheme calls a symbol.  So we
should probably add a new primitive type `atom' to build-guile-gtk and
convert between atoms and symbols automatically.

I'll look into this and when it easy enough, I'll add it tonight.

- Marius

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

* Re: obtaining the selection: gtk_selection_convert?
  2000-04-10 23:19 ` sen_ml
  2000-04-12 12:09   ` Marius Vollmer
@ 2000-04-12 12:55   ` Marius Vollmer
  2000-04-13 18:23     ` sen_ml
  1 sibling, 1 reply; 7+ messages in thread
From: Marius Vollmer @ 2000-04-12 12:55 UTC (permalink / raw)
  To: sen_ml; +Cc: guile-gtk

sen_ml@eccosys.com writes:

> my guess would have been to add:
> 
>   (define-func gtk_selection_convert
>     int
>     ((GtkWidget widget)
>      (GdkAtom selection)
>      (GdkAtom target)
>      (uint time)))

Ok, I have done this now in CVS.  Can you test it?

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

* Re: obtaining the selection: gtk_selection_convert?
  2000-04-12 12:55   ` Marius Vollmer
@ 2000-04-13 18:23     ` sen_ml
       [not found]       ` <874s91st4c.fsf@zagadka.ping.de>
  0 siblings, 1 reply; 7+ messages in thread
From: sen_ml @ 2000-04-13 18:23 UTC (permalink / raw)
  To: guile-gtk; +Cc: mvo

thanks for the response.  my comments follow.

> sen_ml@eccosys.com writes:
> 
> > my guess would have been to add:
> > 
> >   (define-func gtk_selection_convert
> >     int
> >     ((GtkWidget widget)
> >      (GdkAtom selection)
> >      (GdkAtom target)
> >      (uint time)))
> 
> Ok, I have done this now in CVS.  Can you test it?

sorry to be slow -- it took a day to set up a development machine ;-)

gtk-selection-convert itself seems to work -- 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 yet.

GtkSelectionData's definition (or the underscore version) is:

struct _GtkSelectionData
   {
     GdkAtom selection;
     GdkAtom target;
     GdkAtom type;
     gint    format;
     guchar *data;
     gint    length;
   };

not really knowing what to do, i tried adding:

(define-object GtkSelectionData ()
  (fields
    (atom selection)
    (atom target)
    (atom type)
    (uint format)
    (pointer data)
    (int length)))

to gtk-1.2.defs, but make ended in:

...
gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/local/include -I/usr/include -I/usr/lib/glib/include -I/usr/X11R6/include -g -O2 -Wp,-MD,.deps/gtk-glue.pp -c gtk-glue.c
 -fPIC -DPIC -o .libs/gtk-glue.lo
gtk-glue.c:799: `gtk_selection_data_get_type' undeclared here (not in a function)
gtk-glue.c:799: initializer element is not constant
gtk-glue.c:799: (near initialization for `sgtk_gtk_selection_data_info.init_func')
gtk-glue.c:14462: parse error before `:'
make: *** [gtk-glue.lo] Error 1

does this mean there are some related function definitions i should
add as well?

p.s. what is the recommended procedure for building guile-gtk from a fresh
checkout via cvs?  right now i'm doing:

  % sh autogen.sh
  % ./configure
  % make

i only figured out the bit about autogen.sh by looking through the archives.
is there an important bit of documentation i am missing?

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

* Re: obtaining the selection: gtk_selection_convert?
       [not found]       ` <874s91st4c.fsf@zagadka.ping.de>
@ 2000-04-17  2:41         ` sen_ml
  2000-04-18 12:48           ` Marius Vollmer
  0 siblings, 1 reply; 7+ messages in thread
From: sen_ml @ 2000-04-17  2:41 UTC (permalink / raw)
  To: mvo, guile-gtk

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

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

* Re: obtaining the selection: gtk_selection_convert?
  2000-04-17  2:41         ` sen_ml
@ 2000-04-18 12:48           ` Marius Vollmer
  0 siblings, 0 replies; 7+ messages in thread
From: Marius Vollmer @ 2000-04-18 12:48 UTC (permalink / raw)
  To: sen_ml; +Cc: guile-gtk

sen_ml@eccosys.com writes:

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

Ok, thanks.  I think we should make two accessor functions: one for
returning the data as a string (because that should be a very common
need) and one for returning a vector of integers.

> > >     (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*

We can't access data and length as fields.  Their semantics are too
complex for fields (or fields are too stupid).  We have to write C
functions that can be then be wrapped with define-func.  I'd have to
review what build-guile-gtk can actually do with vectors to say more.

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

It's not so much skill, it's the sorry state of the guile-gtk
documentation.

- Marius

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

end of thread, other threads:[~2000-04-18 12:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-10  3:12 obtaining the selection: gtk_selection_convert? sen_ml
2000-04-10 23:19 ` sen_ml
2000-04-12 12:09   ` Marius Vollmer
2000-04-12 12:55   ` Marius Vollmer
2000-04-13 18:23     ` sen_ml
     [not found]       ` <874s91st4c.fsf@zagadka.ping.de>
2000-04-17  2:41         ` sen_ml
2000-04-18 12:48           ` Marius Vollmer

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