removed the hex entry from the GimpColorScales widget.

2005-05-19  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpcolorscales.c: removed the hex entry from the
	GimpColorScales widget.

	* libgimpwidgets/gimpcolorselection.c: added it here instead.

	* app/widgets/gimpcoloreditor.[ch]: and here, next to the FG/BG
	editor.
This commit is contained in:
Sven Neumann 2005-05-19 17:08:03 +00:00 committed by Sven Neumann
parent 9b29707961
commit 38f5546f5b
5 changed files with 169 additions and 99 deletions

View file

@ -1,3 +1,13 @@
2005-05-19 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcolorscales.c: removed the hex entry from the
GimpColorScales widget.
* libgimpwidgets/gimpcolorselection.c: added it here instead.
* app/widgets/gimpcoloreditor.[ch]: and here, next to the FG/BG
editor.
2005-05-19 Sven Neumann <sven@gimp.org>
* app/core/gimpstrokeoptions.[ch]: renamed property "miter" to

View file

@ -76,6 +76,8 @@ static void gimp_color_editor_fg_bg_notify (GtkWidget *widget,
static void gimp_color_editor_color_picked (GtkWidget *widget,
const GimpRGB *rgb,
GimpColorEditor *editor);
static void gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
GimpColorEditor *editor);
static GimpEditorClass *parent_class = NULL;
@ -135,6 +137,8 @@ static void
gimp_color_editor_init (GimpColorEditor *editor)
{
GtkWidget *notebook;
GtkWidget *hbox;
GtkWidget *vbox;
gint content_spacing;
gint button_spacing;
GtkIconSize button_icon_size;
@ -229,15 +233,35 @@ gimp_color_editor_init (GimpColorEditor *editor)
editor);
}
hbox = gtk_hbox_new (TRUE, 6);
gtk_box_pack_start (GTK_BOX (editor), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
/* FG/BG editor */
editor->fg_bg = gimp_fg_bg_editor_new (NULL);
gtk_widget_set_size_request (editor->fg_bg, -1, 48);
gtk_box_pack_start (GTK_BOX (editor), editor->fg_bg, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), editor->fg_bg, TRUE, TRUE, 0);
gtk_widget_show (editor->fg_bg);
g_signal_connect (editor->fg_bg, "notify::active-color",
G_CALLBACK (gimp_color_editor_fg_bg_notify),
editor);
/* The hex triplet entry */
vbox = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
gtk_widget_show (vbox);
editor->hex_entry = gimp_color_hex_entry_new ();
gimp_help_set_help_data (editor->hex_entry,
_("Hexadecimal color notation "
"as used in HTML and CSS"), NULL);
gtk_box_pack_end (GTK_BOX (vbox), editor->hex_entry, FALSE, FALSE, 0);
gtk_widget_show (editor->hex_entry);
g_signal_connect (editor->hex_entry, "color_changed",
G_CALLBACK (gimp_color_editor_entry_changed),
editor);
}
static GtkWidget *
@ -390,9 +414,6 @@ gimp_color_editor_destroy (GtkObject *object)
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
/* public functions */
GtkWidget *
gimp_color_editor_new (GimpContext *context)
{
@ -422,7 +443,36 @@ gimp_color_editor_style_set (GtkWidget *widget,
}
/* public functions */
static void
gimp_color_editor_set_color (GimpColorEditor *editor,
const GimpRGB *rgb)
{
GimpHSV hsv;
gimp_rgb_to_hsv (rgb, &hsv);
g_signal_handlers_block_by_func (editor->notebook,
gimp_color_editor_color_changed,
editor);
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook),
rgb, &hsv);
g_signal_handlers_unblock_by_func (editor->notebook,
gimp_color_editor_color_changed,
editor);
g_signal_handlers_block_by_func (editor->hex_entry,
gimp_color_editor_entry_changed,
editor);
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry),
rgb);
g_signal_handlers_unblock_by_func (editor->hex_entry,
gimp_color_editor_entry_changed,
editor);
}
static void
gimp_color_editor_fg_changed (GimpContext *context,
@ -430,22 +480,7 @@ gimp_color_editor_fg_changed (GimpContext *context,
GimpColorEditor *editor)
{
if (! editor->edit_bg)
{
GimpHSV hsv;
gimp_rgb_to_hsv (rgb, &hsv);
g_signal_handlers_block_by_func (editor->notebook,
gimp_color_editor_color_changed,
editor);
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook),
rgb, &hsv);
g_signal_handlers_unblock_by_func (editor->notebook,
gimp_color_editor_color_changed,
editor);
}
gimp_color_editor_set_color (editor, rgb);
}
static void
@ -454,22 +489,7 @@ gimp_color_editor_bg_changed (GimpContext *context,
GimpColorEditor *editor)
{
if (editor->edit_bg)
{
GimpHSV hsv;
gimp_rgb_to_hsv (rgb, &hsv);
g_signal_handlers_block_by_func (editor->notebook,
gimp_color_editor_color_changed,
editor);
gimp_color_selector_set_color (GIMP_COLOR_SELECTOR (editor->notebook),
rgb, &hsv);
g_signal_handlers_unblock_by_func (editor->notebook,
gimp_color_editor_color_changed,
editor);
}
gimp_color_editor_set_color (editor, rgb);
}
static void
@ -505,6 +525,17 @@ gimp_color_editor_color_changed (GimpColorSelector *selector,
editor);
}
}
g_signal_handlers_block_by_func (editor->hex_entry,
gimp_color_editor_entry_changed,
editor);
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (editor->hex_entry),
rgb);
g_signal_handlers_unblock_by_func (editor->hex_entry,
gimp_color_editor_entry_changed,
editor);
}
static void
@ -577,3 +608,20 @@ gimp_color_editor_color_picked (GtkWidget *widget,
gimp_context_set_foreground (editor->context, rgb);
}
}
static void
gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
GimpColorEditor *editor)
{
GimpRGB rgb;
gimp_color_hex_entry_get_color (entry, &rgb);
if (editor->context)
{
if (editor->edit_bg)
gimp_context_set_background (editor->context, &rgb);
else
gimp_context_set_foreground (editor->context, &rgb);
}
}

