mirror of https://github.com/GNOME/gimp.git
app/widgets/Makefile.am new widget featuring a proof-of-concept palette
2006-11-03 Michael Natterer <mitch@gimp.org> * app/widgets/Makefile.am * app/widgets/gimpcolorselectorpalette.[ch]: new widget featuring a proof-of-concept palette color selector. It always shows the current palette and doesn't bother to have any features yet. If I don't get around finishing this I will disable it for the 2.4 release, but it's better kept in CVS than on my disk... Addresses bug #132146. * app/widgets/gimpcolordialog.c (gimp_color_dialog_new): attach the passed context to the dialog so the palette selector can find it (puke). * app/gui/gui.c (gui_restore_callback): register the new object with the GType system.
This commit is contained in:
parent
725a4e414f
commit
cd0c301a3f
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2006-11-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/widgets/Makefile.am
|
||||
* app/widgets/gimpcolorselectorpalette.[ch]: new widget featuring
|
||||
a proof-of-concept palette color selector. It always shows the
|
||||
current palette and doesn't bother to have any features yet. If I
|
||||
don't get around finishing this I will disable it for the 2.4
|
||||
release, but it's better kept in CVS than on my disk...
|
||||
Addresses bug #132146.
|
||||
|
||||
* app/widgets/gimpcolordialog.c (gimp_color_dialog_new): attach
|
||||
the passed context to the dialog so the palette selector can find
|
||||
it (puke).
|
||||
|
||||
* app/gui/gui.c (gui_restore_callback): register the new object
|
||||
with the GType system.
|
||||
|
||||
2006-11-03 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/core-enums.[ch] (enum GimpUndoType): added value
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include "tools/gimp-tools.h"
|
||||
|
||||
#include "widgets/gimpclipboard.h"
|
||||
#include "widgets/gimpcolorselectorpalette.h"
|
||||
#include "widgets/gimpcontrollers.h"
|
||||
#include "widgets/gimpdevices.h"
|
||||
#include "widgets/gimpdevicestatus.h"
|
||||
|
@ -421,6 +422,8 @@ gui_restore_callback (Gimp *gimp,
|
|||
gimp_controllers_init (gimp);
|
||||
session_init (gimp);
|
||||
|
||||
g_type_class_unref (g_type_class_ref (GIMP_TYPE_COLOR_SELECTOR_PALETTE));
|
||||
|
||||
(* status_callback) (NULL, _("Tool Options"), 1.0);
|
||||
gimp_tools_restore (gimp);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ libappwidgets_a_sources = \
|
|||
gimpcolormapeditor.h \
|
||||
gimpcolorpanel.c \
|
||||
gimpcolorpanel.h \
|
||||
gimpcolorselectorpalette.c \
|
||||
gimpcolorselectorpalette.h \
|
||||
gimpcomponenteditor.c \
|
||||
gimpcomponenteditor.h \
|
||||
gimpcontainerbox.c \
|
||||
|
|
|
@ -293,8 +293,11 @@ gimp_color_dialog_new (GimpViewable *viewable,
|
|||
show_alpha);
|
||||
|
||||
if (context)
|
||||
gimp_color_selection_set_config (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
context->gimp->config->color_management);
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
|
||||
color);
|
||||
|
|
|
@ -0,0 +1,147 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorselectorpalette.c
|
||||
* Copyright (C) 2006 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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
|
||||
* Library 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "widgets-types.h"
|
||||
|
||||
#include "core/gimpcontext.h"
|
||||
#include "core/gimppalette.h"
|
||||
|
||||
#include "gimpcolorselectorpalette.h"
|
||||
#include "gimppaletteview.h"
|
||||
#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);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpColorSelectorPalette, gimp_color_selector_palette,
|
||||
GIMP_TYPE_COLOR_SELECTOR)
|
||||
|
||||
#define parent_class gimp_color_selector_palette_parent_class
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
static void
|
||||
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,
|
||||
const GimpHSV *hsv)
|
||||
{
|
||||
GimpColorSelectorPalette *select = GIMP_COLOR_SELECTOR_PALETTE (selector);
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpcolorselectorpalette.h
|
||||
* Copyright (C) 2006 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* 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
|
||||
* Library 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.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_COLOR_SELECTOR_PALETTE_H__
|
||||
#define __GIMP_COLOR_SELECTOR_PALETTE_H__
|
||||
|
||||
|
||||
#include "libgimpwidgets/gimpcolorselector.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_COLOR_SELECTOR_PALETTE (gimp_color_selector_palette_get_type ())
|
||||
#define GIMP_COLOR_SELECTOR_PALETTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_SELECTOR_PALETTE, GimpColorSelectorPalette))
|
||||
#define GIMP_IS_COLOR_SELECTOR_PALETTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_SELECTOR_PALETTE))
|
||||
#define GIMP_COLOR_SELECTOR_PALETTE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_SELECTOR_PALETTE, GimpColorSelectorPaletteClass))
|
||||
#define GIMP_IS_COLOR_SELECTOR_PALETTE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_SELECTOR_PALETTE))
|
||||
#define GIMP_COLOR_SELECTOR_PALETTE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_SELECTOR_PALETTE, GimpColorSelectorPaletteClass))
|
||||
|
||||
|
||||
typedef struct _GimpColorSelectorPalette GimpColorSelectorPalette;
|
||||
typedef struct _GimpColorSelectorPaletteClass GimpColorSelectorPaletteClass;
|
||||
|
||||
struct _GimpColorSelectorPalette
|
||||
{
|
||||
GimpColorSelector parent_instance;
|
||||
|
||||
GimpContext *context;
|
||||
GtkWidget *view;
|
||||
};
|
||||
|
||||
struct _GimpColorSelectorPaletteClass
|
||||
{
|
||||
GimpColorSelectorClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_color_selector_palette_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_COLOR_SELECTOR_PALETTE_H__ */
|
Loading…
Reference in New Issue