Re: Some cut,copy and paste thoughts



Damian Ivereigh <damian cisco com> writes:

> On 30 May 2001 08:40:42 -0600, Mark Leisher wrote:
> > 
> >     Damian> The first place I got stuck was wanting to make each selection
> >     Damian> sensitive according to what was going on - for example only
> >     Damian> offering Paste if there was something actually in the CLIPBOARD.
> > 
> > Every time the edit menu is popped up, I do two things to check for this:
> > 
> > 1. I check to see if the clipboard has an owner.
> > 
> > 2. I check to see if the clipboard actually has something on it.  Applications
> >    may or may not leave data on the clipboard when they exit.  Here is some
> >    example code I use to check the contents (the FONTGRID_CLIPBOARD is my own
> >    application-specific selection and FONTGRID_GLYPHLIST a special selection
> >    type):
> > 
> > #ifdef HAVE_XLIB
> >     /*
> >      * Check to see if the clipboard contents are empty or not.
> >      *
> >      * This is handled specially to allow determination of this without
> >      * using up what might be a lot of memory to get the whole contents.  It
> >      * will have to be changed for Windows.
> >      */
> >     if (XGetWindowProperty(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(owner),
> >                            FONTGRID_CLIPBOARD, 0, 4, FALSE, FONTGRID_GLYPHLIST,
> >                            &atype, &aformat, &nitems, &remaining, &data)) {
> >         if (nitems > 0) {
> >             empty = FALSE;
> >             free((char *) data);
> >         }
> >     }
> > #endif
> 
> That is interesting code, I'll have to try and figure it out! Up until now I
> only been doing the 1st check. What is the performance hit on this? Does it have
> to contact the owner to get the info? Either way my comment is still the same,
> it would be really nice to have a gdk wrapper around the whole thing.

I think this code is quite specific to Mark's application; some other
part of the code probably sets the property that he is checking
specifically.

While properties are set as part of the selection protocol, they won't
be set until it starts, and they will be deleted afterwards.

I don't see that there is any way to bypass the actual selection
protocol; you have to ask for TARGETS or for the target you want and
then wait for the response.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]