2012-01-29 15:42:34 +00:00
|
|
|
/* 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
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2012-01-29 15:42:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-02-09 00:36:10 +00:00
|
|
|
#include "gtkcolorswatchprivate.h"
|
2012-02-04 05:02:49 +00:00
|
|
|
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkbox.h"
|
2012-02-14 17:16:56 +00:00
|
|
|
#include "gtkcolorchooserprivate.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkcssnodeprivate.h"
|
2012-01-29 15:42:34 +00:00
|
|
|
#include "gtkdnd.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkdragdest.h"
|
|
|
|
#include "gtkdragsource.h"
|
|
|
|
#include "gtkgesturelongpress.h"
|
2019-05-29 17:10:46 +00:00
|
|
|
#include "gtkgestureclick.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkgesturesingle.h"
|
2012-01-29 15:42:34 +00:00
|
|
|
#include "gtkicontheme.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkimage.h"
|
|
|
|
#include "gtkintl.h"
|
2012-01-30 14:56:20 +00:00
|
|
|
#include "gtkmain.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkmodelbutton.h"
|
|
|
|
#include "gtkpopover.h"
|
2012-01-29 15:42:34 +00:00
|
|
|
#include "gtkprivate.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtksnapshot.h"
|
2015-10-31 02:16:18 +00:00
|
|
|
#include "gtkstylecontextprivate.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
#include "gtkwidgetprivate.h"
|
2018-03-05 13:59:21 +00:00
|
|
|
#include "gtkeventcontrollerkey.h"
|
2019-05-04 18:43:04 +00:00
|
|
|
#include "gtknative.h"
|
2018-02-08 13:39:45 +00:00
|
|
|
|
2012-12-27 17:11:12 +00:00
|
|
|
#include "a11y/gtkcolorswatchaccessibleprivate.h"
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2015-10-31 01:29:46 +00:00
|
|
|
/*
|
|
|
|
* GtkColorSwatch has two CSS nodes, the main one named colorswatch
|
2015-10-31 01:43:50 +00:00
|
|
|
* and a subnode named overlay. The main node gets the .light or .dark
|
2015-10-31 01:29:46 +00:00
|
|
|
* style classes added depending on the brightness of the color that
|
|
|
|
* the swatch is showing.
|
2015-10-31 02:16:18 +00:00
|
|
|
*
|
|
|
|
* The color swatch has the .activatable style class by default. It can
|
|
|
|
* be removed for non-activatable swatches.
|
2015-10-31 01:29:46 +00:00
|
|
|
*/
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
typedef struct
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
|
|
|
GdkRGBA color;
|
|
|
|
gdouble radius[4];
|
|
|
|
gchar *icon;
|
|
|
|
guint has_color : 1;
|
2012-02-03 23:34:33 +00:00
|
|
|
guint use_alpha : 1;
|
2012-02-17 16:01:50 +00:00
|
|
|
guint selectable : 1;
|
2015-06-14 01:56:41 +00:00
|
|
|
guint has_menu : 1;
|
2012-02-20 12:45:58 +00:00
|
|
|
|
2017-05-17 07:14:40 +00:00
|
|
|
GtkWidget *overlay_widget;
|
2015-08-05 02:58:40 +00:00
|
|
|
|
|
|
|
GtkWidget *popover;
|
2018-07-07 14:08:21 +00:00
|
|
|
} GtkColorSwatchPrivate;
|
2012-01-29 15:42:34 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_ZERO,
|
2012-02-17 16:01:50 +00:00
|
|
|
PROP_RGBA,
|
2015-06-14 01:56:41 +00:00
|
|
|
PROP_SELECTABLE,
|
|
|
|
PROP_HAS_MENU
|
2012-01-29 15:42:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ACTIVATE,
|
|
|
|
CUSTOMIZE,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
static guint signals[LAST_SIGNAL];
|
|
|
|
|
2014-04-08 19:18:38 +00:00
|
|
|
|
2013-06-27 19:02:52 +00:00
|
|
|
G_DEFINE_TYPE_WITH_PRIVATE (GtkColorSwatch, gtk_color_swatch, GTK_TYPE_WIDGET)
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2017-05-04 07:45:05 +00:00
|
|
|
#define INTENSITY(r, g, b) ((r) * 0.30 + (g) * 0.59 + (b) * 0.11)
|
2016-12-19 18:30:55 +00:00
|
|
|
static void
|
|
|
|
swatch_snapshot (GtkWidget *widget,
|
|
|
|
GtkSnapshot *snapshot)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2012-01-31 07:05:37 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
if (priv->has_color)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
2012-01-31 05:58:07 +00:00
|
|
|
cairo_pattern_t *pattern;
|
|
|
|
cairo_matrix_t matrix;
|
2014-10-07 21:24:51 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
if (priv->use_alpha && !gdk_rgba_is_opaque (&priv->color))
|
2012-01-31 07:05:37 +00:00
|
|
|
{
|
2016-12-19 18:30:55 +00:00
|
|
|
cairo_t *cr;
|
2012-02-08 21:37:25 +00:00
|
|
|
|
2019-03-08 12:19:13 +00:00
|
|
|
cr = gtk_snapshot_append_cairo (snapshot,
|
|
|
|
&GRAPHENE_RECT_INIT (
|
|
|
|
0, 0,
|
|
|
|
gtk_widget_get_width (widget),
|
|
|
|
gtk_widget_get_height (widget)));
|
2012-01-31 07:05:37 +00:00
|
|
|
cairo_set_source_rgb (cr, 0.33, 0.33, 0.33);
|
2016-12-19 18:30:55 +00:00
|
|
|
cairo_paint (cr);
|
2012-01-31 05:58:07 +00:00
|
|
|
|
2012-02-14 17:16:56 +00:00
|
|
|
pattern = _gtk_color_chooser_get_checkered_pattern ();
|
2012-01-31 07:05:37 +00:00
|
|
|
cairo_matrix_init_scale (&matrix, 0.125, 0.125);
|
|
|
|
cairo_pattern_set_matrix (pattern, &matrix);
|
2012-02-08 21:37:25 +00:00
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 0.66, 0.66, 0.66);
|
2012-01-31 07:05:37 +00:00
|
|
|
cairo_mask (cr, pattern);
|
|
|
|
cairo_pattern_destroy (pattern);
|
2012-01-31 05:58:07 +00:00
|
|
|
|
2016-12-19 18:30:55 +00:00
|
|
|
cairo_destroy (cr);
|
2012-02-08 21:37:25 +00:00
|
|
|
|
2017-01-13 03:46:09 +00:00
|
|
|
gtk_snapshot_append_color (snapshot,
|
2018-07-07 14:08:21 +00:00
|
|
|
&priv->color,
|
2019-03-08 12:19:13 +00:00
|
|
|
&GRAPHENE_RECT_INIT (
|
|
|
|
0, 0,
|
|
|
|
gtk_widget_get_width (widget),
|
|
|
|
gtk_widget_get_height (widget)));
|
2012-01-31 07:05:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GdkRGBA color = priv->color;
|
2016-12-19 18:30:55 +00:00
|
|
|
|
|
|
|
color.alpha = 1.0;
|
|
|
|
|
2017-01-13 03:46:09 +00:00
|
|
|
gtk_snapshot_append_color (snapshot,
|
|
|
|
&color,
|
2019-03-08 12:19:13 +00:00
|
|
|
&GRAPHENE_RECT_INIT (
|
|
|
|
0, 0,
|
|
|
|
gtk_widget_get_width (widget),
|
|
|
|
gtk_widget_get_height (widget)));
|
2012-01-31 07:05:37 +00:00
|
|
|
}
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
gtk_widget_snapshot_child (widget, priv->overlay_widget, snapshot);
|
2015-12-14 21:10:28 +00:00
|
|
|
}
|
|
|
|
|
2017-05-04 07:45:05 +00:00
|
|
|
|
2012-01-29 15:42:34 +00:00
|
|
|
static void
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_set_color_icon (GdkDrag *drag,
|
2012-01-29 15:42:34 +00:00
|
|
|
const GdkRGBA *color)
|
|
|
|
{
|
2018-03-26 04:29:06 +00:00
|
|
|
GtkSnapshot *snapshot;
|
|
|
|
GdkPaintable *paintable;
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2018-04-24 01:17:23 +00:00
|
|
|
snapshot = gtk_snapshot_new ();
|
2018-03-26 04:29:06 +00:00
|
|
|
gtk_snapshot_append_color (snapshot,
|
|
|
|
color,
|
2018-04-24 01:17:23 +00:00
|
|
|
&GRAPHENE_RECT_INIT(0, 0, 48, 32));
|
2018-04-02 04:15:50 +00:00
|
|
|
paintable = gtk_snapshot_free_to_paintable (snapshot, NULL);
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2018-06-29 17:34:14 +00:00
|
|
|
gtk_drag_set_icon_paintable (drag, paintable, 4, 4);
|
2018-03-27 11:14:41 +00:00
|
|
|
g_object_unref (paintable);
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
swatch_drag_begin (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
|
|
|
GdkRGBA color;
|
|
|
|
|
2012-02-03 23:34:33 +00:00
|
|
|
gtk_color_swatch_get_rgba (swatch, &color);
|
2018-06-29 17:34:14 +00:00
|
|
|
drag_set_color_icon (drag, &color);
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
swatch_drag_data_get (GtkWidget *widget,
|
2018-06-29 17:34:14 +00:00
|
|
|
GdkDrag *drag,
|
2018-06-16 02:49:47 +00:00
|
|
|
GtkSelectionData *selection_data)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
|
|
|
guint16 vals[4];
|
|
|
|
GdkRGBA color;
|
|
|
|
|
2012-02-03 23:34:33 +00:00
|
|
|
gtk_color_swatch_get_rgba (swatch, &color);
|
2012-01-29 15:42:34 +00:00
|
|
|
|
|
|
|
vals[0] = color.red * 0xffff;
|
|
|
|
vals[1] = color.green * 0xffff;
|
|
|
|
vals[2] = color.blue * 0xffff;
|
|
|
|
vals[3] = color.alpha * 0xffff;
|
|
|
|
|
|
|
|
gtk_selection_data_set (selection_data,
|
2017-12-14 04:39:03 +00:00
|
|
|
g_intern_static_string ("application/x-color"),
|
2012-01-29 15:42:34 +00:00
|
|
|
16, (guchar *)vals, 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
swatch_drag_data_received (GtkWidget *widget,
|
2018-05-16 02:50:24 +00:00
|
|
|
GdkDrop *drop,
|
|
|
|
GtkSelectionData *selection_data)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
|
|
|
gint length;
|
|
|
|
guint16 *vals;
|
|
|
|
GdkRGBA color;
|
|
|
|
|
|
|
|
length = gtk_selection_data_get_length (selection_data);
|
|
|
|
|
|
|
|
if (length < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* We accept drops with the wrong format, since the KDE color
|
|
|
|
* chooser incorrectly drops application/x-color with format 8.
|
|
|
|
*/
|
|
|
|
if (length != 8)
|
|
|
|
{
|
2016-02-28 16:06:25 +00:00
|
|
|
g_warning ("Received invalid color data");
|
2012-01-29 15:42:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
vals = (guint16 *) gtk_selection_data_get_data (selection_data);
|
|
|
|
|
|
|
|
color.red = (gdouble)vals[0] / 0xffff;
|
|
|
|
color.green = (gdouble)vals[1] / 0xffff;
|
|
|
|
color.blue = (gdouble)vals[2] / 0xffff;
|
|
|
|
color.alpha = (gdouble)vals[3] / 0xffff;
|
|
|
|
|
2012-02-03 23:34:33 +00:00
|
|
|
gtk_color_swatch_set_rgba (GTK_COLOR_SWATCH (widget), &color);
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2018-03-05 13:59:21 +00:00
|
|
|
key_controller_key_pressed (GtkEventControllerKey *controller,
|
|
|
|
guint keyval,
|
|
|
|
guint keycode,
|
|
|
|
GdkModifierType state,
|
|
|
|
GtkWidget *widget)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2017-08-25 14:44:48 +00:00
|
|
|
|
|
|
|
if (keyval == GDK_KEY_space ||
|
|
|
|
keyval == GDK_KEY_Return ||
|
|
|
|
keyval == GDK_KEY_ISO_Enter||
|
|
|
|
keyval == GDK_KEY_KP_Enter ||
|
|
|
|
keyval == GDK_KEY_KP_Space)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
if (priv->has_color &&
|
|
|
|
priv->selectable &&
|
2012-02-17 16:01:50 +00:00
|
|
|
(gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED) == 0)
|
2012-02-09 04:48:11 +00:00
|
|
|
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
|
2012-01-29 15:42:34 +00:00
|
|
|
else
|
|
|
|
g_signal_emit (swatch, signals[ACTIVATE], 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-01-30 14:56:20 +00:00
|
|
|
static void
|
|
|
|
emit_customize (GtkColorSwatch *swatch)
|
|
|
|
{
|
|
|
|
g_signal_emit (swatch, signals[CUSTOMIZE], 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2015-08-05 02:58:40 +00:00
|
|
|
do_popup (GtkColorSwatch *swatch)
|
2012-01-30 14:56:20 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
|
|
|
if (priv->popover == NULL)
|
2015-08-05 02:58:40 +00:00
|
|
|
{
|
|
|
|
GtkWidget *box;
|
|
|
|
GtkWidget *item;
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
priv->popover = gtk_popover_new (GTK_WIDGET (swatch));
|
2015-08-05 02:58:40 +00:00
|
|
|
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
2018-07-07 14:08:21 +00:00
|
|
|
gtk_container_add (GTK_CONTAINER (priv->popover), box);
|
2015-08-05 02:58:40 +00:00
|
|
|
g_object_set (box, "margin", 10, NULL);
|
|
|
|
item = g_object_new (GTK_TYPE_MODEL_BUTTON,
|
|
|
|
"text", _("C_ustomize"),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect_swapped (item, "clicked",
|
|
|
|
G_CALLBACK (emit_customize), swatch);
|
|
|
|
gtk_container_add (GTK_CONTAINER (box), item);
|
|
|
|
}
|
2012-01-30 14:56:20 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
gtk_popover_popup (GTK_POPOVER (priv->popover));
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
2012-03-03 06:48:55 +00:00
|
|
|
static gboolean
|
|
|
|
swatch_primary_action (GtkColorSwatch *swatch)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2012-03-03 06:48:55 +00:00
|
|
|
GtkWidget *widget = (GtkWidget *)swatch;
|
|
|
|
GtkStateFlags flags;
|
|
|
|
|
|
|
|
flags = gtk_widget_get_state_flags (widget);
|
2018-07-07 14:08:21 +00:00
|
|
|
if (!priv->has_color)
|
2012-03-03 06:48:55 +00:00
|
|
|
{
|
|
|
|
g_signal_emit (swatch, signals[ACTIVATE], 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
2018-07-07 14:08:21 +00:00
|
|
|
else if (priv->selectable &&
|
2012-03-03 06:48:55 +00:00
|
|
|
(flags & GTK_STATE_FLAG_SELECTED) == 0)
|
|
|
|
{
|
|
|
|
gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_SELECTED, FALSE);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-04-08 19:18:38 +00:00
|
|
|
hold_action (GtkGestureLongPress *gesture,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
GtkColorSwatch *swatch)
|
2012-03-03 06:48:55 +00:00
|
|
|
{
|
2015-08-05 02:58:40 +00:00
|
|
|
do_popup (swatch);
|
2014-04-08 19:18:38 +00:00
|
|
|
gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
|
2012-03-03 06:48:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2019-05-29 17:10:46 +00:00
|
|
|
tap_action (GtkGestureClick *gesture,
|
|
|
|
gint n_press,
|
|
|
|
gdouble x,
|
|
|
|
gdouble y,
|
|
|
|
GtkColorSwatch *swatch)
|
2014-04-08 19:18:38 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2014-05-09 23:24:27 +00:00
|
|
|
guint button;
|
|
|
|
|
|
|
|
button = gtk_gesture_single_get_current_button (GTK_GESTURE_SINGLE (gesture));
|
|
|
|
|
|
|
|
if (button == GDK_BUTTON_PRIMARY)
|
|
|
|
{
|
|
|
|
if (n_press == 1)
|
|
|
|
swatch_primary_action (swatch);
|
|
|
|
else if (n_press > 1)
|
|
|
|
g_signal_emit (swatch, signals[ACTIVATE], 0);
|
|
|
|
}
|
|
|
|
else if (button == GDK_BUTTON_SECONDARY)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
if (priv->has_color && priv->has_menu)
|
2015-08-05 02:58:40 +00:00
|
|
|
do_popup (swatch);
|
2014-05-09 23:24:27 +00:00
|
|
|
}
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
2012-02-20 12:45:58 +00:00
|
|
|
static void
|
2018-08-16 04:53:03 +00:00
|
|
|
swatch_size_allocate (GtkWidget *widget,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
int baseline)
|
2012-02-20 12:45:58 +00:00
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
2018-08-16 04:53:03 +00:00
|
|
|
gtk_widget_size_allocate (priv->overlay_widget,
|
|
|
|
&(GtkAllocation) {
|
|
|
|
0, 0,
|
|
|
|
width, height
|
|
|
|
}, -1);
|
2019-05-04 18:43:04 +00:00
|
|
|
|
|
|
|
if (priv->popover)
|
|
|
|
gtk_native_check_resize (GTK_NATIVE (priv->popover));
|
2015-12-14 21:10:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2017-05-04 07:45:05 +00:00
|
|
|
gtk_color_swatch_measure (GtkWidget *widget,
|
2016-10-22 14:06:14 +00:00
|
|
|
GtkOrientation orientation,
|
|
|
|
int for_size,
|
|
|
|
int *minimum,
|
|
|
|
int *natural,
|
|
|
|
int *minimum_baseline,
|
|
|
|
int *natural_baseline)
|
2015-12-14 21:10:28 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2017-05-04 07:45:05 +00:00
|
|
|
gint w, h, min;
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
gtk_widget_measure (priv->overlay_widget,
|
2017-05-17 07:14:40 +00:00
|
|
|
orientation,
|
|
|
|
-1,
|
|
|
|
minimum, natural,
|
|
|
|
NULL, NULL);
|
2017-05-04 07:45:05 +00:00
|
|
|
|
|
|
|
gtk_widget_get_size_request (widget, &w, &h);
|
|
|
|
if (orientation == GTK_ORIENTATION_HORIZONTAL)
|
|
|
|
min = w < 0 ? 48 : w;
|
|
|
|
else
|
|
|
|
min = h < 0 ? 32 : h;
|
|
|
|
|
|
|
|
*minimum = MAX (*minimum, min);
|
|
|
|
*natural = MAX (*natural, min);
|
2015-12-14 21:10:28 +00:00
|
|
|
}
|
|
|
|
|
2016-10-22 14:06:14 +00:00
|
|
|
|
2012-02-17 17:31:19 +00:00
|
|
|
|
2012-01-30 14:56:20 +00:00
|
|
|
static gboolean
|
2015-08-05 02:58:40 +00:00
|
|
|
swatch_popup_menu (GtkWidget *widget)
|
2012-01-30 14:56:20 +00:00
|
|
|
{
|
2015-08-05 02:58:40 +00:00
|
|
|
do_popup (GTK_COLOR_SWATCH (widget));
|
2012-01-30 14:56:20 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2016-01-08 00:20:55 +00:00
|
|
|
static void
|
|
|
|
update_icon (GtkColorSwatch *swatch)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
GtkImage *image = GTK_IMAGE (priv->overlay_widget);
|
2016-01-08 00:20:55 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
if (priv->icon)
|
|
|
|
gtk_image_set_from_icon_name (image, priv->icon);
|
2016-01-08 00:20:55 +00:00
|
|
|
else if (gtk_widget_get_state_flags (GTK_WIDGET (swatch)) & GTK_STATE_FLAG_SELECTED)
|
2017-11-15 00:43:13 +00:00
|
|
|
gtk_image_set_from_icon_name (image, "object-select-symbolic");
|
2016-01-08 00:20:55 +00:00
|
|
|
else
|
2017-05-17 07:14:40 +00:00
|
|
|
gtk_image_clear (image);
|
2016-01-08 00:20:55 +00:00
|
|
|
}
|
|
|
|
|
2015-10-31 01:29:46 +00:00
|
|
|
static void
|
|
|
|
swatch_state_flags_changed (GtkWidget *widget,
|
|
|
|
GtkStateFlags previous_state)
|
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (widget);
|
|
|
|
|
2016-01-08 00:20:55 +00:00
|
|
|
update_icon (swatch);
|
|
|
|
|
2015-12-02 03:36:31 +00:00
|
|
|
GTK_WIDGET_CLASS (gtk_color_swatch_parent_class)->state_flags_changed (widget, previous_state);
|
2015-10-31 01:29:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 05:02:49 +00:00
|
|
|
/* GObject implementation {{{1 */
|
|
|
|
|
|
|
|
static void
|
|
|
|
swatch_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2012-02-04 05:02:49 +00:00
|
|
|
GdkRGBA color;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_RGBA:
|
|
|
|
gtk_color_swatch_get_rgba (swatch, &color);
|
|
|
|
g_value_set_boxed (value, &color);
|
|
|
|
break;
|
2012-02-17 16:01:50 +00:00
|
|
|
case PROP_SELECTABLE:
|
|
|
|
g_value_set_boolean (value, gtk_color_swatch_get_selectable (swatch));
|
|
|
|
break;
|
2015-06-14 01:56:41 +00:00
|
|
|
case PROP_HAS_MENU:
|
2018-07-07 14:08:21 +00:00
|
|
|
g_value_set_boolean (value, priv->has_menu);
|
2015-06-14 01:56:41 +00:00
|
|
|
break;
|
2012-02-04 05:02:49 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
swatch_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2012-02-04 05:02:49 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_RGBA:
|
|
|
|
gtk_color_swatch_set_rgba (swatch, g_value_get_boxed (value));
|
|
|
|
break;
|
2012-02-17 16:01:50 +00:00
|
|
|
case PROP_SELECTABLE:
|
|
|
|
gtk_color_swatch_set_selectable (swatch, g_value_get_boolean (value));
|
|
|
|
break;
|
2015-06-14 01:56:41 +00:00
|
|
|
case PROP_HAS_MENU:
|
2018-07-07 14:08:21 +00:00
|
|
|
priv->has_menu = g_value_get_boolean (value);
|
2015-06-14 01:56:41 +00:00
|
|
|
break;
|
2012-02-04 05:02:49 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
swatch_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2012-02-04 05:02:49 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
g_free (priv->icon);
|
|
|
|
gtk_widget_unparent (priv->overlay_widget);
|
2014-04-08 19:18:38 +00:00
|
|
|
|
2012-02-04 05:02:49 +00:00
|
|
|
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2015-08-05 02:58:40 +00:00
|
|
|
static void
|
|
|
|
swatch_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkColorSwatch *swatch = GTK_COLOR_SWATCH (object);
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2015-08-05 02:58:40 +00:00
|
|
|
|
2018-11-13 19:53:14 +00:00
|
|
|
g_clear_pointer (&priv->popover, gtk_widget_destroy);
|
2015-08-05 02:58:40 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_color_swatch_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2012-01-29 15:42:34 +00:00
|
|
|
static void
|
|
|
|
gtk_color_swatch_class_init (GtkColorSwatchClass *class)
|
|
|
|
{
|
|
|
|
GtkWidgetClass *widget_class = (GtkWidgetClass *)class;
|
|
|
|
GObjectClass *object_class = (GObjectClass *)class;
|
|
|
|
|
|
|
|
object_class->get_property = swatch_get_property;
|
|
|
|
object_class->set_property = swatch_set_property;
|
|
|
|
object_class->finalize = swatch_finalize;
|
2015-08-05 02:58:40 +00:00
|
|
|
object_class->dispose = swatch_dispose;
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2017-05-04 07:45:05 +00:00
|
|
|
widget_class->measure = gtk_color_swatch_measure;
|
2016-12-19 18:30:55 +00:00
|
|
|
widget_class->snapshot = swatch_snapshot;
|
2012-01-29 15:42:34 +00:00
|
|
|
widget_class->drag_begin = swatch_drag_begin;
|
|
|
|
widget_class->drag_data_get = swatch_drag_data_get;
|
|
|
|
widget_class->drag_data_received = swatch_drag_data_received;
|
2012-02-04 05:02:49 +00:00
|
|
|
widget_class->popup_menu = swatch_popup_menu;
|
2012-02-20 12:45:58 +00:00
|
|
|
widget_class->size_allocate = swatch_size_allocate;
|
2015-10-31 01:29:46 +00:00
|
|
|
widget_class->state_flags_changed = swatch_state_flags_changed;
|
2012-01-29 15:42:34 +00:00
|
|
|
|
|
|
|
signals[ACTIVATE] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("activate"),
|
2012-01-29 15:42:34 +00:00
|
|
|
GTK_TYPE_COLOR_SWATCH,
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GtkColorSwatchClass, activate),
|
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 0);
|
|
|
|
|
|
|
|
signals[CUSTOMIZE] =
|
2015-09-12 13:13:00 +00:00
|
|
|
g_signal_new (I_("customize"),
|
2012-01-29 15:42:34 +00:00
|
|
|
GTK_TYPE_COLOR_SWATCH,
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GtkColorSwatchClass, customize),
|
|
|
|
NULL, NULL, NULL, G_TYPE_NONE, 0);
|
|
|
|
|
2012-02-03 23:34:33 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_RGBA,
|
|
|
|
g_param_spec_boxed ("rgba", P_("RGBA Color"), P_("Color as RGBA"),
|
2012-01-29 15:42:34 +00:00
|
|
|
GDK_TYPE_RGBA, GTK_PARAM_READWRITE));
|
2012-02-17 16:01:50 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_SELECTABLE,
|
|
|
|
g_param_spec_boolean ("selectable", P_("Selectable"), P_("Whether the swatch is selectable"),
|
|
|
|
TRUE, GTK_PARAM_READWRITE));
|
2015-06-14 01:56:41 +00:00
|
|
|
g_object_class_install_property (object_class, PROP_HAS_MENU,
|
|
|
|
g_param_spec_boolean ("has-menu", P_("Has Menu"), P_("Whether the swatch should offer customization"),
|
|
|
|
TRUE, GTK_PARAM_READWRITE));
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2012-02-15 02:03:11 +00:00
|
|
|
gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_COLOR_SWATCH_ACCESSIBLE);
|
2017-11-18 03:49:57 +00:00
|
|
|
gtk_widget_class_set_css_name (widget_class, I_("colorswatch"));
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
2015-12-14 21:10:28 +00:00
|
|
|
static void
|
|
|
|
gtk_color_swatch_init (GtkColorSwatch *swatch)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2018-04-20 17:58:06 +00:00
|
|
|
GtkEventController *controller;
|
2018-03-09 05:14:59 +00:00
|
|
|
GtkGesture *gesture;
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
priv->use_alpha = TRUE;
|
|
|
|
priv->selectable = TRUE;
|
|
|
|
priv->has_menu = TRUE;
|
2015-12-14 21:10:28 +00:00
|
|
|
|
|
|
|
gtk_widget_set_can_focus (GTK_WIDGET (swatch), TRUE);
|
2019-03-08 12:19:13 +00:00
|
|
|
gtk_widget_set_overflow (GTK_WIDGET (swatch), GTK_OVERFLOW_HIDDEN);
|
2015-12-14 21:10:28 +00:00
|
|
|
|
2018-03-09 05:36:22 +00:00
|
|
|
gesture = gtk_gesture_long_press_new ();
|
|
|
|
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture),
|
2015-12-14 21:10:28 +00:00
|
|
|
TRUE);
|
2018-03-09 05:36:22 +00:00
|
|
|
g_signal_connect (gesture, "pressed",
|
2015-12-14 21:10:28 +00:00
|
|
|
G_CALLBACK (hold_action), swatch);
|
2018-03-09 05:36:22 +00:00
|
|
|
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (gesture));
|
2015-12-14 21:10:28 +00:00
|
|
|
|
2019-05-29 17:10:46 +00:00
|
|
|
gesture = gtk_gesture_click_new ();
|
2018-03-09 05:14:59 +00:00
|
|
|
gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
|
|
|
|
g_signal_connect (gesture, "pressed",
|
2015-12-14 21:10:28 +00:00
|
|
|
G_CALLBACK (tap_action), swatch);
|
2018-03-09 05:14:59 +00:00
|
|
|
gtk_widget_add_controller (GTK_WIDGET (swatch), GTK_EVENT_CONTROLLER (gesture));
|
2015-12-14 21:10:28 +00:00
|
|
|
|
2018-04-20 17:58:06 +00:00
|
|
|
controller = gtk_event_controller_key_new ();
|
|
|
|
g_signal_connect (controller, "key-pressed",
|
2018-03-05 13:59:21 +00:00
|
|
|
G_CALLBACK (key_controller_key_pressed), swatch);
|
2018-04-20 17:58:06 +00:00
|
|
|
gtk_widget_add_controller (GTK_WIDGET (swatch), controller);
|
2018-03-05 13:59:21 +00:00
|
|
|
|
2017-05-04 07:45:05 +00:00
|
|
|
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (swatch)), "activatable");
|
2016-01-08 00:20:55 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
priv->overlay_widget = g_object_new (GTK_TYPE_IMAGE,
|
2017-05-17 07:14:40 +00:00
|
|
|
"css-name", "overlay",
|
|
|
|
NULL);
|
2018-07-07 14:08:21 +00:00
|
|
|
gtk_widget_set_parent (priv->overlay_widget, GTK_WIDGET (swatch));
|
2015-12-14 21:10:28 +00:00
|
|
|
}
|
2015-06-14 01:56:41 +00:00
|
|
|
|
2012-01-29 15:42:34 +00:00
|
|
|
/* Public API {{{1 */
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gtk_color_swatch_new (void)
|
|
|
|
{
|
|
|
|
return (GtkWidget *) g_object_new (GTK_TYPE_COLOR_SWATCH, NULL);
|
|
|
|
}
|
|
|
|
|
2017-11-16 23:28:53 +00:00
|
|
|
static const char *dnd_targets[] = {
|
|
|
|
"application/x-color"
|
2012-02-04 05:02:49 +00:00
|
|
|
};
|
|
|
|
|
2012-01-29 15:42:34 +00:00
|
|
|
void
|
2012-02-03 23:34:33 +00:00
|
|
|
gtk_color_swatch_set_rgba (GtkColorSwatch *swatch,
|
|
|
|
const GdkRGBA *color)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
2012-02-08 21:35:57 +00:00
|
|
|
GtkStyleContext *context;
|
|
|
|
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (swatch));
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
if (!priv->has_color)
|
2012-02-08 21:35:57 +00:00
|
|
|
{
|
2017-11-18 01:19:53 +00:00
|
|
|
GdkContentFormats *targets = gdk_content_formats_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
|
2012-02-08 21:35:57 +00:00
|
|
|
gtk_drag_source_set (GTK_WIDGET (swatch),
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
2017-11-14 21:32:23 +00:00
|
|
|
targets,
|
2012-02-08 21:35:57 +00:00
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
2017-11-18 01:19:53 +00:00
|
|
|
gdk_content_formats_unref (targets);
|
2012-02-08 21:35:57 +00:00
|
|
|
}
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
priv->has_color = TRUE;
|
|
|
|
priv->color = *color;
|
2012-01-29 15:42:34 +00:00
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
if (INTENSITY (priv->color.red, priv->color.green, priv->color.blue) > 0.5)
|
2015-10-31 01:29:46 +00:00
|
|
|
{
|
|
|
|
gtk_style_context_add_class (context, "light");
|
|
|
|
gtk_style_context_remove_class (context, "dark");
|
|
|
|
}
|
2012-02-08 21:35:57 +00:00
|
|
|
else
|
2015-10-31 01:29:46 +00:00
|
|
|
{
|
|
|
|
gtk_style_context_add_class (context, "dark");
|
|
|
|
gtk_style_context_remove_class (context, "light");
|
|
|
|
}
|
2012-02-08 21:35:57 +00:00
|
|
|
|
2012-01-29 15:42:34 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (swatch));
|
2012-02-03 23:34:33 +00:00
|
|
|
g_object_notify (G_OBJECT (swatch), "rgba");
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2012-02-03 23:34:33 +00:00
|
|
|
gtk_color_swatch_get_rgba (GtkColorSwatch *swatch,
|
|
|
|
GdkRGBA *color)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
|
|
|
if (priv->has_color)
|
2012-01-29 15:42:34 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
color->red = priv->color.red;
|
|
|
|
color->green = priv->color.green;
|
|
|
|
color->blue = priv->color.blue;
|
|
|
|
color->alpha = priv->color.alpha;
|
2012-01-29 15:42:34 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
color->red = 1.0;
|
|
|
|
color->green = 1.0;
|
|
|
|
color->blue = 1.0;
|
|
|
|
color->alpha = 1.0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_color_swatch_set_icon (GtkColorSwatch *swatch,
|
|
|
|
const gchar *icon)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
|
|
|
priv->icon = g_strdup (icon);
|
2016-01-08 00:20:55 +00:00
|
|
|
update_icon (swatch);
|
2012-01-29 15:42:34 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (swatch));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_color_swatch_set_can_drop (GtkColorSwatch *swatch,
|
|
|
|
gboolean can_drop)
|
|
|
|
{
|
2012-02-09 03:56:14 +00:00
|
|
|
if (can_drop)
|
|
|
|
{
|
2017-11-18 01:19:53 +00:00
|
|
|
GdkContentFormats *targets = gdk_content_formats_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
|
2012-02-09 03:56:14 +00:00
|
|
|
gtk_drag_dest_set (GTK_WIDGET (swatch),
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
2017-11-14 21:32:23 +00:00
|
|
|
targets,
|
2012-02-09 03:56:14 +00:00
|
|
|
GDK_ACTION_COPY);
|
2017-11-18 01:19:53 +00:00
|
|
|
gdk_content_formats_unref (targets);
|
2012-02-09 03:56:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_drag_dest_unset (GTK_WIDGET (swatch));
|
|
|
|
}
|
2012-01-29 15:42:34 +00:00
|
|
|
}
|
|
|
|
|
2012-01-31 07:05:37 +00:00
|
|
|
void
|
2012-02-03 23:34:33 +00:00
|
|
|
gtk_color_swatch_set_use_alpha (GtkColorSwatch *swatch,
|
2012-02-04 05:02:49 +00:00
|
|
|
gboolean use_alpha)
|
2012-01-31 07:05:37 +00:00
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
|
|
|
priv->use_alpha = use_alpha;
|
2012-01-31 07:05:37 +00:00
|
|
|
gtk_widget_queue_draw (GTK_WIDGET (swatch));
|
|
|
|
}
|
|
|
|
|
2012-02-17 16:01:50 +00:00
|
|
|
void
|
|
|
|
gtk_color_swatch_set_selectable (GtkColorSwatch *swatch,
|
|
|
|
gboolean selectable)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
|
|
|
if (selectable == priv->selectable)
|
2012-02-17 16:01:50 +00:00
|
|
|
return;
|
|
|
|
|
2018-07-07 14:08:21 +00:00
|
|
|
priv->selectable = selectable;
|
2012-02-17 16:01:50 +00:00
|
|
|
g_object_notify (G_OBJECT (swatch), "selectable");
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gtk_color_swatch_get_selectable (GtkColorSwatch *swatch)
|
|
|
|
{
|
2018-07-07 14:08:21 +00:00
|
|
|
GtkColorSwatchPrivate *priv = gtk_color_swatch_get_instance_private (swatch);
|
|
|
|
|
|
|
|
return priv->selectable;
|
2012-02-17 16:01:50 +00:00
|
|
|
}
|
|
|
|
|
2012-01-29 15:42:34 +00:00
|
|
|
/* vim:set foldmethod=marker: */
|