[gimp/gimp-2-10] app: move the palette editor color dialog code to GimpPaletteEditor
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: move the palette editor color dialog code to GimpPaletteEditor
- Date: Thu, 21 Jun 2018 10:54:47 +0000 (UTC)
commit 913389aa916aba48b48a9a06a70ea3615899c250
Author: Michael Natterer <mitch gimp org>
Date: Thu Jun 21 12:43:59 2018 +0200
app: move the palette editor color dialog code to GimpPaletteEditor
That's cleaner than having it in palette-editor-commands.c
(cherry picked from commit 1c1dd2038e14773333381c36c1a56479c288d969)
app/actions/palette-editor-commands.c | 88 +----------------------------------
app/widgets/gimppaletteeditor.c | 88 +++++++++++++++++++++++++++++++++--
app/widgets/gimppaletteeditor.h | 1 +
po/POTFILES.in | 1 -
4 files changed, 86 insertions(+), 92 deletions(-)
---
diff --git a/app/actions/palette-editor-commands.c b/app/actions/palette-editor-commands.c
index 2eb0422513..5f4fbd0625 100644
--- a/app/actions/palette-editor-commands.c
+++ b/app/actions/palette-editor-commands.c
@@ -20,32 +20,16 @@
#include <gegl.h>
#include <gtk/gtk.h>
-#include "libgimpwidgets/gimpwidgets.h"
-
#include "actions-types.h"
-#include "core/gimp.h"
#include "core/gimpcontext.h"
-#include "core/gimpdatafactory.h"
#include "core/gimppalette.h"
-#include "widgets/gimpcolordialog.h"
-#include "widgets/gimpdialogfactory.h"
#include "widgets/gimppaletteeditor.h"
#include "widgets/gimppaletteview.h"
#include "palette-editor-commands.h"
-#include "gimp-intl.h"
-
-
-/* local function prototypes */
-
-static void palette_editor_edit_color_update (GimpColorDialog *dialog,
- const GimpRGB *color,
- GimpColorDialogState state,
- GimpPaletteEditor *editor);
-
/* public functions */
@@ -53,47 +37,9 @@ void
palette_editor_edit_color_cmd_callback (GtkAction *action,
gpointer data)
{
- GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
- GimpDataEditor *data_editor = GIMP_DATA_EDITOR (data);
- GimpPalette *palette;
-
- if (! (data_editor->data_editable && editor->color))
- return;
-
- palette = GIMP_PALETTE (data_editor->data);
-
- if (! editor->color_dialog)
- {
- editor->color_dialog =
- gimp_color_dialog_new (GIMP_VIEWABLE (palette),
- data_editor->context,
- _("Edit Palette Color"),
- GIMP_ICON_PALETTE,
- _("Edit Color Palette Entry"),
- GTK_WIDGET (editor),
- gimp_dialog_factory_get_singleton (),
- "gimp-palette-editor-color-dialog",
- &editor->color->color,
- FALSE, FALSE);
-
- g_signal_connect (editor->color_dialog, "destroy",
- G_CALLBACK (gtk_widget_destroyed),
- &editor->color_dialog);
-
- g_signal_connect (editor->color_dialog, "update",
- G_CALLBACK (palette_editor_edit_color_update),
- editor);
- }
- else
- {
- gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (editor->color_dialog),
- GIMP_VIEWABLE (palette),
- data_editor->context);
- gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (editor->color_dialog),
- &editor->color->color);
- }
+ GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (data);
- gtk_window_present (GTK_WINDOW (editor->color_dialog));
+ gimp_palette_editor_edit_color (editor);
}
void
@@ -144,33 +90,3 @@ palette_editor_zoom_cmd_callback (GtkAction *action,
gimp_palette_editor_zoom (editor, (GimpZoomType) value);
}
-
-
-/* private functions */
-
-static void
-palette_editor_edit_color_update (GimpColorDialog *dialog,
- const GimpRGB *color,
- GimpColorDialogState state,
- GimpPaletteEditor *editor)
-{
- GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
-
- switch (state)
- {
- case GIMP_COLOR_DIALOG_UPDATE:
- break;
-
- case GIMP_COLOR_DIALOG_OK:
- if (editor->color)
- {
- editor->color->color = *color;
- gimp_data_dirty (GIMP_DATA (palette));
- }
- /* Fallthrough */
-
- case GIMP_COLOR_DIALOG_CANCEL:
- gtk_widget_hide (editor->color_dialog);
- break;
- }
-}
diff --git a/app/widgets/gimppaletteeditor.c b/app/widgets/gimppaletteeditor.c
index 70af7eaff2..7097d8b578 100644
--- a/app/widgets/gimppaletteeditor.c
+++ b/app/widgets/gimppaletteeditor.c
@@ -35,8 +35,10 @@
#include "core/gimpdatafactory.h"
#include "core/gimppalette.h"
+#include "gimpcolordialog.h"
#include "gimpdnd.h"
#include "gimpdocked.h"
+#include "gimpdialogfactory.h"
#include "gimphelp-ids.h"
#include "gimppaletteeditor.h"
#include "gimppaletteview.h"
@@ -121,6 +123,10 @@ static void palette_editor_resize (GimpPaletteEditor *editor,
gint width,
gdouble zoom_factor);
static void palette_editor_scroll_top_left (GimpPaletteEditor *editor);
+static void palette_editor_edit_color_update (GimpColorDialog *dialog,
+ const GimpRGB *color,
+ GimpColorDialogState state,
+ GimpPaletteEditor *editor);
G_DEFINE_TYPE_WITH_CODE (GimpPaletteEditor, gimp_palette_editor,
@@ -301,11 +307,7 @@ gimp_palette_editor_dispose (GObject *object)
{
GimpPaletteEditor *editor = GIMP_PALETTE_EDITOR (object);
- if (editor->color_dialog)
- {
- gtk_widget_destroy (editor->color_dialog);
- editor->color_dialog = NULL;
- }
+ g_clear_pointer (&editor->color_dialog, gtk_widget_destroy);
G_OBJECT_CLASS (parent_class)->dispose (object);
}
@@ -452,6 +454,55 @@ gimp_palette_editor_new (GimpContext *context,
NULL);
}
+void
+gimp_palette_editor_edit_color (GimpPaletteEditor *editor)
+{
+ GimpDataEditor *data_editor;
+ GimpPalette *palette;
+
+ g_return_if_fail (GIMP_IS_PALETTE_EDITOR (editor));
+
+ data_editor = GIMP_DATA_EDITOR (editor);
+
+ if (! (data_editor->data_editable && editor->color))
+ return;
+
+ palette = GIMP_PALETTE (gimp_data_editor_get_data (data_editor));
+
+ if (! editor->color_dialog)
+ {
+ editor->color_dialog =
+ gimp_color_dialog_new (GIMP_VIEWABLE (palette),
+ data_editor->context,
+ _("Edit Palette Color"),
+ GIMP_ICON_PALETTE,
+ _("Edit Color Palette Entry"),
+ GTK_WIDGET (editor),
+ gimp_dialog_factory_get_singleton (),
+ "gimp-palette-editor-color-dialog",
+ &editor->color->color,
+ FALSE, FALSE);
+
+ g_signal_connect (editor->color_dialog, "destroy",
+ G_CALLBACK (gtk_widget_destroyed),
+ &editor->color_dialog);
+
+ g_signal_connect (editor->color_dialog, "update",
+ G_CALLBACK (palette_editor_edit_color_update),
+ editor);
+ }
+ else
+ {
+ gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (editor->color_dialog),
+ GIMP_VIEWABLE (palette),
+ data_editor->context);
+ gimp_color_dialog_set_color (GIMP_COLOR_DIALOG (editor->color_dialog),
+ &editor->color->color);
+ }
+
+ gtk_window_present (GTK_WINDOW (editor->color_dialog));
+}
+
void
gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
const GimpRGB *color,
@@ -864,3 +915,30 @@ palette_editor_scroll_top_left (GimpPaletteEditor *palette_editor)
if (vadj)
gtk_adjustment_set_value (vadj, 0.0);
}
+
+static void
+palette_editor_edit_color_update (GimpColorDialog *dialog,
+ const GimpRGB *color,
+ GimpColorDialogState state,
+ GimpPaletteEditor *editor)
+{
+ GimpPalette *palette = GIMP_PALETTE (GIMP_DATA_EDITOR (editor)->data);
+
+ switch (state)
+ {
+ case GIMP_COLOR_DIALOG_UPDATE:
+ break;
+
+ case GIMP_COLOR_DIALOG_OK:
+ if (editor->color)
+ {
+ editor->color->color = *color;
+ gimp_data_dirty (GIMP_DATA (palette));
+ }
+ /* Fallthrough */
+
+ case GIMP_COLOR_DIALOG_CANCEL:
+ gtk_widget_hide (editor->color_dialog);
+ break;
+ }
+}
diff --git a/app/widgets/gimppaletteeditor.h b/app/widgets/gimppaletteeditor.h
index 6abbee6cf7..086dfb8b25 100644
--- a/app/widgets/gimppaletteeditor.h
+++ b/app/widgets/gimppaletteeditor.h
@@ -62,6 +62,7 @@ GType gimp_palette_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_palette_editor_new (GimpContext *context,
GimpMenuFactory *menu_factory);
+void gimp_palette_editor_edit_color (GimpPaletteEditor *editor);
void gimp_palette_editor_pick_color (GimpPaletteEditor *editor,
const GimpRGB *color,
GimpColorPickState pick_state);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 8a1e2e9afc..6681456505 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -58,7 +58,6 @@ app/actions/layers-actions.c
app/actions/layers-commands.c
app/actions/mypaint-brushes-actions.c
app/actions/palette-editor-actions.c
-app/actions/palette-editor-commands.c
app/actions/palettes-actions.c
app/actions/palettes-commands.c
app/actions/patterns-actions.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]