Deprecate GtkColorChooser and implementations
authorMatthias Clasen <mclasen@redhat.com>
Thu, 27 Oct 2022 01:52:06 +0000 (21:52 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 29 Oct 2022 17:31:41 +0000 (13:31 -0400)
These are being replaced by GtkColorDialog
and GtkColorDialogButton.

This commit only moves the headers for GtkColorChooserWidget
and GtkColorChooserDialog to deprecated/, and keeps the
implementations in gtk/, since they will eventually be
salvaged into a private GtkColorChooserWindow.

29 files changed:
demos/gtk-demo/dnd.c
demos/gtk-demo/font_features.c
demos/gtk-demo/paint.c
demos/widget-factory/widget-factory.c
gtk/deprecated/gtkcolorbutton.c [new file with mode: 0644]
gtk/deprecated/gtkcolorbutton.h [new file with mode: 0644]
gtk/deprecated/gtkcolorchooser.c [new file with mode: 0644]
gtk/deprecated/gtkcolorchooser.h [new file with mode: 0644]
gtk/deprecated/gtkcolorchooserdialog.h [new file with mode: 0644]
gtk/deprecated/gtkcolorchooserprivate.h [new file with mode: 0644]
gtk/deprecated/gtkcolorchooserwidget.h [new file with mode: 0644]
gtk/deprecated/meson.build
gtk/gtk.h
gtk/gtkcolorbutton.c [deleted file]
gtk/gtkcolorbutton.h [deleted file]
gtk/gtkcolorchooser.c [deleted file]
gtk/gtkcolorchooser.h [deleted file]
gtk/gtkcolorchooserdialog.c
gtk/gtkcolorchooserdialog.h [deleted file]
gtk/gtkcolorchooserprivate.h [deleted file]
gtk/gtkcolorchooserwidget.c
gtk/gtkcolorchooserwidget.h [deleted file]
gtk/gtkcolordialog.c
gtk/gtkcoloreditor.c
gtk/gtkcolorscale.c
gtk/gtkcolorswatch.c
gtk/meson.build
tests/testdialog.c
testsuite/gtk/templates.c

index e406ca3972dc569a845566209bd9e8acef1580c1..fbf28ec30560914fa8ffbd4286384dcfd197217e 100644 (file)
@@ -726,7 +726,9 @@ do_dnd (GtkWidget *do_widget)
       GtkCssProvider *provider;
       GString *css;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
       button = gtk_color_button_new ();
+G_GNUC_END_IGNORE_DEPRECATIONS
       g_object_unref (g_object_ref_sink (button));
 
       provider = gtk_css_provider_new ();
index ed71354f1d4ea550e07427e82531bee3b8ea0dd4..fd358eb47bf3570587420cc0c1920b0f8052d47e 100644 (file)
@@ -21,6 +21,8 @@
 #include "script-names.h"
 #include "language-names.h"
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 /* {{{ ScriptLang object */
 
 G_DECLARE_FINAL_TYPE (ScriptLang, script_lang, SCRIPT, LANG, GObject)
index 92774b0efbf47729983521d39cf9e5bd8c458e9d..d60991f9811c64b7eaa5c03f2c7b6617f7a192ec 100644 (file)
@@ -7,6 +7,8 @@
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 enum {
   COLOR_SET,
   N_SIGNALS
index 705606fcfef0ef67e825b0cd9cc4c7300401ac11..b41283d10f835daafb8239bdadc45cbaf3d4df84 100644 (file)
@@ -1096,7 +1096,9 @@ set_color (GtkListBox *box, GtkListBoxRow *row, GtkColorChooser *chooser)
   if (gdk_rgba_parse (&rgba, color))
     {
       g_signal_handlers_block_by_func (chooser, rgba_changed, box);
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
       gtk_color_chooser_set_rgba (chooser, &rgba);
+G_GNUC_END_IGNORE_DEPRECATIONS
       g_signal_handlers_unblock_by_func (chooser, rgba_changed, box);
     }
 }
diff --git a/gtk/deprecated/gtkcolorbutton.c b/gtk/deprecated/gtkcolorbutton.c
new file mode 100644 (file)
index 0000000..6cd4010
--- /dev/null
@@ -0,0 +1,748 @@
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+/* Color picker button for GNOME
+ *
+ * Author: Federico Mena <federico@nuclecu.unam.mx>
+ *
+ * Modified by the GTK+ Team and others 2003.  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 "gtkcolorbutton.h"
+
+#include "gtkbinlayout.h"
+#include "gtkbutton.h"
+#include "gtkcolorchooser.h"
+#include "gtkcolorchooserprivate.h"
+#include "gtkcolorchooserdialog.h"
+#include "gtkcolorswatchprivate.h"
+#include "gtkdragsource.h"
+#include "gtkdroptarget.h"
+#include <glib/gi18n-lib.h>
+#include "gtkmain.h"
+#include "gtkmarshalers.h"
+#include "gtkprivate.h"
+#include "gtksnapshot.h"
+#include "gtkwidgetprivate.h"
+
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
+/**
+ * GtkColorButton:
+ *
+ * The `GtkColorButton` allows to open a color chooser dialog to change
+ * the color.
+ *
+ * ![An example GtkColorButton](color-button.png)
+ *
+ * It is suitable widget for selecting a color in a preference dialog.
+ *
+ * # CSS nodes
+ *
+ * ```
+ * colorbutton
+ * ╰── button.color
+ *     ╰── [content]
+ * ```
+ *
+ * `GtkColorButton` has a single CSS node with name colorbutton which
+ * contains a button node. To differentiate it from a plain `GtkButton`,
+ * it gets the .color style class.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
+ */
+
+typedef struct _GtkColorButtonClass     GtkColorButtonClass;
+
+struct _GtkColorButton {
+  GtkWidget parent_instance;
+
+  GtkWidget *button;
+
+  GtkWidget *swatch;    /* Widget where we draw the color sample */
+  GtkWidget *cs_dialog; /* Color selection dialog */
+
+  char *title;         /* Title for the color chooser dialog */
+  GdkRGBA rgba;
+
+  guint use_alpha   : 1;  /* Use alpha or not */
+  guint show_editor : 1;
+  guint modal       : 1;
+};
+
+struct _GtkColorButtonClass {
+  GtkWidgetClass parent_class;
+
+  void (* color_set) (GtkColorButton *cp);
+  void (* activate)  (GtkColorButton *self);
+};
+
+/* Properties */
+enum
+{
+  PROP_0,
+  PROP_USE_ALPHA,
+  PROP_TITLE,
+  PROP_RGBA,
+  PROP_SHOW_EDITOR,
+  PROP_MODAL
+};
+
+/* Signals */
+enum
+{
+  COLOR_SET,
+  ACTIVATE,
+  LAST_SIGNAL
+};
+
+/* gobject signals */
+static void gtk_color_button_finalize      (GObject          *object);
+static void gtk_color_button_set_property  (GObject          *object,
+                                            guint             param_id,
+                                            const GValue     *value,
+                                            GParamSpec       *pspec);
+static void gtk_color_button_get_property  (GObject          *object,
+                                            guint             param_id,
+                                            GValue           *value,
+                                            GParamSpec       *pspec);
+
+static void gtk_color_button_root          (GtkWidget        *widget);
+
+/* gtkbutton signals */
+static void gtk_color_button_clicked       (GtkButton        *button,
+                                            gpointer          user_data);
+
+
+static guint color_button_signals[LAST_SIGNAL] = { 0 };
+
+static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_WIDGET,
+                         G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
+                                                gtk_color_button_iface_init))
+
+static void
+gtk_color_button_activate (GtkColorButton *self)
+{
+  gtk_widget_activate (self->button);
+}
+
+static void
+gtk_color_button_class_init (GtkColorButtonClass *klass)
+{
+  GObjectClass *gobject_class;
+  GtkWidgetClass *widget_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  widget_class = GTK_WIDGET_CLASS (klass);
+
+  gobject_class->get_property = gtk_color_button_get_property;
+  gobject_class->set_property = gtk_color_button_set_property;
+  gobject_class->finalize = gtk_color_button_finalize;
+
+  widget_class->grab_focus = gtk_widget_grab_focus_child;
+  widget_class->focus = gtk_widget_focus_child;
+  widget_class->root = gtk_color_button_root;
+
+  klass->color_set = NULL;
+  klass->activate = gtk_color_button_activate;
+
+  g_object_class_override_property (gobject_class, PROP_RGBA, "rgba");
+  g_object_class_override_property (gobject_class, PROP_USE_ALPHA, "use-alpha");
+
+  /**
+   * GtkColorButton:title: (attributes org.gtk.Property.get=gtk_color_button_get_title org.gtk.Property.set=gtk_color_button_set_title)
+   *
+   * The title of the color chooser dialog
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_TITLE,
+                                   g_param_spec_string ("title", NULL, NULL,
+                                                        _("Pick a Color"),
+                                                        GTK_PARAM_READWRITE));
+
+
+  /**
+   * GtkColorButton::color-set:
+   * @widget: the object which received the signal.
+   *
+   * Emitted when the user selects a color.
+   *
+   * When handling this signal, use [method@Gtk.ColorChooser.get_rgba]
+   * to find out which color was just selected.
+   *
+   * Note that this signal is only emitted when the user changes the color.
+   * If you need to react to programmatic color changes as well, use
+   * the notify::rgba signal.
+   */
+  color_button_signals[COLOR_SET] = g_signal_new (I_("color-set"),
+                                                  G_TYPE_FROM_CLASS (gobject_class),
+                                                  G_SIGNAL_RUN_FIRST,
+                                                  G_STRUCT_OFFSET (GtkColorButtonClass, color_set),
+                                                  NULL, NULL,
+                                                  NULL,
+                                                  G_TYPE_NONE, 0);
+
+  /**
+   * GtkColorButton::activate:
+   * @widget: the object which received the signal.
+   *
+   * Emitted to when the color button is activated.
+   *
+   * The `::activate` signal on `GtkMenuButton` is an action signal and
+   * emitting it causes the button to pop up its dialog.
+   *
+   * Since: 4.4
+   */
+  color_button_signals[ACTIVATE] =
+      g_signal_new (I_ ("activate"),
+                    G_OBJECT_CLASS_TYPE (gobject_class),
+                    G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+                    G_STRUCT_OFFSET (GtkColorButtonClass, activate),
+                    NULL, NULL,
+                    NULL,
+                    G_TYPE_NONE, 0);
+
+  gtk_widget_class_set_activate_signal (widget_class, color_button_signals[ACTIVATE]);
+
+  /**
+   * GtkColorButton:show-editor:
+   *
+   * Whether the color chooser should open in editor mode.
+   *
+   * This property should be used in cases where the palette
+   * in the editor would be redundant, such as when the color
+   * button is already part of a palette.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_SHOW_EDITOR,
+                                   g_param_spec_boolean ("show-editor", NULL, NULL,
+                                                         FALSE,
+                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+  /**
+   * GtkColorButton:modal: (attributes org.gtk.Property.get=gtk_color_button_get_modal org.gtk.Property.set=gtk_color_button_set_modal)
+   *
+   * Whether the color chooser dialog should be modal.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_MODAL,
+                                   g_param_spec_boolean ("modal", NULL, NULL,
+                                                         TRUE,
+                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+
+  gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
+  gtk_widget_class_set_css_name (widget_class, "colorbutton");
+}
+
+static gboolean
+gtk_color_button_drop (GtkDropTarget  *dest,
+                       const GValue   *value,
+                       double          x,
+                       double          y,
+                       GtkColorButton *button)
+{
+  GdkRGBA *color = g_value_get_boxed (value);
+
+  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
+  return TRUE;
+}
+
+static GdkContentProvider *
+gtk_color_button_drag_prepare (GtkDragSource  *source,
+                               double          x,
+                               double          y,
+                               GtkColorButton *button)
+{
+  return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &button->rgba);
+}
+
+static void
+gtk_color_button_init (GtkColorButton *button)
+{
+  PangoLayout *layout;
+  PangoRectangle rect;
+  GtkDragSource *source;
+  GtkDropTarget *dest;
+
+  button->button = gtk_button_new ();
+  g_signal_connect (button->button, "clicked", G_CALLBACK (gtk_color_button_clicked), button);
+  gtk_widget_set_parent (button->button, GTK_WIDGET (button));
+
+  button->swatch = g_object_new (GTK_TYPE_COLOR_SWATCH,
+                                 "accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
+                                 "selectable", FALSE,
+                                 "has-menu", FALSE,
+                                 "can-drag", FALSE,
+                                 NULL);
+  gtk_widget_set_can_focus (button->swatch, FALSE);
+  gtk_widget_remove_css_class (button->swatch, "activatable");
+  layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
+  pango_layout_get_pixel_extents (layout, NULL, &rect);
+  g_object_unref (layout);
+
+  gtk_widget_set_size_request (button->swatch, rect.width, rect.height);
+
+  gtk_button_set_child (GTK_BUTTON (button->button), button->swatch);
+
+  button->title = g_strdup (_("Pick a Color")); /* default title */
+
+  /* Start with opaque black, alpha disabled */
+  button->rgba.red = 0;
+  button->rgba.green = 0;
+  button->rgba.blue = 0;
+  button->rgba.alpha = 1;
+  button->use_alpha = FALSE;
+  button->modal = TRUE;
+
+  dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
+  g_signal_connect (dest, "drop", G_CALLBACK (gtk_color_button_drop), button);
+  gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
+
+  source = gtk_drag_source_new ();
+  g_signal_connect (source, "prepare", G_CALLBACK (gtk_color_button_drag_prepare), button);
+  gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (source), GTK_PHASE_CAPTURE);
+  gtk_widget_add_controller (button->button, GTK_EVENT_CONTROLLER (source));
+
+  gtk_widget_add_css_class (button->button, "color");
+}
+
+static void
+gtk_color_button_finalize (GObject *object)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (object);
+
+  if (button->cs_dialog != NULL)
+    gtk_window_destroy (GTK_WINDOW (button->cs_dialog));
+
+  g_free (button->title);
+  gtk_widget_unparent (button->button);
+
+  G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
+}
+
+
+/**
+ * gtk_color_button_new:
+ *
+ * Creates a new color button.
+ *
+ * This returns a widget in the form of a small button containing
+ * a swatch representing the current selected color. When the button
+ * is clicked, a color chooser dialog will open, allowing the user
+ * to select a color. The swatch will be updated to reflect the new
+ * color when the user finishes.
+ *
+ * Returns: a new color button
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
+ */
+GtkWidget *
+gtk_color_button_new (void)
+{
+  return g_object_new (GTK_TYPE_COLOR_BUTTON, NULL);
+}
+
+/**
+ * gtk_color_button_new_with_rgba:
+ * @rgba: A `GdkRGBA` to set the current color with
+ *
+ * Creates a new color button showing the given color.
+ *
+ * Returns: a new color button
+ */
+GtkWidget *
+gtk_color_button_new_with_rgba (const GdkRGBA *rgba)
+{
+  return g_object_new (GTK_TYPE_COLOR_BUTTON, "rgba", rgba, NULL);
+}
+
+static gboolean
+dialog_destroy (GtkWidget *widget,
+                gpointer   data)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (data);
+
+  button->cs_dialog = NULL;
+
+  return FALSE;
+}
+
+static void
+dialog_response (GtkDialog *dialog,
+                 int        response,
+                 gpointer   data)
+{
+  if (response == GTK_RESPONSE_CANCEL)
+    gtk_widget_hide (GTK_WIDGET (dialog));
+  else if (response == GTK_RESPONSE_OK)
+    {
+      GtkColorButton *button = GTK_COLOR_BUTTON (data);
+
+      gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &button->rgba);
+      gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (button->swatch), &button->rgba);
+
+      gtk_widget_hide (GTK_WIDGET (dialog));
+      g_object_ref (button);
+      g_signal_emit (button, color_button_signals[COLOR_SET], 0);
+
+      g_object_freeze_notify (G_OBJECT (button));
+      g_object_notify (G_OBJECT (button), "rgba");
+      g_object_thaw_notify (G_OBJECT (button));
+      g_object_unref (button);
+    }
+}
+
+/* Create the dialog and connects its buttons */
+static void
+ensure_dialog (GtkColorButton *button)
+{
+  GtkWidget *parent, *dialog;
+
+  if (button->cs_dialog != NULL)
+    return;
+
+  parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
+
+  button->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->title, NULL);
+  gtk_window_set_hide_on_close (GTK_WINDOW (dialog), TRUE);
+  gtk_window_set_modal (GTK_WINDOW (dialog), button->modal);
+
+  if (GTK_IS_WINDOW (parent))
+    {
+      if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
+        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
+
+      if (gtk_window_get_modal (GTK_WINDOW (parent)))
+        gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+    }
+
+  g_signal_connect (dialog, "response",
+                    G_CALLBACK (dialog_response), button);
+  g_signal_connect (dialog, "destroy",
+                    G_CALLBACK (dialog_destroy), button);
+}
+
+static void
+gtk_color_button_root (GtkWidget *widget)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (widget);
+  GtkWidget *parent;
+
+  GTK_WIDGET_CLASS (gtk_color_button_parent_class)->root (widget);
+
+  if (!button->cs_dialog)
+    return;
+
+  parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
+  if (GTK_IS_WINDOW (parent))
+    {
+      if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (button->cs_dialog)))
+        gtk_window_set_transient_for (GTK_WINDOW (button->cs_dialog), GTK_WINDOW (parent));
+
+      if (gtk_window_get_modal (GTK_WINDOW (parent)))
+        gtk_window_set_modal (GTK_WINDOW (button->cs_dialog), TRUE);
+    }
+}
+
+static void
+gtk_color_button_clicked (GtkButton *b,
+                          gpointer   user_data)
+{
+  GtkColorButton *button = user_data;
+
+  /* if dialog already exists, make sure it's shown and raised */
+  ensure_dialog (button);
+
+  g_object_set (button->cs_dialog, "show-editor", button->show_editor, NULL);
+
+  gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->cs_dialog), button->use_alpha);
+
+  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button->cs_dialog), &button->rgba);
+
+  gtk_window_present (GTK_WINDOW (button->cs_dialog));
+}
+
+static guint
+scale_round (double value,
+             double scale)
+{
+  value = floor (value * scale + 0.5);
+  value = CLAMP (value, 0, scale);
+  return (guint)value;
+}
+
+static char *
+accessible_color_name (const GdkRGBA *color)
+{
+  if (color->alpha < 1.0)
+    return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%, Alpha %d%%"),
+                            scale_round (color->red, 100),
+                            scale_round (color->green, 100),
+                            scale_round (color->blue, 100),
+                            scale_round (color->alpha, 100));
+  else
+    return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%"),
+                            scale_round (color->red, 100),
+                            scale_round (color->green, 100),
+                            scale_round (color->blue, 100));
+}
+
+static void
+gtk_color_button_set_rgba (GtkColorChooser *chooser,
+                           const GdkRGBA   *rgba)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
+  char *text;
+
+  g_return_if_fail (GTK_IS_COLOR_BUTTON (chooser));
+  g_return_if_fail (rgba != NULL);
+
+  button->rgba = *rgba;
+  gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (button->swatch), &button->rgba);
+
+  text = accessible_color_name (rgba);
+  gtk_accessible_update_property (GTK_ACCESSIBLE (button->swatch),
+                                  GTK_ACCESSIBLE_PROPERTY_LABEL, text,
+                                  -1);
+  g_free (text);
+
+  g_object_notify (G_OBJECT (chooser), "rgba");
+}
+
+static void
+gtk_color_button_get_rgba (GtkColorChooser *chooser,
+                           GdkRGBA        *rgba)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
+
+  g_return_if_fail (GTK_IS_COLOR_BUTTON (chooser));
+  g_return_if_fail (rgba != NULL);
+
+  *rgba = button->rgba;
+}
+
+static void
+set_use_alpha (GtkColorButton *button,
+               gboolean        use_alpha)
+{
+  use_alpha = (use_alpha != FALSE);
+
+  if (button->use_alpha != use_alpha)
+    {
+      button->use_alpha = use_alpha;
+
+      gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (button->swatch), use_alpha);
+
+      g_object_notify (G_OBJECT (button), "use-alpha");
+    }
+}
+
+/**
+ * gtk_color_button_set_title: (attributes org.gtk.Method.set_property=title)
+ * @button: a `GtkColorButton`
+ * @title: String containing new window title
+ *
+ * Sets the title for the color chooser dialog.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
+ */
+void
+gtk_color_button_set_title (GtkColorButton *button,
+                            const char     *title)
+{
+  char *old_title;
+
+  g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
+
+  old_title = button->title;
+  button->title = g_strdup (title);
+  g_free (old_title);
+
+  if (button->cs_dialog)
+    gtk_window_set_title (GTK_WINDOW (button->cs_dialog), button->title);
+
+  g_object_notify (G_OBJECT (button), "title");
+}
+
+/**
+ * gtk_color_button_get_title: (attributes org.gtk.Method.get_property=title)
+ * @button: a `GtkColorButton`
+ *
+ * Gets the title of the color chooser dialog.
+ *
+ * Returns: An internal string, do not free the return value
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
+ */
+const char *
+gtk_color_button_get_title (GtkColorButton *button)
+{
+  g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
+
+  return button->title;
+}
+
+/**
+ * gtk_color_button_set_modal: (attributes org.gtk.Method.set_property=modal)
+ * @button: a `GtkColorButton`
+ * @modal: %TRUE to make the dialog modal
+ *
+ * Sets whether the dialog should be modal.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
+ */
+void
+gtk_color_button_set_modal (GtkColorButton *button,
+                            gboolean        modal)
+{
+  g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
+
+  if (button->modal == modal)
+    return;
+
+  button->modal = modal;
+
+  if (button->cs_dialog)
+    gtk_window_set_modal (GTK_WINDOW (button->cs_dialog), button->modal);
+
+  g_object_notify (G_OBJECT (button), "modal");
+}
+
+/**
+ * gtk_color_button_get_modal: (attributes org.gtk.Method.get_property=modal)
+ * @button: a `GtkColorButton`
+ *
+ * Gets whether the dialog is modal.
+ *
+ * Returns: %TRUE if the dialog is modal
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
+ */
+gboolean
+gtk_color_button_get_modal (GtkColorButton *button)
+{
+  g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
+
+  return button->modal;
+}
+
+static void
+gtk_color_button_set_property (GObject      *object,
+                               guint         param_id,
+                               const GValue *value,
+                               GParamSpec   *pspec)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (object);
+
+  switch (param_id)
+    {
+    case PROP_USE_ALPHA:
+      set_use_alpha (button, g_value_get_boolean (value));
+      break;
+    case PROP_TITLE:
+      gtk_color_button_set_title (button, g_value_get_string (value));
+      break;
+    case PROP_RGBA:
+      gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), g_value_get_boxed (value));
+      break;
+    case PROP_SHOW_EDITOR:
+      {
+        gboolean show_editor = g_value_get_boolean (value);
+        if (button->show_editor != show_editor)
+          {
+            button->show_editor = show_editor;
+            g_object_notify (object, "show-editor");
+          }
+      }
+      break;
+    case PROP_MODAL:
+      gtk_color_button_set_modal (button, g_value_get_boolean (value));
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+      break;
+    }
+}
+
+static void
+gtk_color_button_get_property (GObject    *object,
+                               guint       param_id,
+                               GValue     *value,
+                               GParamSpec *pspec)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (object);
+
+  switch (param_id)
+    {
+    case PROP_USE_ALPHA:
+      g_value_set_boolean (value, button->use_alpha);
+      break;
+    case PROP_TITLE:
+      g_value_set_string (value, gtk_color_button_get_title (button));
+      break;
+    case PROP_RGBA:
+      {
+        GdkRGBA rgba;
+
+        gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
+        g_value_set_boxed (value, &rgba);
+      }
+      break;
+    case PROP_SHOW_EDITOR:
+      g_value_set_boolean (value, button->show_editor);
+      break;
+    case PROP_MODAL:
+      g_value_set_boolean (value, button->modal);
+      break;
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+      break;
+    }
+}
+
+static void
+gtk_color_button_add_palette (GtkColorChooser *chooser,
+                              GtkOrientation   orientation,
+                              int              colors_per_line,
+                              int              n_colors,
+                              GdkRGBA         *colors)
+{
+  GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
+
+  ensure_dialog (button);
+
+  gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->cs_dialog),
+                                 orientation, colors_per_line, n_colors, colors);
+}
+
+static void
+gtk_color_button_iface_init (GtkColorChooserInterface *iface)
+{
+  iface->get_rgba = gtk_color_button_get_rgba;
+  iface->set_rgba = gtk_color_button_set_rgba;
+  iface->add_palette = gtk_color_button_add_palette;
+}
diff --git a/gtk/deprecated/gtkcolorbutton.h b/gtk/deprecated/gtkcolorbutton.h
new file mode 100644 (file)
index 0000000..ce565d6
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * GTK - The GIMP Toolkit
+ * Copyright (C) 1998, 1999 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/* Color picker button for GNOME
+ *
+ * Author: Federico Mena <federico@nuclecu.unam.mx>
+ *
+ * Modified by the GTK+ Team and others 2003.  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 __GTK_COLOR_BUTTON_H__
+#define __GTK_COLOR_BUTTON_H__
+
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkbutton.h>
+
+G_BEGIN_DECLS
+
+
+#define GTK_TYPE_COLOR_BUTTON             (gtk_color_button_get_type ())
+#define GTK_COLOR_BUTTON(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_BUTTON, GtkColorButton))
+#define GTK_IS_COLOR_BUTTON(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_BUTTON))
+
+typedef struct _GtkColorButton GtkColorButton;
+
+GDK_AVAILABLE_IN_ALL
+GType        gtk_color_button_get_type      (void) G_GNUC_CONST;
+GDK_DEPRECATED_IN_4_10
+GtkWidget *  gtk_color_button_new           (void);
+GDK_DEPRECATED_IN_4_10
+GtkWidget *  gtk_color_button_new_with_rgba (const GdkRGBA  *rgba);
+GDK_DEPRECATED_IN_4_10
+void         gtk_color_button_set_title     (GtkColorButton *button,
+                                             const char     *title);
+GDK_DEPRECATED_IN_4_10
+const char *gtk_color_button_get_title     (GtkColorButton *button);
+
+GDK_DEPRECATED_IN_4_10
+gboolean     gtk_color_button_get_modal        (GtkColorButton *button);
+GDK_DEPRECATED_IN_4_10
+void         gtk_color_button_set_modal        (GtkColorButton *button,
+                                                gboolean        modal);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorButton, g_object_unref)
+
+G_END_DECLS
+
+#endif  /* __GTK_COLOR_BUTTON_H__ */
diff --git a/gtk/deprecated/gtkcolorchooser.c b/gtk/deprecated/gtkcolorchooser.c
new file mode 100644 (file)
index 0000000..c38eb43
--- /dev/null
@@ -0,0 +1,251 @@
+/* GTK - The GIMP Toolkit
+ *
+ * Copyright (C) 2012, Red Hat, Inc.
+ *
+ * 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/>.
+ */
+
+#include "config.h"
+
+#include "gtkcolorchooser.h"
+#include "gtkcolorchooserprivate.h"
+#include "gtktypebuiltins.h"
+#include "gtkprivate.h"
+#include "gtksnapshot.h"
+#include "gdk/gdkrgbaprivate.h"
+
+/**
+ * GtkColorChooser:
+ *
+ * `GtkColorChooser` is an interface that is implemented by widgets
+ * for choosing colors.
+ *
+ * Depending on the situation, colors may be allowed to have alpha (translucency).
+ *
+ * In GTK, the main widgets that implement this interface are
+ * [class@Gtk.ColorChooserWidget], [class@Gtk.ColorChooserDialog] and
+ * [class@Gtk.ColorButton].
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] and [class@Gtk.ColorDialogButton]
+ *   instead of widgets implementing `GtkColorChooser`
+ */
+
+enum
+{
+  COLOR_ACTIVATED,
+  LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
+G_DEFINE_INTERFACE (GtkColorChooser, gtk_color_chooser, G_TYPE_OBJECT);
+
+static void
+gtk_color_chooser_default_init (GtkColorChooserInterface *iface)
+{
+  /**
+   * GtkColorChooser:rgba: (attributes org.gtk.Property.get=gtk_color_chooser_get_rgba org.gtk.Property.set=gtk_color_chooser_set_rgba)
+   *
+   * The currently selected color, as a `GdkRGBA` struct.
+   *
+   * The property can be set to change the current selection
+   * programmatically.
+   */
+  g_object_interface_install_property (iface,
+      g_param_spec_boxed ("rgba", NULL, NULL,
+                          GDK_TYPE_RGBA,
+                          GTK_PARAM_READWRITE));
+
+  /**
+   * GtkColorChooser:use-alpha: (attributes org.gtk.Property.get=gtk_color_chooser_get_use_alpha org.gtk.Property.set=gtk_color_chooser_set_use_alpha)
+   *
+   * Whether colors may have alpha (translucency).
+   *
+   * When ::use-alpha is %FALSE, the `GdkRGBA` struct obtained
+   * via the [property@Gtk.ColorChooser:rgba] property will be
+   * forced to have alpha == 1.
+   *
+   * Implementations are expected to show alpha by rendering the color
+   * over a non-uniform background (like a checkerboard pattern).
+   */
+  g_object_interface_install_property (iface,
+      g_param_spec_boolean ("use-alpha", NULL, NULL,
+                            TRUE,
+                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
+
+  /**
+   * GtkColorChooser::color-activated:
+   * @chooser: the object which received the signal
+   * @color: the color
+   *
+   * Emitted when a color is activated from the color chooser.
+   *
+   * This usually happens when the user clicks a color swatch,
+   * or a color is selected and the user presses one of the keys
+   * Space, Shift+Space, Return or Enter.
+   */
+  signals[COLOR_ACTIVATED] =
+    g_signal_new (I_("color-activated"),
+                  GTK_TYPE_COLOR_CHOOSER,
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GtkColorChooserInterface, color_activated),
+                  NULL, NULL,
+                  NULL,
+                  G_TYPE_NONE,
+                  1, GDK_TYPE_RGBA);
+}
+
+void
+_gtk_color_chooser_color_activated (GtkColorChooser *chooser,
+                                    const GdkRGBA   *color)
+{
+  g_signal_emit (chooser, signals[COLOR_ACTIVATED], 0, color);
+}
+
+/**
+ * gtk_color_chooser_get_rgba: (attributes org.gtk.Method.get_property=rgba)
+ * @chooser: a `GtkColorChooser`
+ * @color: (out): a `GdkRGBA` to fill in with the current color
+ *
+ * Gets the currently-selected color.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
+ */
+void
+gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
+                            GdkRGBA         *color)
+{
+  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
+
+  GTK_COLOR_CHOOSER_GET_IFACE (chooser)->get_rgba (chooser, color);
+}
+
+/**
+ * gtk_color_chooser_set_rgba: (attributes org.gtk.Method.set_property=rgba)
+ * @chooser: a `GtkColorChooser`
+ * @color: the new color
+ *
+ * Sets the color.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
+ */
+void
+gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
+                            const GdkRGBA   *color)
+{
+  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
+  g_return_if_fail (color != NULL);
+
+  GTK_COLOR_CHOOSER_GET_IFACE (chooser)->set_rgba (chooser, color);
+}
+
+/**
+ * gtk_color_chooser_get_use_alpha: (attributes org.gtk.Method.get_property=use-alpha)
+ * @chooser: a `GtkColorChooser`
+ *
+ * Returns whether the color chooser shows the alpha channel.
+ *
+ * Returns: %TRUE if the color chooser uses the alpha channel,
+ *   %FALSE if not
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
+ */
+gboolean
+gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser)
+{
+  gboolean use_alpha;
+
+  g_return_val_if_fail (GTK_IS_COLOR_CHOOSER (chooser), TRUE);
+
+  g_object_get (chooser, "use-alpha", &use_alpha, NULL);
+
+  return use_alpha;
+}
+
+/**
+ * gtk_color_chooser_set_use_alpha: (attributes org.gtk.Method.set_property=use-alpha)
+ * @chooser: a `GtkColorChooser`
+ * @use_alpha: %TRUE if color chooser should use alpha channel, %FALSE if not
+ *
+ * Sets whether or not the color chooser should use the alpha channel.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
+ */
+void
+gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
+                                 gboolean         use_alpha)
+{
+
+  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
+
+  g_object_set (chooser, "use-alpha", use_alpha, NULL);
+}
+
+/**
+ * gtk_color_chooser_add_palette:
+ * @chooser: a `GtkColorChooser`
+ * @orientation: %GTK_ORIENTATION_HORIZONTAL if the palette should
+ *   be displayed in rows, %GTK_ORIENTATION_VERTICAL for columns
+ * @colors_per_line: the number of colors to show in each row/column
+ * @n_colors: the total number of elements in @colors
+ * @colors: (nullable) (array length=n_colors): the colors of the palette
+ *
+ * Adds a palette to the color chooser.
+ *
+ * If @orientation is horizontal, the colors are grouped in rows,
+ * with @colors_per_line colors in each row. If @horizontal is %FALSE,
+ * the colors are grouped in columns instead.
+ *
+ * The default color palette of [class@Gtk.ColorChooserWidget] has
+ * 45 colors, organized in columns of 5 colors (this includes some
+ * grays).
+ *
+ * The layout of the color chooser widget works best when the
+ * palettes have 9-10 columns.
+ *
+ * Calling this function for the first time has the side effect
+ * of removing the default color palette from the color chooser.
+ *
+ * If @colors is %NULL, removes all previously added palettes.
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
+ */
+void
+gtk_color_chooser_add_palette (GtkColorChooser *chooser,
+                               GtkOrientation   orientation,
+                               int              colors_per_line,
+                               int              n_colors,
+                               GdkRGBA         *colors)
+{
+  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
+
+  if (GTK_COLOR_CHOOSER_GET_IFACE (chooser)->add_palette)
+    GTK_COLOR_CHOOSER_GET_IFACE (chooser)->add_palette (chooser, orientation, colors_per_line, n_colors, colors);
+}
+
+void
+_gtk_color_chooser_snapshot_checkered_pattern (GtkSnapshot *snapshot,
+                                               int          width,
+                                               int          height)
+{
+  const GdkRGBA color1 = GDK_RGBA("A8A8A8");
+  const GdkRGBA color2 = GDK_RGBA("545454");
+
+  gtk_snapshot_push_repeat (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height), NULL);
+  gtk_snapshot_append_color (snapshot, &color1, &GRAPHENE_RECT_INIT (0,  0,  10, 10));
+  gtk_snapshot_append_color (snapshot, &color2, &GRAPHENE_RECT_INIT (10, 0,  10, 10));
+  gtk_snapshot_append_color (snapshot, &color2, &GRAPHENE_RECT_INIT (0,  10, 10, 10));
+  gtk_snapshot_append_color (snapshot, &color1, &GRAPHENE_RECT_INIT (10, 10, 10, 10));
+  gtk_snapshot_pop (snapshot);
+}
diff --git a/gtk/deprecated/gtkcolorchooser.h b/gtk/deprecated/gtkcolorchooser.h
new file mode 100644 (file)
index 0000000..1c573a2
--- /dev/null
@@ -0,0 +1,90 @@
+/* GTK - The GIMP Toolkit
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * 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/>.
+ */
+
+#ifndef __GTK_COLOR_CHOOSER_H__
+#define __GTK_COLOR_CHOOSER_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_COLOR_CHOOSER                  (gtk_color_chooser_get_type ())
+#define GTK_COLOR_CHOOSER(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER, GtkColorChooser))
+#define GTK_IS_COLOR_CHOOSER(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER))
+#define GTK_COLOR_CHOOSER_GET_IFACE(inst)       (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_COLOR_CHOOSER, GtkColorChooserInterface))
+
+typedef struct _GtkColorChooser          GtkColorChooser;
+typedef struct _GtkColorChooserInterface GtkColorChooserInterface;
+
+struct _GtkColorChooserInterface
+{
+  GTypeInterface base_interface;
+
+  /* Methods */
+  void (* get_rgba)    (GtkColorChooser *chooser,
+                        GdkRGBA         *color);
+  void (* set_rgba)    (GtkColorChooser *chooser,
+                        const GdkRGBA   *color);
+
+  void (* add_palette) (GtkColorChooser *chooser,
+                        GtkOrientation   orientation,
+                        int              colors_per_line,
+                        int              n_colors,
+                        GdkRGBA         *colors);
+
+  /* Signals */
+  void (* color_activated) (GtkColorChooser *chooser,
+                            const GdkRGBA   *color);
+
+  /*< private >*/
+  /* Padding; remove in GTK-next */
+  gpointer padding[12];
+};
+
+GDK_AVAILABLE_IN_ALL
+GType    gtk_color_chooser_get_type        (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_4_10
+void     gtk_color_chooser_get_rgba       (GtkColorChooser *chooser,
+                                           GdkRGBA         *color);
+GDK_DEPRECATED_IN_4_10
+void     gtk_color_chooser_set_rgba       (GtkColorChooser *chooser,
+                                           const GdkRGBA   *color);
+GDK_DEPRECATED_IN_4_10
+gboolean gtk_color_chooser_get_use_alpha  (GtkColorChooser *chooser);
+
+GDK_DEPRECATED_IN_4_10
+void     gtk_color_chooser_set_use_alpha  (GtkColorChooser *chooser,
+                                           gboolean         use_alpha);
+
+GDK_DEPRECATED_IN_4_10
+void     gtk_color_chooser_add_palette    (GtkColorChooser *chooser,
+                                           GtkOrientation   orientation,
+                                           int              colors_per_line,
+                                           int              n_colors,
+                                           GdkRGBA         *colors);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooser, g_object_unref)
+
+G_END_DECLS
+
+#endif /* __GTK_COLOR_CHOOSER_H__ */
diff --git a/gtk/deprecated/gtkcolorchooserdialog.h b/gtk/deprecated/gtkcolorchooserdialog.h
new file mode 100644 (file)
index 0000000..a5d0f4e
--- /dev/null
@@ -0,0 +1,46 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * 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/>.
+ */
+
+#ifndef __GTK_COLOR_CHOOSER_DIALOG_H__
+#define __GTK_COLOR_CHOOSER_DIALOG_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkdialog.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_COLOR_CHOOSER_DIALOG              (gtk_color_chooser_dialog_get_type ())
+#define GTK_COLOR_CHOOSER_DIALOG(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG, GtkColorChooserDialog))
+#define GTK_IS_COLOR_CHOOSER_DIALOG(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG))
+
+typedef struct _GtkColorChooserDialog        GtkColorChooserDialog;
+
+GDK_AVAILABLE_IN_ALL
+GType       gtk_color_chooser_dialog_get_type (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_4_10
+GtkWidget * gtk_color_chooser_dialog_new      (const char *title,
+                                               GtkWindow   *parent);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserDialog, g_object_unref)
+
+G_END_DECLS
+
+#endif /* __GTK_COLOR_CHOOSER_DIALOG_H__ */
diff --git a/gtk/deprecated/gtkcolorchooserprivate.h b/gtk/deprecated/gtkcolorchooserprivate.h
new file mode 100644 (file)
index 0000000..c4c1c93
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_COLOR_CHOOSER_PRIVATE_H__
+#define __GTK_COLOR_CHOOSER_PRIVATE_H__
+
+#include "gtkcolorchooser.h"
+
+G_BEGIN_DECLS
+
+void _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
+                                         const GdkRGBA   *color);
+
+void _gtk_color_chooser_snapshot_checkered_pattern (GtkSnapshot *snapshot,
+                                                    int          width,
+                                                    int          height);
+
+
+G_END_DECLS
+
+#endif /* ! __GTK_COLOR_CHOOSER_PRIVATE_H__ */
diff --git a/gtk/deprecated/gtkcolorchooserwidget.h b/gtk/deprecated/gtkcolorchooserwidget.h
new file mode 100644 (file)
index 0000000..51dfb27
--- /dev/null
@@ -0,0 +1,45 @@
+/* GTK - The GIMP Toolkit
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * 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/>.
+ */
+
+#ifndef __GTK_COLOR_CHOOSER_WIDGET_H__
+#define __GTK_COLOR_CHOOSER_WIDGET_H__
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#error "Only <gtk/gtk.h> can be included directly."
+#endif
+
+#include <gtk/gtkwidget.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_COLOR_CHOOSER_WIDGET              (gtk_color_chooser_widget_get_type ())
+#define GTK_COLOR_CHOOSER_WIDGET(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER_WIDGET, GtkColorChooserWidget))
+#define GTK_IS_COLOR_CHOOSER_WIDGET(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER_WIDGET))
+
+typedef struct _GtkColorChooserWidget        GtkColorChooserWidget;
+
+GDK_AVAILABLE_IN_ALL
+GType       gtk_color_chooser_widget_get_type (void) G_GNUC_CONST;
+
+GDK_DEPRECATED_IN_4_10
+GtkWidget * gtk_color_chooser_widget_new      (void);
+
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWidget, g_object_unref)
+
+G_END_DECLS
+
+#endif /* __GTK_COLOR_CHOOSER_WIDGET_H__ */
index cd5b1821706c343b2f43408549c3325bb92d1835..ae5012bb5ba8fc4f99e72ddaa477539c62076490 100644 (file)
@@ -19,6 +19,8 @@ gtk_deprecated_sources = [
   'deprecated/gtkcellrenderertext.c',
   'deprecated/gtkcellrenderertoggle.c',
   'deprecated/gtkcellview.c',
+  'deprecated/gtkcolorbutton.c',
+  'deprecated/gtkcolorchooser.c',
   'deprecated/gtkcombobox.c',
   'deprecated/gtkcomboboxtext.c',
   'deprecated/gtkentrycompletion.c',
@@ -60,6 +62,10 @@ gtk_deprecated_headers = [
   'deprecated/gtkcellrenderertext.h',
   'deprecated/gtkcellrenderertoggle.h',
   'deprecated/gtkcellview.h',
+  'deprecated/gtkcolorbutton.h',
+  'deprecated/gtkcolorchooser.h',
+  'deprecated/gtkcolorchooserdialog.h',
+  'deprecated/gtkcolorchooserwidget.h',
   'deprecated/gtkcombobox.h',
   'deprecated/gtkcomboboxtext.h',
   'deprecated/gtkentrycompletion.h',
index edc98bf0867bceefb43ab1a6232ae8e8b5be65b0..a33ad62bc977ca2a185c3d300585c049f67ea2c4 100644 (file)
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
 #include <gtk/gtkcenterbox.h>
 #include <gtk/gtkcenterlayout.h>
 #include <gtk/gtkcheckbutton.h>
-#include <gtk/gtkcolorbutton.h>
-#include <gtk/gtkcolorchooser.h>
-#include <gtk/gtkcolorchooserdialog.h>
-#include <gtk/gtkcolorchooserwidget.h>
+#include <gtk/deprecated/gtkcolorbutton.h>
+#include <gtk/deprecated/gtkcolorchooser.h>
+#include <gtk/deprecated/gtkcolorchooserdialog.h>
+#include <gtk/deprecated/gtkcolorchooserwidget.h>
 #include <gtk/gtkcolordialog.h>
 #include <gtk/gtkcolordialogbutton.h>
 #include <gtk/gtkcolorutils.h>
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
deleted file mode 100644 (file)
index 8d1e4ce..0000000
+++ /dev/null
@@ -1,734 +0,0 @@
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-/* Color picker button for GNOME
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- *
- * Modified by the GTK+ Team and others 2003.  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 "gtkcolorbutton.h"
-
-#include "gtkbinlayout.h"
-#include "gtkbutton.h"
-#include "gtkcolorchooser.h"
-#include "gtkcolorchooserprivate.h"
-#include "gtkcolorchooserdialog.h"
-#include "gtkcolorswatchprivate.h"
-#include "gtkdragsource.h"
-#include "gtkdroptarget.h"
-#include <glib/gi18n-lib.h>
-#include "gtkmain.h"
-#include "gtkmarshalers.h"
-#include "gtkprivate.h"
-#include "gtksnapshot.h"
-#include "gtkwidgetprivate.h"
-
-
-/**
- * GtkColorButton:
- *
- * The `GtkColorButton` allows to open a color chooser dialog to change
- * the color.
- *
- * ![An example GtkColorButton](color-button.png)
- *
- * It is suitable widget for selecting a color in a preference dialog.
- *
- * # CSS nodes
- *
- * ```
- * colorbutton
- * ╰── button.color
- *     ╰── [content]
- * ```
- *
- * `GtkColorButton` has a single CSS node with name colorbutton which
- * contains a button node. To differentiate it from a plain `GtkButton`,
- * it gets the .color style class.
- */
-
-typedef struct _GtkColorButtonClass     GtkColorButtonClass;
-
-struct _GtkColorButton {
-  GtkWidget parent_instance;
-
-  GtkWidget *button;
-
-  GtkWidget *swatch;    /* Widget where we draw the color sample */
-  GtkWidget *cs_dialog; /* Color selection dialog */
-
-  char *title;         /* Title for the color chooser dialog */
-  GdkRGBA rgba;
-
-  guint use_alpha   : 1;  /* Use alpha or not */
-  guint show_editor : 1;
-  guint modal       : 1;
-};
-
-struct _GtkColorButtonClass {
-  GtkWidgetClass parent_class;
-
-  void (* color_set) (GtkColorButton *cp);
-  void (* activate)  (GtkColorButton *self);
-};
-
-/* Properties */
-enum
-{
-  PROP_0,
-  PROP_USE_ALPHA,
-  PROP_TITLE,
-  PROP_RGBA,
-  PROP_SHOW_EDITOR,
-  PROP_MODAL
-};
-
-/* Signals */
-enum
-{
-  COLOR_SET,
-  ACTIVATE,
-  LAST_SIGNAL
-};
-
-/* gobject signals */
-static void gtk_color_button_finalize      (GObject          *object);
-static void gtk_color_button_set_property  (GObject          *object,
-                                            guint             param_id,
-                                            const GValue     *value,
-                                            GParamSpec       *pspec);
-static void gtk_color_button_get_property  (GObject          *object,
-                                            guint             param_id,
-                                            GValue           *value,
-                                            GParamSpec       *pspec);
-
-static void gtk_color_button_root          (GtkWidget        *widget);
-
-/* gtkbutton signals */
-static void gtk_color_button_clicked       (GtkButton        *button,
-                                            gpointer          user_data);
-
-
-static guint color_button_signals[LAST_SIGNAL] = { 0 };
-
-static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
-
-G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_WIDGET,
-                         G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
-                                                gtk_color_button_iface_init))
-
-static void
-gtk_color_button_activate (GtkColorButton *self)
-{
-  gtk_widget_activate (self->button);
-}
-
-static void
-gtk_color_button_class_init (GtkColorButtonClass *klass)
-{
-  GObjectClass *gobject_class;
-  GtkWidgetClass *widget_class;
-
-  gobject_class = G_OBJECT_CLASS (klass);
-  widget_class = GTK_WIDGET_CLASS (klass);
-
-  gobject_class->get_property = gtk_color_button_get_property;
-  gobject_class->set_property = gtk_color_button_set_property;
-  gobject_class->finalize = gtk_color_button_finalize;
-
-  widget_class->grab_focus = gtk_widget_grab_focus_child;
-  widget_class->focus = gtk_widget_focus_child;
-  widget_class->root = gtk_color_button_root;
-
-  klass->color_set = NULL;
-  klass->activate = gtk_color_button_activate;
-
-  g_object_class_override_property (gobject_class, PROP_RGBA, "rgba");
-  g_object_class_override_property (gobject_class, PROP_USE_ALPHA, "use-alpha");
-
-  /**
-   * GtkColorButton:title: (attributes org.gtk.Property.get=gtk_color_button_get_title org.gtk.Property.set=gtk_color_button_set_title)
-   *
-   * The title of the color chooser dialog
-   */
-  g_object_class_install_property (gobject_class,
-                                   PROP_TITLE,
-                                   g_param_spec_string ("title", NULL, NULL,
-                                                        _("Pick a Color"),
-                                                        GTK_PARAM_READWRITE));
-
-
-  /**
-   * GtkColorButton::color-set:
-   * @widget: the object which received the signal.
-   *
-   * Emitted when the user selects a color.
-   *
-   * When handling this signal, use [method@Gtk.ColorChooser.get_rgba]
-   * to find out which color was just selected.
-   *
-   * Note that this signal is only emitted when the user changes the color.
-   * If you need to react to programmatic color changes as well, use
-   * the notify::rgba signal.
-   */
-  color_button_signals[COLOR_SET] = g_signal_new (I_("color-set"),
-                                                  G_TYPE_FROM_CLASS (gobject_class),
-                                                  G_SIGNAL_RUN_FIRST,
-                                                  G_STRUCT_OFFSET (GtkColorButtonClass, color_set),
-                                                  NULL, NULL,
-                                                  NULL,
-                                                  G_TYPE_NONE, 0);
-
-  /**
-   * GtkColorButton::activate:
-   * @widget: the object which received the signal.
-   *
-   * Emitted to when the color button is activated.
-   *
-   * The `::activate` signal on `GtkMenuButton` is an action signal and
-   * emitting it causes the button to pop up its dialog.
-   *
-   * Since: 4.4
-   */
-  color_button_signals[ACTIVATE] =
-      g_signal_new (I_ ("activate"),
-                    G_OBJECT_CLASS_TYPE (gobject_class),
-                    G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
-                    G_STRUCT_OFFSET (GtkColorButtonClass, activate),
-                    NULL, NULL,
-                    NULL,
-                    G_TYPE_NONE, 0);
-
-  gtk_widget_class_set_activate_signal (widget_class, color_button_signals[ACTIVATE]);
-
-  /**
-   * GtkColorButton:show-editor:
-   *
-   * Whether the color chooser should open in editor mode.
-   *
-   * This property should be used in cases where the palette
-   * in the editor would be redundant, such as when the color
-   * button is already part of a palette.
-   */
-  g_object_class_install_property (gobject_class,
-                                   PROP_SHOW_EDITOR,
-                                   g_param_spec_boolean ("show-editor", NULL, NULL,
-                                                         FALSE,
-                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-  /**
-   * GtkColorButton:modal: (attributes org.gtk.Property.get=gtk_color_button_get_modal org.gtk.Property.set=gtk_color_button_set_modal)
-   *
-   * Whether the color chooser dialog should be modal.
-   */
-  g_object_class_install_property (gobject_class,
-                                   PROP_MODAL,
-                                   g_param_spec_boolean ("modal", NULL, NULL,
-                                                         TRUE,
-                                                         GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-
-  gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
-  gtk_widget_class_set_css_name (widget_class, "colorbutton");
-}
-
-static gboolean
-gtk_color_button_drop (GtkDropTarget  *dest,
-                       const GValue   *value,
-                       double          x,
-                       double          y,
-                       GtkColorButton *button)
-{
-  GdkRGBA *color = g_value_get_boxed (value);
-
-  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), color);
-  return TRUE;
-}
-
-static GdkContentProvider *
-gtk_color_button_drag_prepare (GtkDragSource  *source,
-                               double          x,
-                               double          y,
-                               GtkColorButton *button)
-{
-  return gdk_content_provider_new_typed (GDK_TYPE_RGBA, &button->rgba);
-}
-
-static void
-gtk_color_button_init (GtkColorButton *button)
-{
-  PangoLayout *layout;
-  PangoRectangle rect;
-  GtkDragSource *source;
-  GtkDropTarget *dest;
-
-  button->button = gtk_button_new ();
-  g_signal_connect (button->button, "clicked", G_CALLBACK (gtk_color_button_clicked), button);
-  gtk_widget_set_parent (button->button, GTK_WIDGET (button));
-
-  button->swatch = g_object_new (GTK_TYPE_COLOR_SWATCH,
-                                 "accessible-role", GTK_ACCESSIBLE_ROLE_IMG,
-                                 "selectable", FALSE,
-                                 "has-menu", FALSE,
-                                 "can-drag", FALSE,
-                                 NULL);
-  gtk_widget_set_can_focus (button->swatch, FALSE);
-  gtk_widget_remove_css_class (button->swatch, "activatable");
-  layout = gtk_widget_create_pango_layout (GTK_WIDGET (button), "Black");
-  pango_layout_get_pixel_extents (layout, NULL, &rect);
-  g_object_unref (layout);
-
-  gtk_widget_set_size_request (button->swatch, rect.width, rect.height);
-
-  gtk_button_set_child (GTK_BUTTON (button->button), button->swatch);
-
-  button->title = g_strdup (_("Pick a Color")); /* default title */
-
-  /* Start with opaque black, alpha disabled */
-  button->rgba.red = 0;
-  button->rgba.green = 0;
-  button->rgba.blue = 0;
-  button->rgba.alpha = 1;
-  button->use_alpha = FALSE;
-  button->modal = TRUE;
-
-  dest = gtk_drop_target_new (GDK_TYPE_RGBA, GDK_ACTION_COPY);
-  g_signal_connect (dest, "drop", G_CALLBACK (gtk_color_button_drop), button);
-  gtk_widget_add_controller (GTK_WIDGET (button), GTK_EVENT_CONTROLLER (dest));
-
-  source = gtk_drag_source_new ();
-  g_signal_connect (source, "prepare", G_CALLBACK (gtk_color_button_drag_prepare), button);
-  gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (source), GTK_PHASE_CAPTURE);
-  gtk_widget_add_controller (button->button, GTK_EVENT_CONTROLLER (source));
-
-  gtk_widget_add_css_class (button->button, "color");
-}
-
-static void
-gtk_color_button_finalize (GObject *object)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (object);
-
-  if (button->cs_dialog != NULL)
-    gtk_window_destroy (GTK_WINDOW (button->cs_dialog));
-
-  g_free (button->title);
-  gtk_widget_unparent (button->button);
-
-  G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
-}
-
-
-/**
- * gtk_color_button_new:
- *
- * Creates a new color button.
- *
- * This returns a widget in the form of a small button containing
- * a swatch representing the current selected color. When the button
- * is clicked, a color chooser dialog will open, allowing the user
- * to select a color. The swatch will be updated to reflect the new
- * color when the user finishes.
- *
- * Returns: a new color button
- */
-GtkWidget *
-gtk_color_button_new (void)
-{
-  return g_object_new (GTK_TYPE_COLOR_BUTTON, NULL);
-}
-
-/**
- * gtk_color_button_new_with_rgba:
- * @rgba: A `GdkRGBA` to set the current color with
- *
- * Creates a new color button showing the given color.
- *
- * Returns: a new color button
- */
-GtkWidget *
-gtk_color_button_new_with_rgba (const GdkRGBA *rgba)
-{
-  return g_object_new (GTK_TYPE_COLOR_BUTTON, "rgba", rgba, NULL);
-}
-
-static gboolean
-dialog_destroy (GtkWidget *widget,
-                gpointer   data)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (data);
-
-  button->cs_dialog = NULL;
-
-  return FALSE;
-}
-
-static void
-dialog_response (GtkDialog *dialog,
-                 int        response,
-                 gpointer   data)
-{
-  if (response == GTK_RESPONSE_CANCEL)
-    gtk_widget_hide (GTK_WIDGET (dialog));
-  else if (response == GTK_RESPONSE_OK)
-    {
-      GtkColorButton *button = GTK_COLOR_BUTTON (data);
-
-      gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &button->rgba);
-      gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (button->swatch), &button->rgba);
-
-      gtk_widget_hide (GTK_WIDGET (dialog));
-      g_object_ref (button);
-      g_signal_emit (button, color_button_signals[COLOR_SET], 0);
-
-      g_object_freeze_notify (G_OBJECT (button));
-      g_object_notify (G_OBJECT (button), "rgba");
-      g_object_thaw_notify (G_OBJECT (button));
-      g_object_unref (button);
-    }
-}
-
-/* Create the dialog and connects its buttons */
-static void
-ensure_dialog (GtkColorButton *button)
-{
-  GtkWidget *parent, *dialog;
-
-  if (button->cs_dialog != NULL)
-    return;
-
-  parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
-
-  button->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->title, NULL);
-  gtk_window_set_hide_on_close (GTK_WINDOW (dialog), TRUE);
-  gtk_window_set_modal (GTK_WINDOW (dialog), button->modal);
-
-  if (GTK_IS_WINDOW (parent))
-    {
-      if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
-        gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
-
-      if (gtk_window_get_modal (GTK_WINDOW (parent)))
-        gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
-    }
-
-  g_signal_connect (dialog, "response",
-                    G_CALLBACK (dialog_response), button);
-  g_signal_connect (dialog, "destroy",
-                    G_CALLBACK (dialog_destroy), button);
-}
-
-static void
-gtk_color_button_root (GtkWidget *widget)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (widget);
-  GtkWidget *parent;
-
-  GTK_WIDGET_CLASS (gtk_color_button_parent_class)->root (widget);
-
-  if (!button->cs_dialog)
-    return;
-
-  parent = GTK_WIDGET (gtk_widget_get_root (GTK_WIDGET (button)));
-  if (GTK_IS_WINDOW (parent))
-    {
-      if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (button->cs_dialog)))
-        gtk_window_set_transient_for (GTK_WINDOW (button->cs_dialog), GTK_WINDOW (parent));
-
-      if (gtk_window_get_modal (GTK_WINDOW (parent)))
-        gtk_window_set_modal (GTK_WINDOW (button->cs_dialog), TRUE);
-    }
-}
-
-static void
-gtk_color_button_clicked (GtkButton *b,
-                          gpointer   user_data)
-{
-  GtkColorButton *button = user_data;
-
-  /* if dialog already exists, make sure it's shown and raised */
-  ensure_dialog (button);
-
-  g_object_set (button->cs_dialog, "show-editor", button->show_editor, NULL);
-
-  gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->cs_dialog), button->use_alpha);
-
-  gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button->cs_dialog), &button->rgba);
-
-  gtk_window_present (GTK_WINDOW (button->cs_dialog));
-}
-
-static guint
-scale_round (double value,
-             double scale)
-{
-  value = floor (value * scale + 0.5);
-  value = CLAMP (value, 0, scale);
-  return (guint)value;
-}
-
-static char *
-accessible_color_name (const GdkRGBA *color)
-{
-  if (color->alpha < 1.0)
-    return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%, Alpha %d%%"),
-                            scale_round (color->red, 100),
-                            scale_round (color->green, 100),
-                            scale_round (color->blue, 100),
-                            scale_round (color->alpha, 100));
-  else
-    return g_strdup_printf (_("Red %d%%, Green %d%%, Blue %d%%"),
-                            scale_round (color->red, 100),
-                            scale_round (color->green, 100),
-                            scale_round (color->blue, 100));
-}
-
-static void
-gtk_color_button_set_rgba (GtkColorChooser *chooser,
-                           const GdkRGBA   *rgba)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
-  char *text;
-
-  g_return_if_fail (GTK_IS_COLOR_BUTTON (chooser));
-  g_return_if_fail (rgba != NULL);
-
-  button->rgba = *rgba;
-  gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (button->swatch), &button->rgba);
-
-  text = accessible_color_name (rgba);
-  gtk_accessible_update_property (GTK_ACCESSIBLE (button->swatch),
-                                  GTK_ACCESSIBLE_PROPERTY_LABEL, text,
-                                  -1);
-  g_free (text);
-
-  g_object_notify (G_OBJECT (chooser), "rgba");
-}
-
-static void
-gtk_color_button_get_rgba (GtkColorChooser *chooser,
-                           GdkRGBA        *rgba)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
-
-  g_return_if_fail (GTK_IS_COLOR_BUTTON (chooser));
-  g_return_if_fail (rgba != NULL);
-
-  *rgba = button->rgba;
-}
-
-static void
-set_use_alpha (GtkColorButton *button,
-               gboolean        use_alpha)
-{
-  use_alpha = (use_alpha != FALSE);
-
-  if (button->use_alpha != use_alpha)
-    {
-      button->use_alpha = use_alpha;
-
-      gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (button->swatch), use_alpha);
-
-      g_object_notify (G_OBJECT (button), "use-alpha");
-    }
-}
-
-/**
- * gtk_color_button_set_title: (attributes org.gtk.Method.set_property=title)
- * @button: a `GtkColorButton`
- * @title: String containing new window title
- *
- * Sets the title for the color chooser dialog.
- */
-void
-gtk_color_button_set_title (GtkColorButton *button,
-                            const char     *title)
-{
-  char *old_title;
-
-  g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
-
-  old_title = button->title;
-  button->title = g_strdup (title);
-  g_free (old_title);
-
-  if (button->cs_dialog)
-    gtk_window_set_title (GTK_WINDOW (button->cs_dialog), button->title);
-
-  g_object_notify (G_OBJECT (button), "title");
-}
-
-/**
- * gtk_color_button_get_title: (attributes org.gtk.Method.get_property=title)
- * @button: a `GtkColorButton`
- *
- * Gets the title of the color chooser dialog.
- *
- * Returns: An internal string, do not free the return value
- */
-const char *
-gtk_color_button_get_title (GtkColorButton *button)
-{
-  g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
-
-  return button->title;
-}
-
-/**
- * gtk_color_button_set_modal: (attributes org.gtk.Method.set_property=modal)
- * @button: a `GtkColorButton`
- * @modal: %TRUE to make the dialog modal
- *
- * Sets whether the dialog should be modal.
- */
-void
-gtk_color_button_set_modal (GtkColorButton *button,
-                            gboolean        modal)
-{
-  g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
-
-  if (button->modal == modal)
-    return;
-
-  button->modal = modal;
-
-  if (button->cs_dialog)
-    gtk_window_set_modal (GTK_WINDOW (button->cs_dialog), button->modal);
-
-  g_object_notify (G_OBJECT (button), "modal");
-}
-
-/**
- * gtk_color_button_get_modal: (attributes org.gtk.Method.get_property=modal)
- * @button: a `GtkColorButton`
- *
- * Gets whether the dialog is modal.
- *
- * Returns: %TRUE if the dialog is modal
- */
-gboolean
-gtk_color_button_get_modal (GtkColorButton *button)
-{
-  g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
-
-  return button->modal;
-}
-
-static void
-gtk_color_button_set_property (GObject      *object,
-                               guint         param_id,
-                               const GValue *value,
-                               GParamSpec   *pspec)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (object);
-
-  switch (param_id)
-    {
-    case PROP_USE_ALPHA:
-      set_use_alpha (button, g_value_get_boolean (value));
-      break;
-    case PROP_TITLE:
-      gtk_color_button_set_title (button, g_value_get_string (value));
-      break;
-    case PROP_RGBA:
-      gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), g_value_get_boxed (value));
-      break;
-    case PROP_SHOW_EDITOR:
-      {
-        gboolean show_editor = g_value_get_boolean (value);
-        if (button->show_editor != show_editor)
-          {
-            button->show_editor = show_editor;
-            g_object_notify (object, "show-editor");
-          }
-      }
-      break;
-    case PROP_MODAL:
-      gtk_color_button_set_modal (button, g_value_get_boolean (value));
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-      break;
-    }
-}
-
-static void
-gtk_color_button_get_property (GObject    *object,
-                               guint       param_id,
-                               GValue     *value,
-                               GParamSpec *pspec)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (object);
-
-  switch (param_id)
-    {
-    case PROP_USE_ALPHA:
-      g_value_set_boolean (value, button->use_alpha);
-      break;
-    case PROP_TITLE:
-      g_value_set_string (value, gtk_color_button_get_title (button));
-      break;
-    case PROP_RGBA:
-      {
-        GdkRGBA rgba;
-
-        gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
-        g_value_set_boxed (value, &rgba);
-      }
-      break;
-    case PROP_SHOW_EDITOR:
-      g_value_set_boolean (value, button->show_editor);
-      break;
-    case PROP_MODAL:
-      g_value_set_boolean (value, button->modal);
-      break;
-    default:
-      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
-      break;
-    }
-}
-
-static void
-gtk_color_button_add_palette (GtkColorChooser *chooser,
-                              GtkOrientation   orientation,
-                              int              colors_per_line,
-                              int              n_colors,
-                              GdkRGBA         *colors)
-{
-  GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
-
-  ensure_dialog (button);
-
-  gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->cs_dialog),
-                                 orientation, colors_per_line, n_colors, colors);
-}
-
-static void
-gtk_color_button_iface_init (GtkColorChooserInterface *iface)
-{
-  iface->get_rgba = gtk_color_button_get_rgba;
-  iface->set_rgba = gtk_color_button_set_rgba;
-  iface->add_palette = gtk_color_button_add_palette;
-}
diff --git a/gtk/gtkcolorbutton.h b/gtk/gtkcolorbutton.h
deleted file mode 100644 (file)
index a8ac6cb..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * GTK - The GIMP Toolkit
- * Copyright (C) 1998, 1999 Red Hat, Inc.
- * All rights reserved.
- *
- * This Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-/* Color picker button for GNOME
- *
- * Author: Federico Mena <federico@nuclecu.unam.mx>
- *
- * Modified by the GTK+ Team and others 2003.  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 __GTK_COLOR_BUTTON_H__
-#define __GTK_COLOR_BUTTON_H__
-
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkbutton.h>
-
-G_BEGIN_DECLS
-
-
-#define GTK_TYPE_COLOR_BUTTON             (gtk_color_button_get_type ())
-#define GTK_COLOR_BUTTON(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_BUTTON, GtkColorButton))
-#define GTK_IS_COLOR_BUTTON(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_BUTTON))
-
-typedef struct _GtkColorButton GtkColorButton;
-
-GDK_AVAILABLE_IN_ALL
-GType        gtk_color_button_get_type      (void) G_GNUC_CONST;
-GDK_AVAILABLE_IN_ALL
-GtkWidget *  gtk_color_button_new           (void);
-GDK_AVAILABLE_IN_ALL
-GtkWidget *  gtk_color_button_new_with_rgba (const GdkRGBA  *rgba);
-GDK_AVAILABLE_IN_ALL
-void         gtk_color_button_set_title     (GtkColorButton *button,
-                                             const char     *title);
-GDK_AVAILABLE_IN_ALL
-const char *gtk_color_button_get_title     (GtkColorButton *button);
-
-GDK_AVAILABLE_IN_ALL
-gboolean     gtk_color_button_get_modal        (GtkColorButton *button);
-GDK_AVAILABLE_IN_ALL
-void         gtk_color_button_set_modal        (GtkColorButton *button,
-                                                gboolean        modal);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorButton, g_object_unref)
-
-G_END_DECLS
-
-#endif  /* __GTK_COLOR_BUTTON_H__ */
diff --git a/gtk/gtkcolorchooser.c b/gtk/gtkcolorchooser.c
deleted file mode 100644 (file)
index 3e89cd6..0000000
+++ /dev/null
@@ -1,238 +0,0 @@
-/* GTK - The GIMP Toolkit
- *
- * Copyright (C) 2012, Red Hat, Inc.
- *
- * 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/>.
- */
-
-#include "config.h"
-
-#include "gtkcolorchooser.h"
-#include "gtkcolorchooserprivate.h"
-#include "gtktypebuiltins.h"
-#include "gtkprivate.h"
-#include "gtksnapshot.h"
-#include "gdk/gdkrgbaprivate.h"
-
-/**
- * GtkColorChooser:
- *
- * `GtkColorChooser` is an interface that is implemented by widgets
- * for choosing colors.
- *
- * Depending on the situation, colors may be allowed to have alpha (translucency).
- *
- * In GTK, the main widgets that implement this interface are
- * [class@Gtk.ColorChooserWidget], [class@Gtk.ColorChooserDialog] and
- * [class@Gtk.ColorButton].
- */
-
-enum
-{
-  COLOR_ACTIVATED,
-  LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
-G_DEFINE_INTERFACE (GtkColorChooser, gtk_color_chooser, G_TYPE_OBJECT);
-
-static void
-gtk_color_chooser_default_init (GtkColorChooserInterface *iface)
-{
-  /**
-   * GtkColorChooser:rgba: (attributes org.gtk.Property.get=gtk_color_chooser_get_rgba org.gtk.Property.set=gtk_color_chooser_set_rgba)
-   *
-   * The currently selected color, as a `GdkRGBA` struct.
-   *
-   * The property can be set to change the current selection
-   * programmatically.
-   */
-  g_object_interface_install_property (iface,
-      g_param_spec_boxed ("rgba", NULL, NULL,
-                          GDK_TYPE_RGBA,
-                          GTK_PARAM_READWRITE));
-
-  /**
-   * GtkColorChooser:use-alpha: (attributes org.gtk.Property.get=gtk_color_chooser_get_use_alpha org.gtk.Property.set=gtk_color_chooser_set_use_alpha)
-   *
-   * Whether colors may have alpha (translucency).
-   *
-   * When ::use-alpha is %FALSE, the `GdkRGBA` struct obtained
-   * via the [property@Gtk.ColorChooser:rgba] property will be
-   * forced to have alpha == 1.
-   *
-   * Implementations are expected to show alpha by rendering the color
-   * over a non-uniform background (like a checkerboard pattern).
-   */
-  g_object_interface_install_property (iface,
-      g_param_spec_boolean ("use-alpha", NULL, NULL,
-                            TRUE,
-                            GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY));
-
-  /**
-   * GtkColorChooser::color-activated:
-   * @chooser: the object which received the signal
-   * @color: the color
-   *
-   * Emitted when a color is activated from the color chooser.
-   *
-   * This usually happens when the user clicks a color swatch,
-   * or a color is selected and the user presses one of the keys
-   * Space, Shift+Space, Return or Enter.
-   */
-  signals[COLOR_ACTIVATED] =
-    g_signal_new (I_("color-activated"),
-                  GTK_TYPE_COLOR_CHOOSER,
-                  G_SIGNAL_RUN_FIRST,
-                  G_STRUCT_OFFSET (GtkColorChooserInterface, color_activated),
-                  NULL, NULL,
-                  NULL,
-                  G_TYPE_NONE,
-                  1, GDK_TYPE_RGBA);
-}
-
-void
-_gtk_color_chooser_color_activated (GtkColorChooser *chooser,
-                                    const GdkRGBA   *color)
-{
-  g_signal_emit (chooser, signals[COLOR_ACTIVATED], 0, color);
-}
-
-/**
- * gtk_color_chooser_get_rgba: (attributes org.gtk.Method.get_property=rgba)
- * @chooser: a `GtkColorChooser`
- * @color: (out): a `GdkRGBA` to fill in with the current color
- *
- * Gets the currently-selected color.
- */
-void
-gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
-                            GdkRGBA         *color)
-{
-  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
-
-  GTK_COLOR_CHOOSER_GET_IFACE (chooser)->get_rgba (chooser, color);
-}
-
-/**
- * gtk_color_chooser_set_rgba: (attributes org.gtk.Method.set_property=rgba)
- * @chooser: a `GtkColorChooser`
- * @color: the new color
- *
- * Sets the color.
- */
-void
-gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
-                            const GdkRGBA   *color)
-{
-  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
-  g_return_if_fail (color != NULL);
-
-  GTK_COLOR_CHOOSER_GET_IFACE (chooser)->set_rgba (chooser, color);
-}
-
-/**
- * gtk_color_chooser_get_use_alpha: (attributes org.gtk.Method.get_property=use-alpha)
- * @chooser: a `GtkColorChooser`
- *
- * Returns whether the color chooser shows the alpha channel.
- *
- * Returns: %TRUE if the color chooser uses the alpha channel,
- *   %FALSE if not
- */
-gboolean
-gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser)
-{
-  gboolean use_alpha;
-
-  g_return_val_if_fail (GTK_IS_COLOR_CHOOSER (chooser), TRUE);
-
-  g_object_get (chooser, "use-alpha", &use_alpha, NULL);
-
-  return use_alpha;
-}
-
-/**
- * gtk_color_chooser_set_use_alpha: (attributes org.gtk.Method.set_property=use-alpha)
- * @chooser: a `GtkColorChooser`
- * @use_alpha: %TRUE if color chooser should use alpha channel, %FALSE if not
- *
- * Sets whether or not the color chooser should use the alpha channel.
- */
-void
-gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
-                                 gboolean         use_alpha)
-{
-
-  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
-
-  g_object_set (chooser, "use-alpha", use_alpha, NULL);
-}
-
-/**
- * gtk_color_chooser_add_palette:
- * @chooser: a `GtkColorChooser`
- * @orientation: %GTK_ORIENTATION_HORIZONTAL if the palette should
- *   be displayed in rows, %GTK_ORIENTATION_VERTICAL for columns
- * @colors_per_line: the number of colors to show in each row/column
- * @n_colors: the total number of elements in @colors
- * @colors: (nullable) (array length=n_colors): the colors of the palette
- *
- * Adds a palette to the color chooser.
- *
- * If @orientation is horizontal, the colors are grouped in rows,
- * with @colors_per_line colors in each row. If @horizontal is %FALSE,
- * the colors are grouped in columns instead.
- *
- * The default color palette of [class@Gtk.ColorChooserWidget] has
- * 45 colors, organized in columns of 5 colors (this includes some
- * grays).
- *
- * The layout of the color chooser widget works best when the
- * palettes have 9-10 columns.
- *
- * Calling this function for the first time has the side effect
- * of removing the default color palette from the color chooser.
- *
- * If @colors is %NULL, removes all previously added palettes.
- */
-void
-gtk_color_chooser_add_palette (GtkColorChooser *chooser,
-                               GtkOrientation   orientation,
-                               int              colors_per_line,
-                               int              n_colors,
-                               GdkRGBA         *colors)
-{
-  g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
-
-  if (GTK_COLOR_CHOOSER_GET_IFACE (chooser)->add_palette)
-    GTK_COLOR_CHOOSER_GET_IFACE (chooser)->add_palette (chooser, orientation, colors_per_line, n_colors, colors);
-}
-
-void
-_gtk_color_chooser_snapshot_checkered_pattern (GtkSnapshot *snapshot,
-                                               int          width,
-                                               int          height)
-{
-  const GdkRGBA color1 = GDK_RGBA("A8A8A8");
-  const GdkRGBA color2 = GDK_RGBA("545454");
-
-  gtk_snapshot_push_repeat (snapshot, &GRAPHENE_RECT_INIT (0, 0, width, height), NULL);
-  gtk_snapshot_append_color (snapshot, &color1, &GRAPHENE_RECT_INIT (0,  0,  10, 10));
-  gtk_snapshot_append_color (snapshot, &color2, &GRAPHENE_RECT_INIT (10, 0,  10, 10));
-  gtk_snapshot_append_color (snapshot, &color2, &GRAPHENE_RECT_INIT (0,  10, 10, 10));
-  gtk_snapshot_append_color (snapshot, &color1, &GRAPHENE_RECT_INIT (10, 10, 10, 10));
-  gtk_snapshot_pop (snapshot);
-}
diff --git a/gtk/gtkcolorchooser.h b/gtk/gtkcolorchooser.h
deleted file mode 100644 (file)
index 7a97865..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/* GTK - The GIMP Toolkit
- *
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * 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/>.
- */
-
-#ifndef __GTK_COLOR_CHOOSER_H__
-#define __GTK_COLOR_CHOOSER_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkwidget.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_COLOR_CHOOSER                  (gtk_color_chooser_get_type ())
-#define GTK_COLOR_CHOOSER(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER, GtkColorChooser))
-#define GTK_IS_COLOR_CHOOSER(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER))
-#define GTK_COLOR_CHOOSER_GET_IFACE(inst)       (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_COLOR_CHOOSER, GtkColorChooserInterface))
-
-typedef struct _GtkColorChooser          GtkColorChooser;
-typedef struct _GtkColorChooserInterface GtkColorChooserInterface;
-
-struct _GtkColorChooserInterface
-{
-  GTypeInterface base_interface;
-
-  /* Methods */
-  void (* get_rgba)    (GtkColorChooser *chooser,
-                        GdkRGBA         *color);
-  void (* set_rgba)    (GtkColorChooser *chooser,
-                        const GdkRGBA   *color);
-
-  void (* add_palette) (GtkColorChooser *chooser,
-                        GtkOrientation   orientation,
-                        int              colors_per_line,
-                        int              n_colors,
-                        GdkRGBA         *colors);
-
-  /* Signals */
-  void (* color_activated) (GtkColorChooser *chooser,
-                            const GdkRGBA   *color);
-
-  /*< private >*/
-  /* Padding; remove in GTK-next */
-  gpointer padding[12];
-};
-
-GDK_AVAILABLE_IN_ALL
-GType    gtk_color_chooser_get_type        (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-void     gtk_color_chooser_get_rgba       (GtkColorChooser *chooser,
-                                           GdkRGBA         *color);
-GDK_AVAILABLE_IN_ALL
-void     gtk_color_chooser_set_rgba       (GtkColorChooser *chooser,
-                                           const GdkRGBA   *color);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_color_chooser_get_use_alpha  (GtkColorChooser *chooser);
-
-GDK_AVAILABLE_IN_ALL
-void     gtk_color_chooser_set_use_alpha  (GtkColorChooser *chooser,
-                                           gboolean         use_alpha);
-
-GDK_AVAILABLE_IN_ALL
-void     gtk_color_chooser_add_palette    (GtkColorChooser *chooser,
-                                           GtkOrientation   orientation,
-                                           int              colors_per_line,
-                                           int              n_colors,
-                                           GdkRGBA         *colors);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooser, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GTK_COLOR_CHOOSER_H__ */
index 81ac26188042f0f15a77994f75e3cbc58eddf584..4c3dad79aeb1eef94f1b0d3cd1ff32c71cf609be 100644 (file)
 #include "gtkprivate.h"
 #include "gtksettings.h"
 
-#include "gtkcolorchooserprivate.h"
-#include "gtkcolorchooserdialog.h"
-#include "gtkcolorchooserwidget.h"
+#include "deprecated/gtkcolorchooserprivate.h"
+#include "deprecated/gtkcolorchooserdialog.h"
+#include "deprecated/gtkcolorchooserwidget.h"
+
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
 
 /**
  * GtkColorChooserDialog:
@@ -43,6 +45,8 @@
  * To change the initially selected color, use
  * [method@Gtk.ColorChooser.set_rgba]. To get the selected color use
  * [method@Gtk.ColorChooser.get_rgba].
+ *
+ * `GtkColorChooserDialog` has been deprecated in favor of [class@Gtk.ColorDialog].
  */
 
 typedef struct _GtkColorChooserDialogClass   GtkColorChooserDialogClass;
@@ -281,6 +285,8 @@ gtk_color_chooser_dialog_iface_init (GtkColorChooserInterface *iface)
  * Creates a new `GtkColorChooserDialog`.
  *
  * Returns: a new `GtkColorChooserDialog`
+ *
+ * Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
  */
 GtkWidget *
 gtk_color_chooser_dialog_new (const char *title,
diff --git a/gtk/gtkcolorchooserdialog.h b/gtk/gtkcolorchooserdialog.h
deleted file mode 100644 (file)
index c5212d9..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * 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/>.
- */
-
-#ifndef __GTK_COLOR_CHOOSER_DIALOG_H__
-#define __GTK_COLOR_CHOOSER_DIALOG_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkdialog.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_COLOR_CHOOSER_DIALOG              (gtk_color_chooser_dialog_get_type ())
-#define GTK_COLOR_CHOOSER_DIALOG(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG, GtkColorChooserDialog))
-#define GTK_IS_COLOR_CHOOSER_DIALOG(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG))
-
-typedef struct _GtkColorChooserDialog        GtkColorChooserDialog;
-
-GDK_AVAILABLE_IN_ALL
-GType       gtk_color_chooser_dialog_get_type (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-GtkWidget * gtk_color_chooser_dialog_new      (const char *title,
-                                               GtkWindow   *parent);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserDialog, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GTK_COLOR_CHOOSER_DIALOG_H__ */
diff --git a/gtk/gtkcolorchooserprivate.h b/gtk/gtkcolorchooserprivate.h
deleted file mode 100644 (file)
index c4c1c93..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library 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
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public
- * License along with this library. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __GTK_COLOR_CHOOSER_PRIVATE_H__
-#define __GTK_COLOR_CHOOSER_PRIVATE_H__
-
-#include "gtkcolorchooser.h"
-
-G_BEGIN_DECLS
-
-void _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
-                                         const GdkRGBA   *color);
-
-void _gtk_color_chooser_snapshot_checkered_pattern (GtkSnapshot *snapshot,
-                                                    int          width,
-                                                    int          height);
-
-
-G_END_DECLS
-
-#endif /* ! __GTK_COLOR_CHOOSER_PRIVATE_H__ */
index c6b1a445f15254c71eea17ea6794243ef340a2b8..f1a01054a26eb7aef1bdfa496328cc62f5659155 100644 (file)
@@ -18,8 +18,8 @@
 
 #include "config.h"
 
-#include "gtkcolorchooserprivate.h"
-#include "gtkcolorchooserwidget.h"
+#include "deprecated/gtkcolorchooserprivate.h"
+#include "deprecated/gtkcolorchooserwidget.h"
 #include "gtkcoloreditorprivate.h"
 #include "gtkcolorswatchprivate.h"
 #include "gtkgrid.h"
@@ -34,6 +34,8 @@
 
 #include <math.h>
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 /**
  * GtkColorChooserWidget:
  *
@@ -61,6 +63,8 @@
  * # CSS names
  *
  * `GtkColorChooserWidget` has a single CSS node with name colorchooser.
+ *
+ * Deprecated: 4.10: Direct use of `GtkColorChooserWidget` is deprecated.
  */
 
 typedef struct _GtkColorChooserWidgetClass   GtkColorChooserWidgetClass;
diff --git a/gtk/gtkcolorchooserwidget.h b/gtk/gtkcolorchooserwidget.h
deleted file mode 100644 (file)
index 6634f0e..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/* GTK - The GIMP Toolkit
- * Copyright (C) 2012 Red Hat, Inc.
- *
- * 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/>.
- */
-
-#ifndef __GTK_COLOR_CHOOSER_WIDGET_H__
-#define __GTK_COLOR_CHOOSER_WIDGET_H__
-
-#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
-#error "Only <gtk/gtk.h> can be included directly."
-#endif
-
-#include <gtk/gtkwidget.h>
-
-G_BEGIN_DECLS
-
-#define GTK_TYPE_COLOR_CHOOSER_WIDGET              (gtk_color_chooser_widget_get_type ())
-#define GTK_COLOR_CHOOSER_WIDGET(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER_WIDGET, GtkColorChooserWidget))
-#define GTK_IS_COLOR_CHOOSER_WIDGET(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER_WIDGET))
-
-typedef struct _GtkColorChooserWidget        GtkColorChooserWidget;
-
-GDK_AVAILABLE_IN_ALL
-GType       gtk_color_chooser_widget_get_type (void) G_GNUC_CONST;
-
-GDK_AVAILABLE_IN_ALL
-GtkWidget * gtk_color_chooser_widget_new      (void);
-
-G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWidget, g_object_unref)
-
-G_END_DECLS
-
-#endif /* __GTK_COLOR_CHOOSER_WIDGET_H__ */
index 180bba9a4f7e14bd4d69b4b5b95c7b39b586b86c..ec53c8d0d3aa7ec129f7e7b3189a735ec8f804a3 100644 (file)
@@ -21,8 +21,8 @@
 
 #include "gtkcolordialog.h"
 
-#include "gtkcolorchooserdialog.h"
-#include "gtkcolorchooser.h"
+#include "deprecated/gtkcolorchooserdialog.h"
+#include "deprecated/gtkcolorchooser.h"
 #include "gtkbutton.h"
 #include "gtkdialogerror.h"
 #include <glib/gi18n-lib.h>
@@ -379,8 +379,10 @@ response_cb (GTask *task,
       GtkColorChooserDialog *window;
       GdkRGBA color;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
       window = GTK_COLOR_CHOOSER_DIALOG (g_task_get_task_data (task));
       gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (window), &color);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
       g_task_return_pointer (task, gdk_rgba_copy (&color), (GDestroyNotify) gdk_rgba_free);
     }
