GTK+ Traduction Française du Manuel de référence | ||||
---|---|---|---|---|
SélectionsSélections — Fonctions pour manipuler des interprocessus de communication via des sélections. |
Le mécanisme de la sélection fournit les bases pour différents types de communication entre processus. En particulier, le glisser-déposer et GtkClipboard fonctionnent via des selections. Vous aurez très rarement, voir jamais besoin d'utiliser la plupart des fonctions de cette section directement; GtkClipboard fournit un interface plus agréable pour la même fonctionnalité.
Certains types de données décrits dans cette section sont utilisés dans le GtkClipboard et l'API du glisser-déposer également.La structure GtkTargetEntry et les objets GtkTargetList représentent les listes de types de données supportées pendant l'envoie ou la réception de données. L'objet GtkSelectionData est utilisé pour stocker un paquet de données avec le type de données et d'autres informations associées.
typedef struct { |
typedef struct { |
typedef struct { |
GtkTargetList* gtk_target_list_new (const GtkTargetEntry *targets, |
Créé un nouveau GtkTargetList à partir d'un tableau de GtkTargetEntry.
targets : |
Pointeur sur un tableau de GtkTargetEntry |
ntargets : |
nombre d'entrées dans targets .
|
Retourne : | le nouveau GtkTargetList. |
GtkTargetList* gtk_target_list_ref (GtkTargetList *list); |
Augmente de 1 le compteur de référence d'un GtkTargetList .
list : |
un GtkTargetList |
Retourne : | ce qui est passé dans (the passed in) GtkTargetList. |
void gtk_target_list_unref (GtkTargetList *list); |
Diminue de 1 le compteur de référence de GtkTargetList . Si le résultat du compteur de référence est zéro, la liste est libérée.
list : |
un GtkTargetList |
void gtk_target_list_add (GtkTargetList *list, |
list : |
un GtkTargetList |
target : |
atome interne représentant la cible |
flags : |
flags pour la cible |
info : |
un ID qui sera passé après à l'application |
void gtk_target_list_add_table (GtkTargetList *list, |
list : |
un GtkTargetList |
targets : |
la table de GtkTargetEntry |
ntargets : |
nombre de cibles dans la table |
void gtk_target_list_add_text_targets (GtkTargetList *list, |
info
.list : |
un GtkTargetList |
info : |
un ID qui sera passé après à l'application |
Depuis 2.6
void gtk_target_list_add_image_targets (GtkTargetList *list, |
info
.
list : |
un GtkTargetList |
info : |
un ID qui sera passé après à l'application |
writable : |
pour ajouter seulement les cibles pour lesquelles GTK+ sait comment convertir un pixbuf dans le format |
Depuis 2.6
void gtk_target_list_add_uri_targets (GtkTargetList *list, |
Ajoute les cibles URI supportées par GtkSelection
à la liste des cibles.rget list. Toutes les cibles sont ajoutées avec la même info
.
list : |
un GtkTargetList |
info : |
un ID qui sera passé après à l'application |
Depuis 2.6
void gtk_target_list_add_rich_text_targets |
gtk_text_buffer_register_serialize_format()
ou
gtk_text_buffer_register_deserialize_format()
à la liste des cibles. Toutes les cibles sont ajoutées avec la même info
.list : |
un GtkTargetList |
info : |
un ID qui sera passé après à l'application |
deserializable : |
si TRUE , alors des formats rich texte deserializable seront ajoutés, des formats serializable autrement.
|
buffer : |
un GtkTextBuffer. |
Depuis 2.10
void gtk_target_list_remove (GtkTargetList *list, |
Supprime une cible d'une liste de cibles.
list : |
un GtkTargetList |
target : |
atome interne représentant la cible |
gboolean gtk_target_list_find (GtkTargetList *list, |
Recherche une cible données dans un GtkTargetList.
list : |
un GtkTargetList |
target : |
un atome interne représentant la cible recherchée. |
info : |
un pointeur sur l'endroit où stocker les information de l'application pour la cible. |
Retourne : | TRUE si la cible a été trouvée, autrement FALSE
|
void gtk_target_table_free (GtkTargetEntry *targets, |
Cette fonction lébère une table de cibles comme celle retournée par
gtk_target_table_new_from_list()
targets : |
un tableau GtkTargetEntry |
n_targets : |
le nombre d'entrées dans le tableau |
Depuis 2.10
GtkTargetEntry* gtk_target_table_new_from_list (GtkTargetList *list, |
Cette fonction créé un tableau GtkTargetEntry qui contient les mêmes cibles que celles qui sont passée à list
.La table retournée est nouvellement allouée et doit être libérée en utilisant gtk_target_table_free()
quand elle n'est plus nécessaire.
list : |
un GtkTargetList |
n_targets : |
retourne l'endroit pour ne nombre de cibles dans la table |
Retourne : | la nouvelle table |
Depuis 2.10
gboolean gtk_selection_owner_set (GtkWidget *widget, |
Réclame la propriété d'une sélection donnée pour un widget particulier, ou, si widget
est NULL
, libére la propriété de la sélection.
gboolean gtk_selection_owner_set_for_display (GdkDisplay *display,
GtkWidget *widget,
GdkAtom selection,
guint32 time_);
Claim ownership of a given selection for a particular widget, or,
if widget
is NULL
, release
ownership of the selection.
display : |
the Gdkdisplay where the selection is set |
widget : |
new selection owner (a GdkWidget),
or NULL .
|
selection : |
an interned atom representing the selection to claim. |
time_ : |
timestamp with which to claim the selection |
Returns : | TRUE if the operation succeeded |
Since 2.2
void gtk_selection_add_target (GtkWidget *widget,
GdkAtom selection,
GdkAtom target,
guint info);
Appends a specified target to the list of supported targets for a given widget and selection.
widget : |
a GtkTarget |
selection : |
the selection |
target : |
target to add. |
info : |
A unsigned integer which will be passed back to the application. |
void gtk_selection_add_targets (GtkWidget *widget,
GdkAtom selection,
const GtkTargetEntry *targets,
guint ntargets);
Prepends a table of targets to the list of supported targets for a given widget and selection.
widget : |
a GtkWidget |
selection : |
the selection |
targets : |
a table of targets to add |
ntargets : |
number of entries in targets
|
void gtk_selection_clear_targets (GtkWidget *widget,
GdkAtom selection);
Remove all targets registered for the given selection for the widget.
widget : |
a GtkWidget |
selection : |
an atom representing a selection |
gboolean gtk_selection_convert (GtkWidget *widget,
GdkAtom selection,
GdkAtom target,
guint32 time_);
Requests the contents of a selection. When received, a "selection_received" signal will be generated.
widget : |
The widget which acts as requestor |
selection : |
Which selection to get |
target : |
Form of information desired (e.g., STRING) |
time_ : |
Time of request (usually of triggering event) In emergency, you could use GDK_CURRENT_TIME |
Returns : | TRUE if requested
succeeded. FALSE if we could not
process
request. (e.g., there was already a request in process for
this widget).
|
void gtk_selection_data_set (GtkSelectionData *selection_data,
GdkAtom type,
gint format,
const guchar *data,
gint length);
Stores new data into a GtkSelectionData object. Should only be called from a selection handler callback. Zero-terminates the stored data.
selection_data : |
a pointer to a GtkSelectionData structure. |
type : |
the type of selection data |
format : |
format (number of bits in a unit) |
data : |
pointer to the data (will be copied) |
length : |
length of the data |
gboolean gtk_selection_data_set_text (GtkSelectionData *selection_data,
const gchar *str,
gint len);
Sets the contents of the selection from a UTF-8 encoded string.
The string is converted to the form determined by
selection_data->target
.
selection_data : |
a GtkSelectionData |
str : |
a UTF-8 string |
len : |
the length of str ,
or -1 if str
is nul-terminated.
|
Returns : | TRUE if the selection
was successfully set,
otherwise FALSE .
|
guchar* gtk_selection_data_get_text (GtkSelectionData *selection_data);
Gets the contents of the selection data as a UTF-8 string.
selection_data : |
a GtkSelectionData |
Returns : | if the selection data contained a recognized
text type and it could be converted to UTF-8, a newly allocated
string containing the converted text, otherwise NULL .
If the result is non-NULL it must be freed
with g_free() .
|
gboolean gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
GdkPixbuf *pixbuf);
Sets the contents of the selection from a GdkPixbuf
The pixbuf is converted to the form determined by
selection_data->target
.
selection_data : |
a GtkSelectionData |
pixbuf : |
a GdkPixbuf |
Returns : | TRUE if the selection
was successfully set,
otherwise FALSE .
|
Since 2.6
GdkPixbuf* gtk_selection_data_get_pixbuf (GtkSelectionData *selection_data);
Gets the contents of the selection data as a GdkPixbuf.
selection_data : |
a GtkSelectionData |
Returns : | if the selection data contained a recognized
image type and it could be converted to a GdkPixbuf, a newly
allocated pixbuf is returned, otherwise NULL .
If the result is non-NULL it must be freed
with g_object_unref() .
|
Since 2.6
gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data,
gchar **uris);
Sets the contents of the selection from a list of URIs.
The string is converted to the form determined by
selection_data->target
.
selection_data : |
a GtkSelectionData |
uris : |
a NULL -terminated array
of strings hilding URIs
|
Returns : | TRUE if the selection
was successfully set,
otherwise FALSE .
|
Since 2.6
gchar** gtk_selection_data_get_uris (GtkSelectionData *selection_data);
Gets the contents of the selection data as array of URIs.
selection_data : |
a GtkSelectionData |
Returns : | if the selection data contains a list of
URIs, a newly allocated NULL -terminated
string array
containing the URIs, otherwise NULL . If the result
is non-NULL it must be freed
with g_strfreev() .
|
Since 2.6
gboolean gtk_selection_data_get_targets (GtkSelectionData *selection_data,
GdkAtom **targets,
gint *n_atoms);
Gets the contents of selection_data
as an array of targets.
This can be used to interpret the results of getting
the standard TARGETS target that is always supplied for
any selection.
selection_data : |
a GtkSelectionData object |
targets : |
location to store an array of targets. The result
stored here must be freed with g_free() .
|
n_atoms : |
location to store number of items in targets .
|
Returns : | TRUE if selection_data
contains a valid
array of targets, otherwise FALSE .
|
gboolean gtk_selection_data_targets_include_image
(GtkSelectionData *selection_data,
gboolean writable);
Given a GtkSelectionData object
holding a list of targets,
determines if any of the targets in targets
can be used to
provide a GdkPixbuf.
selection_data : |
a GtkSelectionData object |
writable : |
whether to accept only targets for which GTK+ knows how to convert a pixbuf into the format |
Returns : | TRUE if selection_data
holds a list of targets,
and a suitable target for images is included, otherwise FALSE .
|
Since 2.6
gboolean gtk_selection_data_targets_include_text
(GtkSelectionData *selection_data);
Given a GtkSelectionData object
holding a list of targets,
determines if any of the targets in targets
can be used to
provide text.
selection_data : |
a GtkSelectionData object |
Returns : | TRUE if selection_data
holds a list of targets,
and a suitable target for text is included, otherwise FALSE .
|
gboolean gtk_selection_data_targets_include_uri
(GtkSelectionData *selection_data);
Given a GtkSelectionData object
holding a list of targets,
determines if any of the targets in targets
can be used to
provide a list or URIs.
selection_data : |
a GtkSelectionData object |
Returns : | TRUE if selection_data
holds a list of targets,
and a suitable target for text is included, otherwise FALSE .
|
Since 2.10
gboolean gtk_selection_data_targets_include_rich_text
(GtkSelectionData *selection_data,
GtkTextBuffer *buffer);
Given a GtkSelectionData object
holding a list of targets,
determines if any of the targets in targets
can be used to
provide rich text.
selection_data : |
a GtkSelectionData object |
buffer : |
a GtkTextBuffer |
Returns : | TRUE if selection_data
holds a list of targets,
and a suitable target for rich text is included,
otherwise FALSE .
|
Since 2.10
gboolean gtk_targets_include_image (GdkAtom *targets,
gint n_targets,
gboolean writable);
Determines if any of the targets in targets
can be used to
provide a GdkPixbuf.
targets : |
an array of GdkAtoms |
n_targets : |
the length of targets
|
writable : |
whether to accept only targets for which GTK+ knows how to convert a pixbuf into the format |
Returns : | TRUE if targets
include a suitable target for images,
otherwise FALSE .
|
Since 2.10
gboolean gtk_targets_include_text (GdkAtom *targets,
gint n_targets);
Determines if any of the targets in targets
can be used to
provide text.
targets : |
an array of GdkAtoms |
n_targets : |
the length of targets
|
Returns : | TRUE if targets
include a suitable target for text,
otherwise FALSE .
|
Since 2.10
gboolean gtk_targets_include_uri (GdkAtom *targets,
gint n_targets);
Determines if any of the targets in targets
can be used to
provide an uri list.
targets : |
an array of GdkAtoms |
n_targets : |
the length of targets
|
Returns : | TRUE if targets
include a suitable target for uri lists,
otherwise FALSE .
|
Since 2.10
gboolean gtk_targets_include_rich_text (GdkAtom *targets,
gint n_targets,
GtkTextBuffer *buffer);
Determines if any of the targets in targets
can be used to
provide rich text.
targets : |
an array of GdkAtoms |
n_targets : |
the length of targets
|
buffer : |
a GtkTextBuffer |
Returns : | TRUE if targets
include a suitable target for rich text,
otherwise FALSE .
|
Since 2.10
void gtk_selection_remove_all (GtkWidget *widget);
Removes all handlers and unsets ownership of all selections for a widget. Called when widget is being destroyed. This function will not generally be called by applications.
widget : |
a GtkWidget |
gboolean gtk_selection_clear (GtkWidget *widget,
GdkEventSelection *event);
gtk_selection_clear
has been deprecated since version 2.4 and should not be used in
newly-written code. Instead of calling this function, chain up from
your selection_clear_event handler. Calling this function
from any other context is illegal.
The default handler for the GtkWidget::selection_clear_event signal.
Since 2.2
GtkSelectionData* gtk_selection_data_copy (GtkSelectionData *data);
Makes a copy of a GtkSelectionData structure and its data.
data : |
a pointer to a GtkSelectionData structure. |
Returns : | a pointer to a copy of data .
|
void gtk_selection_data_free (GtkSelectionData *data);
Frees a GtkSelectionData
structure returned from
gtk_selection_data_copy()
.
data : |
a pointer to a GtkSelectionData structure. |