GtkColorButton: Reduce internal use of deprecated API

Drop the blanket GDK_DISABLE_DEPRECATION_WARNINGS and avoid
deprecated API as much as possible.
This commit is contained in:
Matthias Clasen 2014-05-02 18:42:18 -04:00
parent 69234cfecc
commit 67b10e649e

View File

@ -26,7 +26,6 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/. * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/ */
#define GDK_DISABLE_DEPRECATION_WARNINGS
#include "config.h" #include "config.h"
#include "gtkcolorbutton.h" #include "gtkcolorbutton.h"
@ -875,7 +874,7 @@ gtk_color_button_set_property (GObject *object,
switch (param_id) switch (param_id)
{ {
case PROP_USE_ALPHA: case PROP_USE_ALPHA:
gtk_color_button_set_use_alpha (button, g_value_get_boolean (value)); gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button), g_value_get_boolean (value));
break; break;
case PROP_TITLE: case PROP_TITLE:
gtk_color_button_set_title (button, g_value_get_string (value)); gtk_color_button_set_title (button, g_value_get_string (value));
@ -892,14 +891,16 @@ gtk_color_button_set_property (GObject *object,
rgba.blue = color->blue / 65535.0; rgba.blue = color->blue / 65535.0;
rgba.alpha = 1.0; rgba.alpha = 1.0;
gtk_color_button_set_rgba (button, &rgba); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), &rgba);
} }
break; break;
case PROP_ALPHA: case PROP_ALPHA:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_color_button_set_alpha (button, g_value_get_uint (value)); gtk_color_button_set_alpha (button, g_value_get_uint (value));
G_GNUC_END_IGNORE_DEPRECATIONS
break; break;
case PROP_RGBA: case PROP_RGBA:
gtk_color_button_set_rgba (button, g_value_get_boxed (value)); gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), g_value_get_boxed (value));
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@ -918,7 +919,7 @@ gtk_color_button_get_property (GObject *object,
switch (param_id) switch (param_id)
{ {
case PROP_USE_ALPHA: case PROP_USE_ALPHA:
g_value_set_boolean (value, gtk_color_button_get_use_alpha (button)); g_value_set_boolean (value, gtk_color_chooser_get_use_alpha (GTK_COLOR_CHOOSER (button)));
break; break;
case PROP_TITLE: case PROP_TITLE:
g_value_set_string (value, gtk_color_button_get_title (button)); g_value_set_string (value, gtk_color_button_get_title (button));
@ -928,7 +929,7 @@ gtk_color_button_get_property (GObject *object,
GdkColor color; GdkColor color;
GdkRGBA rgba; GdkRGBA rgba;
gtk_color_button_get_rgba (button, &rgba); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
color.red = (guint16) (rgba.red * 65535 + 0.5); color.red = (guint16) (rgba.red * 65535 + 0.5);
color.green = (guint16) (rgba.green * 65535 + 0.5); color.green = (guint16) (rgba.green * 65535 + 0.5);
@ -938,13 +939,15 @@ gtk_color_button_get_property (GObject *object,
} }
break; break;
case PROP_ALPHA: case PROP_ALPHA:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
g_value_set_uint (value, gtk_color_button_get_alpha (button)); g_value_set_uint (value, gtk_color_button_get_alpha (button));
G_GNUC_END_IGNORE_DEPRECATIONS
break; break;
case PROP_RGBA: case PROP_RGBA:
{ {
GdkRGBA rgba; GdkRGBA rgba;
gtk_color_button_get_rgba (button, &rgba); gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &rgba);
g_value_set_boxed (value, &rgba); g_value_set_boxed (value, &rgba);
} }
break; break;
@ -975,8 +978,10 @@ typedef void (* set_rgba) (GtkColorChooser *, const GdkRGBA *);
static void static void
gtk_color_button_iface_init (GtkColorChooserInterface *iface) gtk_color_button_iface_init (GtkColorChooserInterface *iface)
{ {
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
iface->get_rgba = (get_rgba)gtk_color_button_get_rgba; iface->get_rgba = (get_rgba)gtk_color_button_get_rgba;
iface->set_rgba = (set_rgba)gtk_color_button_set_rgba; iface->set_rgba = (set_rgba)gtk_color_button_set_rgba;
G_GNUC_END_IGNORE_DEPRECATIONS
iface->add_palette = gtk_color_button_add_palette; iface->add_palette = gtk_color_button_add_palette;
} }