@@ -407,11 +409,13 @@ create_color_chooser (GtkColorDialog *self,
   else
     title = _("Pick a Color");
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
   window = gtk_color_chooser_dialog_new (title, parent);
   if (initial_color)
     gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (window), initial_color);
   gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (window), self->with_alpha);
   gtk_window_set_modal (GTK_WINDOW (window), self->modal);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
   return window;
 }
index a2b03db60536607c34eac56f4e7c837e9c861bcf..39c95db7b156a1a33b24c09d143591807bab221c 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "gtkcoloreditorprivate.h"
 
-#include "gtkcolorchooserprivate.h"
+#include "deprecated/gtkcolorchooserprivate.h"
 #include "gtkcolorplaneprivate.h"
 #include "gtkcolorscaleprivate.h"
 #include "gtkcolorswatchprivate.h"
@@ -38,6 +38,8 @@
 
 #include <math.h>
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 typedef struct _GtkColorEditorClass GtkColorEditorClass;
 
 struct _GtkColorEditor
index c0456193fd8005aa4e226f5b46a9d27afe6e0c83..b054c7eb7f4941bb9568c214b1e78960c1e05a7d 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "gtkcolorscaleprivate.h"
 
-#include "gtkcolorchooserprivate.h"
+#include "deprecated/gtkcolorchooserprivate.h"
 #include "gtkgesturelongpress.h"
 #include "gtkgestureclick.h"
 #include "gtkcolorutils.h"
