From a4b42f0b736943be15924963c8d563c44962225f Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Thu, 14 Dec 2017 01:03:00 +0100 Subject: [PATCH] gdk: Remove selection defines And with it, remove the selections section from the docs. So selections are gone for good now. --- docs/reference/gdk/gdk4-sections.txt | 21 ---- gdk/broadway/gdkproperty-broadway.c | 1 - gdk/broadway/gdkselection-broadway.c | 4 +- gdk/gdk.h | 1 - gdk/gdkselection.c | 33 +----- gdk/gdkselection.h | 157 --------------------------- gdk/meson.build | 1 - gdk/quartz/gdkselection-quartz.c | 3 +- gdk/wayland/gdkselection-wayland.c | 1 - gdk/win32/gdkproperty-win32.c | 42 +------ gdk/win32/gdkselection-win32.c | 5 +- gdk/x11/gdkproperty-x11.c | 1 - gdk/x11/gdkselection-x11.c | 3 +- gtk/gtkselection.c | 12 +- tests/testgtk.c | 53 --------- 15 files changed, 15 insertions(+), 323 deletions(-) delete mode 100644 gdk/gdkselection.h diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 7036a0717f..0132380967 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -406,27 +406,6 @@ gdk_file_list_get_type gdk_content_formats_get_type -
-Selections -selections -GDK_SELECTION_PRIMARY -GDK_SELECTION_SECONDARY -GDK_SELECTION_CLIPBOARD -GDK_TARGET_BITMAP -GDK_TARGET_COLORMAP -GDK_TARGET_DRAWABLE -GDK_TARGET_PIXMAP -GDK_TARGET_STRING -GDK_SELECTION_TYPE_ATOM -GDK_SELECTION_TYPE_BITMAP -GDK_SELECTION_TYPE_COLORMAP -GDK_SELECTION_TYPE_DRAWABLE -GDK_SELECTION_TYPE_INTEGER -GDK_SELECTION_TYPE_PIXMAP -GDK_SELECTION_TYPE_WINDOW -GDK_SELECTION_TYPE_STRING -
-
Properties and Atoms properties diff --git a/gdk/broadway/gdkproperty-broadway.c b/gdk/broadway/gdkproperty-broadway.c index b60488b0ec..0caaf30688 100644 --- a/gdk/broadway/gdkproperty-broadway.c +++ b/gdk/broadway/gdkproperty-broadway.c @@ -29,7 +29,6 @@ #include "gdkinternals.h" #include "gdkdisplay-broadway.h" #include "gdkprivate-broadway.h" -#include "gdkselection.h" #include diff --git a/gdk/broadway/gdkselection-broadway.c b/gdk/broadway/gdkselection-broadway.c index 9c5a4ab81f..cce27a7673 100644 --- a/gdk/broadway/gdkselection-broadway.c +++ b/gdk/broadway/gdkselection-broadway.c @@ -24,8 +24,6 @@ #include "config.h" -#include "gdkselection.h" - #include "gdkproperty.h" #include "gdkprivate-broadway.h" #include "gdkdisplay-broadway.h" @@ -123,7 +121,7 @@ _gdk_broadway_display_text_property_to_utf8_list (GdkDisplay *display, g_return_val_if_fail (length >= 0, 0); g_return_val_if_fail (GDK_IS_DISPLAY (display), 0); - if (encoding == GDK_TARGET_STRING) + if (encoding == gdk_atom_intern_static_string ("STRING")) { return make_list ((gchar *)text, length, TRUE, list); } diff --git a/gdk/gdk.h b/gdk/gdk.h index 4f0bf80c78..1515ad493d 100644 --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -60,7 +60,6 @@ #include #include #include -#include #include #include #include diff --git a/gdk/gdkselection.c b/gdk/gdkselection.c index 09e495083f..23674b7dd8 100644 --- a/gdk/gdkselection.c +++ b/gdk/gdkselection.c @@ -24,42 +24,11 @@ #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 diff --git a/gdk/gdkselection.h b/gdk/gdkselection.h deleted file mode 100644 index 5728f92f13..0000000000 --- a/gdk/gdkselection.h +++ /dev/null @@ -1,157 +0,0 @@ -/* 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 . - */ - -/* - * 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/. - */ - -#ifndef __GDK_SELECTION_H__ -#define __GDK_SELECTION_H__ - -#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION) -#error "Only can be included directly." -#endif - -#include -#include - -G_BEGIN_DECLS - -/* Predefined atoms relating to selections. In general, one will need to use - * gdk_intern_atom - */ -/** - * GDK_SELECTION_PRIMARY: - * - * A #GdkAtom representing the `PRIMARY` selection. - */ -#define GDK_SELECTION_PRIMARY gdk_atom_intern_static_string ("PRIMARY") - -/** - * GDK_SELECTION_SECONDARY: - * - * A #GdkAtom representing the `SECONDARY` selection. - */ -#define GDK_SELECTION_SECONDARY gdk_atom_intern_static_string ("SECONDARY") - -/** - * GDK_SELECTION_CLIPBOARD: - * - * A #GdkAtom representing the `CLIPBOARD` selection. - */ -#define GDK_SELECTION_CLIPBOARD gdk_atom_intern_static_string ("CLIPBOARD") - -/** - * GDK_TARGET_BITMAP: - * - * A #GdkAtom representing the `BITMAP` selection target. - */ -#define GDK_TARGET_BITMAP gdk_atom_intern_static_string ("BITMAP") - -/** - * GDK_TARGET_COLORMAP: - * - * A #GdkAtom representing the `COLORMAP` selection target. - */ -#define GDK_TARGET_COLORMAP gdk_atom_intern_static_string ("COLORMAP") - -/** - * GDK_TARGET_DRAWABLE: - * - * A #GdkAtom representing the `DRAWABLE` selection target. - */ -#define GDK_TARGET_DRAWABLE gdk_atom_intern_static_string ("DRAWABLE") - -/** - * GDK_TARGET_PIXMAP: - * - * A #GdkAtom representing the `PIXMAP` selection target. - */ -#define GDK_TARGET_PIXMAP gdk_atom_intern_static_string ("PIXMAP") - -/** - * GDK_TARGET_STRING: - * - * A #GdkAtom representing the `STRING` selection target. - */ -#define GDK_TARGET_STRING gdk_atom_intern_static_string ("STRING") - -/** - * GDK_SELECTION_TYPE_ATOM: - * - * A #GdkAtom representing the `ATOM` selection type. - */ -#define GDK_SELECTION_TYPE_ATOM gdk_atom_intern_static_string ("ATOM") - -/** - * GDK_SELECTION_TYPE_BITMAP: - * - * A #GdkAtom representing the `BITMAP` selection type. - */ -#define GDK_SELECTION_TYPE_BITMAP gdk_atom_intern_static_string ("BITMAP") - -/** - * GDK_SELECTION_TYPE_COLORMAP: - * - * A #GdkAtom representing the `COLORMAP` selection type. - */ -#define GDK_SELECTION_TYPE_COLORMAP gdk_atom_intern_static_string ("COLORMAP") - -/** - * GDK_SELECTION_TYPE_DRAWABLE: - * - * A #GdkAtom representing the `DRAWABLE` selection type. - */ -#define GDK_SELECTION_TYPE_DRAWABLE gdk_atom_intern_static_string ("DRAWABLE") - -/** - * GDK_SELECTION_TYPE_INTEGER: - * - * A #GdkAtom representing the `INTEGER` selection type. - */ -#define GDK_SELECTION_TYPE_INTEGER gdk_atom_intern_static_string ("INTEGER") - -/** - * GDK_SELECTION_TYPE_PIXMAP: - * - * A #GdkAtom representing the `PIXMAP` selection type. - */ -#define GDK_SELECTION_TYPE_PIXMAP gdk_atom_intern_static_string ("PIXMAP") - -/** - * GDK_SELECTION_TYPE_WINDOW: - * - * A #GdkAtom representing the `WINDOW` selection type. - */ -#define GDK_SELECTION_TYPE_WINDOW gdk_atom_intern_static_string ("WINDOW") - -/** - * GDK_SELECTION_TYPE_STRING: - * - * A #GdkAtom representing the `STRING` selection type. - */ -#define GDK_SELECTION_TYPE_STRING gdk_atom_intern_static_string ("STRING") - -/* Selections - */ - -G_END_DECLS - -#endif /* __GDK_SELECTION_H__ */ diff --git a/gdk/meson.build b/gdk/meson.build index 90f8001aac..10a4f6490b 100644 --- a/gdk/meson.build +++ b/gdk/meson.build @@ -75,7 +75,6 @@ gdk_public_headers = files([ 'gdkrectangle.h', 'gdkrgba.h', 'gdkseat.h', - 'gdkselection.h', 'gdkthreads.h', 'gdktexture.h', 'gdktypes.h', diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c index 5cc5f68d58..855dd39066 100644 --- a/gdk/quartz/gdkselection-quartz.c +++ b/gdk/quartz/gdkselection-quartz.c @@ -20,7 +20,6 @@ #include "config.h" -#include "gdkselection.h" #include "gdkproperty.h" #include "gdkquartz.h" @@ -110,7 +109,7 @@ _gdk_quartz_display_text_property_to_utf8_list (GdkDisplay *display, g_return_val_if_fail (text != NULL, 0); g_return_val_if_fail (length >= 0, 0); - if (encoding == GDK_TARGET_STRING) + if (encoding == gdk_atom_intern_static_string ("STRING")) { return make_list ((gchar *)text, length, TRUE, list); } diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index 233eebbcd6..caec000bb3 100644 --- a/gdk/wayland/gdkselection-wayland.c +++ b/gdk/wayland/gdkselection-wayland.c @@ -29,7 +29,6 @@ #include "gdkdisplay-wayland.h" #include "gdkcontentformatsprivate.h" #include "gdkdndprivate.h" -#include "gdkselection.h" #include "gdkproperty.h" #include diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c index 16a8db5bff..4692df5dfc 100644 --- a/gdk/win32/gdkproperty-win32.c +++ b/gdk/win32/gdkproperty-win32.c @@ -29,7 +29,6 @@ #include #include "gdkproperty.h" -#include "gdkselection.h" #include "gdkdisplayprivate.h" #include "gdkprivate-win32.h" #include "gdkwin32.h" @@ -49,33 +48,9 @@ _gdk_win32_display_manager_atom_intern (GdkDisplayManager *manager, retval = g_hash_table_lookup (atom_hash, atom_name); if (!retval) { - if (strcmp (atom_name, "PRIMARY") == 0) - retval = GDK_SELECTION_PRIMARY; - else if (strcmp (atom_name, "SECONDARY") == 0) - retval = GDK_SELECTION_SECONDARY; - else if (strcmp (atom_name, "CLIPBOARD") == 0) - retval = GDK_SELECTION_CLIPBOARD; - else if (strcmp (atom_name, "ATOM") == 0) - retval = GDK_SELECTION_TYPE_ATOM; - else if (strcmp (atom_name, "BITMAP") == 0) - retval = GDK_SELECTION_TYPE_BITMAP; - else if (strcmp (atom_name, "COLORMAP") == 0) - retval = GDK_SELECTION_TYPE_COLORMAP; - else if (strcmp (atom_name, "DRAWABLE") == 0) - retval = GDK_SELECTION_TYPE_DRAWABLE; - else if (strcmp (atom_name, "INTEGER") == 0) - retval = GDK_SELECTION_TYPE_INTEGER; - else if (strcmp (atom_name, "PIXMAP") == 0) - retval = GDK_SELECTION_TYPE_PIXMAP; - else if (strcmp (atom_name, "WINDOW") == 0) - retval = GDK_SELECTION_TYPE_WINDOW; - else if (strcmp (atom_name, "STRING") == 0) - retval = GDK_SELECTION_TYPE_STRING; - else - { - win32_atom = GlobalAddAtom (atom_name); - retval = GUINT_TO_POINTER ((guint) win32_atom); - } + win32_atom = GlobalAddAtom (atom_name); + retval = GUINT_TO_POINTER ((guint) win32_atom); + g_hash_table_insert (atom_hash, g_strdup (atom_name), retval); @@ -92,17 +67,6 @@ _gdk_win32_display_manager_get_atom_name (GdkDisplayManager *manager, gchar name[256]; if (NULL == atom) return g_strdup (""); - else if (GDK_SELECTION_PRIMARY == atom) return g_strdup ("PRIMARY"); - else if (GDK_SELECTION_SECONDARY == atom) return g_strdup ("SECONDARY"); - else if (GDK_SELECTION_CLIPBOARD == atom) return g_strdup ("CLIPBOARD"); - else if (GDK_SELECTION_TYPE_ATOM == atom) return g_strdup ("ATOM"); - else if (GDK_SELECTION_TYPE_BITMAP == atom) return g_strdup ("BITMAP"); - else if (GDK_SELECTION_TYPE_COLORMAP == atom) return g_strdup ("COLORMAP"); - else if (GDK_SELECTION_TYPE_DRAWABLE == atom) return g_strdup ("DRAWABLE"); - else if (GDK_SELECTION_TYPE_INTEGER == atom) return g_strdup ("INTEGER"); - else if (GDK_SELECTION_TYPE_PIXMAP == atom) return g_strdup ("PIXMAP"); - else if (GDK_SELECTION_TYPE_WINDOW == atom) return g_strdup ("WINDOW"); - else if (GDK_SELECTION_TYPE_STRING == atom) return g_strdup ("STRING"); win32_atom = GPOINTER_TO_UINT (atom); diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c index 18a285908a..35ef0be45f 100644 --- a/gdk/win32/gdkselection-win32.c +++ b/gdk/win32/gdkselection-win32.c @@ -284,7 +284,6 @@ which emits the "drag-data-received" signal for the app. #include #include "gdkproperty.h" -#include "gdkselection.h" #include "gdkdisplay.h" #include "gdkprivate-win32.h" #include "gdkselection-win32.h" @@ -2558,7 +2557,7 @@ gdk_text_property_to_text_list_for_display (GdkDisplay *display, if (!list) return 0; - if (encoding == GDK_TARGET_STRING) + if (encoding == gdk_atom_intern_static_string ("STRING")) source_charset = g_strdup ("ISO-8859-1"); else if (encoding == _gdk_win32_selection_atom (GDK_WIN32_ATOM_INDEX_UTF8_STRING)) source_charset = g_strdup ("UTF-8"); @@ -2669,7 +2668,7 @@ _gdk_win32_display_text_property_to_utf8_list (GdkDisplay *display, g_return_val_if_fail (text != NULL, 0); g_return_val_if_fail (length >= 0, 0); - if (encoding == GDK_TARGET_STRING) + if (encoding == gdk_atom_intern_static_string ("STRING")) { return make_list ((gchar *)text, length, TRUE, list); } diff --git a/gdk/x11/gdkproperty-x11.c b/gdk/x11/gdkproperty-x11.c index 5528ada680..863cd8556c 100644 --- a/gdk/x11/gdkproperty-x11.c +++ b/gdk/x11/gdkproperty-x11.c @@ -26,7 +26,6 @@ #include "gdkproperty.h" #include "gdkinternals.h" -#include "gdkselection.h" #include "gdkprivate-x11.h" #include "gdkdisplay-x11.h" #include "gdkscreen-x11.h" diff --git a/gdk/x11/gdkselection-x11.c b/gdk/x11/gdkselection-x11.c index 632684063e..1162f7c20c 100644 --- a/gdk/x11/gdkselection-x11.c +++ b/gdk/x11/gdkselection-x11.c @@ -24,7 +24,6 @@ #include "config.h" -#include "gdkselection.h" #include "gdkproperty.h" #include "gdkprivate-x11.h" #include "gdkdisplay-x11.h" @@ -200,7 +199,7 @@ _gdk_x11_display_text_property_to_utf8_list (GdkDisplay *display, gint length, gchar ***list) { - if (encoding == GDK_TARGET_STRING) + if (encoding == gdk_atom_intern_static_string ("STRING")) { return make_list ((gchar *)text, length, TRUE, list); } diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 0c7cd566a6..25c3b0afb5 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -170,7 +170,7 @@ gtk_content_formats_add_text_targets (GdkContentFormats *list) gdk_content_formats_builder_add_mime_type (builder, utf8_atom); gdk_content_formats_builder_add_mime_type (builder, ctext_atom); gdk_content_formats_builder_add_mime_type (builder, text_atom); - gdk_content_formats_builder_add_mime_type (builder, GDK_TARGET_STRING); + gdk_content_formats_builder_add_mime_type (builder, gdk_atom_intern_static_string ("STRING")); gdk_content_formats_builder_add_mime_type (builder, text_plain_utf8_atom); if (!g_get_charset (NULL)) gdk_content_formats_builder_add_mime_type (builder, text_plain_locale_atom); @@ -479,7 +479,7 @@ selection_set_string (GtkSelectionData *selection_data, if (latin1) { gtk_selection_data_set (selection_data, - GDK_SELECTION_TYPE_STRING, + gdk_atom_intern_static_string ("STRING"), 8, (guchar *) latin1, strlen (latin1)); g_free (latin1); @@ -702,7 +702,7 @@ gtk_selection_data_set_text (GtkSelectionData *selection_data, 8, (guchar *)str, len); return TRUE; } - else if (selection_data->target == GDK_TARGET_STRING) + else if (selection_data->target == gdk_atom_intern_static_string ("STRING")) { return selection_set_string (selection_data, str, len); } @@ -745,7 +745,7 @@ gtk_selection_data_get_text (const GtkSelectionData *selection_data) init_atoms (); if (selection_data->length >= 0 && - (selection_data->type == GDK_TARGET_STRING || + (selection_data->type == gdk_atom_intern_static_string ("STRING") || selection_data->type == ctext_atom || selection_data->type == utf8_atom)) { @@ -1131,7 +1131,7 @@ gtk_selection_data_get_targets (const GtkSelectionData *selection_data, if (selection_data->length >= 0 && selection_data->format == 32 && - selection_data->type == GDK_SELECTION_TYPE_ATOM) + selection_data->type == gdk_atom_intern_static_string ("ATOM")) { if (targets) *targets = g_memdup (selection_data->data, selection_data->length); @@ -1182,7 +1182,7 @@ gtk_targets_include_text (GdkAtom *targets, { if (targets[i] == utf8_atom || targets[i] == text_atom || - targets[i] == GDK_TARGET_STRING || + targets[i] == gdk_atom_intern_static_string ("STRING") || targets[i] == ctext_atom || targets[i] == text_plain_atom || targets[i] == text_plain_utf8_atom || diff --git a/tests/testgtk.c b/tests/testgtk.c index 9a16003c56..cb017e738e 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -7031,59 +7031,6 @@ create_snapshot (GtkWidget *widget) } -/* - * Selection Test - */ - -void -selection_test_received (GtkWidget *tree_view, - GtkSelectionData *selection_data) -{ - GtkTreeModel *model; - GtkListStore *store; - GdkAtom *atoms; - int i, l; - - if (gtk_selection_data_get_length (selection_data) < 0) - { - g_print ("Selection retrieval failed\n"); - return; - } - if (gtk_selection_data_get_data_type (selection_data) != GDK_SELECTION_TYPE_ATOM) - { - g_print ("Selection \"TARGETS\" was not returned as atoms!\n"); - return; - } - - /* Clear out any current list items */ - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); - store = GTK_LIST_STORE (model); - gtk_list_store_clear (store); - - /* Add new items to list */ - - gtk_selection_data_get_targets (selection_data, - &atoms, &l); - - for (i = 0; i < l; i++) - { - char *name; - GtkTreeIter iter; - - name = gdk_atom_name (atoms[i]); - if (name != NULL) - { - gtk_list_store_insert_with_values (store, &iter, i, 0, name, -1); - g_free (name); - } - else - gtk_list_store_insert_with_values (store, &iter, i, 0, "(bad atom)", -1); - } - - return; -} - /* * Test scrolling */