[gimp] Bug 750546 - Include recently used colors in the Dockable Colors Dialog
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 750546 - Include recently used colors in the Dockable Colors Dialog
- Date: Wed, 23 Dec 2015 12:28:23 +0000 (UTC)
commit 4b6d4f1fd7fb3928065c5bb93a78b3bec418cdd3
Author: Jehan <jehan girinstud io>
Date: Wed Dec 23 03:32:25 2015 +0100
Bug 750546 - Include recently used colors in the Dockable Colors Dialog
New GimpColorHistory widget, replacing the code in GimpColorDialog, and
added to GimpColorEditor to have the color history accessible in the
color dock as well.
Thanks to Thomas Manni for the initial implementation attempt.
app/widgets/Makefile.am | 2 +
app/widgets/gimpcolordialog.c | 181 +++++++-----------------
app/widgets/gimpcolordialog.h | 1 -
app/widgets/gimpcoloreditor.c | 39 +++++
app/widgets/gimpcolorhistory.c | 308 ++++++++++++++++++++++++++++++++++++++++
app/widgets/gimpcolorhistory.h | 61 ++++++++
app/widgets/widgets-types.h | 1 +
po/POTFILES.in | 1 +
8 files changed, 463 insertions(+), 131 deletions(-)
---
diff --git a/app/widgets/Makefile.am b/app/widgets/Makefile.am
index 2b8c82e..6978e73 100644
--- a/app/widgets/Makefile.am
+++ b/app/widgets/Makefile.am
@@ -64,6 +64,8 @@ libappwidgets_a_sources = \
gimpcoloreditor.h \
gimpcolorframe.c \
gimpcolorframe.h \
+ gimpcolorhistory.c \
+ gimpcolorhistory.h \
gimpcolormapeditor.c \
gimpcolormapeditor.h \
gimpcolorpanel.c \
diff --git a/app/widgets/gimpcolordialog.c b/app/widgets/gimpcolordialog.c
index 4456e52..b3c35bc 100644
--- a/app/widgets/gimpcolordialog.c
+++ b/app/widgets/gimpcolordialog.c
@@ -36,6 +36,7 @@
#include "core/gimppalettemru.h"
#include "gimpcolordialog.h"
+#include "gimpcolorhistory.h"
#include "gimpdialogfactory.h"
#include "gimphelp-ids.h"
#include "gimpwidgets-utils.h"
@@ -54,26 +55,22 @@ enum
};
-static void gimp_color_dialog_constructed (GObject *object);
+static void gimp_color_dialog_constructed (GObject *object);
-static void gimp_color_dialog_response (GtkDialog *dialog,
- gint response_id);
+static void gimp_color_dialog_response (GtkDialog *dialog,
+ gint response_id);
-static void gimp_color_dialog_help_func (const gchar *help_id,
- gpointer help_data);
-static void gimp_color_dialog_color_changed (GimpColorSelection *selection,
- GimpColorDialog *dialog);
+static void gimp_color_dialog_help_func (const gchar *help_id,
+ gpointer help_data);
+static void gimp_color_dialog_color_changed (GimpColorSelection *selection,
+ GimpColorDialog *dialog);
-static void gimp_color_history_changed (GimpPalette *history,
- GimpColorDialog *dialog);
-
-static void gimp_color_history_color_clicked (GtkWidget *widget,
- GimpColorDialog *dialog);
-static void gimp_color_history_color_changed (GtkWidget *widget,
- gpointer data);
-static void gimp_color_history_add_clicked (GtkWidget *widget,
- GimpColorDialog *dialog);
+static void gimp_color_history_add_clicked (GtkWidget *widget,
+ GimpColorDialog *dialog);
+static void gimp_color_dialog_history_selected (GimpColorHistory *history,
+ const GimpRGB *rgb,
+ GimpColorDialog *dialog);
G_DEFINE_TYPE (GimpColorDialog, gimp_color_dialog, GIMP_TYPE_VIEWABLE_DIALOG)
@@ -107,11 +104,6 @@ gimp_color_dialog_class_init (GimpColorDialogClass *klass)
static void
gimp_color_dialog_init (GimpColorDialog *dialog)
{
- GtkWidget *table;
- GtkWidget *button;
- GtkWidget *arrow;
- gint i;
-
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
GIMP_STOCK_RESET, RESPONSE_RESET,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@@ -134,18 +126,29 @@ gimp_color_dialog_init (GimpColorDialog *dialog)
g_signal_connect (dialog->selection, "color-changed",
G_CALLBACK (gimp_color_dialog_color_changed),
dialog);
+}
+
+static void
+gimp_color_dialog_constructed (GObject *object)
+{
+ GimpColorDialog *dialog = GIMP_COLOR_DIALOG (object);
+ GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (object);
+ GtkWidget *hbox;
+ GtkWidget *history;
+ GtkWidget *button;
+ GtkWidget *arrow;
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
- /* The color history */
- table = gtk_table_new (2, 1 + GIMP_COLOR_DIALOG_HISTORY_SIZE / 2, TRUE);
- gtk_table_set_row_spacings (GTK_TABLE (table), 2);
- gtk_table_set_col_spacings (GTK_TABLE (table), 2);
- gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
+ /* Color history box. */
+ hbox = gtk_hbox_new (FALSE, 4);
gtk_box_pack_end (GTK_BOX (GIMP_COLOR_SELECTION (dialog->selection)->right_vbox),
- table, FALSE, FALSE, 0);
- gtk_widget_show (table);
+ hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+ /* Button for adding to color history. */
button = gtk_button_new ();
- gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 0, 1);
+ gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (button), FALSE, FALSE, 0);
gimp_help_set_help_data (button,
_("Add the current color to the color history"),
NULL);
@@ -159,52 +162,14 @@ gimp_color_dialog_init (GimpColorDialog *dialog)
gtk_container_add (GTK_CONTAINER (button), arrow);
gtk_widget_show (arrow);
- for (i = 0; i < GIMP_COLOR_DIALOG_HISTORY_SIZE; i++)
- {
- GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
- gint row, column;
-
- column = i % (GIMP_COLOR_DIALOG_HISTORY_SIZE / 2);
- row = i / (GIMP_COLOR_DIALOG_HISTORY_SIZE / 2);
-
- button = gtk_button_new ();
- gtk_widget_set_size_request (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
- gtk_table_attach_defaults (GTK_TABLE (table), button,
- column + 1, column + 2, row, row + 1);
- gtk_widget_show (button);
-
- dialog->history[i] = gimp_color_area_new (&black,
- GIMP_COLOR_AREA_SMALL_CHECKS,
- GDK_BUTTON2_MASK);
- gtk_container_add (GTK_CONTAINER (button), dialog->history[i]);
- gtk_widget_show (dialog->history[i]);
-
- g_signal_connect (button, "clicked",
- G_CALLBACK (gimp_color_history_color_clicked),
- dialog);
-
- g_signal_connect (dialog->history[i], "color-changed",
- G_CALLBACK (gimp_color_history_color_changed),
- GINT_TO_POINTER (i));
- }
-}
+ /* Color history table. */
+ history = gimp_color_history_new (viewable_dialog->context, 12);
+ gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (history), TRUE, TRUE, 0);
+ gtk_widget_show (GTK_WIDGET (history));
-static void
-gimp_color_dialog_constructed (GObject *object)
-{
- GimpColorDialog *dialog = GIMP_COLOR_DIALOG (object);
- GimpViewableDialog *viewable_dialog = GIMP_VIEWABLE_DIALOG (object);
- GimpPalette *history;
-
- G_OBJECT_CLASS (parent_class)->constructed (object);
-
- history = gimp_palettes_get_color_history (viewable_dialog->context->gimp);
-
- g_signal_connect_object (history, "dirty",
- G_CALLBACK (gimp_color_history_changed),
- G_OBJECT (dialog), 0);
-
- gimp_color_history_changed (history, dialog);
+ g_signal_connect (history, "color-selected",
+ G_CALLBACK (gimp_color_dialog_history_selected),
+ dialog);
}
static void
@@ -390,62 +355,7 @@ gimp_color_dialog_color_changed (GimpColorSelection *selection,
}
-/* color history callbacks */
-
-static void
-gimp_color_history_changed (GimpPalette *history,
- GimpColorDialog *dialog)
-{
- gint i;
-
- for (i = 0; i < GIMP_COLOR_DIALOG_HISTORY_SIZE; i++)
- {
- GimpPaletteEntry *entry = gimp_palette_get_entry (history, i);
- GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
-
- g_signal_handlers_block_by_func (dialog->history[i],
- gimp_color_history_color_changed,
- GINT_TO_POINTER (i));
-
- gimp_color_area_set_color (GIMP_COLOR_AREA (dialog->history[i]),
- entry ? &entry->color : &black);
-
- g_signal_handlers_unblock_by_func (dialog->history[i],
- gimp_color_history_color_changed,
- GINT_TO_POINTER (i));
- }
-}
-
-static void
-gimp_color_history_color_clicked (GtkWidget *widget,
- GimpColorDialog *dialog)
-{
- GimpColorArea *color_area;
- GimpRGB color;
-
- color_area = GIMP_COLOR_AREA (gtk_bin_get_child (GTK_BIN (widget)));
-
- gimp_color_area_get_color (color_area, &color);
- gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
- &color);
-}
-
-static void
-gimp_color_history_color_changed (GtkWidget *widget,
- gpointer data)
-{
- GimpViewableDialog *viewable_dialog;
- GimpPalette *history;
- GimpRGB color;
-
- viewable_dialog = GIMP_VIEWABLE_DIALOG (gtk_widget_get_toplevel (widget));
-
- history = gimp_palettes_get_color_history (viewable_dialog->context->gimp);
-
- gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
-
- gimp_palette_set_entry_color (history, GPOINTER_TO_INT (data), &color);
-}
+/* History-adding button callback */
static void
gimp_color_history_add_clicked (GtkWidget *widget,
@@ -462,3 +372,14 @@ gimp_color_history_add_clicked (GtkWidget *widget,
gimp_palette_mru_add (GIMP_PALETTE_MRU (history), &color);
}
+
+/* Color history callback */
+
+static void
+gimp_color_dialog_history_selected (GimpColorHistory *history,
+ const GimpRGB *rgb,
+ GimpColorDialog *dialog)
+{
+ gimp_color_selection_set_color (GIMP_COLOR_SELECTION (dialog->selection),
+ rgb);
+}
diff --git a/app/widgets/gimpcolordialog.h b/app/widgets/gimpcolordialog.h
index 64d3187..2fcecb1 100644
--- a/app/widgets/gimpcolordialog.h
+++ b/app/widgets/gimpcolordialog.h
@@ -44,7 +44,6 @@ struct _GimpColorDialog
gboolean wants_updates;
GtkWidget *selection;
- GtkWidget *history[GIMP_COLOR_DIALOG_HISTORY_SIZE];
};
struct _GimpColorDialogClass
diff --git a/app/widgets/gimpcoloreditor.c b/app/widgets/gimpcoloreditor.c
index 1f503a3..2b83af0 100644
--- a/app/widgets/gimpcoloreditor.c
+++ b/app/widgets/gimpcoloreditor.c
@@ -36,6 +36,7 @@
#include "core/gimpcontext.h"
#include "gimpcoloreditor.h"
+#include "gimpcolorhistory.h"
#include "gimpdocked.h"
#include "gimpfgbgeditor.h"
#include "gimpfgbgview.h"
@@ -53,6 +54,7 @@ enum
static void gimp_color_editor_docked_iface_init (GimpDockedInterface *iface);
+static void gimp_color_editor_constructed (GObject *object);
static void gimp_color_editor_dispose (GObject *object);
static void gimp_color_editor_set_property (GObject *object,
guint property_id,
@@ -96,6 +98,9 @@ static void gimp_color_editor_color_picked (GtkWidget *widget,
static void gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
GimpColorEditor *editor);
+static void gimp_color_editor_history_selected (GimpColorHistory *history,
+ const GimpRGB *rgb,
+ GimpColorEditor *editor);
G_DEFINE_TYPE_WITH_CODE (GimpColorEditor, gimp_color_editor, GIMP_TYPE_EDITOR,
G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
@@ -112,6 +117,7 @@ gimp_color_editor_class_init (GimpColorEditorClass* klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->constructed = gimp_color_editor_constructed;
object_class->dispose = gimp_color_editor_dispose;
object_class->set_property = gimp_color_editor_set_property;
object_class->get_property = gimp_color_editor_get_property;
@@ -122,6 +128,7 @@ gimp_color_editor_class_init (GimpColorEditorClass* klass)
g_param_spec_object ("context",
NULL, NULL,
GIMP_TYPE_CONTEXT,
+ G_PARAM_CONSTRUCT |
GIMP_PARAM_READWRITE));
}
@@ -270,6 +277,24 @@ gimp_color_editor_init (GimpColorEditor *editor)
}
static void
+gimp_color_editor_constructed (GObject *object)
+{
+ GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
+ GtkWidget *history;
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ /* The color history */
+ history = gimp_color_history_new (editor->context, 12);
+ gtk_box_pack_end (GTK_BOX (editor), history, FALSE, FALSE, 0);
+ gtk_widget_show (history);
+
+ g_signal_connect (history, "color-selected",
+ G_CALLBACK (gimp_color_editor_history_selected),
+ editor);
+}
+
+static void
gimp_color_editor_dispose (GObject *object)
{
GimpColorEditor *editor = GIMP_COLOR_EDITOR (object);
@@ -663,3 +688,17 @@ gimp_color_editor_entry_changed (GimpColorHexEntry *entry,
gimp_context_set_foreground (editor->context, &rgb);
}
}
+
+static void
+gimp_color_editor_history_selected (GimpColorHistory *history,
+ const GimpRGB *rgb,
+ GimpColorEditor *editor)
+{
+ if (editor->context)
+ {
+ if (editor->edit_bg)
+ gimp_context_set_background (editor->context, rgb);
+ else
+ gimp_context_set_foreground (editor->context, rgb);
+ }
+}
diff --git a/app/widgets/gimpcolorhistory.c b/app/widgets/gimpcolorhistory.c
new file mode 100644
index 0000000..584fff7
--- /dev/null
+++ b/app/widgets/gimpcolorhistory.c
@@ -0,0 +1,308 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpcolorhistory.c
+ * Copyright (C) 2015 Jehan <jehan girinstud io>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gegl.h>
+#include <gtk/gtk.h>
+
+#include "libgimpwidgets/gimpwidgets.h"
+
+#include "widgets-types.h"
+
+#include "core/gimp-palettes.h"
+#include "core/gimpcontext.h"
+#include "core/gimpmarshal.h"
+#include "core/gimppalettemru.h"
+
+#include "gimpcolorhistory.h"
+
+#include "gimp-intl.h"
+
+enum
+{
+ COLOR_SELECTED,
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_CONTEXT,
+ PROP_HISTORY_SIZE,
+};
+
+
+#define DEFAULT_HISTORY_SIZE 12
+#define COLOR_AREA_SIZE 20
+
+static void gimp_color_history_constructed (GObject *object);
+static void gimp_color_history_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gimp_color_history_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
+
+static void gimp_color_history_color_clicked (GtkWidget *widget,
+ GimpColorHistory *history);
+
+static void gimp_color_history_palette_dirty (GimpPalette *palette,
+ GimpColorHistory *history);
+
+static void gimp_color_history_color_changed (GtkWidget *widget,
+ gpointer data);
+
+
+G_DEFINE_TYPE (GimpColorHistory, gimp_color_history, GTK_TYPE_TABLE)
+
+#define parent_class gimp_color_history_parent_class
+
+static guint history_signals[LAST_SIGNAL] = { 0 };
+
+static void
+gimp_color_history_class_init (GimpColorHistoryClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = gimp_color_history_constructed;
+ object_class->set_property = gimp_color_history_set_property;
+ object_class->get_property = gimp_color_history_get_property;
+
+ history_signals[COLOR_SELECTED] =
+ g_signal_new ("color-selected",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (GimpColorHistoryClass, color_selected),
+ NULL, NULL,
+ gimp_marshal_VOID__OBJECT_POINTER,
+ G_TYPE_NONE, 1,
+ G_TYPE_POINTER);
+
+ g_object_class_install_property (object_class, PROP_CONTEXT,
+ g_param_spec_object ("context", NULL, NULL,
+ GIMP_TYPE_CONTEXT,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+ g_object_class_install_property (object_class, PROP_HISTORY_SIZE,
+ g_param_spec_int ("history-size",
+ NULL, NULL,
+ 2, G_MAXINT,
+ DEFAULT_HISTORY_SIZE,
+ GIMP_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+
+ klass->color_selected = NULL;
+}
+
+static void
+gimp_color_history_init (GimpColorHistory *history)
+{
+ history->color_areas = NULL;
+}
+
+static void
+gimp_color_history_constructed (GObject *object)
+{
+ GimpColorHistory *history = GIMP_COLOR_HISTORY (object);
+ GimpPalette *palette;
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ palette = gimp_palettes_get_color_history (history->context->gimp);
+
+ g_signal_connect_object (palette, "dirty",
+ G_CALLBACK (gimp_color_history_palette_dirty),
+ G_OBJECT (history), 0);
+
+ gimp_color_history_palette_dirty (palette, history);
+}
+
+static void
+gimp_color_history_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GimpColorHistory *history = GIMP_COLOR_HISTORY (object);
+
+ switch (property_id)
+ {
+ case PROP_CONTEXT:
+ history->context = g_value_get_object (value);
+ break;
+ case PROP_HISTORY_SIZE:
+ {
+ GtkWidget *button;
+ gint i;
+
+ /* Destroy previous color buttons. */
+ gtk_container_foreach (GTK_CONTAINER (history),
+ (GtkCallback) gtk_widget_destroy, NULL);
+ history->history_size = g_value_get_int (value);
+ gtk_table_resize (GTK_TABLE (history),
+ 2, (history->history_size + 1)/ 2);
+ gtk_table_set_row_spacings (GTK_TABLE (history), 2);
+ gtk_table_set_col_spacings (GTK_TABLE (history), 2);
+ history->color_areas = g_realloc_n (history->color_areas,
+ history->history_size,
+ sizeof (GtkWidget*));
+ for (i = 0; i < history->history_size; i++)
+ {
+ GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
+ gint row, column;
+
+ column = i % (history->history_size / 2);
+ row = i / (history->history_size / 2);
+
+ button = gtk_button_new ();
+ gtk_widget_set_size_request (button, COLOR_AREA_SIZE, COLOR_AREA_SIZE);
+ gtk_table_attach_defaults (GTK_TABLE (history), button,
+ column, column + 1, row, row + 1);
+ gtk_widget_show (button);
+
+ history->color_areas[i] = gimp_color_area_new (&black,
+ GIMP_COLOR_AREA_SMALL_CHECKS,
+ GDK_BUTTON2_MASK);
+ gtk_container_add (GTK_CONTAINER (button), history->color_areas[i]);
+ gtk_widget_show (history->color_areas[i]);
+
+ g_signal_connect (button, "clicked",
+ G_CALLBACK (gimp_color_history_color_clicked),
+ history);
+
+ g_signal_connect (history->color_areas[i], "color-changed",
+ G_CALLBACK (gimp_color_history_color_changed),
+ GINT_TO_POINTER (i));
+ }
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gimp_color_history_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GimpColorHistory *history = GIMP_COLOR_HISTORY (object);
+
+ switch (property_id)
+ {
+ case PROP_CONTEXT:
+ g_value_set_object (value, history->context);
+ break;
+ case PROP_HISTORY_SIZE:
+ g_value_set_int (value, history->history_size);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+/* Public Functions */
+
+GtkWidget *
+gimp_color_history_new (GimpContext *context,
+ gint history_size)
+{
+ GimpColorHistory *history;
+
+ g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+ history = g_object_new (GIMP_TYPE_COLOR_HISTORY,
+ "context", context,
+ "history-size", history_size,
+ NULL);
+
+ return GTK_WIDGET (history);
+}
+
+/* Color history callback. */
+
+static void
+gimp_color_history_color_clicked (GtkWidget *widget,
+ GimpColorHistory *history)
+{
+ GimpColorArea *color_area;
+ GimpRGB color;
+
+ color_area = GIMP_COLOR_AREA (gtk_bin_get_child (GTK_BIN (widget)));
+
+ gimp_color_area_get_color (color_area, &color);
+
+ g_signal_emit (history, history_signals[COLOR_SELECTED], 0,
+ &color);
+}
+
+/* Color history palette callback. */
+
+static void
+gimp_color_history_palette_dirty (GimpPalette *palette,
+ GimpColorHistory *history)
+{
+ gint i;
+
+ for (i = 0; i < history->history_size; i++)
+ {
+ GimpPaletteEntry *entry = gimp_palette_get_entry (palette, i);
+ GimpRGB black = { 0.0, 0.0, 0.0, 1.0 };
+
+ g_signal_handlers_block_by_func (history->color_areas[i],
+ gimp_color_history_color_changed,
+ GINT_TO_POINTER (i));
+
+ gimp_color_area_set_color (GIMP_COLOR_AREA (history->color_areas[i]),
+ entry ? &entry->color : &black);
+
+ g_signal_handlers_unblock_by_func (history->color_areas[i],
+ gimp_color_history_color_changed,
+ GINT_TO_POINTER (i));
+ }
+}
+
+/* Color area callbacks. */
+
+static void
+gimp_color_history_color_changed (GtkWidget *widget,
+ gpointer data)
+{
+ GimpColorHistory *history;
+ GimpPalette *palette;
+ GimpRGB color;
+
+ history = GIMP_COLOR_HISTORY (gtk_widget_get_ancestor (widget,
+ GIMP_TYPE_COLOR_HISTORY));
+
+ palette = gimp_palettes_get_color_history (history->context->gimp);
+
+ gimp_color_area_get_color (GIMP_COLOR_AREA (widget), &color);
+
+ gimp_palette_set_entry_color (palette, GPOINTER_TO_INT (data), &color);
+}
diff --git a/app/widgets/gimpcolorhistory.h b/app/widgets/gimpcolorhistory.h
new file mode 100644
index 0000000..d3e5948
--- /dev/null
+++ b/app/widgets/gimpcolorhistory.h
@@ -0,0 +1,61 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpcolorhistory.h
+ * Copyright (C) 2015 Jehan <jehan girinstud io>
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_COLOR_HISTORY_H__
+#define __GIMP_COLOR_HISTORY_H__
+
+
+#define GIMP_TYPE_COLOR_HISTORY (gimp_color_history_get_type ())
+#define GIMP_COLOR_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_COLOR_HISTORY,
GimpColorHistory))
+#define GIMP_COLOR_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_COLOR_HISTORY,
GimpColorHistoryClass))
+#define GIMP_IS_COLOR_HISTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_COLOR_HISTORY))
+#define GIMP_IS_COLOR_HISTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_COLOR_HISTORY))
+#define GIMP_COLOR_HISTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_COLOR_HISTORY,
GimpColorHistoryClass))
+
+
+typedef struct _GimpColorHistoryClass GimpColorHistoryClass;
+
+struct _GimpColorHistory
+{
+ GtkTable parent_instance;
+
+ GimpContext *context;
+
+ GtkWidget **color_areas;
+ gint history_size;
+};
+
+struct _GimpColorHistoryClass
+{
+ GtkTableClass parent_class;
+
+ /* signals */
+ void (* color_selected) (GimpColorHistory *history,
+ const GimpRGB *rgb);
+};
+
+
+GType gimp_color_history_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_color_history_new (GimpContext *context,
+ gint history_size);
+
+#endif /* __GIMP_COLOR_HISTORY_H__ */
+
diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h
index 98a1620..9aaa257 100644
--- a/app/widgets/widgets-types.h
+++ b/app/widgets/widgets-types.h
@@ -166,6 +166,7 @@ typedef struct _GimpCircle GimpCircle;
typedef struct _GimpColorBar GimpColorBar;
typedef struct _GimpColorDisplayEditor GimpColorDisplayEditor;
typedef struct _GimpColorFrame GimpColorFrame;
+typedef struct _GimpColorHistory GimpColorHistory;
typedef struct _GimpColorPanel GimpColorPanel;
typedef struct _GimpComboTagEntry GimpComboTagEntry;
typedef struct _GimpControllerEditor GimpControllerEditor;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0a3eb83..fe147bb 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -450,6 +450,7 @@ app/widgets/gimpcolordialog.c
app/widgets/gimpcolordisplayeditor.c
app/widgets/gimpcoloreditor.c
app/widgets/gimpcolorframe.c
+app/widgets/gimpcolorhistory.c
app/widgets/gimpcolormapeditor.c
app/widgets/gimpcolorselectorpalette.c
app/widgets/gimpcontainergridview.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]