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.
This commit is contained in:
Matthias Clasen 2022-10-26 21:52:06 -04:00
parent 8bee62dd36
commit a51a6a3ee2
22 changed files with 89 additions and 34 deletions

View 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 ();

View 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)

View File

@ -7,6 +7,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
enum {
COLOR_SET,
N_SIGNALS

View 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);
}
}

View File

@ -46,6 +46,8 @@
#include "gtkwidgetprivate.h"
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
/**
* GtkColorButton:
*
@ -67,6 +69,8 @@
* `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;
@ -353,6 +357,8 @@ gtk_color_button_finalize (GObject *object)
* color when the user finishes.
*
* Returns: a new color button
*
* Deprecated: 4.10: Use [class@Gtk.ColorDialogButton] instead
*/
GtkWidget *
gtk_color_button_new (void)
@ -561,6 +567,8 @@ set_use_alpha (GtkColorButton *button,
* @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,
@ -587,6 +595,8 @@ gtk_color_button_set_title (GtkColorButton *button,
* 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)
@ -602,6 +612,8 @@ gtk_color_button_get_title (GtkColorButton *button)
* @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,
@ -627,6 +639,8 @@ gtk_color_button_set_modal (GtkColorButton *button,
* 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)

View File

@ -48,19 +48,19 @@ typedef struct _GtkColorButton GtkColorButton;
GDK_AVAILABLE_IN_ALL
GType gtk_color_button_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_color_button_new (void);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_color_button_new_with_rgba (const GdkRGBA *rgba);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_color_button_set_title (GtkColorButton *button,
const char *title);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
const char *gtk_color_button_get_title (GtkColorButton *button);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
gboolean gtk_color_button_get_modal (GtkColorButton *button);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_color_button_set_modal (GtkColorButton *button,
gboolean modal);

View File

@ -36,6 +36,9 @@
* 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
@ -116,6 +119,8 @@ _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
* @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,
@ -132,6 +137,8 @@ gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
* @color: the new color
*
* Sets the color.
*
* Deprecated: 4.10: Use [class@Gtk.ColorDialog] instead
*/
void
gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
@ -151,6 +158,8 @@ gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
*
* 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)
@ -170,6 +179,8 @@ gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser)
* @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,
@ -207,6 +218,8 @@ gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
* 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,

View File

@ -63,20 +63,20 @@ struct _GtkColorChooserInterface
GDK_AVAILABLE_IN_ALL
GType gtk_color_chooser_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
GdkRGBA *color);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
const GdkRGBA *color);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
gboolean gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
gboolean use_alpha);
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
void gtk_color_chooser_add_palette (GtkColorChooser *chooser,
GtkOrientation orientation,
int colors_per_line,

View File

@ -35,7 +35,7 @@ typedef struct _GtkColorChooserDialog GtkColorChooserDialog;
GDK_AVAILABLE_IN_ALL
GType gtk_color_chooser_dialog_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_color_chooser_dialog_new (const char *title,
GtkWindow *parent);

View File

@ -35,7 +35,7 @@ typedef struct _GtkColorChooserWidget GtkColorChooserWidget;
GDK_AVAILABLE_IN_ALL
GType gtk_color_chooser_widget_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
GDK_DEPRECATED_IN_4_10
GtkWidget * gtk_color_chooser_widget_new (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkColorChooserWidget, g_object_unref)

View 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',

View File

@ -79,10 +79,10 @@
#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>

View File

@ -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,

View 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;

View 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;
}

View 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

View File

@ -19,7 +19,7 @@
#include "gtkcolorscaleprivate.h"
#include "gtkcolorchooserprivate.h"
#include "deprecated/gtkcolorchooserprivate.h"
#include "gtkgesturelongpress.h"
#include "gtkgestureclick.h"
#include "gtkcolorutils.h"

View 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"

View 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',

View 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)
{

View File

@ -22,6 +22,8 @@
# include <gtk/gtkunixprint.h>
#endif
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static gboolean
main_loop_quit_cb (gpointer data)
{