[gtk+/wip/colorchooser-v2: 34/40] Rework the API a bit
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/colorchooser-v2: 34/40] Rework the API a bit
- Date: Tue, 7 Feb 2012 17:47:20 +0000 (UTC)
commit 1cfe7bdd49f0b6ddc19d342ea80acefc94a5fc76
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Feb 3 18:34:33 2012 -0500
Rework the API a bit
Rename get/set_color to get/set_rgba and show_alpha to use_alpha,
to match existing GtkColorButton API and let GtkColorButton implement
GtkColorChooser.
gtk/gtkcolorbutton.c | 336 ++++++++++++++++++++++---------------------
gtk/gtkcolorbutton.h | 43 +++---
gtk/gtkcolorchooser.c | 36 +++---
gtk/gtkcolorchooser.h | 22 ++--
gtk/gtkcolorchooserwidget.c | 86 ++++++------
gtk/gtkcoloreditor.c | 66 ++++-----
gtk/gtkcolorscale.c | 4 +-
gtk/gtkcolorscale.h | 10 +-
gtk/gtkcolorswatch.c | 42 +++---
gtk/gtkcolorswatch.h | 8 +-
tests/testcolorchooser.c | 8 +-
11 files changed, 339 insertions(+), 322 deletions(-)
---
diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c
index 1955afd..e43d240 100644
--- a/gtk/gtkcolorbutton.c
+++ b/gtk/gtkcolorbutton.c
@@ -28,6 +28,7 @@
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
+#define GDK_DISABLE_DEPRECATION_WARNINGS
#include "config.h"
#include "gtkcolorbutton.h"
@@ -119,7 +120,7 @@ static void gtk_color_button_drag_data_get (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time,
- GtkColorButton *color_button);
+ GtkColorButton *button);
/* target side drag signals */
static void gtk_color_button_drag_data_received (GtkWidget *widget,
@@ -129,14 +130,18 @@ static void gtk_color_button_drag_data_received (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint32 time,
- GtkColorButton *color_button);
+ GtkColorButton *button);
static guint color_button_signals[LAST_SIGNAL] = { 0 };
static const GtkTargetEntry drop_types[] = { { "application/x-color", 0, 0 } };
-G_DEFINE_TYPE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON)
+static void gtk_color_button_iface_init (GtkColorChooserInterface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (GtkColorButton, gtk_color_button, GTK_TYPE_BUTTON,
+ G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
+ gtk_color_button_iface_init))
static void
gtk_color_button_class_init (GtkColorButtonClass *klass)
@@ -262,10 +267,9 @@ gtk_color_button_class_init (GtkColorButtonClass *klass)
}
static gboolean
-gtk_color_button_has_alpha (GtkColorButton *color_button)
+gtk_color_button_has_alpha (GtkColorButton *button)
{
- return color_button->priv->use_alpha &&
- color_button->priv->rgba.alpha < 1;
+ return button->priv->use_alpha && button->priv->rgba.alpha < 1;
}
static cairo_pattern_t *
@@ -297,10 +301,10 @@ gtk_color_button_draw_cb (GtkWidget *widget,
cairo_t *cr,
gpointer data)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
+ GtkColorButton *button = GTK_COLOR_BUTTON (data);
cairo_pattern_t *checkered;
- if (gtk_color_button_has_alpha (color_button))
+ if (gtk_color_button_has_alpha (button))
{
cairo_set_source_rgb (cr, CHECK_DARK, CHECK_DARK, CHECK_DARK);
cairo_paint (cr);
@@ -312,19 +316,19 @@ gtk_color_button_draw_cb (GtkWidget *widget,
cairo_mask (cr, checkered);
cairo_pattern_destroy (checkered);
- gdk_cairo_set_source_rgba (cr, &color_button->priv->rgba);
+ gdk_cairo_set_source_rgba (cr, &button->priv->rgba);
}
else
{
cairo_set_source_rgb (cr,
- color_button->priv->rgba.red,
- color_button->priv->rgba.green,
- color_button->priv->rgba.blue);
+ button->priv->rgba.red,
+ button->priv->rgba.green,
+ button->priv->rgba.blue);
}
cairo_paint (cr);
- if (!gtk_widget_is_sensitive (GTK_WIDGET (color_button)))
+ if (!gtk_widget_is_sensitive (GTK_WIDGET (button)))
{
GtkStyleContext *context;
GdkRGBA color;
@@ -356,7 +360,7 @@ gtk_color_button_drag_data_received (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint32 time,
- GtkColorButton *color_button)
+ GtkColorButton *button)
{
gint length;
guint16 *dropped;
@@ -378,20 +382,20 @@ gtk_color_button_drag_data_received (GtkWidget *widget,
dropped = (guint16 *) gtk_selection_data_get_data (selection_data);
- color_button->priv->rgba.red = dropped[0] / 65535.;
- color_button->priv->rgba.green = dropped[1] / 65535.;
- color_button->priv->rgba.blue = dropped[2] / 65535.;
- color_button->priv->rgba.alpha = dropped[3] / 65535.;
+ button->priv->rgba.red = dropped[0] / 65535.;
+ button->priv->rgba.green = dropped[1] / 65535.;
+ button->priv->rgba.blue = dropped[2] / 65535.;
+ button->priv->rgba.alpha = dropped[3] / 65535.;
- gtk_widget_queue_draw (color_button->priv->draw_area);
+ gtk_widget_queue_draw (button->priv->draw_area);
- g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+ g_signal_emit (button, color_button_signals[COLOR_SET], 0);
- g_object_freeze_notify (G_OBJECT (color_button));
- g_object_notify (G_OBJECT (color_button), "color");
- g_object_notify (G_OBJECT (color_button), "alpha");
- g_object_notify (G_OBJECT (color_button), "rgba");
- g_object_thaw_notify (G_OBJECT (color_button));
+ g_object_freeze_notify (G_OBJECT (button));
+ g_object_notify (G_OBJECT (button), "color");
+ g_object_notify (G_OBJECT (button), "alpha");
+ g_object_notify (G_OBJECT (button), "rgba");
+ g_object_thaw_notify (G_OBJECT (button));
}
static void
@@ -419,9 +423,9 @@ gtk_color_button_drag_begin (GtkWidget *widget,
GdkDragContext *context,
gpointer data)
{
- GtkColorButton *color_button = data;
+ GtkColorButton *button = data;
- set_color_icon (context, &color_button->priv->rgba);
+ set_color_icon (context, &button->priv->rgba);
}
static void
@@ -430,14 +434,14 @@ gtk_color_button_drag_data_get (GtkWidget *widget,
GtkSelectionData *selection_data,
guint info,
guint time,
- GtkColorButton *color_button)
+ GtkColorButton *button)
{
guint16 dropped[4];
- dropped[0] = (guint16) (color_button->priv->rgba.red * 65535);
- dropped[1] = (guint16) (color_button->priv->rgba.green * 65535);
- dropped[2] = (guint16) (color_button->priv->rgba.blue * 65535);
- dropped[3] = (guint16) (color_button->priv->rgba.alpha * 65535);
+ dropped[0] = (guint16) (button->priv->rgba.red * 65535);
+ dropped[1] = (guint16) (button->priv->rgba.green * 65535);
+ dropped[2] = (guint16) (button->priv->rgba.blue * 65535);
+ dropped[3] = (guint16) (button->priv->rgba.alpha * 65535);
gtk_selection_data_set (selection_data,
gtk_selection_data_get_target (selection_data),
@@ -445,7 +449,7 @@ gtk_color_button_drag_data_get (GtkWidget *widget,
}
static void
-gtk_color_button_init (GtkColorButton *color_button)
+gtk_color_button_init (GtkColorButton *button)
{
GtkWidget *alignment;
GtkWidget *frame;
@@ -453,15 +457,15 @@ gtk_color_button_init (GtkColorButton *color_button)
PangoRectangle rect;
/* Create the widgets */
- color_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (color_button,
- GTK_TYPE_COLOR_BUTTON,
- GtkColorButtonPrivate);
+ button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button,
+ GTK_TYPE_COLOR_BUTTON,
+ GtkColorButtonPrivate);
gtk_widget_push_composite_child ();
alignment = gtk_alignment_new (0.5, 0.5, 0.5, 1.0);
gtk_container_set_border_width (GTK_CONTAINER (alignment), 1);
- gtk_container_add (GTK_CONTAINER (color_button), alignment);
+ gtk_container_add (GTK_CONTAINER (button), alignment);
gtk_widget_show (alignment);
frame = gtk_frame_new (NULL);
@@ -470,43 +474,43 @@ gtk_color_button_init (GtkColorButton *color_button)
gtk_widget_show (frame);
/* Just some widget we can hook to expose-event on */
- color_button->priv->draw_area = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
+ button->priv->draw_area = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- layout = gtk_widget_create_pango_layout (GTK_WIDGET (color_button), "Black");
+ 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 (color_button->priv->draw_area, rect.width - 2, rect.height - 2);
- g_signal_connect (color_button->priv->draw_area, "draw",
- G_CALLBACK (gtk_color_button_draw_cb), color_button);
- gtk_container_add (GTK_CONTAINER (frame), color_button->priv->draw_area);
- gtk_widget_show (color_button->priv->draw_area);
+ gtk_widget_set_size_request (button->priv->draw_area, rect.width - 2, rect.height - 2);
+ g_signal_connect (button->priv->draw_area, "draw",
+ G_CALLBACK (gtk_color_button_draw_cb), button);
+ gtk_container_add (GTK_CONTAINER (frame), button->priv->draw_area);
+ gtk_widget_show (button->priv->draw_area);
- color_button->priv->title = g_strdup (_("Pick a Color")); /* default title */
+ button->priv->title = g_strdup (_("Pick a Color")); /* default title */
/* Start with opaque black, alpha disabled */
- color_button->priv->rgba.red = 0;
- color_button->priv->rgba.green = 0;
- color_button->priv->rgba.blue = 0;
- color_button->priv->rgba.alpha = 1;
- color_button->priv->use_alpha = FALSE;
+ button->priv->rgba.red = 0;
+ button->priv->rgba.green = 0;
+ button->priv->rgba.blue = 0;
+ button->priv->rgba.alpha = 1;
+ button->priv->use_alpha = FALSE;
- gtk_drag_dest_set (GTK_WIDGET (color_button),
+ gtk_drag_dest_set (GTK_WIDGET (button),
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
drop_types, 1, GDK_ACTION_COPY);
- gtk_drag_source_set (GTK_WIDGET(color_button),
+ gtk_drag_source_set (GTK_WIDGET (button),
GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
drop_types, 1,
GDK_ACTION_COPY);
- g_signal_connect (color_button, "drag-begin",
- G_CALLBACK (gtk_color_button_drag_begin), color_button);
- g_signal_connect (color_button, "drag-data-received",
- G_CALLBACK (gtk_color_button_drag_data_received), color_button);
- g_signal_connect (color_button, "drag-data-get",
- G_CALLBACK (gtk_color_button_drag_data_get), color_button);
+ g_signal_connect (button, "drag-begin",
+ G_CALLBACK (gtk_color_button_drag_begin), button);
+ g_signal_connect (button, "drag-data-received",
+ G_CALLBACK (gtk_color_button_drag_data_received), button);
+ g_signal_connect (button, "drag-data-get",
+ G_CALLBACK (gtk_color_button_drag_data_get), button);
gtk_widget_pop_composite_child ();
}
@@ -514,14 +518,14 @@ gtk_color_button_init (GtkColorButton *color_button)
static void
gtk_color_button_finalize (GObject *object)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
+ GtkColorButton *button = GTK_COLOR_BUTTON (object);
- if (color_button->priv->cs_dialog != NULL)
- gtk_widget_destroy (color_button->priv->cs_dialog);
- color_button->priv->cs_dialog = NULL;
+ if (button->priv->cs_dialog != NULL)
+ gtk_widget_destroy (button->priv->cs_dialog);
+ button->priv->cs_dialog = NULL;
- g_free (color_button->priv->title);
- color_button->priv->title = NULL;
+ g_free (button->priv->title);
+ button->priv->title = NULL;
G_OBJECT_CLASS (gtk_color_button_parent_class)->finalize (object);
}
@@ -586,9 +590,9 @@ static gboolean
dialog_destroy (GtkWidget *widget,
gpointer data)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
+ GtkColorButton *button = GTK_COLOR_BUTTON (data);
- color_button->priv->cs_dialog = NULL;
+ button->priv->cs_dialog = NULL;
return FALSE;
}
@@ -602,40 +606,40 @@ dialog_response (GtkDialog *dialog,
gtk_widget_hide (GTK_WIDGET (dialog));
else if (response == GTK_RESPONSE_OK)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (data);
+ GtkColorButton *button = GTK_COLOR_BUTTON (data);
- gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (dialog),
- &color_button->priv->rgba);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog),
+ &button->priv->rgba);
gtk_widget_hide (GTK_WIDGET (dialog));
- gtk_widget_queue_draw (color_button->priv->draw_area);
+ gtk_widget_queue_draw (button->priv->draw_area);
- g_signal_emit (color_button, color_button_signals[COLOR_SET], 0);
+ g_signal_emit (button, color_button_signals[COLOR_SET], 0);
- g_object_freeze_notify (G_OBJECT (color_button));
- g_object_notify (G_OBJECT (color_button), "color");
- g_object_notify (G_OBJECT (color_button), "alpha");
- g_object_notify (G_OBJECT (color_button), "rgba");
- g_object_thaw_notify (G_OBJECT (color_button));
+ g_object_freeze_notify (G_OBJECT (button));
+ g_object_notify (G_OBJECT (button), "color");
+ g_object_notify (G_OBJECT (button), "alpha");
+ g_object_notify (G_OBJECT (button), "rgba");
+ g_object_thaw_notify (G_OBJECT (button));
}
}
static void
-gtk_color_button_clicked (GtkButton *button)
+gtk_color_button_clicked (GtkButton *b)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (button);
+ GtkColorButton *button = GTK_COLOR_BUTTON (b);
GtkWidget *dialog;
/* if dialog already exists, make sure it's shown and raised */
- if (!color_button->priv->cs_dialog)
+ if (!button->priv->cs_dialog)
{
/* Create the dialog and connects its buttons */
GtkWidget *parent;
- parent = gtk_widget_get_toplevel (GTK_WIDGET (color_button));
+ parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
- color_button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (color_button->priv->title, NULL);
+ button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
@@ -647,20 +651,20 @@ gtk_color_button_clicked (GtkButton *button)
}
g_signal_connect (dialog, "response",
- G_CALLBACK (dialog_response), color_button);
+ G_CALLBACK (dialog_response), button);
g_signal_connect (dialog, "destroy",
- G_CALLBACK (dialog_destroy), color_button);
+ G_CALLBACK (dialog_destroy), button);
}
- gtk_color_chooser_set_show_alpha (GTK_COLOR_CHOOSER (color_button->priv->cs_dialog),
- color_button->priv->use_alpha);
+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
+ button->priv->use_alpha);
- gtk_window_present (GTK_WINDOW (color_button->priv->cs_dialog));
+ gtk_window_present (GTK_WINDOW (button->priv->cs_dialog));
}
/**
* gtk_color_button_set_color:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @color: A #GdkColor to set the current color with
*
* Sets the current color to be @color.
@@ -670,26 +674,26 @@ gtk_color_button_clicked (GtkButton *button)
* Deprecated: Use gtk_color_button_set_rgba() instead.
*/
void
-gtk_color_button_set_color (GtkColorButton *color_button,
+gtk_color_button_set_color (GtkColorButton *button,
const GdkColor *color)
{
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
g_return_if_fail (color != NULL);
- color_button->priv->rgba.red = color->red / 65535.;
- color_button->priv->rgba.green = color->green / 65535.;
- color_button->priv->rgba.blue = color->blue / 65535.;
+ button->priv->rgba.red = color->red / 65535.;
+ button->priv->rgba.green = color->green / 65535.;
+ button->priv->rgba.blue = color->blue / 65535.;
- gtk_widget_queue_draw (color_button->priv->draw_area);
+ gtk_widget_queue_draw (button->priv->draw_area);
- g_object_notify (G_OBJECT (color_button), "color");
- g_object_notify (G_OBJECT (color_button), "rgba");
+ g_object_notify (G_OBJECT (button), "color");
+ g_object_notify (G_OBJECT (button), "rgba");
}
/**
* gtk_color_button_set_alpha:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @alpha: an integer between 0 and 65535
*
* Sets the current opacity to be @alpha.
@@ -697,22 +701,22 @@ gtk_color_button_set_color (GtkColorButton *color_button,
* Since: 2.4
*/
void
-gtk_color_button_set_alpha (GtkColorButton *color_button,
+gtk_color_button_set_alpha (GtkColorButton *button,
guint16 alpha)
{
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
- color_button->priv->rgba.alpha = alpha / 65535.;
+ button->priv->rgba.alpha = alpha / 65535.;
- gtk_widget_queue_draw (color_button->priv->draw_area);
+ gtk_widget_queue_draw (button->priv->draw_area);
- g_object_notify (G_OBJECT (color_button), "alpha");
- g_object_notify (G_OBJECT (color_button), "rgba");
+ g_object_notify (G_OBJECT (button), "alpha");
+ g_object_notify (G_OBJECT (button), "rgba");
}
/**
* gtk_color_button_get_color:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @color: (out): a #GdkColor to fill in with the current color
*
* Sets @color to be the current color in the #GtkColorButton widget.
@@ -722,19 +726,19 @@ gtk_color_button_set_alpha (GtkColorButton *color_button,
* Deprecated: 3.4: Use gtk_color_button_get_rgba() instead.
*/
void
-gtk_color_button_get_color (GtkColorButton *color_button,
+gtk_color_button_get_color (GtkColorButton *button,
GdkColor *color)
{
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
- color->red = (guint16) (color_button->priv->rgba.red * 65535);
- color->green = (guint16) (color_button->priv->rgba.green * 65535);
- color->blue = (guint16) (color_button->priv->rgba.blue * 65535);
+ color->red = (guint16) (button->priv->rgba.red * 65535);
+ color->green = (guint16) (button->priv->rgba.green * 65535);
+ color->blue = (guint16) (button->priv->rgba.blue * 65535);
}
/**
* gtk_color_button_get_alpha:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
*
* Returns the current alpha value.
*
@@ -743,16 +747,16 @@ gtk_color_button_get_color (GtkColorButton *color_button,
* Since: 2.4
*/
guint16
-gtk_color_button_get_alpha (GtkColorButton *color_button)
+gtk_color_button_get_alpha (GtkColorButton *button)
{
- g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), 0);
+ g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), 0);
- return (guint16) (color_button->priv->rgba.alpha * 65535);
+ return (guint16) (button->priv->rgba.alpha * 65535);
}
/**
* gtk_color_button_set_rgba:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @rgba: a #GdkRGBA to set the current color with
*
* Sets the current color to be @rgba.
@@ -760,24 +764,23 @@ gtk_color_button_get_alpha (GtkColorButton *color_button)
* Since: 3.0
*/
void
-gtk_color_button_set_rgba (GtkColorButton *color_button,
+gtk_color_button_set_rgba (GtkColorButton *button,
const GdkRGBA *rgba)
{
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
g_return_if_fail (rgba != NULL);
- color_button->priv->rgba = *rgba;
-
- gtk_widget_queue_draw (color_button->priv->draw_area);
+ button->priv->rgba = *rgba;
+ gtk_widget_queue_draw (button->priv->draw_area);
- g_object_notify (G_OBJECT (color_button), "color");
- g_object_notify (G_OBJECT (color_button), "alpha");
- g_object_notify (G_OBJECT (color_button), "rgba");
+ g_object_notify (G_OBJECT (button), "color");
+ g_object_notify (G_OBJECT (button), "alpha");
+ g_object_notify (G_OBJECT (button), "rgba");
}
/**
* gtk_color_button_get_rgba:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @rgba: (out): a #GdkRGBA to fill in with the current color
*
* Sets @rgba to be the current color in the #GtkColorButton widget.
@@ -785,18 +788,18 @@ gtk_color_button_set_rgba (GtkColorButton *color_button,
* Since: 3.0
*/
void
-gtk_color_button_get_rgba (GtkColorButton *color_button,
+gtk_color_button_get_rgba (GtkColorButton *button,
GdkRGBA *rgba)
{
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
g_return_if_fail (rgba != NULL);
- *rgba = color_button->priv->rgba;
+ *rgba = button->priv->rgba;
}
/**
* gtk_color_button_set_use_alpha:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @use_alpha: %TRUE if color button should use alpha channel, %FALSE if not
*
* Sets whether or not the color button should use the alpha channel.
@@ -804,26 +807,26 @@ gtk_color_button_get_rgba (GtkColorButton *color_button,
* Since: 2.4
*/
void
-gtk_color_button_set_use_alpha (GtkColorButton *color_button,
+gtk_color_button_set_use_alpha (GtkColorButton *button,
gboolean use_alpha)
{
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
use_alpha = (use_alpha != FALSE);
- if (color_button->priv->use_alpha != use_alpha)
+ if (button->priv->use_alpha != use_alpha)
{
- color_button->priv->use_alpha = use_alpha;
+ button->priv->use_alpha = use_alpha;
- gtk_widget_queue_draw (color_button->priv->draw_area);
+ gtk_widget_queue_draw (button->priv->draw_area);
- g_object_notify (G_OBJECT (color_button), "use-alpha");
+ g_object_notify (G_OBJECT (button), "use-alpha");
}
}
/**
* gtk_color_button_get_use_alpha:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
*
* Does the color selection dialog use the alpha channel ?
*
@@ -832,17 +835,17 @@ gtk_color_button_set_use_alpha (GtkColorButton *color_button,
* Since: 2.4
*/
gboolean
-gtk_color_button_get_use_alpha (GtkColorButton *color_button)
+gtk_color_button_get_use_alpha (GtkColorButton *button)
{
- g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), FALSE);
+ g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), FALSE);
- return color_button->priv->use_alpha;
+ return button->priv->use_alpha;
}
/**
* gtk_color_button_set_title:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
* @title: String containing new window title
*
* Sets the title for the color selection dialog.
@@ -850,27 +853,27 @@ gtk_color_button_get_use_alpha (GtkColorButton *color_button)
* Since: 2.4
*/
void
-gtk_color_button_set_title (GtkColorButton *color_button,
+gtk_color_button_set_title (GtkColorButton *button,
const gchar *title)
{
gchar *old_title;
- g_return_if_fail (GTK_IS_COLOR_BUTTON (color_button));
+ g_return_if_fail (GTK_IS_COLOR_BUTTON (button));
- old_title = color_button->priv->title;
- color_button->priv->title = g_strdup (title);
+ old_title = button->priv->title;
+ button->priv->title = g_strdup (title);
g_free (old_title);
- if (color_button->priv->cs_dialog)
- gtk_window_set_title (GTK_WINDOW (color_button->priv->cs_dialog),
- color_button->priv->title);
+ if (button->priv->cs_dialog)
+ gtk_window_set_title (GTK_WINDOW (button->priv->cs_dialog),
+ button->priv->title);
- g_object_notify (G_OBJECT (color_button), "title");
+ g_object_notify (G_OBJECT (button), "title");
}
/**
* gtk_color_button_get_title:
- * @color_button: a #GtkColorButton
+ * @button: a #GtkColorButton
*
* Gets the title of the color selection dialog.
*
@@ -879,11 +882,11 @@ gtk_color_button_set_title (GtkColorButton *color_button,
* Since: 2.4
*/
const gchar *
-gtk_color_button_get_title (GtkColorButton *color_button)
+gtk_color_button_get_title (GtkColorButton *button)
{
- g_return_val_if_fail (GTK_IS_COLOR_BUTTON (color_button), NULL);
+ g_return_val_if_fail (GTK_IS_COLOR_BUTTON (button), NULL);
- return color_button->priv->title;
+ return button->priv->title;
}
static void
@@ -892,15 +895,15 @@ gtk_color_button_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
+ GtkColorButton *button = GTK_COLOR_BUTTON (object);
switch (param_id)
{
case PROP_USE_ALPHA:
- gtk_color_button_set_use_alpha (color_button, g_value_get_boolean (value));
+ gtk_color_button_set_use_alpha (button, g_value_get_boolean (value));
break;
case PROP_TITLE:
- gtk_color_button_set_title (color_button, g_value_get_string (value));
+ gtk_color_button_set_title (button, g_value_get_string (value));
break;
case PROP_COLOR:
{
@@ -914,14 +917,14 @@ gtk_color_button_set_property (GObject *object,
rgba.blue = color->blue / 65535.0;
rgba.alpha = 1.0;
- gtk_color_button_set_rgba (color_button, &rgba);
+ gtk_color_button_set_rgba (button, &rgba);
}
break;
case PROP_ALPHA:
- gtk_color_button_set_alpha (color_button, g_value_get_uint (value));
+ gtk_color_button_set_alpha (button, g_value_get_uint (value));
break;
case PROP_RGBA:
- gtk_color_button_set_rgba (color_button, g_value_get_boxed (value));
+ gtk_color_button_set_rgba (button, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -935,22 +938,22 @@ gtk_color_button_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
- GtkColorButton *color_button = GTK_COLOR_BUTTON (object);
+ GtkColorButton *button = GTK_COLOR_BUTTON (object);
switch (param_id)
{
case PROP_USE_ALPHA:
- g_value_set_boolean (value, gtk_color_button_get_use_alpha (color_button));
+ g_value_set_boolean (value, gtk_color_button_get_use_alpha (button));
break;
case PROP_TITLE:
- g_value_set_string (value, gtk_color_button_get_title (color_button));
+ g_value_set_string (value, gtk_color_button_get_title (button));
break;
case PROP_COLOR:
{
GdkColor color;
GdkRGBA rgba;
- gtk_color_button_get_rgba (color_button, &rgba);
+ gtk_color_button_get_rgba (button, &rgba);
color.red = (guint16) (rgba.red * 65535 + 0.5);
color.green = (guint16) (rgba.green * 65535 + 0.5);
@@ -960,13 +963,13 @@ gtk_color_button_get_property (GObject *object,
}
break;
case PROP_ALPHA:
- g_value_set_uint (value, gtk_color_button_get_alpha (color_button));
+ g_value_set_uint (value, gtk_color_button_get_alpha (button));
break;
case PROP_RGBA:
{
GdkRGBA rgba;
- gtk_color_button_get_rgba (color_button, &rgba);
+ gtk_color_button_get_rgba (button, &rgba);
g_value_set_boxed (value, &rgba);
}
break;
@@ -975,3 +978,14 @@ gtk_color_button_get_property (GObject *object,
break;
}
}
+
+typedef void (* get_rgba) (GtkColorChooser *, GdkRGBA *);
+typedef void (* set_rgba) (GtkColorChooser *, const GdkRGBA *);
+
+static void
+gtk_color_button_iface_init (GtkColorChooserInterface *iface)
+{
+ iface->get_rgba = (get_rgba)gtk_color_button_get_rgba;
+ iface->set_rgba = (set_rgba)gtk_color_button_set_rgba;
+}
+
diff --git a/gtk/gtkcolorbutton.h b/gtk/gtkcolorbutton.h
index 8f2d2ca..47ed059 100644
--- a/gtk/gtkcolorbutton.h
+++ b/gtk/gtkcolorbutton.h
@@ -73,32 +73,37 @@ struct _GtkColorButtonClass {
};
-GType gtk_color_button_get_type (void) G_GNUC_CONST;
-GtkWidget *gtk_color_button_new (void);
-GtkWidget *gtk_color_button_new_with_rgba (const GdkRGBA *rgba);
-void gtk_color_button_set_alpha (GtkColorButton *color_button,
- guint16 alpha);
-guint16 gtk_color_button_get_alpha (GtkColorButton *color_button);
-void gtk_color_button_set_use_alpha (GtkColorButton *color_button,
- gboolean use_alpha);
-gboolean gtk_color_button_get_use_alpha (GtkColorButton *color_button);
-void gtk_color_button_set_rgba (GtkColorButton *color_button,
- const GdkRGBA *rgba);
-void gtk_color_button_get_rgba (GtkColorButton *color_button,
- GdkRGBA *rgba);
-void gtk_color_button_set_title (GtkColorButton *color_button,
- const gchar *title);
-const gchar *gtk_color_button_get_title (GtkColorButton *color_button);
+GType gtk_color_button_get_type (void) G_GNUC_CONST;
+GtkWidget * gtk_color_button_new (void);
+GtkWidget * gtk_color_button_new_with_rgba (const GdkRGBA *rgba);
+void gtk_color_button_set_title (GtkColorButton *button,
+ const gchar *title);
+const gchar *gtk_color_button_get_title (GtkColorButton *button);
GDK_DEPRECATED_FOR(gtk_color_button_new_with_rgba)
GtkWidget *gtk_color_button_new_with_color (const GdkColor *color);
GDK_DEPRECATED_FOR(gtk_color_button_set_rgba)
-void gtk_color_button_set_color (GtkColorButton *color_button,
+void gtk_color_button_set_color (GtkColorButton *button,
const GdkColor *color);
GDK_DEPRECATED_FOR(gtk_color_button_get_rgba)
-void gtk_color_button_get_color (GtkColorButton *color_button,
+void gtk_color_button_get_color (GtkColorButton *button,
GdkColor *color);
-
+GDK_DEPRECATED_FOR(gtk_color_button_set_rgba)
+void gtk_color_button_set_alpha (GtkColorButton *button,
+ guint16 alpha);
+GDK_DEPRECATED_FOR(gtk_color_button_get_rgba)
+guint16 gtk_color_button_get_alpha (GtkColorButton *button);
+GDK_DEPRECATED_FOR(gtk_color_chooser_set_use_alpha)
+void gtk_color_button_set_use_alpha (GtkColorButton *button,
+ gboolean use_alpha);
+GDK_DEPRECATED_FOR(gtk_color_chooser_get_use_alpha)
+gboolean gtk_color_button_get_use_alpha (GtkColorButton *button);
+GDK_DEPRECATED_FOR(gtk_color_chooser_set_rgba)
+void gtk_color_button_set_rgba (GtkColorButton *button,
+ const GdkRGBA *rgba);
+GDK_DEPRECATED_FOR(gtk_color_chooser_get_rgba)
+void gtk_color_button_get_rgba (GtkColorButton *button,
+ GdkRGBA *rgba);
G_END_DECLS
diff --git a/gtk/gtkcolorchooser.c b/gtk/gtkcolorchooser.c
index 9013d2c..563ba9a 100644
--- a/gtk/gtkcolorchooser.c
+++ b/gtk/gtkcolorchooser.c
@@ -40,15 +40,15 @@ static void
gtk_color_chooser_default_init (GtkColorChooserInterface *iface)
{
g_object_interface_install_property (iface,
- g_param_spec_boxed ("color",
+ g_param_spec_boxed ("rgba",
P_("Color"),
P_("Current color, as a GdkRGBA"),
GDK_TYPE_RGBA,
GTK_PARAM_READWRITE));
g_object_interface_install_property (iface,
- g_param_spec_boolean ("show-alpha",
- P_("Show alpha"),
+ g_param_spec_boolean ("use-alpha",
+ P_("Use alpha"),
P_("Whether alpha should be shown"),
TRUE,
GTK_PARAM_READWRITE));
@@ -75,36 +75,36 @@ gtk_color_chooser_default_init (GtkColorChooserInterface *iface)
}
/**
- * gtk_color_chooser_get_color:
+ * gtk_color_chooser_get_rgba:
* @chooser: a #GtkColorChooser
* @color: return location for the color
*
* Gets the currently-selected color.
*/
void
-gtk_color_chooser_get_color (GtkColorChooser *chooser,
- GdkRGBA *color)
+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_color (chooser, color);
+ GTK_COLOR_CHOOSER_GET_IFACE (chooser)->get_rgba (chooser, color);
}
/**
- * gtk_color_chooser_set_color:
+ * gtk_color_chooser_set_rgba:
* @chooser: a #GtkColorChooser
* @color: the new color
*
* Sets the currently-selected color.
*/
void
-gtk_color_chooser_set_color (GtkColorChooser *chooser,
- const GdkRGBA *color)
+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_color (chooser, color);
+ GTK_COLOR_CHOOSER_GET_IFACE (chooser)->set_rgba (chooser, color);
}
void
@@ -117,23 +117,23 @@ _gtk_color_chooser_color_activated (GtkColorChooser *chooser,
}
gboolean
-gtk_color_chooser_get_show_alpha (GtkColorChooser *chooser)
+gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser)
{
- gboolean show_alpha;
+ gboolean use_alpha;
g_return_val_if_fail (GTK_IS_COLOR_CHOOSER (chooser), TRUE);
- g_object_get (chooser, "show-alpha", &show_alpha, NULL);
+ g_object_get (chooser, "use-alpha", &use_alpha, NULL);
- return show_alpha;
+ return use_alpha;
}
void
-gtk_color_chooser_set_show_alpha (GtkColorChooser *chooser,
- gboolean show_alpha)
+gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
+ gboolean use_alpha)
{
g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
- g_object_set (chooser, "show-alpha", show_alpha, NULL);
+ g_object_set (chooser, "use-alpha", use_alpha, NULL);
}
diff --git a/gtk/gtkcolorchooser.h b/gtk/gtkcolorchooser.h
index 3d38c0f..287c551 100644
--- a/gtk/gtkcolorchooser.h
+++ b/gtk/gtkcolorchooser.h
@@ -42,10 +42,10 @@ struct _GtkColorChooserInterface
GTypeInterface base_interface;
/* Methods */
- void (* get_color) (GtkColorChooser *chooser,
- GdkRGBA *color);
- void (* set_color) (GtkColorChooser *chooser,
- const GdkRGBA *color);
+ void (* get_rgba) (GtkColorChooser *chooser,
+ GdkRGBA *color);
+ void (* set_rgba) (GtkColorChooser *chooser,
+ const GdkRGBA *color);
/* Signals */
void (* color_activated) (GtkColorChooser *chooser,
@@ -57,13 +57,13 @@ struct _GtkColorChooserInterface
GType gtk_color_chooser_get_type (void) G_GNUC_CONST;
-void gtk_color_chooser_get_color (GtkColorChooser *chooser,
- GdkRGBA *color);
-void gtk_color_chooser_set_color (GtkColorChooser *chooser,
- const GdkRGBA *color);
-gboolean gtk_color_chooser_get_show_alpha (GtkColorChooser *chooser);
-void gtk_color_chooser_set_show_alpha (GtkColorChooser *chooser,
- gboolean show_alpha);
+void gtk_color_chooser_get_rgba (GtkColorChooser *chooser,
+ GdkRGBA *color);
+void gtk_color_chooser_set_rgba (GtkColorChooser *chooser,
+ const GdkRGBA *color);
+gboolean gtk_color_chooser_get_use_alpha (GtkColorChooser *chooser);
+void gtk_color_chooser_set_use_alpha (GtkColorChooser *chooser,
+ gboolean show_alpha);
G_END_DECLS
diff --git a/gtk/gtkcolorchooserwidget.c b/gtk/gtkcolorchooserwidget.c
index a299f98..b079b90 100644
--- a/gtk/gtkcolorchooserwidget.c
+++ b/gtk/gtkcolorchooserwidget.c
@@ -45,7 +45,7 @@ struct _GtkColorChooserWidgetPrivate
GtkWidget *button;
GtkColorSwatch *current;
- gboolean show_alpha;
+ gboolean use_alpha;
GtkSizeGroup *size_group;
@@ -55,8 +55,8 @@ struct _GtkColorChooserWidgetPrivate
enum
{
PROP_ZERO,
- PROP_COLOR,
- PROP_SHOW_ALPHA,
+ PROP_RGBA,
+ PROP_USE_ALPHA,
PROP_SHOW_EDITOR
};
@@ -78,11 +78,11 @@ select_swatch (GtkColorChooserWidget *cc,
gtk_color_swatch_set_selected (cc->priv->current, FALSE);
gtk_color_swatch_set_selected (swatch, TRUE);
cc->priv->current = swatch;
- gtk_color_swatch_get_color (swatch, &color);
+ gtk_color_swatch_get_rgba (swatch, &color);
g_settings_set (cc->priv->settings, "selected-color", "(bdddd)",
TRUE, color.red, color.green, color.blue, color.alpha);
- g_object_notify (G_OBJECT (cc), "color");
+ g_object_notify (G_OBJECT (cc), "rgba");
}
static void save_custom_colors (GtkColorChooserWidget *cc);
@@ -99,7 +99,7 @@ button_activate (GtkColorSwatch *swatch,
color.blue = 0.25;
color.alpha = 1.0;
- gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (cc->priv->editor), &color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc->priv->editor), &color);
gtk_widget_hide (cc->priv->palette);
gtk_widget_show (cc->priv->editor);
@@ -111,7 +111,7 @@ swatch_activate (GtkColorSwatch *swatch,
{
GdkRGBA color;
- gtk_color_swatch_get_color (swatch, &color);
+ gtk_color_swatch_get_rgba (swatch, &color);
_gtk_color_chooser_color_activated (GTK_COLOR_CHOOSER (cc), &color);
}
@@ -121,8 +121,8 @@ swatch_customize (GtkColorSwatch *swatch,
{
GdkRGBA color;
- gtk_color_swatch_get_color (swatch, &color);
- gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (cc->priv->editor), &color);
+ gtk_color_swatch_get_rgba (swatch, &color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc->priv->editor), &color);
gtk_widget_hide (cc->priv->palette);
gtk_widget_show (cc->priv->editor);
@@ -173,7 +173,7 @@ save_custom_colors (GtkColorChooserWidget *cc)
while ((child = gtk_grid_get_child_at (GTK_GRID (cc->priv->custom), i, 0)) != NULL)
{
i++;
- if (gtk_color_swatch_get_color (GTK_COLOR_SWATCH (child), &color))
+ if (gtk_color_swatch_get_rgba (GTK_COLOR_SWATCH (child), &color))
{
g_variant_builder_add (&builder, "(dddd)",
color.red, color.green, color.blue, color.alpha);
@@ -249,7 +249,7 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
else
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (p), 1, 1, 1, 1);
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (p), &color);
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), &color);
gtk_grid_attach (GTK_GRID (grid), p, i, j, 1, 1);
}
}
@@ -275,7 +275,7 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
else
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (p), 1, 1, 1, 1);
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (p), &color);
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), &color);
gtk_grid_attach (GTK_GRID (grid), p, i, 0, 1, 1);
}
@@ -305,7 +305,7 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
i++;
p = gtk_color_swatch_new ();
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (p), 1, 1, 1, 1);
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (p), &color);
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), &color);
gtk_color_swatch_set_can_drop (GTK_COLOR_SWATCH (p), TRUE);
connect_custom_signals (p, cc);
gtk_grid_attach (GTK_GRID (grid), p, i, 0, 1, 1);
@@ -338,7 +338,7 @@ gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
&selected,
&color.red, &color.green, &color.blue, &color.alpha);
if (selected)
- gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (cc), &color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc), &color);
gtk_widget_show_all (GTK_WIDGET (cc));
gtk_widget_hide (GTK_WIDGET (cc->priv->editor));
@@ -363,16 +363,16 @@ gtk_color_chooser_widget_get_property (GObject *object,
switch (prop_id)
{
- case PROP_COLOR:
+ case PROP_RGBA:
{
GdkRGBA color;
- gtk_color_chooser_get_color (cc, &color);
+ gtk_color_chooser_get_rgba (cc, &color);
g_value_set_boxed (value, &color);
}
break;
- case PROP_SHOW_ALPHA:
- g_value_set_boolean (value, cw->priv->show_alpha);
+ case PROP_USE_ALPHA:
+ g_value_set_boolean (value, cw->priv->use_alpha);
break;
case PROP_SHOW_EDITOR:
g_value_set_boolean (value, gtk_widget_get_visible (cw->priv->editor));
@@ -384,16 +384,16 @@ gtk_color_chooser_widget_get_property (GObject *object,
}
static void
-gtk_color_chooser_widget_set_show_alpha (GtkColorChooserWidget *cc,
- gboolean show_alpha)
+gtk_color_chooser_widget_set_use_alpha (GtkColorChooserWidget *cc,
+ gboolean use_alpha)
{
GtkWidget *grids[3];
gint i;
GList *children, *l;
GtkWidget *swatch;
- cc->priv->show_alpha = show_alpha;
- gtk_color_chooser_set_show_alpha (GTK_COLOR_CHOOSER (cc->priv->editor), show_alpha);
+ cc->priv->use_alpha = use_alpha;
+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (cc->priv->editor), use_alpha);
grids[0] = cc->priv->colors;
grids[1] = cc->priv->grays;
@@ -405,7 +405,7 @@ gtk_color_chooser_widget_set_show_alpha (GtkColorChooserWidget *cc,
for (l = children; l; l = l->next)
{
swatch = l->data;
- gtk_color_swatch_set_show_alpha (GTK_COLOR_SWATCH (swatch), show_alpha);
+ gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (swatch), use_alpha);
}
g_list_free (children);
}
@@ -431,13 +431,13 @@ gtk_color_chooser_widget_set_property (GObject *object,
switch (prop_id)
{
- case PROP_COLOR:
- gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (cc),
- g_value_get_boxed (value));
+ case PROP_RGBA:
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (cc),
+ g_value_get_boxed (value));
break;
- case PROP_SHOW_ALPHA:
- gtk_color_chooser_widget_set_show_alpha (cc,
- g_value_get_boolean (value));
+ case PROP_USE_ALPHA:
+ gtk_color_chooser_widget_set_use_alpha (cc,
+ g_value_get_boolean (value));
break;
case PROP_SHOW_EDITOR:
gtk_color_chooser_widget_set_show_editor (cc,
@@ -469,8 +469,8 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class)
object_class->set_property = gtk_color_chooser_widget_set_property;
object_class->finalize = gtk_color_chooser_widget_finalize;
- g_object_class_override_property (object_class, PROP_COLOR, "color");
- g_object_class_override_property (object_class, PROP_SHOW_ALPHA, "show-alpha");
+ g_object_class_override_property (object_class, PROP_RGBA, "rgba");
+ g_object_class_override_property (object_class, PROP_USE_ALPHA, "use-alpha");
g_object_class_install_property (object_class, PROP_SHOW_EDITOR,
g_param_spec_boolean ("show-editor", P_("Show editor"), P_("Show editor"),
@@ -480,15 +480,15 @@ gtk_color_chooser_widget_class_init (GtkColorChooserWidgetClass *class)
}
static void
-gtk_color_chooser_widget_get_color (GtkColorChooser *chooser,
- GdkRGBA *color)
+gtk_color_chooser_widget_get_rgba (GtkColorChooser *chooser,
+ GdkRGBA *color)
{
GtkColorChooserWidget *cc = GTK_COLOR_CHOOSER_WIDGET (chooser);
if (gtk_widget_get_visible (cc->priv->editor))
- gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (cc->priv->editor), color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (cc->priv->editor), color);
else if (cc->priv->current)
- gtk_color_swatch_get_color (cc->priv->current, color);
+ gtk_color_swatch_get_rgba (cc->priv->current, color);
else
{
color->red = 1.0;
@@ -497,7 +497,7 @@ gtk_color_chooser_widget_get_color (GtkColorChooser *chooser,
color->alpha = 1.0;
}
- if (!cc->priv->show_alpha)
+ if (!cc->priv->use_alpha)
color->alpha = 1.0;
}
@@ -519,7 +519,7 @@ add_custom_color (GtkColorChooserWidget *cc,
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (cc->priv->button), 10, 1, 1, 10);
p = gtk_color_swatch_new ();
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (p), color);
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (p), color);
gtk_color_swatch_set_can_drop (GTK_COLOR_SWATCH (p), TRUE);
connect_custom_signals (p, cc);
@@ -537,8 +537,8 @@ add_custom_color (GtkColorChooserWidget *cc,
}
static void
-gtk_color_chooser_widget_set_color (GtkColorChooser *chooser,
- const GdkRGBA *color)
+gtk_color_chooser_widget_set_rgba (GtkColorChooser *chooser,
+ const GdkRGBA *color)
{
GtkColorChooserWidget *cc = GTK_COLOR_CHOOSER_WIDGET (chooser);
GList *children, *l;
@@ -557,8 +557,8 @@ gtk_color_chooser_widget_set_color (GtkColorChooser *chooser,
for (l = children; l; l = l->next)
{
swatch = l->data;
- gtk_color_swatch_get_color (swatch, &c);
- if (!cc->priv->show_alpha)
+ gtk_color_swatch_get_rgba (swatch, &c);
+ if (!cc->priv->use_alpha)
c.alpha = color->alpha;
if (gdk_rgba_equal (color, &c))
{
@@ -576,8 +576,8 @@ gtk_color_chooser_widget_set_color (GtkColorChooser *chooser,
static void
gtk_color_chooser_widget_iface_init (GtkColorChooserInterface *iface)
{
- iface->get_color = gtk_color_chooser_widget_get_color;
- iface->set_color = gtk_color_chooser_widget_set_color;
+ iface->get_rgba = gtk_color_chooser_widget_get_rgba;
+ iface->set_rgba = gtk_color_chooser_widget_set_rgba;
}
GtkWidget *
diff --git a/gtk/gtkcoloreditor.c b/gtk/gtkcoloreditor.c
index 1e5146c..80a91c4 100644
--- a/gtk/gtkcoloreditor.c
+++ b/gtk/gtkcoloreditor.c
@@ -75,14 +75,14 @@ struct _GtkColorEditorPrivate
GtkAdjustment *a_adj;
guint text_changed : 1;
- guint show_alpha : 1;
+ guint use_alpha : 1;
};
enum
{
PROP_ZERO,
- PROP_COLOR,
- PROP_SHOW_ALPHA
+ PROP_RGBA,
+ PROP_USE_ALPHA
};
static void gtk_color_editor_iface_init (GtkColorChooserInterface *iface);
@@ -135,7 +135,7 @@ entry_apply (GtkWidget *entry,
if (gdk_rgba_parse (&color, text))
{
color.alpha = gtk_adjustment_get_value (editor->priv->a_adj);
- gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (editor), &color);
+ gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (editor), &color);
}
editor->priv->text_changed = FALSE;
@@ -172,9 +172,9 @@ hsv_changed (GtkColorEditor *editor)
gtk_hsv_to_rgb (h, s, v, &color.red, &color.green, &color.blue);
color.alpha = gtk_adjustment_get_value (editor->priv->a_adj);
update_entry (editor);
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (editor->priv->swatch), &color);
- gtk_color_scale_set_color (GTK_COLOR_SCALE (editor->priv->a_slider), &color);
- g_object_notify (G_OBJECT (editor), "color");
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (editor->priv->swatch), &color);
+ gtk_color_scale_set_rgba (GTK_COLOR_SCALE (editor->priv->a_slider), &color);
+ g_object_notify (G_OBJECT (editor), "rgba");
}
static void
@@ -357,7 +357,7 @@ gtk_color_editor_init (GtkColorEditor *editor)
editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (editor,
GTK_TYPE_COLOR_EDITOR,
GtkColorEditorPrivate);
- editor->priv->show_alpha = TRUE;
+ editor->priv->use_alpha = TRUE;
editor->priv->h_adj = gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0);
editor->priv->s_adj = gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 0);
@@ -529,14 +529,14 @@ gtk_color_editor_get_property (GObject *object,
switch (prop_id)
{
- case PROP_COLOR:
+ case PROP_RGBA:
{
GdkRGBA color;
- gtk_color_chooser_get_color (cc, &color);
+ gtk_color_chooser_get_rgba (cc, &color);
g_value_set_boxed (value, &color);
}
break;
- case PROP_SHOW_ALPHA:
+ case PROP_USE_ALPHA:
g_value_set_boolean (value, gtk_widget_get_visible (ce->priv->a_slider));
break;
default:
@@ -546,16 +546,14 @@ gtk_color_editor_get_property (GObject *object,
}
static void
-gtk_color_editor_set_show_alpha (GtkColorEditor *editor,
- gboolean show_alpha)
+gtk_color_editor_set_use_alpha (GtkColorEditor *editor,
+ gboolean use_alpha)
{
- if (editor->priv->show_alpha != show_alpha)
+ if (editor->priv->use_alpha != use_alpha)
{
- editor->priv->show_alpha = show_alpha;
-
- gtk_widget_set_visible (editor->priv->a_slider, show_alpha);
-
- gtk_color_swatch_set_show_alpha (GTK_COLOR_SWATCH (editor->priv->swatch), show_alpha);
+ editor->priv->use_alpha = use_alpha;
+ gtk_widget_set_visible (editor->priv->a_slider, use_alpha);
+ gtk_color_swatch_set_use_alpha (GTK_COLOR_SWATCH (editor->priv->swatch), use_alpha);
}
}
@@ -570,11 +568,11 @@ gtk_color_editor_set_property (GObject *object,
switch (prop_id)
{
- case PROP_COLOR:
- gtk_color_chooser_set_color (cc, g_value_get_boxed (value));
+ case PROP_RGBA:
+ gtk_color_chooser_set_rgba (cc, g_value_get_boxed (value));
break;
- case PROP_SHOW_ALPHA:
- gtk_color_editor_set_show_alpha (ce, g_value_get_boolean (value));
+ case PROP_USE_ALPHA:
+ gtk_color_editor_set_use_alpha (ce, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -604,15 +602,15 @@ gtk_color_editor_class_init (GtkColorEditorClass *class)
object_class->get_property = gtk_color_editor_get_property;
object_class->set_property = gtk_color_editor_set_property;
- g_object_class_override_property (object_class, PROP_COLOR, "color");
- g_object_class_override_property (object_class, PROP_SHOW_ALPHA, "show-alpha");
+ g_object_class_override_property (object_class, PROP_RGBA, "rgba");
+ g_object_class_override_property (object_class, PROP_USE_ALPHA, "use-alpha");
g_type_class_add_private (class, sizeof (GtkColorEditorPrivate));
}
static void
-gtk_color_editor_get_color (GtkColorChooser *chooser,
- GdkRGBA *color)
+gtk_color_editor_get_rgba (GtkColorChooser *chooser,
+ GdkRGBA *color)
{
GtkColorEditor *editor = GTK_COLOR_EDITOR (chooser);
gdouble h, s, v;
@@ -625,8 +623,8 @@ gtk_color_editor_get_color (GtkColorChooser *chooser,
}
static void
-gtk_color_editor_set_color (GtkColorChooser *chooser,
- const GdkRGBA *color)
+gtk_color_editor_set_rgba (GtkColorChooser *chooser,
+ const GdkRGBA *color)
{
GtkColorEditor *editor = GTK_COLOR_EDITOR (chooser);
gdouble h, s, v;
@@ -637,21 +635,21 @@ gtk_color_editor_set_color (GtkColorChooser *chooser,
gtk_adjustment_set_value (editor->priv->s_adj, s);
gtk_adjustment_set_value (editor->priv->v_adj, v);
gtk_adjustment_set_value (editor->priv->a_adj, color->alpha);
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (editor->priv->swatch), color);
- gtk_color_scale_set_color (GTK_COLOR_SCALE (editor->priv->a_slider), color);
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (editor->priv->swatch), color);
+ gtk_color_scale_set_rgba (GTK_COLOR_SCALE (editor->priv->a_slider), color);
update_entry (editor);
gtk_widget_queue_draw (GTK_WIDGET (editor));
- g_object_notify (G_OBJECT (editor), "color");
+ g_object_notify (G_OBJECT (editor), "rgba");
}
static void
gtk_color_editor_iface_init (GtkColorChooserInterface *iface)
{
- iface->get_color = gtk_color_editor_get_color;
- iface->set_color = gtk_color_editor_set_color;
+ iface->get_rgba = gtk_color_editor_get_rgba;
+ iface->set_rgba = gtk_color_editor_set_rgba;
}
GtkWidget *
diff --git a/gtk/gtkcolorscale.c b/gtk/gtkcolorscale.c
index a5cbae5..fb0f5db 100644
--- a/gtk/gtkcolorscale.c
+++ b/gtk/gtkcolorscale.c
@@ -293,8 +293,8 @@ gtk_color_scale_class_init (GtkColorScaleClass *class)
}
void
-gtk_color_scale_set_color (GtkColorScale *scale,
- const GdkRGBA *color)
+gtk_color_scale_set_rgba (GtkColorScale *scale,
+ const GdkRGBA *color)
{
scale->priv->color.red = color->red;
scale->priv->color.green = color->green;
diff --git a/gtk/gtkcolorscale.h b/gtk/gtkcolorscale.h
index 767b010..acb5888 100644
--- a/gtk/gtkcolorscale.h
+++ b/gtk/gtkcolorscale.h
@@ -65,15 +65,15 @@ typedef enum
} GtkColorScaleType;
G_GNUC_INTERNAL
-GType gtk_color_scale_get_type (void) G_GNUC_CONST;
+GType gtk_color_scale_get_type (void) G_GNUC_CONST;
G_GNUC_INTERNAL
-GtkWidget * gtk_color_scale_new (GtkAdjustment *adjustment,
- GtkColorScaleType type);
+GtkWidget * gtk_color_scale_new (GtkAdjustment *adjustment,
+ GtkColorScaleType type);
G_GNUC_INTERNAL
-void gtk_color_scale_set_color (GtkColorScale *scale,
- const GdkRGBA *color);
+void gtk_color_scale_set_rgba (GtkColorScale *scale,
+ const GdkRGBA *color);
G_END_DECLS
diff --git a/gtk/gtkcolorswatch.c b/gtk/gtkcolorswatch.c
index c376860..60973d3 100644
--- a/gtk/gtkcolorswatch.c
+++ b/gtk/gtkcolorswatch.c
@@ -41,13 +41,13 @@ struct _GtkColorSwatchPrivate
guint has_color : 1;
guint can_drop : 1;
guint contains_pointer : 1;
- guint show_alpha : 1;
+ guint use_alpha : 1;
};
enum
{
PROP_ZERO,
- PROP_COLOR,
+ PROP_RGBA,
PROP_SELECTED
};
@@ -75,7 +75,7 @@ gtk_color_swatch_init (GtkColorSwatch *swatch)
| GDK_EXPOSURE_MASK
| GDK_ENTER_NOTIFY_MASK
| GDK_LEAVE_NOTIFY_MASK);
- swatch->priv->show_alpha = TRUE;
+ swatch->priv->use_alpha = TRUE;
}
static void
@@ -146,7 +146,7 @@ swatch_draw (GtkWidget *widget,
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
- if (swatch->priv->show_alpha)
+ if (swatch->priv->use_alpha)
{
cairo_set_source_rgb (cr, 0.33, 0.33, 0.33);
cairo_fill_preserve (cr);
@@ -251,7 +251,7 @@ swatch_drag_begin (GtkWidget *widget,
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
GdkRGBA color;
- gtk_color_swatch_get_color (swatch, &color);
+ gtk_color_swatch_get_rgba (swatch, &color);
drag_set_color_icon (context, &color);
}
@@ -266,7 +266,7 @@ swatch_drag_data_get (GtkWidget *widget,
guint16 vals[4];
GdkRGBA color;
- gtk_color_swatch_get_color (swatch, &color);
+ gtk_color_swatch_get_rgba (swatch, &color);
vals[0] = color.red * 0xffff;
vals[1] = color.green * 0xffff;
@@ -312,7 +312,7 @@ swatch_drag_data_received (GtkWidget *widget,
color.blue = (gdouble)vals[2] / 0xffff;
color.alpha = (gdouble)vals[3] / 0xffff;
- gtk_color_swatch_set_color (GTK_COLOR_SWATCH (widget), &color);
+ gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (widget), &color);
}
static void
@@ -326,8 +326,8 @@ swatch_get_property (GObject *object,
switch (prop_id)
{
- case PROP_COLOR:
- gtk_color_swatch_get_color (swatch, &color);
+ case PROP_RGBA:
+ gtk_color_swatch_get_rgba (swatch, &color);
g_value_set_boxed (value, &color);
break;
case PROP_SELECTED:
@@ -349,8 +349,8 @@ swatch_set_property (GObject *object,
switch (prop_id)
{
- case PROP_COLOR:
- gtk_color_swatch_set_color (swatch, g_value_get_boxed (value));
+ case PROP_RGBA:
+ gtk_color_swatch_set_rgba (swatch, g_value_get_boxed (value));
break;
case PROP_SELECTED:
gtk_color_swatch_set_selected (swatch, g_value_get_boolean (value));
@@ -585,8 +585,8 @@ gtk_color_swatch_class_init (GtkColorSwatchClass *class)
G_STRUCT_OFFSET (GtkColorSwatchClass, customize),
NULL, NULL, NULL, G_TYPE_NONE, 0);
- g_object_class_install_property (object_class, PROP_COLOR,
- g_param_spec_boxed ("color", P_("Color"), P_("Color"),
+ g_object_class_install_property (object_class, PROP_RGBA,
+ g_param_spec_boxed ("rgba", P_("RGBA Color"), P_("Color as RGBA"),
GDK_TYPE_RGBA, GTK_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_SELECTED,
@@ -606,8 +606,8 @@ gtk_color_swatch_new (void)
}
void
-gtk_color_swatch_set_color (GtkColorSwatch *swatch,
- const GdkRGBA *color)
+gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
+ const GdkRGBA *color)
{
static const GtkTargetEntry targets[] = {
{ "application/x-color", 0 }
@@ -626,12 +626,12 @@ gtk_color_swatch_set_color (GtkColorSwatch *swatch,
swatch->priv->color.alpha = color->alpha;
gtk_widget_queue_draw (GTK_WIDGET (swatch));
- g_object_notify (G_OBJECT (swatch), "color");
+ g_object_notify (G_OBJECT (swatch), "rgba");
}
gboolean
-gtk_color_swatch_get_color (GtkColorSwatch *swatch,
- GdkRGBA *color)
+gtk_color_swatch_get_rgba (GtkColorSwatch *swatch,
+ GdkRGBA *color)
{
if (swatch->priv->has_color)
{
@@ -706,10 +706,10 @@ gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
}
void
-gtk_color_swatch_set_show_alpha (GtkColorSwatch *swatch,
- gboolean show_alpha)
+gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch,
+ gboolean use_alpha)
{
- swatch->priv->show_alpha = show_alpha;
+ swatch->priv->use_alpha = use_alpha;
gtk_widget_queue_draw (GTK_WIDGET (swatch));
}
diff --git a/gtk/gtkcolorswatch.h b/gtk/gtkcolorswatch.h
index 10f6cd8..afb6d27 100644
--- a/gtk/gtkcolorswatch.h
+++ b/gtk/gtkcolorswatch.h
@@ -75,10 +75,10 @@ void gtk_color_swatch_set_corner_radii (GtkColorSwatch *swatch,
gdouble bottom_right,
gdouble bottom_left);
G_GNUC_INTERNAL
-void gtk_color_swatch_set_color (GtkColorSwatch *swatch,
+void gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
const GdkRGBA *color);
G_GNUC_INTERNAL
-gboolean gtk_color_swatch_get_color (GtkColorSwatch *swatch,
+gboolean gtk_color_swatch_get_rgba (GtkColorSwatch *swatch,
GdkRGBA *color);
G_GNUC_INTERNAL
void gtk_color_swatch_set_selected (GtkColorSwatch *swatch,
@@ -90,8 +90,8 @@ G_GNUC_INTERNAL
void gtk_color_swatch_set_icon (GtkColorSwatch *swatch,
const gchar *icon);
G_GNUC_INTERNAL
-void gtk_color_swatch_set_show_alpha (GtkColorSwatch *swatch,
- gboolean show_alpha);
+void gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch,
+ gboolean use_alpha);
G_END_DECLS
diff --git a/tests/testcolorchooser.c b/tests/testcolorchooser.c
index c07d169..9c67bcd 100644
--- a/tests/testcolorchooser.c
+++ b/tests/testcolorchooser.c
@@ -5,7 +5,7 @@ color_changed (GObject *o, GParamSpec *pspect, gpointer data)
{
GdkRGBA color;
- gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (o), &color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (o), &color);
g_print ("color changed: %g %g %g %g\n",
color.red, color.green, color.blue, color.alpha);
}
@@ -18,7 +18,7 @@ dialog_response (GtkDialog *dialog, gint response)
switch (response)
{
case GTK_RESPONSE_OK:
- gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (dialog), &color);
+ gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &color);
g_print ("color accepted: %g %g %g %g\n",
color.red, color.green, color.blue, color.alpha);
break;
@@ -38,10 +38,10 @@ main (int argc, char *argv[])
gtk_init (NULL, NULL);
dialog = gtk_color_chooser_dialog_new ("Select a color", NULL);
- if (argc > 1 && strcmp (argv[1], "--no-alpha") == 0)
+ if (argc > 1 && g_strcmp0 (argv[1], "--no-alpha") == 0)
{
g_print ("turning alpha off\n");
- gtk_color_chooser_set_show_alpha (GTK_COLOR_CHOOSER (dialog), FALSE);
+ gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (dialog), FALSE);
}
g_signal_connect (dialog, "notify::color", G_CALLBACK (color_changed), NULL);
g_signal_connect (dialog, "response", G_CALLBACK (dialog_response), NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]