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



Selections can be converted to different "targets".  From the tutorial:

Right, I've been doing some reviewing all night and it's starting to make
some sense.

What appears to be the `target' is really the type of content.
Replacing the type from atom to string, I was able to recieve strings
(will this work for binary as well?)


"In the following example, we retrieve the special target "TARGETS", which
is a list of all targets into which the selection can be converted."

At the moment, this will show us what sort of things the selection can be
converted into.  (gdk/gdktypes.h has a list of them under the GdkTarget
enum, I think)

"TARGETS", however, is probably not what you're looking for.  What you're
looking for is the "STRING" target instead, which will give us the
contents of the primary clipboard as a string.

Right, that's what I figured. Thanks for clearing it up! :)


Let's change the example so that it does return the literal contents of
the clipboard.  First, let's make changes to get_targets().  I'll rename
it as 'trigger_selection_received()':

void trigger_selection_received(GdkWidget* widget, gpointer data) {
    static GdkAtom string_atom = GDK_NONE:
    if (string_atom == GDK_NONE)
        string_atom = gdk_atom_intern("STRING", FALSE);
    gtk_selection_convert(widget, GDK_SELECTION_PRIMARY,
                          string_atom, GDK_CURRENT_TIME);
}

Right, now that works!!  But will that work for binary as well?
Or does the `selection' buffer must contain ASCII characters?

   GTK certainly has an obtuse way of naming this, I guess visually
if you selected something it would be coppied to the clipboard buffer
(like how xterm and gtk's text widgets work).

Calling them selections really threw me off and I didn't have a clue
gtk selections were ment for this.

   Btw, someone pointed out selections also have drag and drop
implmentations, could you give me some pointers on that if possable?

--
Sincerely,                  ,"-_                         \|/
-Capt. Taura M.             ,   O=__                    --X--
..__                         ,_JNMNNEO=_                 /|\
OMNOUMmnne.                  {OMMNNNEEEEOO=_
UOOOBIOOOEOMMn.               'LONMMMMNNEEEOOO=.__..,,..
UUOOEUUOOOOOOOObe              '"=OMMMMWNEEEOOOOO,"=OEEEOO=,._
OOUUUIEEIOONNOIUbe.                "7OMMMMNNNNNWWEEEEOOOOOO"   "'.
EEBNNMMMNWNWWEEIMMNe.             __  7EMMMNNNNNWWWEEEEEEEOO.     " .
NNMMMMWWWMMMWEINMMMNn            "=BBEEEEMMMMMMMMNNNWWWEEOOOOO=._     .
                  http://furry.ao.net/~learfox/





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