* 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, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gdkselection.h"
#include "gdkproperty.h"
-#include "gdkdisplay.h"
+#include "gdkdisplayprivate.h"
/**
* Sends a response to SelectionRequest event.
*/
void
-gdk_selection_send_notify (GdkNativeWindow requestor,
+gdk_selection_send_notify (GdkWindow *requestor,
GdkAtom selection,
GdkAtom target,
GdkAtom property,
guint32 time)
{
- gdk_selection_send_notify_for_display (gdk_display_get_default (),
+ gdk_selection_send_notify_for_display (gdk_window_get_display (requestor),
requestor, selection,
target, property, time);
}
/**
- * gdk_text_property_to_text_list:
- * @encoding: an atom representing the encoding. The most common
- * values for this are <literal>STRING</literal>,
- * or <literal>COMPOUND_TEXT</literal>. This is
- * value used as the type for the property.
- * @format: the format of the property.
- * @text: the text data.
- * @length: the length of the property, in items.
- * @list: location to store a terminated array of strings
- * in the encoding of the current locale. This
- * array should be freed using gdk_free_text_list().
- *
- * Converts a text string from the encoding as it is stored in
- * a property into an array of strings in the encoding of
- * the current local. (The elements of the array represent
- * the nul-separated elements of the original text string.)
- *
- * Returns: the number of strings stored in @list, or 0,
- * if the conversion failed.
+ * gdk_selection_owner_set_for_display:
+ * @display: the #GdkDisplay
+ * @owner: a #GdkWindow or %NULL to indicate that the owner for
+ * the given should be unset
+ * @selection: an atom identifying a selection
+ * @time_: timestamp to use when setting the selection
+ * If this is older than the timestamp given last time the owner was
+ * set for the given selection, the request will be ignored
+ * @send_event: if %TRUE, and the new owner is different from the current
+ * owner, the current owner will be sent a SelectionClear event
+ *
+ * Sets the #GdkWindow @owner as the current owner of the selection @selection.
+ *
+ * Returns: %TRUE if the selection owner was successfully changed to owner,
+ * otherwise %FALSE.
+ *
+ * Since: 2.2
*/
-gint
-gdk_text_property_to_text_list (GdkAtom encoding,
- gint format,
- const guchar *text,
- gint length,
- gchar ***list)
+gboolean
+gdk_selection_owner_set_for_display (GdkDisplay *display,
+ GdkWindow *owner,
+ GdkAtom selection,
+ guint32 time,
+ gboolean send_event)
{
- return gdk_text_property_to_text_list_for_display (gdk_display_get_default (),
- encoding, format, text, length, list);
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+ g_return_val_if_fail (selection != GDK_NONE, FALSE);
+
+ return GDK_DISPLAY_GET_CLASS (display)
+ ->set_selection_owner (display, owner, selection, time, send_event);
}
/**
- * gdk_text_property_to_utf8_list:
- * @encoding: an atom representing the encoding of the text
- * @format: the format of the property
- * @text: the text to convert
- * @length: the length of @text, in bytes
- * @list: (allow-none): location to store the list of strings or %NULL. The
- * list should be freed with g_strfreev().
- *
- * Convert a text property in the giving encoding to
- * a list of UTF-8 strings.
- *
- * Return value: the number of strings in the resulting
- * list.
- **/
-gint
-gdk_text_property_to_utf8_list (GdkAtom encoding,
- gint format,
- const guchar *text,
- gint length,
- gchar ***list)
+ * gdk_selection_owner_get_for_display:
+ * @display: a #GdkDisplay
+ * @selection: an atom indentifying a selection
+ *
+ * Determine the owner of the given selection.
+ *
+ * Note that the return value may be owned by a different
+ * process if a foreign window was previously created for that
+ * window, but a new foreign window will never be created by this call.
+ *
+ * Returns: (transfer none): if there is a selection owner for this window,
+ * and it is a window known to the current process, the #GdkWindow that
+ * owns the selection, otherwise %NULL.
+ *
+ * Since: 2.2
+ */
+GdkWindow *
+gdk_selection_owner_get_for_display (GdkDisplay *display,
+ GdkAtom selection)
+{
+ g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+ g_return_val_if_fail (selection != GDK_NONE, NULL);
+
+ return GDK_DISPLAY_GET_CLASS (display)->get_selection_owner (display, selection);
+}
+
+/**
+ * gdk_selection_send_notify_for_display:
+ * @display: the #GdkDisplay where @requestor is realized
+ * @requestor: window to which to deliver response
+ * @selection: selection that was requested
+ * @target: target that was selected
+ * @property: property in which the selection owner stored the data,
+ * or %GDK_NONE to indicate that the request was rejected
+ * @time_: timestamp
+ *
+ * Send a response to SelectionRequest event.
+ *
+ * Since: 2.2
+ */
+void
+gdk_selection_send_notify_for_display (GdkDisplay *display,
+ GdkWindow *requestor,
+ GdkAtom selection,
+ GdkAtom target,
+ GdkAtom property,
+ guint32 time_)
+{
+ g_return_if_fail (GDK_IS_DISPLAY (display));
+
+ GDK_DISPLAY_GET_CLASS (display)
+ ->send_selection_notify (display, requestor, selection,target, property, time_);
+}
+
+/**
+ * gdk_selection_property_get: (skip)
+ * @requestor: the window on which the data is stored
+ * @data: location to store a pointer to the retrieved data.
+ If the retrieval failed, %NULL we be stored here, otherwise, it
+ will be non-%NULL and the returned data should be freed with g_free()
+ when you are finished using it. The length of the
+ allocated memory is one more than the length
+ of the returned data, and the final byte will always
+ be zero, to ensure nul-termination of strings
+ * @prop_type: location to store the type of the property
+ * @prop_format: location to store the format of the property
+ *
+ * Retrieves selection data that was stored by the selection
+ * data in response to a call to gdk_selection_convert(). This function
+ * will not be used by applications, who should use the #GtkClipboard
+ * API instead.
+ *
+ * Return value: the length of the retrieved data.
+ */
+gint
+gdk_selection_property_get (GdkWindow *requestor,
+ guchar **data,
+ GdkAtom *ret_type,
+ gint *ret_format)
{
- return gdk_text_property_to_utf8_list_for_display (gdk_display_get_default (),
- encoding, format, text, length, list);
+ GdkDisplay *display;
+
+ g_return_val_if_fail (GDK_IS_WINDOW (requestor), 0);
+
+ display = gdk_window_get_display (requestor);
+
+ return GDK_DISPLAY_GET_CLASS (display)
+ ->get_selection_property (display, requestor, data, ret_type, ret_format);
+}
+
+void
+gdk_selection_convert (GdkWindow *requestor,
+ GdkAtom selection,
+ GdkAtom target,
+ guint32 time)
+{
+ GdkDisplay *display;
+
+ g_return_if_fail (selection != GDK_NONE);
+
+ display = gdk_window_get_display (requestor);
+
+ GDK_DISPLAY_GET_CLASS (display)
+ ->convert_selection (display, requestor, selection, target, time);
}
/**
- * gdk_string_to_compound_text:
- * @str: a nul-terminated string.
- * @encoding: location to store the encoding atom (to be used as
- * the type for the property).
- * @format: location to store the format for the property.
- * @ctext: location to store newly allocated data for the property.
- * @length: location to store the length of @ctext in items.
- *
- * Converts a string from the encoding of the current locale
- * into a form suitable for storing in a window property.
- *
- * Returns: 0 upon sucess, non-zero upon failure.
+ * 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.
+ *
+ * Return value: the number of strings in the resulting list
+ *
+ * Since: 2.2
*/
gint
-gdk_string_to_compound_text (const gchar *str,
- GdkAtom *encoding,
- gint *format,
- guchar **ctext,
- gint *length)
+gdk_text_property_to_utf8_list_for_display (GdkDisplay *display,
+ GdkAtom encoding,
+ gint format,
+ const guchar *text,
+ gint length,
+ gchar ***list)
{
- return gdk_string_to_compound_text_for_display (gdk_display_get_default (),
- str, encoding, format,
- ctext, length);
+ 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_compound_text:
- * @str: a UTF-8 string
- * @encoding: location to store resulting encoding
- * @format: location to store format of the result
- * @ctext: location to store the data of the result
- * @length: location to store the length of the data
- * stored in @ctext
- *
- * Convert from UTF-8 to compound text.
- *
- * Return value: %TRUE if the conversion succeeded, otherwise
- * false.
+ * 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.
+ *
+ * Return value: 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.)
**/
-gboolean
-gdk_utf8_to_compound_text (const gchar *str,
- GdkAtom *encoding,
- gint *format,
- guchar **ctext,
- gint *length)
+gchar *
+gdk_utf8_to_string_target (const gchar *str)
{
- return gdk_utf8_to_compound_text_for_display (gdk_display_get_default (),
- str, encoding, format,
- ctext, length);
+ GdkDisplay *display = gdk_display_get_default ();
+
+ return GDK_DISPLAY_GET_CLASS (display)->utf8_to_string_target (display, str);
}