2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-02-05 14:39:40 +00:00
|
|
|
* Copyright (C) 1995-2001 Spencer Kimball, Peter Mattis, and others
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-25 19:11:26 +00:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-02-05 14:39:40 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2003-09-26 13:33:54 +00:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2003-02-05 14:39:40 +00:00
|
|
|
|
|
|
|
#include "gimpcolorpickeroptions.h"
|
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2003-02-05 14:39:40 +00:00
|
|
|
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2003-10-21 12:45:58 +00:00
|
|
|
PROP_SAMPLE_AVERAGE, /* overrides a GimpColorOptions property */
|
2004-06-30 12:10:08 +00:00
|
|
|
PROP_PICK_MODE,
|
2005-09-26 16:01:13 +00:00
|
|
|
PROP_ADD_TO_PALETTE,
|
|
|
|
PROP_USE_INFO_WINDOW
|
2003-02-07 17:12:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_color_picker_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_color_picker_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
|
2005-12-13 09:13:50 +00:00
|
|
|
G_DEFINE_TYPE (GimpColorPickerOptions, gimp_color_picker_options,
|
2006-05-15 09:46:31 +00:00
|
|
|
GIMP_TYPE_COLOR_OPTIONS)
|
2003-02-05 14:39:40 +00:00
|
|
|
|
|
|
|
|
2003-09-26 13:33:54 +00:00
|
|
|
static void
|
2003-02-05 14:39:40 +00:00
|
|
|
gimp_color_picker_options_class_init (GimpColorPickerOptionsClass *klass)
|
|
|
|
{
|
2004-09-24 12:01:35 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-02-07 17:12:21 +00:00
|
|
|
|
|
|
|
object_class->set_property = gimp_color_picker_options_set_property;
|
|
|
|
object_class->get_property = gimp_color_picker_options_get_property;
|
|
|
|
|
2003-10-21 12:45:58 +00:00
|
|
|
/* override a GimpColorOptions property to get a different default value */
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAMPLE_AVERAGE,
|
|
|
|
"sample-average", NULL,
|
|
|
|
FALSE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-09-26 13:33:54 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PICK_MODE,
|
|
|
|
"pick-mode", NULL,
|
|
|
|
GIMP_TYPE_COLOR_PICK_MODE,
|
|
|
|
GIMP_COLOR_PICK_MODE_FOREGROUND,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2004-06-30 12:10:08 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ADD_TO_PALETTE,
|
|
|
|
"add-to-palette", NULL,
|
|
|
|
FALSE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2005-09-26 16:01:13 +00:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_USE_INFO_WINDOW,
|
|
|
|
"use-info-window", NULL,
|
|
|
|
FALSE,
|
2006-01-18 20:29:40 +00:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-05 14:39:40 +00:00
|
|
|
}
|
|
|
|
|
2005-12-13 09:13:50 +00:00
|
|
|
static void
|
|
|
|
gimp_color_picker_options_init (GimpColorPickerOptions *options)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
static void
|
|
|
|
gimp_color_picker_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
2003-02-05 14:39:40 +00:00
|
|
|
{
|
2003-10-21 12:45:58 +00:00
|
|
|
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_OPTIONS (object);
|
2003-02-05 14:39:40 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2003-10-21 12:45:58 +00:00
|
|
|
case PROP_SAMPLE_AVERAGE:
|
|
|
|
GIMP_COLOR_OPTIONS (options)->sample_average = g_value_get_boolean (value);
|
|
|
|
break;
|
2003-09-26 13:33:54 +00:00
|
|
|
case PROP_PICK_MODE:
|
|
|
|
options->pick_mode = g_value_get_enum (value);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
2004-06-30 12:10:08 +00:00
|
|
|
case PROP_ADD_TO_PALETTE:
|
|
|
|
options->add_to_palette = g_value_get_boolean (value);
|
|
|
|
break;
|
2005-09-26 16:01:13 +00:00
|
|
|
case PROP_USE_INFO_WINDOW:
|
|
|
|
options->use_info_window = g_value_get_boolean (value);
|
|
|
|
break;
|
2003-02-07 17:12:21 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-02-05 14:39:40 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
static void
|
|
|
|
gimp_color_picker_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2003-10-21 12:45:58 +00:00
|
|
|
GimpColorPickerOptions *options = GIMP_COLOR_PICKER_OPTIONS (object);
|
2003-02-05 14:39:40 +00:00
|
|
|
|
2003-02-07 17:12:21 +00:00
|
|
|
switch (property_id)
|
|
|
|
{
|
2003-10-21 12:45:58 +00:00
|
|
|
case PROP_SAMPLE_AVERAGE:
|
|
|
|
g_value_set_boolean (value,
|
|
|
|
GIMP_COLOR_OPTIONS (options)->sample_average);
|
|
|
|
break;
|
2003-09-26 13:33:54 +00:00
|
|
|
case PROP_PICK_MODE:
|
|
|
|
g_value_set_enum (value, options->pick_mode);
|
2003-02-07 17:12:21 +00:00
|
|
|
break;
|
2004-06-30 12:10:08 +00:00
|
|
|
case PROP_ADD_TO_PALETTE:
|
|
|
|
g_value_set_boolean (value, options->add_to_palette);
|
|
|
|
break;
|
2005-09-26 16:01:13 +00:00
|
|
|
case PROP_USE_INFO_WINDOW:
|
|
|
|
g_value_set_boolean (value, options->use_info_window);
|
|
|
|
break;
|
2003-02-07 17:12:21 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-02-09 17:32:52 +00:00
|
|
|
GtkWidget *
|
2003-02-07 17:12:21 +00:00
|
|
|
gimp_color_picker_options_gui (GimpToolOptions *tool_options)
|
|
|
|
{
|
2004-06-30 12:10:08 +00:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
2006-08-27 22:19:35 +00:00
|
|
|
GtkWidget *vbox = gimp_color_options_gui (tool_options);
|
2003-10-25 19:00:49 +00:00
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *frame;
|
|
|
|
gchar *str;
|
2003-02-07 17:12:21 +00:00
|
|
|
|
2003-06-05 18:47:23 +00:00
|
|
|
/* the sample merged toggle button */
|
|
|
|
button = gimp_prop_check_button_new (config, "sample-merged",
|
2004-06-23 20:29:46 +00:00
|
|
|
_("Sample merged"));
|
2003-06-05 18:47:23 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-09-26 13:33:54 +00:00
|
|
|
/* the pick FG/BG frame */
|
2005-09-13 22:17:05 +00:00
|
|
|
str = g_strdup_printf (_("Pick Mode (%s)"),
|
2004-06-28 23:30:57 +00:00
|
|
|
gimp_get_mod_string (GDK_CONTROL_MASK));
|
2003-09-26 13:33:54 +00:00
|
|
|
frame = gimp_prop_enum_radio_frame_new (config, "pick-mode", str, -1, -1);
|
|
|
|
g_free (str);
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2005-09-26 16:01:13 +00:00
|
|
|
/* the use_info_window toggle button */
|
|
|
|
str = g_strdup_printf (_("Use info window (%s)"),
|
2004-06-30 12:10:08 +00:00
|
|
|
gimp_get_mod_string (GDK_SHIFT_MASK));
|
2005-09-26 16:01:13 +00:00
|
|
|
button = gimp_prop_check_button_new (config, "use-info-window", str);
|
2004-06-30 12:10:08 +00:00
|
|
|
g_free (str);
|
|
|
|
|
2005-09-26 16:01:13 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
2004-06-30 12:10:08 +00:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-02-09 17:32:52 +00:00
|
|
|
return vbox;
|
2003-02-05 14:39:40 +00:00
|
|
|
}
|