Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 23dbe49bc2fbd86096de282a461e6c66 > files > 233

gtk2-devel-docs-2.24.7-3.fc15.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>Managing Selections</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REL="HOME"
TITLE="GTK+ 2.0 Tutorial"
HREF="book1.html"><LINK
REL="PREVIOUS"
TITLE="Signal Emission and Propagation"
HREF="x1810.html"><LINK
REL="NEXT"
TITLE="Retrieving the selection"
HREF="x1850.html"></HEAD
><BODY
CLASS="CHAPTER"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>GTK+ 2.0 Tutorial</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="x1810.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="x1850.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="CH-MANAGINGSELECTIONS"
></A
>Managing Selections</H1
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="SEC-SELECTIONSOVERVIEW"
>Overview</A
></H1
><P
>One type of interprocess communication supported by X and GTK is
<I
CLASS="EMPHASIS"
>selections</I
>. A selection identifies a chunk of data, for
instance, a portion of text, selected by the user in some fashion, for
instance, by dragging with the mouse. Only one application on a
display (the <I
CLASS="EMPHASIS"
>owner</I
>) can own a particular selection at one
time, so when a selection is claimed by one application, the previous
owner must indicate to the user that selection has been
relinquished. Other applications can request the contents of a
selection in different forms, called <I
CLASS="EMPHASIS"
>targets</I
>. There can be
any number of selections, but most X applications only handle one, the
<I
CLASS="EMPHASIS"
>primary selection</I
>.</P
><P
>In most cases, it isn't necessary for a GTK application to deal with
selections itself. The standard widgets, such as the Entry widget,
already have the capability to claim the selection when appropriate
(e.g., when the user drags over text), and to retrieve the contents of
the selection owned by another widget or another application (e.g.,
when the user clicks the second mouse button). However, there may be
cases in which you want to give other widgets the ability to supply
the selection, or you wish to retrieve targets not supported by
default.</P
><P
>A fundamental concept needed to understand selection handling is that
of the <I
CLASS="EMPHASIS"
>atom</I
>. An atom is an integer that uniquely identifies a
string (on a certain display). Certain atoms are predefined by the X
server, and in some cases there are constants in <TT
CLASS="LITERAL"
>gtk.h</TT
>
corresponding to these atoms. For instance the constant
<TT
CLASS="LITERAL"
>GDK_PRIMARY_SELECTION</TT
> corresponds to the string "PRIMARY".
In other cases, you should use the functions
<TT
CLASS="LITERAL"
>gdk_atom_intern()</TT
>, to get the atom corresponding to a string,
and <TT
CLASS="LITERAL"
>gdk_atom_name()</TT
>, to get the name of an atom. Both
selections and targets are identified by atoms.</P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x1810.html"
ACCESSKEY="P"
>&#60;&#60;&#60; Previous</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="x1850.html"
ACCESSKEY="N"
>Next &#62;&#62;&#62;</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Signal Emission and Propagation</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Retrieving the selection</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>