View file

@ -46,6 +46,7 @@ struct _GimpColorEditor
GtkWidget *hbox;
GtkWidget *notebook;
GtkWidget *fg_bg;
GtkWidget *hex_entry;
};
struct _GimpColorEditorClass

View file

@ -36,7 +36,6 @@
#include "gimpcolorscale.h"
#include "gimpcolorscales.h"
#include "gimpcolorhexentry.h"
#include "gimpwidgets.h"
#include "libgimp/libgimp-intl.h"
@ -56,7 +55,6 @@ struct _GimpColorScales
GtkWidget *toggles[7];
GtkWidget *sliders[7];
GtkObject *slider_data[7];
GtkWidget *hex_entry;
};
struct _GimpColorScalesClass
@ -88,9 +86,6 @@ static void gimp_color_scales_toggle_update (GtkWidget *widget,
static void gimp_color_scales_scale_update (GtkAdjustment *adjustment,
GimpColorScales *scales);
static void gimp_color_scales_entry_changed (GimpColorHexEntry *entry,
GimpColorScales *scales);
static GimpColorSelectorClass *parent_class = NULL;
@ -145,8 +140,6 @@ gimp_color_scales_init (GimpColorScales *scales)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
GtkWidget *table;
GtkWidget *hbox;
GtkWidget *label;
GSList *group;
gint i;
@ -232,27 +225,6 @@ gimp_color_scales_init (GimpColorScales *scales)
G_CALLBACK (gimp_color_scales_scale_update),
scales);
}
/* The hex triplet entry */
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_end (GTK_BOX (scales), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
scales->hex_entry = gimp_color_hex_entry_new ();
gimp_help_set_help_data (scales->hex_entry,
_("Hexadecimal color notation "
"as used in HTML and CSS"), NULL);
gtk_box_pack_end (GTK_BOX (hbox), scales->hex_entry, TRUE, TRUE, 0);
gtk_widget_show (scales->hex_entry);
label = gtk_label_new_with_mnemonic (_("HTML _Notation:"));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), scales->hex_entry);
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_signal_connect (scales->hex_entry, "color_changed",
G_CALLBACK (gimp_color_scales_entry_changed),
scales);
}
static void
@ -375,17 +347,6 @@ gimp_color_scales_update_scales (GimpColorScales *scales,
gimp_color_scale_set_color (GIMP_COLOR_SCALE (scales->sliders[i]),
&selector->rgb, &selector->hsv);
}
g_signal_handlers_block_by_func (scales->hex_entry,
gimp_color_scales_entry_changed,
scales);
gimp_color_hex_entry_set_color (GIMP_COLOR_HEX_ENTRY (scales->hex_entry),
&selector->rgb);
g_signal_handlers_unblock_by_func (scales->hex_entry,
gimp_color_scales_entry_changed,
scales);
}
static void
@ -465,17 +426,3 @@ gimp_color_scales_scale_update (GtkAdjustment *adjustment,
gimp_color_selector_color_changed (selector);
}
static void
gimp_color_scales_entry_changed (GimpColorHexEntry *entry,
GimpColorScales *scales)
{
GimpColorSelector *selector = GIMP_COLOR_SELECTOR (scales);
gimp_color_hex_entry_get_color (entry, &selector->rgb);
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
gimp_color_scales_update_scales (scales, -1);
gimp_color_selector_color_changed (selector);
}

View file

@ -50,9 +50,15 @@ typedef enum
{
UPDATE_NOTEBOOK = 1 << 0,
UPDATE_SCALES = 1 << 1,
UPDATE_NEW_COLOR = 1 << 2
UPDATE_ENTRY = 1 << 2,
UPDATE_COLOR = 1 << 3
} UpdateType;
#define UPDATE_ALL (UPDATE_NOTEBOOK | \
UPDATE_SCALES | \
UPDATE_ENTRY | \
UPDATE_COLOR)
enum
{
COLOR_CHANGED,
@ -75,6 +81,8 @@ static void gimp_color_selection_scales_changed (GimpColorSelector *select
const GimpRGB *rgb,
const GimpHSV *hsv,
GimpColorSelection *selection);
static void gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
GimpColorSelection *selection);
static void gimp_color_selection_channel_changed (GimpColorSelector *selector,
GimpColorSelectorChannel channel,
GimpColorSelection *selection);
@ -141,6 +149,9 @@ gimp_color_selection_init (GimpColorSelection *selection)
GtkWidget *main_hbox;
GtkWidget *frame;
GtkWidget *table;
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
selection->show_alpha = TRUE;
@ -259,6 +270,29 @@ gimp_color_selection_init (GimpColorSelection *selection)
g_signal_connect (selection->scales, "color_changed",
G_CALLBACK (gimp_color_selection_scales_changed),
selection);
/* The hex triplet entry */
hbox = gtk_hbox_new (FALSE, 6);
gtk_box_pack_end (GTK_BOX (selection->right_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
entry = gimp_color_hex_entry_new ();
gimp_help_set_help_data (entry,
_("Hexadecimal color notation "
"as used in HTML and CSS"), NULL);
gtk_box_pack_end (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
gtk_widget_show (entry);
label = gtk_label_new_with_mnemonic (_("HTML _Notation:"));
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
g_object_set_data (G_OBJECT (selection), "color-hex-entry", entry);
g_signal_connect (entry, "color_changed",
G_CALLBACK (gimp_color_selection_entry_changed),
selection);
}
/**
@ -340,10 +374,7 @@ gimp_color_selection_set_color (GimpColorSelection *selection,
selection->rgb = *color;
gimp_rgb_to_hsv (&selection->rgb, &selection->hsv);
gimp_color_selection_update (selection,
UPDATE_NOTEBOOK |
UPDATE_SCALES |
UPDATE_NEW_COLOR);
gimp_color_selection_update (selection, UPDATE_ALL);
gimp_color_selection_color_changed (selection);
}
@ -458,7 +489,8 @@ gimp_color_selection_notebook_changed (GimpColorSelector *selector,
selection->hsv = *hsv;
selection->rgb = *rgb;
gimp_color_selection_update (selection, UPDATE_SCALES | UPDATE_NEW_COLOR);
gimp_color_selection_update (selection,
UPDATE_SCALES | UPDATE_ENTRY | UPDATE_COLOR);
gimp_color_selection_color_changed (selection);
}
@ -471,7 +503,21 @@ gimp_color_selection_scales_changed (GimpColorSelector *selector,
selection->rgb = *rgb;
selection->hsv = *hsv;
gimp_color_selection_update (selection, UPDATE_NOTEBOOK | UPDATE_NEW_COLOR);
gimp_color_selection_update (selection,
UPDATE_ENTRY | UPDATE_NOTEBOOK | UPDATE_COLOR);
gimp_color_selection_color_changed (selection);
}
static void
gimp_color_selection_entry_changed (GimpColorHexEntry *entry,
GimpColorSelection *selection)
{
gimp_color_hex_entry_get_color (entry, &selection->rgb);
gimp_rgb_to_hsv (&selection->rgb, &selection->hsv);
gimp_color_selection_update (selection,
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_COLOR);
gimp_color_selection_color_changed (selection);
}
@ -493,7 +539,8 @@ gimp_color_selection_new_color_changed (GtkWidget *widget,
gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &selection->rgb);
gimp_rgb_to_hsv (&selection->rgb, &selection->hsv);
gimp_color_selection_update (selection, UPDATE_NOTEBOOK | UPDATE_SCALES);
gimp_color_selection_update (selection,
UPDATE_NOTEBOOK | UPDATE_SCALES | UPDATE_ENTRY);
gimp_color_selection_color_changed (selection);
}
@ -531,7 +578,24 @@ gimp_color_selection_update (GimpColorSelection *selection,
selection);
}
if (update & UPDATE_NEW_COLOR)
if (update & UPDATE_ENTRY)
{
GimpColorHexEntry *entry;
entry = g_object_get_data (G_OBJECT (selection), "color-hex-entry");
g_signal_handlers_block_by_func (entry,
gimp_color_selection_entry_changed,
selection);
gimp_color_hex_entry_set_color (entry, &selection->rgb);
g_signal_handlers_unblock_by_func (entry,
gimp_color_selection_entry_changed,
selection);
}
if (update & UPDATE_COLOR)
{
g_signal_handlers_block_by_func (selection->new_color,
gimp_color_selection_new_color_changed,