Re: Starting to make sense... (was GTK Selection non-sense)



Michael Rothwell <rothwell holly-springs nc us> writes:
I don't suppose you'd post a small snippet to the list demonstrating how
to use the clipboard in the current version of gtk?


Have a look at gtk/gtkeditable.c in the GTK sources, that's the best
example I know of.

Donna Martin seems to have a pretty good chapter on this in her book
"GTK Programming in 21 days" that explains the concepts.

The concepts are the hard part; here is an overview:
 atom - a name stored on the X server, such as "PRIMARY" or
        "CLIPBOARD", used to identify a selection
 client - what X calls an application
 selection - some data that can be provided on demand. clients 
             with data to provide "claim" the selection by 
             advertising that they have data and what formats
             the data is in. Other clients can then request
             that the first client provide said data in one
             of the formats. Selections are identified by 
             atoms.
 target - a type of data the selection contains, such as STRING
 selection owner - client that has claimed the selection and 
                   will provide data

The approximate sequence of events on the owner side is:
 - claim the selection 
 - if you get a selection_get, provide the data
 - if you get selection_clear_event, delete the data, it won't 
   be requested 

On the pasting side:
 - request the data 
 - you get a selection_received signal with the data you 
   requested

Data is passed around as GtkSelectionData which is an uninterpreted
array of bytes. You have to cast the bytes depending on the format of
the selection.

Havoc




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