Commit 632c577f authored by Michael Natterer's avatar Michael Natterer 😴

Bug 689371 - GIMP uses deprecated GtkHSV widget

Swallow GtkHSV back into GIMP and call it GimpColorWheel. Keep it in
modules/ for the time being. Clean up and undeprecate it. Replace
set_metrics() API by set_ring_fraction() and make it follow the size
of its parent container, making its use straightforward. Kept it clean
of GIMP color types so it can be easily adapted by e.g. Inkscape.
parent 4d4905cc
......@@ -71,7 +71,7 @@ libcolor_selector_water_la_SOURCES = color-selector-water.c
libcolor_selector_water_la_LDFLAGS = -avoid-version -module $(no_undefined)
libcolor_selector_water_la_LIBADD = $(color_selector_libadd)
libcolor_selector_wheel_la_SOURCES = color-selector-wheel.c
libcolor_selector_wheel_la_SOURCES = color-selector-wheel.c gimpcolorwheel.c gimpcolorwheel.h
libcolor_selector_wheel_la_LDFLAGS = -avoid-version -module $(no_undefined)
libcolor_selector_wheel_la_LIBADD = $(color_selector_libadd)
......
......@@ -28,6 +28,8 @@
#include "libgimpmodule/gimpmodule.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "gimpcolorwheel.h"
#include "libgimp/libgimp-intl.h"
......@@ -59,11 +61,7 @@ GType colorsel_wheel_get_type (void);
static void colorsel_wheel_set_color (GimpColorSelector *selector,
const GimpRGB *rgb,
const GimpHSV *hsv);
static void colorsel_wheel_size_allocate (GtkWidget *frame,
GtkAllocation *allocation,
ColorselWheel *wheel);
static void colorsel_wheel_changed (GtkHSV *hsv,
static void colorsel_wheel_changed (GimpColorWheel *hsv,
GimpColorSelector *selector);
static const GimpModuleInfo colorsel_wheel_info =
......@@ -121,11 +119,7 @@ colorsel_wheel_init (ColorselWheel *wheel)
gtk_box_pack_start (GTK_BOX (wheel), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
g_signal_connect (frame, "size-allocate",
G_CALLBACK (colorsel_wheel_size_allocate),
wheel);
wheel->hsv = gtk_hsv_new ();
wheel->hsv = gimp_color_wheel_new ();
gtk_container_add (GTK_CONTAINER (frame), wheel->hsv);
gtk_widget_show (wheel->hsv);
......@@ -141,39 +135,18 @@ colorsel_wheel_set_color (GimpColorSelector *selector,
{
ColorselWheel *wheel = COLORSEL_WHEEL (selector);
gtk_hsv_set_color (GTK_HSV (wheel->hsv), hsv->h, hsv->s, hsv->v);
}
static void
colorsel_wheel_size_allocate (GtkWidget *frame,
GtkAllocation *allocation,
ColorselWheel *wheel)
{
GtkStyle *style = gtk_widget_get_style (frame);
gint focus_width;
gint focus_padding;
gint size;
gtk_widget_style_get (frame,
"focus-line-width", &focus_width,
"focus-padding", &focus_padding,
NULL);
size = (MIN (allocation->width, allocation->height) -
2 * MAX (style->xthickness, style->ythickness) -
2 * (focus_width + focus_padding));
gtk_hsv_set_metrics (GTK_HSV (wheel->hsv), size, size / 10);
gimp_color_wheel_set_color (GIMP_COLOR_WHEEL (wheel->hsv),
hsv->h, hsv->s, hsv->v);
}
static void
colorsel_wheel_changed (GtkHSV *hsv,
colorsel_wheel_changed (GimpColorWheel *hsv,
GimpColorSelector *selector)
{
gtk_hsv_get_color (hsv,
&selector->hsv.h,
&selector->hsv.s,
&selector->hsv.v);
gimp_color_wheel_get_color (hsv,
&selector->hsv.h,
&selector->hsv.s,
&selector->hsv.v);
gimp_hsv_to_rgb (&selector->hsv, &selector->rgb);
gimp_color_selector_color_changed (selector);
......
This diff is collapsed.
/* HSV color selector for GTK+
*
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Simon Budig <Simon.Budig@unix-ag.org> (original code)
* Federico Mena-Quintero <federico@gimp.org> (cleanup for GTK+)
* Jonathan Blandford <jrb@redhat.com> (cleanup for GTK+)
*
* 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.
*/
/*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
#ifndef __GIMP_COLOR_WHEEL_H__
#define __GIMP_COLOR_WHEEL_H__
G_BEGIN_DECLS
#define GIMP_TYPE_COLOR_WHEEL (gimp_color_wheel_get_type ())
#define GIMP_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheel))
#define GIMP_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass))
#define GIMP_IS_COLOR_WHEEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_WHEEL))
#define GIMP_IS_COLOR_WHEEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_WHEEL))
#define GIMP_COLOR_WHEEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_WHEEL, GimpColorWheelClass))
typedef struct _GimpColorWheel GimpColorWheel;
typedef struct _GimpColorWheelClass GimpColorWheelClass;
struct _GimpColorWheel
{
GtkWidget parent_instance;
/* Private data */
gpointer priv;
};
struct _GimpColorWheelClass
{
GtkWidgetClass parent_class;
/* Notification signals */
void (* changed) (GimpColorWheel *wheel);
/* Keybindings */
void (* move) (GimpColorWheel *wheel,
GtkDirectionType type);
/* Padding for future expansion */
void (*_gimp_reserved1) (void);
void (*_gimp_reserved2) (void);
void (*_gimp_reserved3) (void);
void (*_gimp_reserved4) (void);
};
GType gimp_color_wheel_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_color_wheel_new (void);
void gimp_color_wheel_set_color (GimpColorWheel *wheel,
double h,
double s,
double v);
void gimp_color_wheel_get_color (GimpColorWheel *wheel,
gdouble *h,
gdouble *s,
gdouble *v);
void gimp_color_wheel_set_ring_fraction (GimpColorWheel *wheel,
gdouble fraction);
gdouble gimp_color_wheel_get_ring_fraction (GimpColorWheel *wheel);
gboolean gimp_color_wheel_is_adjusting (GimpColorWheel *wheel);
G_END_DECLS
#endif /* __GIMP_COLOR_WHEEL_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment