mirror of https://github.com/GNOME/gimp.git
app/widgets/gimpcoloreditor.c temporarily attach the context to the
2006-11-03 Michael Natterer <mitch@gimp.org> * app/widgets/gimpcoloreditor.c * app/widgets/gimpcolordialog.c: temporarily attach the context to the GimpColorConfig object while calling the color selector's set_config(). * app/widgets/gimpcolorselectorpalette.c: moved widget creation and signal connecting to GimpColorSelector::set_config() and use the context attached to the passed GimpColorConfig object.
This commit is contained in:
parent
dd9a1db625
commit
0e4f794f46
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2006-11-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/gimpcoloreditor.c
|
||||
* app/widgets/gimpcolordialog.c: temporarily attach the context to
|
||||
the GimpColorConfig object while calling the color selector's
|
||||
set_config().
|
||||
|
||||
* app/widgets/gimpcolorselectorpalette.c: moved widget creation
|
||||
and signal connecting to GimpColorSelector::set_config() and
|
||||
use the context attached to the passed GimpColorConfig object.
|
||||
|
||||
2006-11-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimp/gimpbrushes.c
|
||||
|
@ -13,7 +24,7 @@
|
|||
2006-11-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage.[ch]: added gimp_image_add_layers() which
|
||||
takes a list of layers and vierport coordinates to center the
|
||||
takes a list of layers and viewport coordinates to center the
|
||||
layers in.
|
||||
|
||||
* app/dialogs/file-open-dialog.c
|
||||
|
|
|
@ -294,9 +294,14 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
|||
|
||||
if (context)
|
||||
{
|
||||
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
||||
"gimp-context", context);
|
||||
|
||||
gimp_color_selection_set_config (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
context->gimp->config->color_management);
|
||||
g_object_set_data (G_OBJECT (dialog), "gimp-context", context);
|
||||
|
||||
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
||||
"gimp-context", NULL);
|
||||
}
|
||||
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
|
|
|
@ -449,8 +449,14 @@ gimp_color_editor_set_context (GimpDocked *docked,
|
|||
gimp_color_editor_fg_changed (editor->context, &rgb, editor);
|
||||
}
|
||||
|
||||
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
||||
"gimp-context", editor->context);
|
||||
|
||||
gimp_color_selector_set_config (GIMP_COLOR_SELECTOR (editor->notebook),
|
||||
context->gimp->config->color_management);
|
||||
|
||||
g_object_set_data (G_OBJECT (context->gimp->config->color_management),
|
||||
"gimp-context", NULL);
|
||||
}
|
||||
|
||||
gimp_fg_bg_editor_set_context (GIMP_FG_BG_EDITOR (editor->fg_bg), context);
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
#include "gimpviewrendererpalette.h"
|
||||
|
||||
|
||||
static void gimp_color_selector_palette_realize (GtkWidget *widget);
|
||||
|
||||
static void gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||
const GimpRGB *rgb,
|
||||
const GimpHSV *hsv);
|
||||
static void gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||
const GimpRGB *rgb,
|
||||
const GimpHSV *hsv);
|
||||
static void gimp_color_selector_palette_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpColorSelectorPalette, gimp_color_selector_palette,
|
||||
|
@ -53,15 +53,13 @@ G_DEFINE_TYPE (GimpColorSelectorPalette, gimp_color_selector_palette,
|
|||
static void
|
||||
gimp_color_selector_palette_class_init (GimpColorSelectorPaletteClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GimpColorSelectorClass *selector_class = GIMP_COLOR_SELECTOR_CLASS (klass);
|
||||
|
||||
widget_class->realize = gimp_color_selector_palette_realize;
|
||||
|
||||
selector_class->name = "Palette";
|
||||
selector_class->help_id = "gimp-colorselector-palette";
|
||||
selector_class->stock_id = GIMP_STOCK_PALETTE;
|
||||
selector_class->set_color = gimp_color_selector_palette_set_color;
|
||||
selector_class->name = "Palette";
|
||||
selector_class->help_id = "gimp-colorselector-palette";
|
||||
selector_class->stock_id = GIMP_STOCK_PALETTE;
|
||||
selector_class->set_color = gimp_color_selector_palette_set_color;
|
||||
selector_class->set_config = gimp_color_selector_palette_set_config;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -69,75 +67,6 @@ gimp_color_selector_palette_init (GimpColorSelectorPalette *select)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_palette_changed (GimpContext *context,
|
||||
GimpPalette *palette,
|
||||
GimpView *view)
|
||||
{
|
||||
gimp_view_set_viewable (view, GIMP_VIEWABLE (palette));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_entry_clicked (GimpPaletteView *view,
|
||||
GimpPaletteEntry *entry,
|
||||
GdkModifierType state,
|
||||
GimpColorSelector *selector)
|
||||
{
|
||||
selector->rgb = entry->color;
|
||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
||||
|
||||
gimp_color_selector_color_changed (selector);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_realize (GtkWidget *widget)
|
||||
{
|
||||
GimpColorSelectorPalette *select = GIMP_COLOR_SELECTOR_PALETTE (widget);
|
||||
|
||||
GTK_WIDGET_CLASS (parent_class)->realize (widget);
|
||||
|
||||
if (! select->context)
|
||||
{
|
||||
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (select));
|
||||
GtkWidget *frame;
|
||||
|
||||
select->context = g_object_get_data (G_OBJECT (toplevel),
|
||||
"gimp-context");
|
||||
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (select->context));
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (select), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
select->view = gimp_view_new_full_by_types (select->context,
|
||||
GIMP_TYPE_PALETTE_VIEW,
|
||||
GIMP_TYPE_PALETTE,
|
||||
100, 100, 0,
|
||||
FALSE, TRUE, FALSE);
|
||||
gimp_view_set_expand (GIMP_VIEW (select->view), TRUE);
|
||||
gimp_view_renderer_palette_set_cell_size
|
||||
(GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (select->view)->renderer), -1);
|
||||
gimp_view_renderer_palette_set_draw_grid
|
||||
(GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (select->view)->renderer), TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), select->view);
|
||||
gtk_widget_show (select->view);
|
||||
|
||||
g_signal_connect (select->view, "entry-clicked",
|
||||
G_CALLBACK (gimp_color_selector_palette_entry_clicked),
|
||||
select);
|
||||
|
||||
g_signal_connect_object (select->context, "palette-changed",
|
||||
G_CALLBACK (gimp_color_selector_palette_palette_changed),
|
||||
select->view, 0);
|
||||
|
||||
gimp_color_selector_palette_palette_changed (select->context,
|
||||
gimp_context_get_palette (select->context),
|
||||
GIMP_VIEW (select->view));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
||||
const GimpRGB *rgb,
|
||||
|
@ -169,3 +98,81 @@ gimp_color_selector_palette_set_color (GimpColorSelector *selector,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_palette_changed (GimpContext *context,
|
||||
GimpPalette *palette,
|
||||
GimpColorSelectorPalette *select)
|
||||
{
|
||||
gimp_view_set_viewable (GIMP_VIEW (select->view), GIMP_VIEWABLE (palette));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_entry_clicked (GimpPaletteView *view,
|
||||
GimpPaletteEntry *entry,
|
||||
GdkModifierType state,
|
||||
GimpColorSelector *selector)
|
||||
{
|
||||
selector->rgb = entry->color;
|
||||
gimp_rgb_to_hsv (&selector->rgb, &selector->hsv);
|
||||
|
||||
gimp_color_selector_color_changed (selector);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_selector_palette_set_config (GimpColorSelector *selector,
|
||||
GimpColorConfig *config)
|
||||
{
|
||||
GimpColorSelectorPalette *select = GIMP_COLOR_SELECTOR_PALETTE (selector);
|
||||
|
||||
if (select->context)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (select->context,
|
||||
gimp_color_selector_palette_palette_changed,
|
||||
select);
|
||||
select->context = NULL;
|
||||
}
|
||||
|
||||
if (config)
|
||||
select->context = g_object_get_data (G_OBJECT (config), "gimp-context");
|
||||
|
||||
if (select->context)
|
||||
{
|
||||
if (! select->view)
|
||||
{
|
||||
GtkWidget *frame;
|
||||
|
||||
frame = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||
gtk_container_add (GTK_CONTAINER (select), frame);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
select->view = gimp_view_new_full_by_types (select->context,
|
||||
GIMP_TYPE_PALETTE_VIEW,
|
||||
GIMP_TYPE_PALETTE,
|
||||
100, 100, 0,
|
||||
FALSE, TRUE, FALSE);
|
||||
gimp_view_set_expand (GIMP_VIEW (select->view), TRUE);
|
||||
gimp_view_renderer_palette_set_cell_size
|
||||
(GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (select->view)->renderer),
|
||||
-1);
|
||||
gimp_view_renderer_palette_set_draw_grid
|
||||
(GIMP_VIEW_RENDERER_PALETTE (GIMP_VIEW (select->view)->renderer),
|
||||
TRUE);
|
||||
gtk_container_add (GTK_CONTAINER (frame), select->view);
|
||||
gtk_widget_show (select->view);
|
||||
|
||||
g_signal_connect (select->view, "entry-clicked",
|
||||
G_CALLBACK (gimp_color_selector_palette_entry_clicked),
|
||||
select);
|
||||
}
|
||||
|
||||
g_signal_connect_object (select->context, "palette-changed",
|
||||
G_CALLBACK (gimp_color_selector_palette_palette_changed),
|
||||
select, 0);
|
||||
|
||||
gimp_color_selector_palette_palette_changed (select->context,
|
||||
gimp_context_get_palette (select->context),
|
||||
select);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue