Re: Some cut,copy and paste thoughts



    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
-----------------------------------------------------------------------------
Mark Leisher                      Times are bad.  Children no longer obey
Computing Research Lab            their parents, and everyone is writing
New Mexico State University       a book.
Box 30001, Dept. 3CRL                -- Marcus Tullius Cicero
Las Cruces, NM  88003




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