From: Matthias Clasen Date: Thu, 27 Oct 2022 01:52:06 +0000 (-0400) Subject: Deprecate GtkColorChooser and implementations X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~132^2~4 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a51a6a3ee23e31f868cdbea2b91171b0ddaabc79;p=gtk4.git Deprecate GtkColorChooser and implementations 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. --- diff --git a/demos/gtk-demo/dnd.c b/demos/gtk-demo/dnd.c index e406ca3972..fbf28ec305 100644 --- a/demos/gtk-demo/dnd.c +++ b/demos/gtk-demo/dnd.c @@ -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 (); diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c index ed71354f1d..fd358eb47b 100644 --- a/demos/gtk-demo/font_features.c +++ b/demos/gtk-demo/font_features.c @@ -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) diff --git a/demos/gtk-demo/paint.c b/demos/gtk-demo/paint.c index 92774b0efb..d60991f981 100644 --- a/demos/gtk-demo/paint.c +++ b/demos/gtk-demo/paint.c @@ -7,6 +7,8 @@ #include #include +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + enum { COLOR_SET, N_SIGNALS diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index 705606fcfe..b41283d10f 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -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 index 0000000000..6cd40101aa --- /dev/null +++ b/gtk/deprecated/gtkcolorbutton.c @@ -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 . + */ +/* Color picker button for GNOME + * + * Author: Federico Mena + * + * 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 +#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 index 0000000000..ce565d6728 --- /dev/null +++ b/gtk/deprecated/gtkcolorbutton.h @@ -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 . + */ + +/* Color picker button for GNOME + * + * Author: Federico Mena + * + * 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 can be included directly." +#endif + +#include + +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 index 0000000000..c38eb43d5e --- /dev/null +++ b/gtk/deprecated/gtkcolorchooser.c @@ -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 . + */ + +#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 index 0000000000..1c573a22d7 --- /dev/null +++ b/gtk/deprecated/gtkcolorchooser.h @@ -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 . + */ + +#ifndef __GTK_COLOR_CHOOSER_H__ +#define __GTK_COLOR_CHOOSER_H__ + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +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 index 0000000000..a5d0f4ef86 --- /dev/null +++ b/gtk/deprecated/gtkcolorchooserdialog.h @@ -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 . + */ + +#ifndef __GTK_COLOR_CHOOSER_DIALOG_H__ +#define __GTK_COLOR_CHOOSER_DIALOG_H__ + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +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 index 0000000000..c4c1c935f9 --- /dev/null +++ b/gtk/deprecated/gtkcolorchooserprivate.h @@ -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 . + */ + +#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 index 0000000000..51dfb278e6 --- /dev/null +++ b/gtk/deprecated/gtkcolorchooserwidget.h @@ -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 . + */ + +#ifndef __GTK_COLOR_CHOOSER_WIDGET_H__ +#define __GTK_COLOR_CHOOSER_WIDGET_H__ + +#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) +#error "Only can be included directly." +#endif + +#include + +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__ */ diff --git a/gtk/deprecated/meson.build b/gtk/deprecated/meson.build index cd5b182170..ae5012bb5b 100644 --- a/gtk/deprecated/meson.build +++ b/gtk/deprecated/meson.build @@ -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', diff --git a/gtk/gtk.h b/gtk/gtk.h index edc98bf086..a33ad62bc9 100644 --- a/gtk/gtk.h +++ b/gtk/gtk.h @@ -79,10 +79,10 @@ #include #include #include -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c deleted file mode 100644 index 8d1e4ceb30..0000000000 --- a/gtk/gtkcolorbutton.c +++ /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 . - */ -/* Color picker button for GNOME - * - * Author: Federico Mena - * - * 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 -#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 index a8ac6cbfe6..0000000000 --- a/gtk/gtkcolorbutton.h +++ /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 . - */ - -/* Color picker button for GNOME - * - * Author: Federico Mena - * - * 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 can be included directly." -#endif - -#include - -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 index 3e89cd6bc2..0000000000 --- a/gtk/gtkcolorchooser.c +++ /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 . - */ - -#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 index 7a97865b8d..0000000000 --- a/gtk/gtkcolorchooser.h +++ /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 . - */ - -#ifndef __GTK_COLOR_CHOOSER_H__ -#define __GTK_COLOR_CHOOSER_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -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__ */ diff --git a/gtk/gtkcolorchooserdialog.c b/gtk/gtkcolorchooserdialog.c index 81ac261880..4c3dad79ae 100644 --- a/gtk/gtkcolorchooserdialog.c +++ b/gtk/gtkcolorchooserdialog.c @@ -24,9 +24,11 @@ #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 index c5212d912d..0000000000 --- a/gtk/gtkcolorchooserdialog.h +++ /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 . - */ - -#ifndef __GTK_COLOR_CHOOSER_DIALOG_H__ -#define __GTK_COLOR_CHOOSER_DIALOG_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -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 index c4c1c935f9..0000000000 --- a/gtk/gtkcolorchooserprivate.h +++ /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 . - */ - -#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/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c index c6b1a445f1..f1a01054a2 100644 --- a/gtk/gtkcolorchooserwidget.c +++ b/gtk/gtkcolorchooserwidget.c @@ -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 +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 index 6634f0eb9c..0000000000 --- a/gtk/gtkcolorchooserwidget.h +++ /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 . - */ - -#ifndef __GTK_COLOR_CHOOSER_WIDGET_H__ -#define __GTK_COLOR_CHOOSER_WIDGET_H__ - -#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION) -#error "Only can be included directly." -#endif - -#include - -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__ */ diff --git a/gtk/gtkcolordialog.c b/gtk/gtkcolordialog.c index 180bba9a4f..ec53c8d0d3 100644 --- a/gtk/gtkcolordialog.c +++ b/gtk/gtkcolordialog.c @@ -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 @@ -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; } diff --git a/gtk/gtkcoloreditor.c b/gtk/gtkcoloreditor.c index a2b03db605..39c95db7b1 100644 --- a/gtk/gtkcoloreditor.c +++ b/gtk/gtkcoloreditor.c @@ -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 +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + typedef struct _GtkColorEditorClass GtkColorEditorClass; struct _GtkColorEditor diff --git a/gtk/gtkcolorscale.c b/gtk/gtkcolorscale.c index c0456193fd..b054c7eb7f 100644 --- a/gtk/gtkcolorscale.c +++ b/gtk/gtkcolorscale.c @@ -19,7 +19,7 @@ #include "gtkcolorscaleprivate.h" -#include "gtkcolorchooserprivate.h" +#include "deprecated/gtkcolorchooserprivate.h" #include "gtkgesturelongpress.h" #include "gtkgestureclick.h" #include "gtkcolorutils.h" diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c index 9f1b7d056c..6bce4f3d61 100644 --- a/gtk/gtkcolorswatch.c +++ b/gtk/gtkcolorswatch.c @@ -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" diff --git a/gtk/meson.build b/gtk/meson.build index 1d575fe3b6..d5849712d6 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -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', diff --git a/tests/testdialog.c b/tests/testdialog.c index 660912cf00..3993339f38 100644 --- a/tests/testdialog.c +++ b/tests/testdialog.c @@ -1,6 +1,8 @@ #include #include +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static void show_message_dialog1 (GtkWindow *parent) { diff --git a/testsuite/gtk/templates.c b/testsuite/gtk/templates.c index b2a549942d..aa3c95f9b3 100644 --- a/testsuite/gtk/templates.c +++ b/testsuite/gtk/templates.c @@ -22,6 +22,8 @@ # include #endif +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static gboolean main_loop_quit_cb (gpointer data) {