gtk2/gdk/gdkselection.c
Benjamin Otte 54f9aef0d4 gdk: Remove gdk_selection_convert()
It's not used anymore.
2017-12-14 00:44:26 +01:00

119 lines
4.6 KiB
C

/* GDK - The GIMP Drawing Kit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#include "config.h"
#include "gdkselection.h"
#include "gdkproperty.h"
#include "gdkdisplayprivate.h"
/**
* SECTION:selections
* @Short_description: Functions for transfering data via the X selection mechanism
* @Title: Selections
*
* The X selection mechanism provides a way to transfer arbitrary chunks of
* data between programs. A “selection” is a essentially
* a named clipboard, identified by a string interned as a #GdkAtom. By
* claiming ownership of a selection, an application indicates that it will
* be responsible for supplying its contents. The most common selections are
* `PRIMARY` and `CLIPBOARD`.
*
* The contents of a selection can be represented in a number of formats,
* called “targets”. Each target is identified by an atom.
* A list of all possible targets supported by the selection owner can be
* retrieved by requesting the special target `TARGETS`. When
* a selection is retrieved, the data is accompanied by a type (an atom), and
* a format (an integer, representing the number of bits per item).
* See [Properties and Atoms][gdk3-Properties-and-Atoms]
* for more information.
*
* The functions in this section only contain the lowlevel parts of the
* selection protocol. A considerably more complicated implementation is needed
* on top of this. GTK+ contains such an implementation in the functions in
* `gtkselection.h` and programmers should use those functions
* instead of the ones presented here. If you plan to implement selection
* handling directly on top of the functions here, you should refer to the
* X Inter-client Communication Conventions Manual (ICCCM).
*/
/**
* gdk_text_property_to_utf8_list_for_display:
* @display: a #GdkDisplay
* @encoding: an atom representing the encoding of the text
* @format: the format of the property
* @text: (array length=length): the text to convert
* @length: the length of @text, in bytes
* @list: (out) (array zero-terminated=1): location to store the list
* of strings or %NULL. The list should be freed with
* g_strfreev().
*
* Converts a text property in the given encoding to
* a list of UTF-8 strings.
*
* Returns: the number of strings in the resulting list
*
* Since: 2.2
*/
gint
gdk_text_property_to_utf8_list_for_display (GdkDisplay *display,
GdkAtom encoding,
gint format,
const guchar *text,
gint length,
gchar ***list)
{
g_return_val_if_fail (text != NULL, 0);
g_return_val_if_fail (length >= 0, 0);
g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
return GDK_DISPLAY_GET_CLASS (display)
->text_property_to_utf8_list (display, encoding, format, text, length, list);
}
/**
* gdk_utf8_to_string_target:
* @str: a UTF-8 string
*
* Converts an UTF-8 string into the best possible representation
* as a STRING. The representation of characters not in STRING
* is not specified; it may be as pseudo-escape sequences
* \x{ABCD}, or it may be in some other form of approximation.
*
* Returns: (nullable): the newly-allocated string, or %NULL if the
* conversion failed. (It should not fail for any properly
* formed UTF-8 string unless system limits like memory or
* file descriptors are exceeded.)
**/
gchar *
gdk_utf8_to_string_target (const gchar *str)
{
GdkDisplay *display = gdk_display_get_default ();
return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str);
}