1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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 2 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, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-02-21 07:20:54 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-01-24 02:49:44 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-05-22 04:30:16 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
#include "gui-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
|
|
|
#include "core/gimpcontext.h"
|
|
|
|
#include "core/gimpdatafactory.h"
|
|
|
|
#include "core/gimppalette.h"
|
|
|
|
|
2001-04-11 09:13:53 +08:00
|
|
|
#include "widgets/gimpcontainerlistview.h"
|
|
|
|
#include "widgets/gimpdatafactoryview.h"
|
2001-05-09 03:29:15 +08:00
|
|
|
#include "widgets/gimpdnd.h"
|
2001-04-11 09:13:53 +08:00
|
|
|
#include "widgets/gimppreview.h"
|
|
|
|
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "color-area.h"
|
|
|
|
#include "color-notebook.h"
|
|
|
|
#include "palette-editor.h"
|
|
|
|
#include "palette-select.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimprc.h"
|
2000-02-24 09:52:31 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
1998-10-05 05:23:57 +08:00
|
|
|
#define ENTRY_WIDTH 12
|
1997-12-07 05:53:02 +08:00
|
|
|
#define ENTRY_HEIGHT 10
|
1999-07-24 23:37:03 +08:00
|
|
|
#define SPACING 1
|
|
|
|
#define COLUMNS 16
|
|
|
|
#define ROWS 11
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
#define PREVIEW_WIDTH ((ENTRY_WIDTH * COLUMNS) + (SPACING * (COLUMNS + 1)))
|
|
|
|
#define PREVIEW_HEIGHT ((ENTRY_HEIGHT * ROWS) + (SPACING * (ROWS + 1)))
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
#define PALETTE_EVENT_MASK (GDK_EXPOSURE_MASK | \
|
|
|
|
GDK_BUTTON_PRESS_MASK | \
|
|
|
|
GDK_ENTER_NOTIFY_MASK)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
struct _PaletteEditor
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
GtkWidget *shell;
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
GtkWidget *name;
|
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
GtkWidget *color_area;
|
|
|
|
GtkWidget *scrolled_window;
|
|
|
|
GtkWidget *color_name;
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
GimpContext *context;
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
GtkWidget *popup_menu;
|
|
|
|
GtkWidget *delete_menu_item;
|
|
|
|
GtkWidget *edit_menu_item;
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
ColorNotebook *color_notebook;
|
|
|
|
gboolean color_notebook_active;
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
GimpPaletteEntry *color;
|
|
|
|
GimpPaletteEntry *dnd_color;
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
guint entry_sig_id;
|
|
|
|
gfloat zoom_factor; /* range from 0.1 to 4.0 */
|
|
|
|
gint col_width;
|
|
|
|
gint last_width;
|
|
|
|
gint columns;
|
|
|
|
gboolean freeze_update;
|
|
|
|
gboolean columns_valid;
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
GQuark invalidate_preview_handler_id;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2001-01-22 05:29:31 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* local function prototypes */
|
2001-07-15 22:32:44 +08:00
|
|
|
static void palette_editor_name_activate (GtkWidget *widget,
|
|
|
|
PaletteEditor *palette_editor);
|
|
|
|
static void palette_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
PaletteEditor *palette_editor);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_create_popup_menu (PaletteEditor *palette_editor);
|
|
|
|
static void palette_editor_new_entry_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_edit_entry_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_delete_entry_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
|
2001-02-19 03:44:28 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
static gint palette_editor_eventbox_button_press (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
GdkEventButton *bevent,
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor);
|
|
|
|
static gint palette_editor_color_area_events (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
GdkEvent *event,
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor);
|
|
|
|
static void palette_editor_draw_entries (PaletteEditor *palette,
|
2001-02-19 03:44:28 +08:00
|
|
|
gint row_start,
|
|
|
|
gint column_highlight);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_redraw (PaletteEditor *palette_editor);
|
|
|
|
static void palette_editor_scroll_top_left (PaletteEditor *palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_color_name_changed (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_zoomin_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_zoomout_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_redraw_zoom (PaletteEditor *palette_editor);
|
|
|
|
static void palette_editor_close_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_palette_changed (GimpContext *context,
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpPalette *palette,
|
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_drag_color (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpRGB *color,
|
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_drop_color (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data);
|
2001-07-15 22:32:44 +08:00
|
|
|
static void palette_editor_drop_palette (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data);
|
2001-07-10 01:58:56 +08:00
|
|
|
static void palette_editor_invalidate_preview (GimpPalette *palette,
|
|
|
|
PaletteEditor *palette_editor);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-24 08:36:57 +08:00
|
|
|
/* dnd stuff */
|
|
|
|
static GtkTargetEntry color_palette_target_table[] =
|
|
|
|
{
|
2001-07-15 22:32:44 +08:00
|
|
|
GIMP_TARGET_COLOR,
|
|
|
|
GIMP_TARGET_PALETTE
|
1999-08-24 08:36:57 +08:00
|
|
|
};
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* called from color_picker.h *********************************************/
|
|
|
|
|
|
|
|
void
|
|
|
|
palette_set_active_color (gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
gint state)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-08-04 03:43:19 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: palette_set_active_color()
|
|
|
|
#endif
|
|
|
|
#if 0
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpPalette *palette;
|
|
|
|
GimpRGB color;
|
2001-01-15 09:48:53 +08:00
|
|
|
|
2001-01-21 21:41:07 +08:00
|
|
|
gimp_rgba_set_uchar (&color,
|
|
|
|
(guchar) r,
|
|
|
|
(guchar) g,
|
|
|
|
(guchar) b,
|
|
|
|
255);
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (top_level_edit_palette)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-02-19 03:44:28 +08:00
|
|
|
palette = gimp_context_get_palette (top_level_edit_palette->context);
|
|
|
|
|
|
|
|
if (palette)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NEW:
|
|
|
|
top_level_edit_palette->color = gimp_palette_add_entry (palette,
|
|
|
|
NULL,
|
|
|
|
&color);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_UPDATE_NEW:
|
|
|
|
top_level_edit_palette->color->color = color;
|
|
|
|
|
|
|
|
gimp_data_dirty (GIMP_DATA (palette));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
2001-01-15 09:48:53 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
if (active_color == FOREGROUND)
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_context_set_foreground (gimp_get_user_context (the_gimp), &color);
|
1999-10-27 02:27:27 +08:00
|
|
|
else if (active_color == BACKGROUND)
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_context_set_background (gimp_get_user_context (the_gimp), &color);
|
2001-08-04 03:43:19 +08:00
|
|
|
#endif
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* called from palette_select.c ********************************************/
|
|
|
|
|
2001-04-16 01:03:52 +08:00
|
|
|
void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_set_palette (PaletteEditor *palette_editor,
|
|
|
|
GimpPalette *palette)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-31 01:17:36 +08:00
|
|
|
g_return_if_fail (palette_editor != NULL);
|
|
|
|
g_return_if_fail (GIMP_IS_PALETTE (palette));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gimp_context_set_palette (palette_editor->context, palette);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
/* the palette & palette edit dialog constructor ***************************/
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *
|
2001-07-15 22:32:44 +08:00
|
|
|
palette_editor_new (Gimp *gimp)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
|
|
|
GtkWidget *main_vbox;
|
2001-02-19 03:44:28 +08:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *scrolledwindow;
|
|
|
|
GtkWidget *palette_region;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *eventbox;
|
|
|
|
GtkWidget *alignment;
|
|
|
|
GtkWidget *button;
|
2001-08-10 22:41:39 +08:00
|
|
|
GtkWidget *image;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = g_new0 (PaletteEditor, 1);
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
palette_editor->context = gimp_create_context (gimp, NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->zoom_factor = 1.0;
|
|
|
|
palette_editor->columns = COLUMNS;
|
|
|
|
palette_editor->columns_valid = TRUE;
|
|
|
|
palette_editor->freeze_update = FALSE;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->shell =
|
|
|
|
gimp_dialog_new (_("Palette Editor"), "palette_editor",
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"dialogs/palette_editor/palette_editor.html",
|
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
"_delete_event_", palette_editor_close_callback,
|
|
|
|
palette_editor, NULL, NULL, TRUE, TRUE,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
NULL);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_dialog_set_has_separator (GTK_DIALOG (palette_editor->shell), FALSE);
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_hide (GTK_DIALOG (palette_editor->shell)->action_area);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
main_vbox = gtk_vbox_new (FALSE, 1);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (palette_editor->shell)->vbox),
|
|
|
|
main_vbox);
|
|
|
|
gtk_widget_show (main_vbox);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
/* Palette's name */
|
|
|
|
palette_editor->name = gtk_entry_new ();
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), palette_editor->name,
|
|
|
|
FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (palette_editor->name);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (palette_editor->name), "activate",
|
|
|
|
G_CALLBACK (palette_editor_name_activate),
|
|
|
|
palette_editor);
|
|
|
|
g_signal_connect (G_OBJECT (palette_editor->name), "focus_out_event",
|
|
|
|
G_CALLBACK (palette_editor_name_focus_out),
|
|
|
|
palette_editor);
|
2001-07-15 22:32:44 +08:00
|
|
|
|
|
|
|
palette_editor->scrolled_window = scrolledwindow =
|
|
|
|
gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_widget_set_usize (scrolledwindow, -1, PREVIEW_HEIGHT);
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), scrolledwindow, TRUE, TRUE, 0);
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_widget_show (scrolledwindow);
|
|
|
|
|
|
|
|
eventbox = gtk_event_box_new ();
|
|
|
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow),
|
|
|
|
eventbox);
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_widget_show (eventbox);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (eventbox), "button_press_event",
|
|
|
|
G_CALLBACK (palette_editor_eventbox_button_press),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (eventbox), alignment);
|
|
|
|
gtk_widget_show (alignment);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color_area = palette_region =
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_preview_new (GTK_PREVIEW_COLOR);
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_preview_set_dither (GTK_PREVIEW (palette_editor->color_area),
|
2001-02-19 03:44:28 +08:00
|
|
|
GDK_RGB_DITHER_MAX);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (palette_region), PREVIEW_WIDTH, PREVIEW_HEIGHT);
|
2001-07-10 01:58:56 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_widget_set_events (palette_region, PALETTE_EVENT_MASK);
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), palette_region);
|
|
|
|
gtk_widget_show (palette_region);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (palette_editor->color_area), "event",
|
|
|
|
G_CALLBACK (palette_editor_color_area_events),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
gtk_drag_source_set (palette_region,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON2_MASK,
|
2001-10-29 19:47:11 +08:00
|
|
|
color_palette_target_table,
|
|
|
|
G_N_ELEMENTS (color_palette_target_table),
|
2001-02-19 03:44:28 +08:00
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
2001-07-10 01:58:56 +08:00
|
|
|
gimp_dnd_color_source_set (palette_region, palette_editor_drag_color,
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
gtk_drag_dest_set (eventbox,
|
2001-02-19 03:44:28 +08:00
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
2001-10-29 19:47:11 +08:00
|
|
|
color_palette_target_table,
|
|
|
|
G_N_ELEMENTS (color_palette_target_table),
|
2001-02-19 03:44:28 +08:00
|
|
|
GDK_ACTION_COPY);
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_dnd_color_dest_set (eventbox, palette_editor_drop_color, palette_editor);
|
|
|
|
gimp_dnd_viewable_dest_set (eventbox, GIMP_TYPE_PALETTE,
|
|
|
|
palette_editor_drop_palette, palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
/* The color name entry */
|
2001-07-10 01:58:56 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (hbox);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
entry = palette_editor->color_name = gtk_entry_new ();
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_widget_show (entry);
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
|
2001-02-19 03:44:28 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), _("Undefined"));
|
|
|
|
gtk_widget_set_sensitive (entry, FALSE);
|
2001-08-04 03:43:19 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->entry_sig_id =
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (entry), "changed",
|
|
|
|
G_CALLBACK (palette_editor_color_name_changed),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
/* + and - buttons */
|
2001-08-10 22:41:39 +08:00
|
|
|
button = gtk_button_new ();
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_IN, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (palette_editor_zoomin_callback),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
button = gtk_button_new ();
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), image);
|
|
|
|
gtk_widget_show (image);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (button), "clicked",
|
|
|
|
G_CALLBACK (palette_editor_zoomout_callback),
|
|
|
|
palette_editor);
|
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (palette_editor->context), "palette_changed",
|
|
|
|
G_CALLBACK (palette_editor_palette_changed),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->invalidate_preview_handler_id =
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_container_add_handler (gimp->palette_factory->container,
|
2001-02-19 03:44:28 +08:00
|
|
|
"invalidate_preview",
|
2001-08-10 22:41:39 +08:00
|
|
|
G_CALLBACK (palette_editor_invalidate_preview),
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_realize (palette_editor->shell);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_create_popup_menu (palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
return palette_editor;
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
/* private functions */
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
static void
|
|
|
|
palette_editor_name_activate (GtkWidget *widget,
|
|
|
|
PaletteEditor *palette_editor)
|
|
|
|
{
|
|
|
|
GimpPalette *palette;
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
const gchar *entry_text;
|
2001-07-15 22:32:44 +08:00
|
|
|
|
|
|
|
palette = gimp_context_get_palette (palette_editor->context);
|
|
|
|
|
|
|
|
entry_text = gtk_entry_get_text (GTK_ENTRY (widget));
|
|
|
|
|
|
|
|
gimp_object_set_name (GIMP_OBJECT (palette), entry_text);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
palette_editor_name_focus_out (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
PaletteEditor *palette_editor)
|
|
|
|
{
|
|
|
|
palette_editor_name_activate (widget, palette_editor);
|
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* the palette dialog popup menu & callbacks *******************************/
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_create_popup_menu (PaletteEditor *palette_editor)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->popup_menu = menu = gtk_menu_new ();
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
menu_item = gtk_menu_item_new_with_label (_("New"));
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_widget_show (menu_item);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
|
|
|
G_CALLBACK (palette_editor_new_entry_callback),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
menu_item = gtk_menu_item_new_with_label (_("Edit"));
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_widget_show (menu_item);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
|
|
|
G_CALLBACK (palette_editor_edit_entry_callback),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->edit_menu_item = menu_item;
|
2001-02-19 03:44:28 +08:00
|
|
|
|
|
|
|
menu_item = gtk_menu_item_new_with_label (_("Delete"));
|
2001-08-04 03:43:19 +08:00
|
|
|
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
|
|
|
|
gtk_widget_show (menu_item);
|
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_connect (G_OBJECT (menu_item), "activate",
|
|
|
|
G_CALLBACK (palette_editor_delete_entry_callback),
|
|
|
|
palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->delete_menu_item = menu_item;
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_new_entry_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
2001-07-15 22:32:44 +08:00
|
|
|
GimpContext *user_context;
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpRGB color;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! (palette_editor && gimp_context_get_palette (palette_editor->context)))
|
2001-02-19 03:44:28 +08:00
|
|
|
return;
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
user_context = gimp_get_user_context (palette_editor->context->gimp);
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
if (active_color == FOREGROUND)
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_get_foreground (user_context, &color);
|
2001-02-19 03:44:28 +08:00
|
|
|
else if (active_color == BACKGROUND)
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_get_background (user_context, &color);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color =
|
|
|
|
gimp_palette_add_entry (gimp_context_get_palette (palette_editor->context),
|
2001-02-19 03:44:28 +08:00
|
|
|
NULL,
|
|
|
|
&color);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-21 06:19:45 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_edit_entry_callback (GtkWidget *widget,
|
1999-10-27 02:27:27 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
2001-01-21 21:41:07 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! (palette_editor && gimp_context_get_palette (palette_editor->context)
|
|
|
|
&& palette_editor->color))
|
2001-01-22 03:53:56 +08:00
|
|
|
return;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! palette_editor->color_notebook)
|
2001-01-22 03:53:56 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color_notebook =
|
2001-01-22 03:53:56 +08:00
|
|
|
color_notebook_new (_("Edit Palette Color"),
|
2001-07-10 01:58:56 +08:00
|
|
|
(const GimpRGB *) &palette_editor->color->color,
|
|
|
|
palette_editor_color_notebook_callback,
|
|
|
|
palette_editor,
|
2001-01-22 03:53:56 +08:00
|
|
|
FALSE,
|
|
|
|
FALSE);
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color_notebook_active = TRUE;
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
|
|
|
else
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! palette_editor->color_notebook_active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
color_notebook_show (palette_editor->color_notebook);
|
|
|
|
palette_editor->color_notebook_active = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
color_notebook_set_color (palette_editor->color_notebook,
|
|
|
|
&palette_editor->color->color);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_delete_entry_callback (GtkWidget *widget,
|
1999-10-27 02:27:27 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! (palette_editor && gimp_context_get_palette (palette_editor->context) &&
|
|
|
|
palette_editor->color))
|
2001-01-22 03:53:56 +08:00
|
|
|
return;
|
2001-01-21 21:41:07 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gimp_palette_delete_entry (gimp_context_get_palette (palette_editor->context),
|
|
|
|
palette_editor->color);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_color_notebook_callback (ColorNotebook *color_notebook,
|
2001-02-19 03:44:28 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
ColorNotebookState state,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
2001-07-15 22:32:44 +08:00
|
|
|
GimpContext *user_context;
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpPalette *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-08-04 03:43:19 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette = gimp_context_get_palette (palette_editor->context);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
user_context = gimp_get_user_context (palette_editor->context->gimp);
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
|
|
|
break;
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
case COLOR_NOTEBOOK_OK:
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color->color = *color;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* Update either foreground or background colors */
|
|
|
|
if (active_color == FOREGROUND)
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_set_foreground (user_context, color);
|
2001-02-19 03:44:28 +08:00
|
|
|
else if (active_color == BACKGROUND)
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_set_background (user_context, color);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (palette));
|
|
|
|
}
|
1999-12-04 21:08:45 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* Fallthrough */
|
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color_notebook_active)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
color_notebook_hide (palette_editor->color_notebook);
|
|
|
|
palette_editor->color_notebook_active = FALSE;
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-12-03 05:04:47 +08:00
|
|
|
/* the color area event callbacks ******************************************/
|
|
|
|
|
|
|
|
static gint
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_eventbox_button_press (GtkWidget *widget,
|
1999-12-03 05:04:47 +08:00
|
|
|
GdkEventButton *bevent,
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor)
|
1999-12-03 05:04:47 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (gtk_get_event_widget ((GdkEvent *) bevent) == palette_editor->color_area)
|
1999-12-04 21:08:45 +08:00
|
|
|
return FALSE;
|
|
|
|
|
1999-12-03 05:04:47 +08:00
|
|
|
if (bevent->button == 3)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (GTK_WIDGET_SENSITIVE (palette_editor->edit_menu_item))
|
1999-12-04 21:08:45 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_set_sensitive (palette_editor->edit_menu_item, FALSE);
|
|
|
|
gtk_widget_set_sensitive (palette_editor->delete_menu_item, FALSE);
|
1999-12-04 21:08:45 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_menu_popup (GTK_MENU (palette_editor->popup_menu), NULL, NULL,
|
1999-12-03 05:04:47 +08:00
|
|
|
NULL, NULL, 3,
|
|
|
|
bevent->time);
|
|
|
|
}
|
|
|
|
|
1999-12-04 21:08:45 +08:00
|
|
|
return TRUE;
|
1999-12-03 05:04:47 +08:00
|
|
|
}
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static gint
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_color_area_events (GtkWidget *widget,
|
1999-10-27 02:27:27 +08:00
|
|
|
GdkEvent *event,
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-15 22:32:44 +08:00
|
|
|
GimpContext *user_context;
|
1998-12-19 08:00:06 +08:00
|
|
|
GdkEventButton *bevent;
|
2001-01-22 03:53:56 +08:00
|
|
|
GList *list;
|
2001-01-15 09:48:53 +08:00
|
|
|
gint entry_width;
|
|
|
|
gint entry_height;
|
|
|
|
gint row, col;
|
|
|
|
gint pos;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
user_context = gimp_get_user_context (palette_editor->context->gimp);
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
switch (event->type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-09-12 00:55:40 +08:00
|
|
|
case GDK_EXPOSE:
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_redraw (palette_editor);
|
1999-09-12 00:55:40 +08:00
|
|
|
break;
|
1999-12-03 05:04:47 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
2001-07-10 01:58:56 +08:00
|
|
|
entry_width = palette_editor->col_width + SPACING;
|
|
|
|
entry_height = (ENTRY_HEIGHT * palette_editor->zoom_factor) + SPACING;
|
1998-12-19 08:00:06 +08:00
|
|
|
col = (bevent->x - 1) / entry_width;
|
|
|
|
row = (bevent->y - 1) / entry_height;
|
2001-07-10 01:58:56 +08:00
|
|
|
pos = row * palette_editor->columns + col;
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (gimp_context_get_palette (palette_editor->context))
|
|
|
|
list = g_list_nth (gimp_context_get_palette (palette_editor->context)->colors, pos);
|
1999-11-03 17:58:46 +08:00
|
|
|
else
|
2001-01-22 03:53:56 +08:00
|
|
|
list = NULL;
|
1999-11-03 17:58:46 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
if (list)
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->dnd_color = list->data;
|
2001-01-22 03:53:56 +08:00
|
|
|
else
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->dnd_color = NULL;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
if ((bevent->button == 1 || bevent->button == 3) &&
|
2001-07-10 01:58:56 +08:00
|
|
|
gimp_context_get_palette (palette_editor->context))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
if (list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->freeze_update = TRUE;
|
|
|
|
palette_editor_draw_entries (palette_editor, -1, -1);
|
|
|
|
palette_editor->freeze_update = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color = (GimpPaletteEntry *) list->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if (active_color == FOREGROUND)
|
1999-08-24 08:36:57 +08:00
|
|
|
{
|
|
|
|
if (bevent->state & GDK_CONTROL_MASK)
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_set_background (user_context,
|
2001-07-10 01:58:56 +08:00
|
|
|
&palette_editor->color->color);
|
1999-08-24 08:36:57 +08:00
|
|
|
else
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_set_foreground (user_context,
|
2001-07-10 01:58:56 +08:00
|
|
|
&palette_editor->color->color);
|
1999-08-24 08:36:57 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
else if (active_color == BACKGROUND)
|
1999-08-24 08:36:57 +08:00
|
|
|
{
|
|
|
|
if (bevent->state & GDK_CONTROL_MASK)
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_set_foreground (user_context,
|
2001-07-10 01:58:56 +08:00
|
|
|
&palette_editor->color->color);
|
1999-08-24 08:36:57 +08:00
|
|
|
else
|
2001-07-15 22:32:44 +08:00
|
|
|
gimp_context_set_background (user_context,
|
2001-07-10 01:58:56 +08:00
|
|
|
&palette_editor->color->color);
|
1999-08-24 08:36:57 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_draw_entries (palette_editor, row, col);
|
2001-08-30 09:09:58 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Update the active color name */
|
2001-07-27 07:35:00 +08:00
|
|
|
g_print ("color name before: >>%s<<\n",
|
|
|
|
palette_editor->color->name);
|
|
|
|
|
2001-08-30 09:09:58 +08:00
|
|
|
g_signal_handler_block (G_OBJECT (palette_editor->color_name),
|
|
|
|
palette_editor->entry_sig_id);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (palette_editor->color_name),
|
|
|
|
palette_editor->color->name);
|
2001-07-27 07:35:00 +08:00
|
|
|
|
2001-08-30 09:09:58 +08:00
|
|
|
g_signal_handler_unblock (G_OBJECT (palette_editor->color_name),
|
|
|
|
palette_editor->entry_sig_id);
|
|
|
|
|
2001-07-27 07:35:00 +08:00
|
|
|
g_print ("color name after: >>%s<<\n",
|
|
|
|
palette_editor->color->name);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_set_sensitive (palette_editor->color_name, TRUE);
|
|
|
|
/* palette_update_current_entry (palette_editor); */
|
1999-11-03 17:58:46 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (bevent->button == 3)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! GTK_WIDGET_SENSITIVE (palette_editor->edit_menu_item))
|
1999-12-04 21:08:45 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_set_sensitive (palette_editor->edit_menu_item, TRUE);
|
|
|
|
gtk_widget_set_sensitive (palette_editor->delete_menu_item, TRUE);
|
1999-12-04 21:08:45 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_menu_popup (GTK_MENU (palette_editor->popup_menu),
|
2001-01-22 03:53:56 +08:00
|
|
|
NULL, NULL,
|
1999-07-24 23:37:03 +08:00
|
|
|
NULL, NULL, 3,
|
1999-12-04 21:08:45 +08:00
|
|
|
bevent->time);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
if (bevent->button == 3)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (GTK_WIDGET_SENSITIVE (palette_editor->edit_menu_item))
|
1999-12-04 21:08:45 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_set_sensitive (palette_editor->edit_menu_item, FALSE);
|
|
|
|
gtk_widget_set_sensitive (palette_editor->delete_menu_item, FALSE);
|
1999-12-04 21:08:45 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_menu_popup (GTK_MENU (palette_editor->popup_menu),
|
2001-01-22 03:53:56 +08:00
|
|
|
NULL, NULL,
|
1999-07-24 23:37:03 +08:00
|
|
|
NULL, NULL, 3,
|
1999-12-04 21:08:45 +08:00
|
|
|
bevent->time);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
break;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
return FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* functions for drawing & updating the palette dialog color area **********/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
static gint
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_draw_color_row (guchar *colors,
|
2001-01-21 21:41:07 +08:00
|
|
|
gint n_colors,
|
1999-10-27 02:27:27 +08:00
|
|
|
gint y,
|
|
|
|
gint column_highlight,
|
|
|
|
guchar *buffer,
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
2001-01-15 09:48:53 +08:00
|
|
|
guchar *p;
|
|
|
|
guchar bcolor;
|
|
|
|
gint width, height;
|
|
|
|
gint entry_width;
|
|
|
|
gint entry_height;
|
|
|
|
gint vsize;
|
|
|
|
gint vspacing;
|
|
|
|
gint i, j;
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *preview;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! palette_editor)
|
1998-12-19 08:00:06 +08:00
|
|
|
return -1;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
preview = palette_editor->color_area;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
bcolor = 0;
|
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
width = preview->requisition.width;
|
|
|
|
height = preview->requisition.height;
|
2001-07-10 01:58:56 +08:00
|
|
|
entry_width = palette_editor->col_width;
|
|
|
|
entry_height = (ENTRY_HEIGHT * palette_editor->zoom_factor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if ((y >= 0) && ((y + SPACING) < height))
|
|
|
|
vspacing = SPACING;
|
|
|
|
else if (y < 0)
|
|
|
|
vspacing = SPACING + y;
|
|
|
|
else
|
|
|
|
vspacing = height - y;
|
|
|
|
|
|
|
|
if (vspacing > 0)
|
|
|
|
{
|
|
|
|
if (y < 0)
|
|
|
|
y += SPACING - vspacing;
|
|
|
|
|
|
|
|
for (i = SPACING - vspacing; i < SPACING; i++, y++)
|
|
|
|
{
|
|
|
|
p = buffer;
|
|
|
|
for (j = 0; j < width; j++)
|
|
|
|
{
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (column_highlight >= 0)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
guchar *ph;
|
|
|
|
|
|
|
|
ph = &buffer[3 * column_highlight * (entry_width + SPACING)];
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (j = 0 ; j <= entry_width + SPACING; j++)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
}
|
2001-01-22 03:53:56 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0,
|
|
|
|
y + entry_height + 1, width);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0, y, width);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (y > SPACING)
|
|
|
|
y += SPACING - vspacing;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
y += SPACING;
|
|
|
|
|
|
|
|
vsize = (y >= 0) ? (entry_height) : (entry_height + y);
|
|
|
|
|
|
|
|
if ((y >= 0) && ((y + entry_height) < height))
|
|
|
|
vsize = entry_height;
|
|
|
|
else if (y < 0)
|
|
|
|
vsize = entry_height + y;
|
|
|
|
else
|
|
|
|
vsize = height - y;
|
|
|
|
|
|
|
|
if (vsize > 0)
|
|
|
|
{
|
|
|
|
p = buffer;
|
2001-01-21 21:41:07 +08:00
|
|
|
for (i = 0; i < n_colors; i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
for (j = 0; j < SPACING; j++)
|
|
|
|
{
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < entry_width; j++)
|
|
|
|
{
|
2001-01-21 21:41:07 +08:00
|
|
|
*p++ = colors[i * 3];
|
|
|
|
*p++ = colors[i * 3 + 1];
|
|
|
|
*p++ = colors[i * 3 + 2];
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
for (i = 0; i < (palette_editor->columns - n_colors); i++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
for (j = 0; j < (SPACING + entry_width); j++)
|
|
|
|
{
|
|
|
|
*p++ = 0;
|
|
|
|
*p++ = 0;
|
|
|
|
*p++ = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < SPACING; j++)
|
|
|
|
{
|
2001-01-21 21:41:07 +08:00
|
|
|
if (n_colors == column_highlight)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
*p++ = ~bcolor;
|
|
|
|
*p++ = ~bcolor;
|
|
|
|
*p++ = ~bcolor;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (y < 0)
|
|
|
|
y += entry_height - vsize;
|
|
|
|
for (i = 0; i < vsize; i++, y++)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (column_highlight >= 0)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
guchar *ph;
|
|
|
|
|
|
|
|
ph = &buffer[3 * column_highlight * (entry_width + SPACING)];
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
2001-01-22 03:53:56 +08:00
|
|
|
ph += 3 * (entry_width);
|
1998-12-19 08:00:06 +08:00
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
}
|
2001-01-22 03:53:56 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0, y, width);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
if (y > entry_height)
|
|
|
|
y += entry_height - vsize;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
y += entry_height;
|
|
|
|
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_draw_entries (PaletteEditor *palette_editor,
|
1999-10-27 02:27:27 +08:00
|
|
|
gint row_start,
|
|
|
|
gint column_highlight)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-22 03:53:56 +08:00
|
|
|
GimpPaletteEntry *entry;
|
|
|
|
guchar *buffer;
|
|
|
|
guchar *colors;
|
|
|
|
GList *list;
|
|
|
|
gint width, height;
|
|
|
|
gint entry_width;
|
|
|
|
gint entry_height;
|
|
|
|
gint index, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! (palette_editor && gimp_context_get_palette (palette_editor->context)))
|
2001-01-22 03:53:56 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
width = palette_editor->color_area->requisition.width;
|
|
|
|
height = palette_editor->color_area->requisition.height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
entry_width = palette_editor->col_width;
|
|
|
|
entry_height = (ENTRY_HEIGHT * palette_editor->zoom_factor);
|
2000-02-14 07:24:16 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
if (entry_width <= 0)
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
colors = g_new (guchar, palette_editor->columns * 3);
|
2001-01-22 03:53:56 +08:00
|
|
|
buffer = g_new (guchar, width * 3);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
if (row_start < 0)
|
|
|
|
{
|
|
|
|
y = 0;
|
2001-07-10 01:58:56 +08:00
|
|
|
list = gimp_context_get_palette (palette_editor->context)->colors;
|
2001-01-22 03:53:56 +08:00
|
|
|
column_highlight = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
y = (entry_height + SPACING) * row_start;
|
2001-07-10 01:58:56 +08:00
|
|
|
list = g_list_nth (gimp_context_get_palette (palette_editor->context)->colors,
|
|
|
|
row_start * palette_editor->columns);
|
2001-01-22 03:53:56 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
index = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
for (; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
entry = (GimpPaletteEntry *) list->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
gimp_rgb_get_uchar (&entry->color,
|
|
|
|
&colors[index * 3],
|
|
|
|
&colors[index * 3 + 1],
|
|
|
|
&colors[index * 3 + 2]);
|
|
|
|
index++;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (index == palette_editor->columns)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
index = 0;
|
2001-07-10 01:58:56 +08:00
|
|
|
y = palette_editor_draw_color_row (colors, palette_editor->columns, y,
|
2001-01-22 03:53:56 +08:00
|
|
|
column_highlight, buffer,
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
if (y >= height || row_start >= 0)
|
|
|
|
{
|
|
|
|
/* This row only */
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_draw (palette_editor->color_area, NULL);
|
2001-01-22 03:53:56 +08:00
|
|
|
g_free (buffer);
|
|
|
|
g_free (colors);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
while (y < height)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
y = palette_editor_draw_color_row (colors, index, y, column_highlight,
|
|
|
|
buffer, palette_editor);
|
2001-01-22 03:53:56 +08:00
|
|
|
index = 0;
|
|
|
|
if (row_start >= 0)
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
g_free (buffer);
|
|
|
|
g_free (colors);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! palette_editor->freeze_update)
|
|
|
|
gtk_widget_draw (palette_editor->color_area, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_scroll_top_left (PaletteEditor *palette_editor)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-12-03 05:04:47 +08:00
|
|
|
GtkAdjustment *hadj;
|
|
|
|
GtkAdjustment *vadj;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! (palette_editor && palette_editor->scrolled_window))
|
2001-01-22 03:53:56 +08:00
|
|
|
return;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (palette_editor->scrolled_window));
|
|
|
|
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (palette_editor->scrolled_window));
|
2001-01-22 03:53:56 +08:00
|
|
|
|
|
|
|
if (hadj)
|
|
|
|
gtk_adjustment_set_value (hadj, 0.0);
|
|
|
|
if (vadj)
|
|
|
|
gtk_adjustment_set_value (vadj, 0.0);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_redraw (PaletteEditor *palette_editor)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
gint vsize;
|
|
|
|
gint nrows;
|
|
|
|
gint n_entries;
|
|
|
|
gint preview_width;
|
|
|
|
guint width;
|
1999-09-12 00:55:40 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (! gimp_context_get_palette (palette_editor->context))
|
2000-08-08 06:20:26 +08:00
|
|
|
return;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
width = palette_editor->color_area->parent->parent->parent->allocation.width;
|
1999-09-12 00:55:40 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if ((palette_editor->columns_valid) && palette_editor->last_width == width)
|
1999-09-12 00:55:40 +08:00
|
|
|
return;
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->last_width = width;
|
|
|
|
palette_editor->col_width = width / (palette_editor->columns + 1) - SPACING;
|
|
|
|
if (palette_editor->col_width < 0) palette_editor->col_width = 0;
|
|
|
|
palette_editor->columns_valid = TRUE;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
n_entries = gimp_context_get_palette (palette_editor->context)->n_colors;
|
|
|
|
nrows = n_entries / palette_editor->columns;
|
|
|
|
if (n_entries % palette_editor->columns)
|
1998-12-19 08:00:06 +08:00
|
|
|
nrows += 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
vsize = nrows * (SPACING + (gint) (ENTRY_HEIGHT * palette_editor->zoom_factor)) + SPACING;
|
Add default to Cancel button, remove unset GTK_RECEIVES_DEFAULT from
Sat Feb 20 16:12:33 CST 1999 Shawn T. Amundson <amundson@gimp.org>
* app/tips_dialog.c: Add default to Cancel button, remove
unset GTK_RECEIVES_DEFAULT from prev/next buttons (they
are like toolbar buttons), changed abreviated prev to
previous, prev/next button are now same size, cancel button
is in a button box. Added vboxes where necessary to prevent
prev/next and check button from filling vertically.
* app/app_procs.c: when splashscreen dialog is larger than the
logo, (due to huge font), center logo.
* app/file_new_dialog.c: patch from Marco Lamb <lm@geocities.com>
disallows resizing, changes vertical expanding of widgets to
not occur
* app/palette.c: patch from Marco Lamb <lm@geocities.com>. Makes
+/- buttons for zoom pixmaps (eventually, these can be replaced
with a magnifying glass with a little +/- I think), so that they
no longer expand as they did before. I modified his patch so it
did not create a misused toolbar. I did some other stuff here too,
moved Close button to the left, made it the window's default,
and unset GTK_RECEIVES_DEFAULT off of the non-bottom buttons.
* app/actionarea.c: another patch from Marco Lamb <lm@geocities.com>.
This one changes buttons to be put in a button box which is right
justified. If we decide later that spread is better, we can
change this easy enough.
* app/tools/zoom_in.xpm, app/tools/zoom_out.xpm: + and - graphics.
* libgimp/gimpunit.h
libgimp/gimpunit.c: New files from Michael Natterer
<mitschel@cs.tu-berlin.de>, gimp_unit_* routines.
* app/gimage.h
app/gimpimage.h
app/gimpimage.c
app/gimpimageP.h
app/xcf.c: Patches from Michael Natterer <mitschel@cs.tu-berlin.de>,
which keep a unit assocated with an image.
1999-02-21 10:08:15 +08:00
|
|
|
|
2001-01-22 03:53:56 +08:00
|
|
|
preview_width =
|
2001-07-10 01:58:56 +08:00
|
|
|
(palette_editor->col_width + SPACING) * palette_editor->columns + SPACING;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_preview_size (GTK_PREVIEW (palette_editor->color_area),
|
2001-01-22 03:53:56 +08:00
|
|
|
preview_width, vsize);
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_queue_resize (palette_editor->color_area);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_draw_entries (palette_editor, -1, -1);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color)
|
|
|
|
{
|
|
|
|
palette_editor_draw_entries (palette_editor,
|
|
|
|
palette_editor->color->position / palette_editor->columns,
|
|
|
|
palette_editor->color->position % palette_editor->columns);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_palette_changed (GimpContext *context,
|
2001-02-19 03:44:28 +08:00
|
|
|
GimpPalette *palette,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* FIXME */
|
|
|
|
if (! palette)
|
|
|
|
return;
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (palette_editor->name),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (palette)));
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color_notebook_active)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
color_notebook_hide (palette_editor->color_notebook);
|
|
|
|
palette_editor->color_notebook_active = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color_notebook)
|
|
|
|
color_notebook_free (palette_editor->color_notebook);
|
|
|
|
palette_editor->color_notebook = NULL;
|
|
|
|
|
|
|
|
palette_editor->columns_valid = FALSE;
|
|
|
|
palette_editor_redraw (palette_editor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_scroll_top_left (palette_editor);
|
2001-02-19 03:44:28 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* Stop errors in case no colors are selected */
|
2001-08-10 22:41:39 +08:00
|
|
|
g_signal_handler_block (G_OBJECT (palette_editor->color_name),
|
|
|
|
palette_editor->entry_sig_id);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (palette_editor->color_name), _("Undefined"));
|
2001-08-10 22:41:39 +08:00
|
|
|
|
|
|
|
g_signal_handler_unblock (G_OBJECT (palette_editor->color_name),
|
|
|
|
palette_editor->entry_sig_id);
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gtk_widget_set_sensitive (palette_editor->color_name, FALSE);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* the color name entry callback *******************************************/
|
|
|
|
|
1999-01-03 08:12:39 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_color_name_changed (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1999-01-03 08:12:39 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1999-01-03 08:12:39 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
g_return_if_fail (gimp_context_get_palette (palette_editor->context) != NULL);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color->name)
|
|
|
|
g_free (palette_editor->color->name);
|
|
|
|
palette_editor->color->name =
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (palette_editor->color_name)));
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
gimp_data_dirty (GIMP_DATA (gimp_context_get_palette (palette_editor->context)));
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
/* palette zoom functions & callbacks **************************************/
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_zoomin_callback (GtkWidget *widget,
|
2001-02-19 03:44:28 +08:00
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->zoom_factor += 0.1;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_redraw_zoom (palette_editor);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_zoomout_callback (GtkWidget *widget,
|
1999-10-27 02:27:27 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
2001-01-22 03:53:56 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->zoom_factor -= 0.1;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_redraw_zoom (palette_editor);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_redraw_zoom (PaletteEditor *palette_editor)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->zoom_factor > 4.0)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->zoom_factor = 4.0;
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
2001-07-10 01:58:56 +08:00
|
|
|
else if (palette_editor->zoom_factor < 0.1)
|
2001-02-19 03:44:28 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->zoom_factor = 0.1;
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|
1999-09-28 01:58:10 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->columns = COLUMNS;
|
1999-01-03 08:12:39 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->columns_valid = FALSE;
|
|
|
|
palette_editor_redraw (palette_editor);
|
2001-02-12 00:14:25 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_scroll_top_left (palette_editor);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
/* the palette dialog action callbacks **************************************/
|
1999-10-27 02:27:27 +08:00
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_close_callback (GtkWidget *widget,
|
1999-10-27 02:27:27 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor->color_notebook_active)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
color_notebook_hide (palette_editor->color_notebook);
|
|
|
|
palette_editor->color_notebook_active = FALSE;
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (GTK_WIDGET_VISIBLE (palette_editor->shell))
|
|
|
|
gtk_widget_hide (palette_editor->shell);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the palette dialog color dnd callbacks **********************************/
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_drag_color (GtkWidget *widget,
|
2001-01-15 09:48:53 +08:00
|
|
|
GimpRGB *color,
|
1999-10-27 02:27:27 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor &&
|
|
|
|
gimp_context_get_palette (palette_editor->context) &&
|
|
|
|
palette_editor->dnd_color)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
*color = palette_editor->dnd_color->color;
|
1999-11-03 17:58:46 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-01-21 21:41:07 +08:00
|
|
|
gimp_rgba_set (color, 0.0, 0.0, 0.0, 1.0);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_drop_color (GtkWidget *widget,
|
2001-01-20 23:37:26 +08:00
|
|
|
const GimpRGB *color,
|
|
|
|
gpointer data)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
PaletteEditor *palette_editor;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor = (PaletteEditor *) data;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette_editor && gimp_context_get_palette (palette_editor->context))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->color =
|
|
|
|
gimp_palette_add_entry (gimp_context_get_palette (palette_editor->context),
|
2001-02-19 03:44:28 +08:00
|
|
|
NULL,
|
|
|
|
(GimpRGB *) color);
|
1999-10-27 02:27:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-07-15 22:32:44 +08:00
|
|
|
static void
|
|
|
|
palette_editor_drop_palette (GtkWidget *widget,
|
|
|
|
GimpViewable *viewable,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PaletteEditor *palette_editor;
|
|
|
|
GimpPalette *palette;
|
|
|
|
|
|
|
|
palette_editor = (PaletteEditor *) data;
|
|
|
|
palette = GIMP_PALETTE (viewable);
|
|
|
|
|
|
|
|
if (palette_editor)
|
|
|
|
{
|
|
|
|
gimp_context_set_palette (palette_editor->context, palette);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-19 03:44:28 +08:00
|
|
|
static void
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor_invalidate_preview (GimpPalette *palette,
|
|
|
|
PaletteEditor *palette_editor)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
if (palette == gimp_context_get_palette (palette_editor->context))
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2001-07-10 01:58:56 +08:00
|
|
|
palette_editor->columns_valid = FALSE;
|
|
|
|
palette_editor_redraw (palette_editor);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
2001-02-19 03:44:28 +08:00
|
|
|
}
|