index 9f1b7d056cb7cfc82ec34cc4b9beeb7ef1d933f1..6bce4f3d612044e8e1e4efa2b1c2b6723fc3d500 100644 (file)
@@ -20,7 +20,7 @@
 #include "gtkcolorswatchprivate.h"
 
 #include "gtkbox.h"
-#include "gtkcolorchooserprivate.h"
+#include "deprecated/gtkcolorchooserprivate.h"
 #include "gtkdragsource.h"
 #include "gtkdroptarget.h"
 #include "gtkgesturelongpress.h"
index 1d575fe3b6655be0ec9c3ebf1dd5ad785293437b..d5849712d631416edca9700e3c78255ab12e7b12 100644 (file)
@@ -31,7 +31,6 @@ gtk_private_sources = files([
   'gtkbuilder-menus.c',
   'gtkbuilderprecompile.c',
   'gtkbuiltinicon.c',
-  'gtkcoloreditor.c',
   'gtkcolorplane.c',
   'gtkcolorpicker.c',
   'gtkcolorpickerkwin.c',
@@ -183,8 +182,7 @@ gtk_public_sources = files([
   'gtkcenterbox.c',
   'gtkcenterlayout.c',
   'gtkcheckbutton.c',
-  'gtkcolorbutton.c',
-  'gtkcolorchooser.c',
+  'gtkcoloreditor.c',
   'gtkcolorchooserdialog.c',
   'gtkcolorchooserwidget.c',
   'gtkcolordialog.c',
@@ -446,10 +444,6 @@ gtk_public_headers = files([
   'gtkcenterbox.h',
   'gtkcenterlayout.h',
   'gtkcheckbutton.h',
-  'gtkcolorbutton.h',
-  'gtkcolorchooser.h',
-  'gtkcolorchooserdialog.h',
-  'gtkcolorchooserwidget.h',
   'gtkcolordialog.h',
   'gtkcolordialogbutton.h',
   'gtkcolorutils.h',
index 660912cf009db3913847b8ada78184210f42bc05..3993339f38de4089a2dc109f1db4f8ff838406ea 100644 (file)
@@ -1,6 +1,8 @@
 #include <gtk/gtk.h>
 #include <glib/gstdio.h>
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 static void
 show_message_dialog1 (GtkWindow *parent)
 {
index b2a549942de33ff5fac27bf13f949fee09bdf756..aa3c95f9b303bbcd1752d0fd4d9c9f8949a318d7 100644 (file)
@@ -22,6 +22,8 @@
 #  include <gtk/gtkunixprint.h>
 #endif
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+
 static gboolean
 main_loop_quit_cb (gpointer data)
 {