Commit 3b6e316e authored by Matthias Clasen's avatar Matthias Clasen

Initial cut at implementing a new color chooser

This is a partial implementation of
https://live.gnome.org/GnomeOS/Design/Whiteboards/ColorSelection
The new color editor has not been implemented yet.
parent e2bde552
......@@ -217,6 +217,9 @@ gtk_public_h_sources = \
gtkcolorbutton.h \
gtkcolorsel.h \
gtkcolorseldialog.h \
gtkcolorchooser.h \
gtkcolorchooserwidget.h \
gtkcolorchooserdialog.h \
gtkcombobox.h \
gtkcomboboxtext.h \
gtkcontainer.h \
......@@ -410,6 +413,9 @@ gtk_private_h_sources = \
gtkbuilderprivate.h \
gtkbuttonprivate.h \
gtkcellareaboxcontextprivate.h \
gtkcolorswatch.h \
gtkcoloreditor.h \
gtkcolorchooserprivate.h \
gtkcontainerprivate.h \
gtkcsscomputedvaluesprivate.h \
gtkcsscustompropertyprivate.h \
......@@ -592,6 +598,11 @@ gtk_base_c_sources = \
gtkcolorbutton.c \
gtkcolorsel.c \
gtkcolorseldialog.c \
gtkcoloreditor.c \
gtkcolorswatch.c \
gtkcolorchooser.c \
gtkcolorchooserwidget.c \
gtkcolorchooserdialog.c \
gtkcombobox.c \
gtkcomboboxtext.c \
gtkcontainer.c \
......@@ -1562,10 +1573,12 @@ EXTRA_DIST += \
gtktypebuiltins.h.template \
gtkprivatetypebuiltins.c.template \
gtkprivatetypebuiltins.h.template \
org.gtk.Settings.FileChooser.gschema.xml
org.gtk.Settings.FileChooser.gschema.xml \
org.gtk.Settings.ColorChooser.gschema.xml
gsettings_SCHEMAS = \
org.gtk.Settings.FileChooser.gschema.xml
org.gtk.Settings.FileChooser.gschema.xml \
org.gtk.Settings.ColorChooser.gschema.xml
@GSETTINGS_RULES@
......
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gtkcolorchooser.h"
#include "gtkcolorchooserprivate.h"
#include "gtkintl.h"
#include "gtktypebuiltins.h"
#include "gtkprivate.h"
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)
{
g_object_interface_install_property (iface,
g_param_spec_boxed ("color",
P_("Color"),
P_("Current color, as a GdkRGBA"),
GDK_TYPE_RGBA,
GTK_PARAM_READWRITE));
/**
* GtkColorChooser::color-activated:
* @self: 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 ("color-activated",
GTK_TYPE_COLOR_CHOOSER,
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkColorChooserInterface, color_activated),
NULL, NULL,
NULL,
G_TYPE_NONE,
1, G_TYPE_STRING);
}
/**
* gtk_color_chooser_get_color:
* @chooser: a #GtkColorChooser
* @color: return location for the color
*
* Gets the currently-selected color.
*/
void
gtk_color_chooser_get_color (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_set_color:
* @chooser: a #GtkColorChooser
* @color: the new color
*
* Sets the currently-selected color.
*/
void
gtk_color_chooser_set_color (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);
}
void
_gtk_color_chooser_color_activated (GtkColorChooser *chooser,
const GdkRGBA *color)
{
g_return_if_fail (GTK_IS_COLOR_CHOOSER (chooser));
g_signal_emit (chooser, signals[COLOR_ACTIVATED], 0, color);
}
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#ifndef __GTK_COLOR_CHOOSER_H__
#define __GTK_COLOR_CHOOSER_H__
#include <gtk/gtkwidget.h>
G_BEGIN_DECLS
#define GTK_TYPE_COLOR_CHOOSER (gtk_color_chooser_get_type ())
#define GTK_COLOR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER, GtkColorChooser))
#define GTK_IS_COLOR_CHOOSER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER))
#define GTK_COLOR_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_COLOR_CHOOSER, GtkColorChooserInterface))
typedef struct _GtkColorChooser GtkColorChooser;
typedef struct _GtkColorChooserInterface GtkColorChooserInterface;
struct _GtkColorChooserInterface
{
GTypeInterface base_interface;
/* Methods */
void (* get_color) (GtkColorChooser *chooser,
GdkRGBA *color);
void (* set_color) (GtkColorChooser *chooser,
const GdkRGBA *color);
/* Signals */
void (* color_activated) (GtkColorChooser *chooser,
const GdkRGBA *color);
/* Padding */
gpointer padding[12];
};
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);
G_END_DECLS
#endif /* __GTK_COLOR_CHOOSER_H__ */
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gtkdialog.h"
#include "gtkstock.h"
#include "gtkbox.h"
#include "gtkintl.h"
#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserdialog.h"
#include "gtkcolorchooserwidget.h"
struct _GtkColorChooserDialogPrivate
{
GtkWidget *color_chooser;
GtkWidget *select_button;
GtkWidget *cancel_button;
};
enum
{
PROP_ZERO,
PROP_COLOR
};
static void gtk_color_chooser_dialog_iface_init (GtkColorChooserInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkColorChooserDialog, gtk_color_chooser_dialog, GTK_TYPE_DIALOG,
G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
gtk_color_chooser_dialog_iface_init))
static void
propagate_notify (GObject *o,
GParamSpec *pspec,
GtkColorChooserDialog *cc)
{
g_object_notify (G_OBJECT (cc), "color");
}
static void
color_activated_cb (GtkColorChooser *chooser,
GdkRGBA *color,
GtkDialog *dialog)
{
gtk_dialog_response (dialog, GTK_RESPONSE_OK);
}
static void
gtk_color_chooser_dialog_init (GtkColorChooserDialog *cc)
{
GtkColorChooserDialogPrivate *priv;
GtkDialog *dialog = GTK_DIALOG (cc);
GtkWidget *action_area, *content_area;
cc->priv = G_TYPE_INSTANCE_GET_PRIVATE (cc,
GTK_TYPE_COLOR_CHOOSER_DIALOG,
GtkColorChooserDialogPrivate);
priv = cc->priv;
content_area = gtk_dialog_get_content_area (dialog);
action_area = gtk_dialog_get_action_area (dialog);
gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
gtk_container_set_border_width (GTK_CONTAINER (action_area), 5);
gtk_box_set_spacing (GTK_BOX (action_area), 6);
gtk_widget_push_composite_child ();
gtk_window_set_resizable (GTK_WINDOW (cc), FALSE);
/* Create the content area */
priv->color_chooser = gtk_color_chooser_widget_new ();
gtk_container_set_border_width (GTK_CONTAINER (priv->color_chooser), 5);
gtk_widget_show (priv->color_chooser);
gtk_box_pack_start (GTK_BOX (content_area),
priv->color_chooser, TRUE, TRUE, 0);
g_signal_connect (priv->color_chooser, "notify::color",
G_CALLBACK (propagate_notify), cc);
g_signal_connect (priv->color_chooser, "color-activated",
G_CALLBACK (color_activated_cb), cc);
/* Create the action area */
priv->cancel_button = gtk_dialog_add_button (dialog,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL);
priv->select_button = gtk_dialog_add_button (dialog,
_("_Select"),
GTK_RESPONSE_OK);
gtk_widget_grab_default (priv->select_button);
gtk_dialog_set_alternative_button_order (dialog,
GTK_RESPONSE_OK,
GTK_RESPONSE_CANCEL,
-1);
gtk_window_set_title (GTK_WINDOW (cc), _("Select a Color"));
gtk_widget_pop_composite_child ();
}
static void
gtk_color_chooser_dialog_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkColorChooser *cc = GTK_COLOR_CHOOSER (object);
switch (prop_id)
{
case PROP_COLOR:
{
GdkRGBA color;
gtk_color_chooser_get_color (cc, &color);
g_value_set_boxed (value, &color);
}
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_color_chooser_dialog_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkColorChooser *cc = GTK_COLOR_CHOOSER (object);
switch (prop_id)
{
case PROP_COLOR:
gtk_color_chooser_set_color (cc, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gtk_color_chooser_dialog_class_init (GtkColorChooserDialogClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->get_property = gtk_color_chooser_dialog_get_property;
object_class->set_property = gtk_color_chooser_dialog_set_property;
g_object_class_override_property (object_class, PROP_COLOR, "color");
g_type_class_add_private (class, sizeof (GtkColorChooserDialogPrivate));
}
static void
gtk_color_chooser_dialog_get_color (GtkColorChooser *chooser,
GdkRGBA *color)
{
GtkColorChooserDialog *cc = GTK_COLOR_CHOOSER_DIALOG (chooser);
gtk_color_chooser_get_color (GTK_COLOR_CHOOSER (cc->priv->color_chooser), color);
}
static void
gtk_color_chooser_dialog_set_color (GtkColorChooser *chooser,
const GdkRGBA *color)
{
GtkColorChooserDialog *cc = GTK_COLOR_CHOOSER_DIALOG (chooser);
gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (cc->priv->color_chooser), color);
}
static void
gtk_color_chooser_dialog_iface_init (GtkColorChooserInterface *iface)
{
iface->get_color = gtk_color_chooser_dialog_get_color;
iface->set_color = gtk_color_chooser_dialog_set_color;
}
GtkWidget *
gtk_color_chooser_dialog_new (const gchar *title,
GtkWindow *parent)
{
GtkColorChooserDialog *dialog;
dialog = g_object_new (GTK_TYPE_COLOR_CHOOSER_DIALOG,
"title", title,
"transient-for", parent,
NULL);
return GTK_WIDGET (dialog);
}
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#ifndef __GTK_COLOR_CHOOSER_DIALOG_H__
#define __GTK_COLOR_CHOOSER_DIALOG_H__
#include <gtk/gtkdialog.h>
G_BEGIN_DECLS
#define GTK_TYPE_COLOR_CHOOSER_DIALOG (gtk_color_chooser_dialog_get_type ())
#define GTK_COLOR_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG, GtkColorChooserDialog))
#define GTK_COLOR_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_COLOR_CHOOSER_DIALOG, GtkColorChooserDialogClass))
#define GTK_IS_COLOR_CHOOSER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG))
#define GTK_IS_COLOR_CHOOSER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_COLOR_CHOOSER_DIALOG))
#define GTK_COLOR_CHOOSER_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_COLOR_CHOOSER_DIALOG, GtkColorChooserDialogClass))
typedef struct _GtkColorChooserDialog GtkColorChooserDialog;
typedef struct _GtkColorChooserDialogPrivate GtkColorChooserDialogPrivate;
typedef struct _GtkColorChooserDialogClass GtkColorChooserDialogClass;
struct _GtkColorChooserDialog
{
GtkDialog parent_instance;
/*< private >*/
GtkColorChooserDialogPrivate *priv;
};
struct _GtkColorChooserDialogClass
{
GtkDialogClass parent_class;
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
void (*_gtk_reserved2) (void);
void (*_gtk_reserved3) (void);
void (*_gtk_reserved4) (void);
};
GType gtk_color_chooser_dialog_get_type (void) G_GNUC_CONST;
GtkWidget * gtk_color_chooser_dialog_new (const gchar *title,
GtkWindow *parent);
G_END_DECLS
#endif /* __GTK_COLOR_CHOOSER_DIALOG_H__ */
/*
* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#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);
G_END_DECLS
#endif /* ! __GTK_COLOR_CHOOSER_PRIVATE_H__ */
/* 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, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gtkcolorchooserprivate.h"
#include "gtkcolorchooserwidget.h"
#include "gtkcoloreditor.h"
#include "gtkcolorswatch.h"
#include "gtkbox.h"
#include "gtkgrid.h"
#include "gtkhsv.h"
#include "gtklabel.h"
#include "gtkorientable.h"
#include "gtkintl.h"
struct _GtkColorChooserWidgetPrivate
{
GtkWidget *palette;
GtkWidget *editor;
GtkWidget *colors;
GtkWidget *grays;
GtkWidget *custom;
GtkColorSwatch *current;
GSettings *settings;
};
enum
{
PROP_ZERO,
PROP_COLOR
};
static void gtk_color_chooser_widget_iface_init (GtkColorChooserInterface *iface);
G_DEFINE_TYPE_WITH_CODE (GtkColorChooserWidget, gtk_color_chooser_widget, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (GTK_TYPE_COLOR_CHOOSER,
gtk_color_chooser_widget_iface_init))
static void
select_swatch (GtkColorChooserWidget *cc,
GtkColorSwatch *swatch)
{
if (cc->priv->current == swatch)
return;
if (cc->priv->current != NULL)
gtk_color_swatch_set_selected (cc->priv->current, FALSE);
gtk_color_swatch_set_selected (swatch, TRUE);
cc->priv->current = swatch;
g_object_notify (G_OBJECT (cc), "color");
}
static void add_custom (GtkColorChooserWidget *cc, GtkColorSwatch *swatch);
static void save_custom (GtkColorChooserWidget *cc);
static void
button_activate (GtkColorSwatch *swatch,
GtkColorChooserWidget *cc)
{
add_custom (cc, swatch);
}
static void
swatch_activate (GtkColorSwatch *swatch,
GtkColorChooserWidget *cc)
{
GdkRGBA color;
gtk_color_swatch_get_color (swatch, &color);
_gtk_color_chooser_color_activated (GTK_COLOR_CHOOSER (cc), &color);
}
static void
swatch_customize (GtkColorSwatch *swatch,
GtkColorChooserWidget *cc)
{
GdkRGBA color;
gtk_color_swatch_get_color (swatch, &color);
gtk_color_chooser_set_color (GTK_COLOR_CHOOSER (cc->priv->editor), &color);
gtk_widget_hide (cc->priv->palette);
gtk_widget_show (cc->priv->editor);
g_print ("TODO: customize color\n");
}
static void
swatch_selected (GtkColorSwatch *swatch,
GParamSpec *pspec,
GtkColorChooserWidget *cc)
{
select_swatch (cc, swatch);
}
static void
connect_swatch_signals (GtkWidget *p, gpointer data)
{
g_signal_connect (p, "activate", G_CALLBACK (swatch_activate), data);
g_signal_connect (p, "customize", G_CALLBACK (swatch_customize), data);
g_signal_connect (p, "notify::selected", G_CALLBACK (swatch_selected), data);
}
static void
connect_button_signals (GtkWidget *p, gpointer data)
{
g_signal_connect (p, "activate", G_CALLBACK (button_activate), data);
}
static void
connect_custom_signals (GtkWidget *p, gpointer data)
{
connect_swatch_signals (p, data);
g_signal_connect_swapped (p, "notify::color", G_CALLBACK (save_custom), data);
}
static void
save_custom (GtkColorChooserWidget *cc)
{
GVariantBuilder builder;
GVariant *variant;
GdkRGBA color;
GList *children, *l;
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(dddd)"));
children = gtk_container_get_children (GTK_CONTAINER (cc->priv->custom));
for (l = children; l; l = l->next)
{
if (gtk_color_swatch_get_color (GTK_COLOR_SWATCH (l->data), &color))
{
g_variant_builder_add (&builder, "(dddd)",
color.red, color.green, color.blue, color.alpha);
}
}
g_list_free (children);
variant = g_variant_builder_end (&builder);
g_settings_set_value (cc->priv->settings, "custom-colors", variant);
}
static void
add_custom (GtkColorChooserWidget *cc, GtkColorSwatch *swatch)
{
GList *children;
gint n_children;
GdkRGBA color;
GtkWidget *p;
children = gtk_container_get_children (GTK_CONTAINER (cc->priv->custom));
n_children = g_list_length (children);
g_list_free (children);
if (n_children >= 9)
{
gtk_widget_error_bell (GTK_WIDGET (cc));
return;
}
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (swatch), 10, 1, 1, 10);
color.red = g_random_double_range (0, 1);
color.green = g_random_double_range (0, 1);
color.blue = g_random_double_range (0, 1);
color.alpha = 1.0;
p = gtk_color_swatch_new ();
gtk_color_swatch_set_color (GTK_COLOR_SWATCH (p), &color);
gtk_color_swatch_set_can_drop (GTK_COLOR_SWATCH (p), TRUE);
connect_custom_signals (p, cc);
if (n_children == 1)
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (p), 1, 10, 10, 1);
else
gtk_color_swatch_set_corner_radii (GTK_COLOR_SWATCH (p), 1, 1, 1, 1);
gtk_grid_insert_next_to (GTK_GRID (cc->priv->custom), GTK_WIDGET (swatch), GTK_POS_RIGHT);
gtk_grid_attach (GTK_GRID (cc->priv->custom), p, 1, 0, 1, 1);
gtk_widget_show (p);
save_custom (cc);
}
static void
gtk_color_chooser_widget_init (GtkColorChooserWidget *cc)
{
GtkWidget *grid