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
|
|
|
*/
|
1999-02-21 07:20:54 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#ifdef HAVE_UNISTD_H
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <unistd.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_DIRENT_H
|
1999-04-23 23:20:10 +08:00
|
|
|
#include <sys/types.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <dirent.h>
|
1999-02-21 07:20:54 +08:00
|
|
|
#endif
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "buildmenu.h"
|
|
|
|
#include "colormaps.h"
|
|
|
|
#include "color_area.h"
|
1999-10-03 21:50:19 +08:00
|
|
|
#include "color_notebook.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "datafiles.h"
|
1998-06-06 11:49:01 +08:00
|
|
|
#include "devices.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "errors.h"
|
1999-08-24 08:36:57 +08:00
|
|
|
#include "gimpdnd.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gimprc.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
#include "gimpui.h"
|
1998-12-19 08:00:06 +08:00
|
|
|
#include "gradient_header.h"
|
|
|
|
#include "gradient.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "palette.h"
|
1998-12-19 08:00:06 +08:00
|
|
|
#include "palette_entries.h"
|
1998-06-23 01:30:40 +08:00
|
|
|
#include "session.h"
|
1998-12-24 08:08:39 +08:00
|
|
|
#include "palette_select.h"
|
1999-01-11 07:20:33 +08:00
|
|
|
#include "dialog_handler.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1999-03-13 06:43:12 +08:00
|
|
|
#include "pixmaps/zoom_in.xpm"
|
|
|
|
#include "pixmaps/zoom_out.xpm"
|
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
|
|
|
|
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
|
|
|
|
|
|
|
#define PREVIEW_WIDTH ((ENTRY_WIDTH * COLUMNS) + (SPACING * (COLUMNS + 1)))
|
|
|
|
#define PREVIEW_HEIGHT ((ENTRY_HEIGHT * ROWS) + (SPACING * (ROWS + 1)))
|
|
|
|
|
|
|
|
#define PALETTE_EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* New palette code... */
|
|
|
|
|
|
|
|
#define IMPORT_PREVIEW_WIDTH 80
|
|
|
|
#define IMPORT_PREVIEW_HEIGHT 80
|
1999-07-24 23:37:03 +08:00
|
|
|
#define MAX_IMAGE_COLORS (10000*2)
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GRAD_IMPORT = 0,
|
|
|
|
IMAGE_IMPORT = 1,
|
|
|
|
} ImportType;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
typedef struct _ImportDialog ImportDialog;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
struct _ImportDialog
|
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *preview;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *select_area;
|
|
|
|
GtkWidget *select;
|
|
|
|
GtkWidget *image_list;
|
|
|
|
GtkWidget *image_menu_item_image;
|
|
|
|
GtkWidget *image_menu_item_gradient;
|
|
|
|
GtkWidget *optionmenu1_menu;
|
|
|
|
GtkWidget *type_option;
|
|
|
|
GtkWidget *threshold_scale;
|
|
|
|
GtkWidget *threshold_text;
|
|
|
|
GtkAdjustment *threshold;
|
|
|
|
GtkAdjustment *sample;
|
|
|
|
ImportType import_type;
|
|
|
|
GimpImage *gimage;
|
|
|
|
};
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
typedef struct _PaletteDialog PaletteDialog;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
struct _PaletteDialog
|
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *shell;
|
|
|
|
GtkWidget *color_area;
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *scrolled_window;
|
1997-11-25 06:05:25 +08:00
|
|
|
GtkWidget *color_name;
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *clist;
|
|
|
|
GtkWidget *popup_menu;
|
|
|
|
GtkWidget *popup_small_menu;
|
1999-10-03 21:50:19 +08:00
|
|
|
ColorNotebookP color_notebook;
|
|
|
|
gboolean color_notebook_active;
|
1998-12-19 08:00:06 +08:00
|
|
|
PaletteEntriesP entries;
|
|
|
|
PaletteEntryP color;
|
|
|
|
GdkGC *gc;
|
|
|
|
guint entry_sig_id;
|
|
|
|
gfloat zoom_factor; /* range from 0.1 to 4.0 */
|
|
|
|
gint columns;
|
|
|
|
gint freeze_update;
|
1999-09-12 00:55:40 +08:00
|
|
|
gint columns_valid;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* This one is called from palette_select.c */
|
|
|
|
void palette_clist_init(GtkWidget *clist, GtkWidget *shell, GdkGC *gc);
|
|
|
|
|
|
|
|
/* Local function prototypes */
|
|
|
|
static void palette_entries_free (PaletteEntriesP);
|
|
|
|
static void palette_entries_load (char *);
|
|
|
|
static void palette_entry_free (PaletteEntryP);
|
|
|
|
static void palette_entries_save (PaletteEntriesP, char *);
|
|
|
|
|
|
|
|
PaletteDialog * create_palette_dialog (gboolean vert);
|
|
|
|
|
1999-08-24 08:36:57 +08:00
|
|
|
static void palette_drag_color (GtkWidget *,
|
|
|
|
guchar *, guchar *, guchar *, gpointer);
|
|
|
|
static void palette_drop_color (GtkWidget *,
|
|
|
|
guchar, guchar, guchar, gpointer);
|
1999-07-24 23:37:03 +08:00
|
|
|
static void palette_draw_entries (PaletteDialog *palette, gint row_start,
|
|
|
|
gint column_highlight);
|
|
|
|
static void redraw_palette (PaletteDialog *palette);
|
|
|
|
|
|
|
|
static GSList * palette_entries_insert_list (GSList *list,
|
|
|
|
PaletteEntriesP entries, gint pos);
|
|
|
|
static void palette_draw_small_preview (GdkGC *gc, PaletteEntriesP p_entry);
|
|
|
|
static void palette_scroll_clist_to_current (PaletteDialog *palette);
|
|
|
|
static void palette_update_small_preview (PaletteDialog *palette);
|
|
|
|
static void palette_scroll_top_left (PaletteDialog *palette);
|
|
|
|
|
|
|
|
static ImportDialog * palette_import_dialog (PaletteDialog *palette);
|
|
|
|
static void palette_import_dialog_callback (GtkWidget *, gpointer);
|
|
|
|
static void import_palette_create_from_image (GImage *gimage,
|
|
|
|
guchar *pname,
|
|
|
|
PaletteDialog *palette);
|
|
|
|
|
|
|
|
static void palette_merge_dialog_callback (GtkWidget *, gpointer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
GSList *palette_entries_list = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
static PaletteEntriesP default_palette_entries = NULL;
|
1999-07-24 23:37:03 +08:00
|
|
|
static gint num_palette_entries = 0;
|
|
|
|
static guchar foreground[3] = { 0, 0, 0 };
|
|
|
|
static guchar background[3] = { 255, 255, 255 };
|
|
|
|
static ImportDialog *import_dialog = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *top_level_edit_palette = NULL;
|
|
|
|
PaletteDialog *top_level_palette = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-24 08:36:57 +08:00
|
|
|
/* dnd stuff */
|
|
|
|
static GtkTargetEntry color_palette_target_table[] =
|
|
|
|
{
|
|
|
|
GIMP_TARGET_COLOR
|
|
|
|
};
|
|
|
|
static guint n_color_palette_targets = (sizeof (color_palette_target_table) /
|
|
|
|
sizeof (color_palette_target_table[0]));
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
|
|
|
palette_entries_free (PaletteEntriesP entries)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
PaletteEntryP entry;
|
|
|
|
GSList * list;
|
|
|
|
|
|
|
|
list = entries->colors;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
entry = (PaletteEntryP) list->data;
|
|
|
|
palette_entry_free (entry);
|
|
|
|
list = list->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (entries->name);
|
|
|
|
if (entries->filename)
|
|
|
|
g_free (entries->filename);
|
|
|
|
g_free (entries);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_entries_delete (gchar *filename)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
if (filename)
|
|
|
|
unlink (filename);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palettes_init (gint no_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-03-27 02:24:42 +08:00
|
|
|
palette_init_palettes (no_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1998-12-19 08:00:06 +08:00
|
|
|
palette_free_palettes (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *list;
|
|
|
|
PaletteEntriesP entries;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
list = palette_entries_list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
while (list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
entries = (PaletteEntriesP) list->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* If the palette has been changed, save it, if possible */
|
|
|
|
if (entries->changed)
|
|
|
|
/* save the palette */
|
|
|
|
palette_entries_save (entries, entries->filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette_entries_free (entries);
|
|
|
|
list = g_slist_next (list);
|
|
|
|
}
|
|
|
|
g_slist_free (palette_entries_list);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
num_palette_entries = 0;
|
|
|
|
palette_entries_list = NULL;
|
|
|
|
}
|
1998-06-23 01:30:40 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
void
|
|
|
|
palettes_free ()
|
|
|
|
{
|
|
|
|
palette_free_palettes ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_get_foreground (guchar *r,
|
|
|
|
guchar *g,
|
|
|
|
guchar *b)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
*r = foreground[0];
|
|
|
|
*g = foreground[1];
|
|
|
|
*b = foreground[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_get_background (guchar *r,
|
|
|
|
guchar *g,
|
|
|
|
guchar *b)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
*r = background[0];
|
|
|
|
*g = background[1];
|
|
|
|
*b = background[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_set_foreground (gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
guchar rr, gg, bb;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Foreground */
|
|
|
|
foreground[0] = r;
|
|
|
|
foreground[1] = g;
|
|
|
|
foreground[2] = b;
|
|
|
|
|
|
|
|
palette_get_foreground (&rr, &gg, &bb);
|
|
|
|
if (no_interface == FALSE)
|
|
|
|
{
|
1999-08-28 05:06:00 +08:00
|
|
|
foreground_pixel = get_color (rr, gg, bb);
|
1997-11-25 06:05:25 +08:00
|
|
|
color_area_update ();
|
1998-06-06 11:49:01 +08:00
|
|
|
device_status_update (current_device);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_set_background (gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
guchar rr, gg, bb;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Background */
|
|
|
|
background[0] = r;
|
|
|
|
background[1] = g;
|
|
|
|
background[2] = b;
|
|
|
|
|
|
|
|
palette_get_background (&rr, &gg, &bb);
|
|
|
|
if (no_interface == FALSE)
|
|
|
|
{
|
1999-08-28 05:06:00 +08:00
|
|
|
background_pixel = get_color (rr, gg, bb);
|
1997-11-25 06:05:25 +08:00
|
|
|
color_area_update ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-02 03:38:25 +08:00
|
|
|
void
|
|
|
|
palette_set_default_colors (void)
|
|
|
|
{
|
|
|
|
palette_set_foreground (0, 0, 0);
|
|
|
|
palette_set_background (255, 255, 255);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
palette_swap_colors (void)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
guchar fg_r, fg_g, fg_b;
|
|
|
|
guchar bg_r, bg_g, bg_b;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
|
|
|
palette_get_foreground (&fg_r, &fg_g, &fg_b);
|
|
|
|
palette_get_background (&bg_r, &bg_g, &bg_b);
|
|
|
|
|
|
|
|
palette_set_foreground (bg_r, bg_g, bg_b);
|
|
|
|
palette_set_background (fg_r, fg_g, fg_b);
|
|
|
|
}
|
|
|
|
|
1997-12-14 19:36:53 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_init_palettes (gint no_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!no_data)
|
1998-03-27 02:24:42 +08:00
|
|
|
datafiles_read_directories (palette_path, palette_entries_load, 0);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-01-03 08:12:39 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select2_set_text_all (PaletteEntriesP entries)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
|
|
|
gint pos = 0;
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar *num_buf;
|
1999-01-03 08:12:39 +08:00
|
|
|
GSList *plist;
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *pp;
|
1999-01-03 08:12:39 +08:00
|
|
|
PaletteEntriesP p_entries = NULL;
|
|
|
|
gchar * num_copy;
|
|
|
|
|
|
|
|
plist = palette_entries_list;
|
|
|
|
|
|
|
|
while (plist)
|
|
|
|
{
|
|
|
|
p_entries = (PaletteEntriesP) plist->data;
|
|
|
|
plist = g_slist_next (plist);
|
|
|
|
|
|
|
|
if (p_entries == entries)
|
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(p_entries == NULL)
|
|
|
|
return; /* This is actually and error */
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
num_buf = g_strdup_printf ("%d", p_entries->n_colors);;
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
num_copy = g_strdup (num_buf);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
|
|
|
pp = top_level_palette;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_set_text (GTK_CLIST (pp->clist), pos, 1, num_copy);
|
|
|
|
redraw_palette (pp);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select2_refresh_all ()
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *pp;
|
1999-01-03 08:12:39 +08:00
|
|
|
|
|
|
|
if(!top_level_palette)
|
|
|
|
return;
|
|
|
|
|
|
|
|
pp = top_level_palette;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_freeze (GTK_CLIST(pp->clist));
|
|
|
|
gtk_clist_clear (GTK_CLIST(pp->clist));
|
|
|
|
palette_clist_init (pp->clist, pp->shell, pp->gc);
|
|
|
|
gtk_clist_thaw (GTK_CLIST (pp->clist));
|
1999-01-03 08:12:39 +08:00
|
|
|
pp->entries = palette_entries_list->data;
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_palette (pp);
|
|
|
|
palette_scroll_clist_to_current (pp);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select2_clist_insert_all (PaletteEntriesP p_entries)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
|
|
|
PaletteEntriesP chk_entries;
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *pp;
|
1999-01-03 08:12:39 +08:00
|
|
|
GSList *plist;
|
|
|
|
gint pos = 0;
|
|
|
|
|
|
|
|
plist = palette_entries_list;
|
|
|
|
|
|
|
|
while (plist)
|
|
|
|
{
|
|
|
|
chk_entries = (PaletteEntriesP) plist->data;
|
|
|
|
plist = g_slist_next (plist);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (chk_entries == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
if (strcmp (p_entries->name, chk_entries->name) == 0)
|
1999-01-03 08:12:39 +08:00
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
pp = top_level_palette;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_freeze (GTK_CLIST (pp->clist));
|
|
|
|
palette_insert_clist (pp->clist, pp->shell, pp->gc, p_entries, pos);
|
|
|
|
gtk_clist_thaw (GTK_CLIST (pp->clist));
|
1999-01-03 08:12:39 +08:00
|
|
|
|
|
|
|
/* if(gradient_select_dialog) */
|
|
|
|
/* { */
|
|
|
|
/* gtk_clist_set_text(GTK_CLIST(gradient_select_dialog->clist),n,1,grad->name); */
|
|
|
|
/* } */
|
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_save_palettes ()
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
PaletteEntriesP entries;
|
|
|
|
|
|
|
|
list = palette_entries_list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
entries = (PaletteEntriesP) list->data;
|
|
|
|
|
|
|
|
/* If the palette has been changed, save it, if possible */
|
|
|
|
if (entries->changed)
|
|
|
|
/* save the palette */
|
|
|
|
palette_entries_save (entries, entries->filename);
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_save_palettes_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_save_palettes ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-12-19 08:00:06 +08:00
|
|
|
palette_entry_free (PaletteEntryP entry)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
if (entry->name)
|
|
|
|
g_free (entry->name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
g_free (entry);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
void
|
|
|
|
palette_free ()
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-24 08:08:39 +08:00
|
|
|
if (top_level_edit_palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
if(import_dialog)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_destroy (import_dialog->dialog);
|
|
|
|
g_free (import_dialog);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog = NULL;
|
|
|
|
}
|
|
|
|
|
1998-12-24 08:08:39 +08:00
|
|
|
gdk_gc_destroy (top_level_edit_palette->gc);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
if (top_level_edit_palette->color_notebook)
|
|
|
|
color_notebook_free (top_level_edit_palette->color_notebook);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1998-12-24 08:08:39 +08:00
|
|
|
g_free (top_level_edit_palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1998-12-24 08:08:39 +08:00
|
|
|
top_level_edit_palette = NULL;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (top_level_palette)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
|
|
|
gdk_gc_destroy (top_level_palette->gc);
|
|
|
|
session_get_window_info (top_level_palette->shell, &palette_session_info);
|
|
|
|
top_level_palette = NULL;
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
palette_entries_save (PaletteEntriesP palette,
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar *filename)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
FILE * fp;
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList * list;
|
1997-11-25 06:05:25 +08:00
|
|
|
PaletteEntryP entry;
|
|
|
|
|
|
|
|
if (! filename)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Open the requested file */
|
1999-06-15 06:18:02 +08:00
|
|
|
if (! (fp = fopen (filename, "w")))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-11-23 22:47:09 +08:00
|
|
|
g_message (_("can't save palette \"%s\"\n"), filename);
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf (fp, "GIMP Palette\n");
|
|
|
|
fprintf (fp, "# %s -- GIMP Palette file\n", palette->name);
|
|
|
|
|
|
|
|
list = palette->colors;
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
entry = (PaletteEntryP) list->data;
|
|
|
|
fprintf (fp, "%d %d %d\t%s\n", entry->color[0], entry->color[1],
|
|
|
|
entry->color[2], entry->name);
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up */
|
|
|
|
fclose (fp);
|
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static PaletteEntryP
|
|
|
|
palette_add_entry (PaletteEntriesP entries,
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar *name,
|
|
|
|
gint r,
|
|
|
|
gint g,
|
|
|
|
gint b)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PaletteEntryP entry;
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if (entries)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
entry = g_new (_PaletteEntry, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
entry->color[0] = r;
|
|
|
|
entry->color[1] = g;
|
|
|
|
entry->color[2] = b;
|
|
|
|
if (name)
|
|
|
|
entry->name = g_strdup (name);
|
|
|
|
else
|
|
|
|
entry->name = g_strdup (_("Untitled"));
|
|
|
|
entry->position = entries->n_colors;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
entries->colors = g_slist_append (entries->colors, entry);
|
|
|
|
entries->n_colors += 1;
|
|
|
|
|
|
|
|
entries->changed = 1;
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_change_color (gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
gint state)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1998-12-24 08:08:39 +08:00
|
|
|
if (top_level_edit_palette && top_level_edit_palette->entries)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case COLOR_NEW:
|
1999-07-24 23:37:03 +08:00
|
|
|
top_level_edit_palette->color =
|
|
|
|
palette_add_entry (top_level_edit_palette->entries,
|
|
|
|
_("Untitled"), r, g, b);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_update_small_preview (top_level_edit_palette);
|
|
|
|
redraw_palette (top_level_edit_palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COLOR_UPDATE_NEW:
|
1998-12-24 08:08:39 +08:00
|
|
|
top_level_edit_palette->color->color[0] = r;
|
|
|
|
top_level_edit_palette->color->color[1] = g;
|
|
|
|
top_level_edit_palette->color->color[2] = b;
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_update_small_preview (top_level_edit_palette);
|
|
|
|
redraw_palette (top_level_edit_palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (active_color == FOREGROUND)
|
|
|
|
palette_set_foreground (r, g, b);
|
|
|
|
else if (active_color == BACKGROUND)
|
|
|
|
palette_set_background (r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_set_active_color (gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
gint state)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
palette_change_color (r, g, b, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_entries_load (gchar *filename)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
PaletteEntriesP entries;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar str[512];
|
|
|
|
gchar *tok;
|
|
|
|
FILE *fp;
|
|
|
|
gint r, g, b;
|
|
|
|
gint linenum;
|
|
|
|
GSList *list;
|
|
|
|
gint pos = 0;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
r = g = b = 0;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
entries = g_new (_PaletteEntries, 1);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
entries->filename = g_strdup (filename);
|
1999-02-07 18:45:56 +08:00
|
|
|
entries->name = g_strdup (g_basename (filename));
|
1998-12-19 08:00:06 +08:00
|
|
|
entries->colors = NULL;
|
|
|
|
entries->n_colors = 0;
|
|
|
|
entries->pixmap = NULL;
|
|
|
|
|
|
|
|
/* Open the requested file */
|
1999-06-15 06:18:02 +08:00
|
|
|
if (!(fp = fopen (filename, "r")))
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
palette_entries_free (entries);
|
1999-06-06 07:41:45 +08:00
|
|
|
g_warning ("failed to open palette file %s: can't happen?", filename);
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-05-04 04:44:01 +08:00
|
|
|
linenum = 0;
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
fread (str, 13, 1, fp);
|
|
|
|
str[13] = '\0';
|
1999-05-04 04:44:01 +08:00
|
|
|
linenum++;
|
1998-12-19 08:00:06 +08:00
|
|
|
if (strcmp (str, "GIMP Palette\n"))
|
|
|
|
{
|
1999-05-04 04:44:01 +08:00
|
|
|
/* bad magic, but maybe it has \r\n at the end of lines? */
|
|
|
|
if (!strcmp (str, "GIMP Palette\r"))
|
1999-07-24 23:37:03 +08:00
|
|
|
g_message (_("Loading palette %s:\n"
|
|
|
|
"Corrupt palette:\n"
|
|
|
|
"missing magic header\n"
|
|
|
|
"Does this file need converting from DOS?"), filename);
|
1999-05-04 04:44:01 +08:00
|
|
|
else
|
1999-07-24 23:37:03 +08:00
|
|
|
g_message (_("Loading palette %s:\n"
|
|
|
|
"Corrupt palette: missing magic header"), filename);
|
1998-12-19 08:00:06 +08:00
|
|
|
fclose (fp);
|
1999-05-04 04:44:01 +08:00
|
|
|
palette_entries_free (entries);
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!feof (fp))
|
|
|
|
{
|
|
|
|
if (!fgets (str, 512, fp))
|
1999-05-04 04:44:01 +08:00
|
|
|
{
|
|
|
|
if (feof (fp))
|
|
|
|
break;
|
|
|
|
g_message (_("Loading palette %s (line %d):\nRead error"),
|
|
|
|
filename, linenum);
|
|
|
|
fclose (fp);
|
|
|
|
palette_entries_free (entries);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
linenum++;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
if (str[0] != '#')
|
|
|
|
{
|
|
|
|
tok = strtok (str, " \t");
|
1999-07-24 23:37:03 +08:00
|
|
|
if (tok)
|
1998-12-19 08:00:06 +08:00
|
|
|
r = atoi (tok);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Missing RED component"), filename, linenum);
|
1999-05-04 04:44:01 +08:00
|
|
|
/* maybe we should just abort? */
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
tok = strtok (NULL, " \t");
|
1999-07-24 23:37:03 +08:00
|
|
|
if (tok)
|
1998-12-19 08:00:06 +08:00
|
|
|
g = atoi (tok);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Missing GREEN component"), filename, linenum);
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
tok = strtok (NULL, " \t");
|
1999-07-24 23:37:03 +08:00
|
|
|
if (tok)
|
1998-12-19 08:00:06 +08:00
|
|
|
b = atoi (tok);
|
1999-07-24 23:37:03 +08:00
|
|
|
else
|
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"Missing BLUE component"), filename, linenum);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-05-04 04:44:01 +08:00
|
|
|
/* optional name */
|
1998-12-19 08:00:06 +08:00
|
|
|
tok = strtok (NULL, "\n");
|
|
|
|
|
1999-05-04 04:44:01 +08:00
|
|
|
if (r < 0 || r > 255 ||
|
|
|
|
g < 0 || g > 255 ||
|
|
|
|
b < 0 || b > 255)
|
1999-07-24 23:37:03 +08:00
|
|
|
g_message (_("Loading palette %s (line %d):\n"
|
|
|
|
"RGB value out of range"), filename, linenum);
|
1999-05-04 04:44:01 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette_add_entry (entries, tok, r, g, b);
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
/* Clean up */
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
entries->changed = 0;
|
|
|
|
|
|
|
|
list = palette_entries_list;
|
1999-05-04 04:44:01 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
|
|
|
{
|
|
|
|
p_entries = default_palette_entries;
|
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
if (strcmp (p_entries->name, entries->name) > 0)
|
1998-12-19 08:00:06 +08:00
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_entries_list = palette_entries_insert_list (palette_entries_list, entries, pos);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
/* Check if the current palette is the default one */
|
1999-07-24 23:37:03 +08:00
|
|
|
if (strcmp (default_palette, g_basename (filename)) == 0)
|
1998-12-19 08:00:06 +08:00
|
|
|
default_palette_entries = entries;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static PaletteDialog *
|
|
|
|
new_top_palette (gboolean vert)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *p;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
p = create_palette_dialog (vert);
|
|
|
|
palette_clist_init (p->clist, p->shell, p->gc);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return p;
|
1998-12-24 08:08:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select_palette_init (void)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
|
|
|
/* Load them if they are not already loaded */
|
|
|
|
if(top_level_edit_palette == NULL)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
top_level_edit_palette = new_top_palette (FALSE);
|
1998-12-24 08:08:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_create (void)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (top_level_palette == NULL)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
top_level_palette = new_top_palette (TRUE);
|
|
|
|
/* top_level_palette = palette_new_selection(_("Palette"),NULL); */
|
|
|
|
session_set_window_geometry (top_level_palette->shell,
|
|
|
|
&palette_session_info, TRUE);
|
1999-01-11 07:20:33 +08:00
|
|
|
/* register this one only */
|
1999-07-24 23:37:03 +08:00
|
|
|
dialog_register (top_level_palette->shell);
|
1999-01-11 07:20:33 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_show (top_level_palette->shell);
|
|
|
|
palette_scroll_clist_to_current (top_level_palette);
|
1998-12-24 08:08:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!GTK_WIDGET_VISIBLE (top_level_palette->shell))
|
|
|
|
{
|
|
|
|
gtk_widget_show (top_level_palette->shell);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gdk_window_raise (top_level_palette->shell->window);
|
1998-12-24 08:08:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1998-12-24 08:08:39 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_create_edit (PaletteEntriesP entries)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *p;
|
1998-12-24 08:08:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (top_level_edit_palette == NULL)
|
1998-12-24 08:08:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
p = new_top_palette (FALSE);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_widget_show(p->shell);
|
|
|
|
|
|
|
|
palette_draw_entries(p,-1,-1);
|
|
|
|
|
1998-12-24 08:08:39 +08:00
|
|
|
top_level_edit_palette = p;
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-24 08:08:39 +08:00
|
|
|
if (!GTK_WIDGET_VISIBLE (top_level_edit_palette->shell))
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1998-12-24 08:08:39 +08:00
|
|
|
gtk_widget_show (top_level_edit_palette->shell);
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_entries (top_level_edit_palette, -1, -1);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gdk_window_raise (top_level_edit_palette->shell->window);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
1998-12-24 08:08:39 +08:00
|
|
|
|
|
|
|
if(entries != NULL)
|
|
|
|
{
|
|
|
|
top_level_edit_palette->entries = entries;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_unselect_all (GTK_CLIST (top_level_edit_palette->clist));
|
|
|
|
palette_scroll_clist_to_current (top_level_edit_palette);
|
1998-12-24 08:08:39 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GSList *
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_entries_insert_list (GSList *list,
|
|
|
|
PaletteEntriesP entries,
|
|
|
|
gint pos)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
GSList *ret_list;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* add it to the list */
|
|
|
|
num_palette_entries++;
|
1999-07-24 23:37:03 +08:00
|
|
|
ret_list = g_slist_insert (list, (void *) entries, pos);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
return ret_list;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static void
|
|
|
|
palette_update_small_preview (PaletteDialog *palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
GSList *list;
|
|
|
|
gint pos = 0;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar *num_buf;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
list = palette_entries_list;
|
|
|
|
|
|
|
|
pos = 0;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
|
|
|
{
|
|
|
|
p_entries = default_palette_entries;
|
|
|
|
}
|
|
|
|
if (p_entries == palette->entries)
|
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
num_buf = g_strdup_printf ("%d", p_entries->n_colors);
|
|
|
|
palette_draw_small_preview (palette->gc, p_entries);
|
|
|
|
gtk_clist_set_text (GTK_CLIST (palette->clist), pos, 1, num_buf);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_delete_entry (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
PaletteEntryP entry;
|
|
|
|
GSList *tmp_link;
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
gint pos = 0;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1998-12-19 08:00:06 +08:00
|
|
|
if (palette && palette->entries && palette->color)
|
|
|
|
{
|
|
|
|
entry = palette->color;
|
|
|
|
palette->entries->colors = g_slist_remove (palette->entries->colors, entry);
|
|
|
|
palette->entries->n_colors--;
|
|
|
|
palette->entries->changed = 1;
|
|
|
|
|
|
|
|
pos = entry->position;
|
|
|
|
palette_entry_free (entry);
|
|
|
|
|
|
|
|
tmp_link = g_slist_nth (palette->entries->colors, pos);
|
|
|
|
|
|
|
|
if (tmp_link)
|
|
|
|
{
|
|
|
|
palette->color = tmp_link->data;
|
|
|
|
|
|
|
|
while (tmp_link)
|
|
|
|
{
|
|
|
|
entry = tmp_link->data;
|
|
|
|
tmp_link = tmp_link->next;
|
|
|
|
entry->position = pos++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tmp_link = g_slist_nth (palette->entries->colors, pos - 1);
|
|
|
|
if (tmp_link)
|
|
|
|
palette->color = tmp_link->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (palette->entries->n_colors == 0)
|
|
|
|
palette->color = palette_add_entry (palette->entries, _("Black"), 0, 0, 0);
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_update_small_preview (palette);
|
|
|
|
palette_select_set_text_all (palette->entries);
|
|
|
|
palette_select2_set_text_all (palette->entries);
|
|
|
|
redraw_palette (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_new_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
char *num_buf;
|
|
|
|
GSList *list;
|
|
|
|
gint pos = 0;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1998-12-19 08:00:06 +08:00
|
|
|
if (palette && palette->entries)
|
|
|
|
{
|
|
|
|
if (active_color == FOREGROUND)
|
|
|
|
palette->color =
|
|
|
|
palette_add_entry (palette->entries, _("Untitled"),
|
|
|
|
foreground[0], foreground[1], foreground[2]);
|
|
|
|
else if (active_color == BACKGROUND)
|
|
|
|
palette->color =
|
|
|
|
palette_add_entry (palette->entries, _("Untitled"),
|
|
|
|
background[0], background[1], background[2]);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_palette (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
list = palette_entries_list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
|
|
|
{
|
|
|
|
p_entries = default_palette_entries;
|
|
|
|
}
|
|
|
|
if (p_entries == palette->entries)
|
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
num_buf = g_strdup_printf ("%d", p_entries->n_colors);;
|
|
|
|
palette_draw_small_preview (palette->gc, p_entries);
|
|
|
|
gtk_clist_set_text (GTK_CLIST (palette->clist), pos, 1, num_buf);
|
|
|
|
palette_select_set_text_all (palette->entries);
|
|
|
|
palette_select2_set_text_all (palette->entries);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static PaletteEntriesP
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_create_entries (gpointer data,
|
|
|
|
gpointer call_data)
|
|
|
|
{
|
|
|
|
gchar *home;
|
|
|
|
gchar *palette_name;
|
|
|
|
gchar *local_path;
|
|
|
|
gchar *first_token;
|
|
|
|
gchar *token;
|
|
|
|
gchar *path;
|
1998-12-19 08:00:06 +08:00
|
|
|
PaletteEntriesP entries = NULL;
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *list;
|
|
|
|
gint pos = 0;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
palette_name = (char *) call_data;
|
|
|
|
if (palette && palette_name)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
entries = g_new (_PaletteEntries, 1);
|
1998-12-19 08:00:06 +08:00
|
|
|
if (palette_path)
|
|
|
|
{
|
|
|
|
/* Get the first path specified in the palette path list */
|
1999-02-03 17:17:37 +08:00
|
|
|
home = g_get_home_dir ();
|
1998-12-19 08:00:06 +08:00
|
|
|
local_path = g_strdup (palette_path);
|
|
|
|
first_token = local_path;
|
1999-07-24 23:37:03 +08:00
|
|
|
token = xstrsep (&first_token, G_SEARCHPATH_SEPARATOR_S);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
if (token)
|
|
|
|
{
|
|
|
|
if (*token == '~')
|
|
|
|
{
|
1999-02-21 07:20:54 +08:00
|
|
|
if (home)
|
1999-07-24 23:37:03 +08:00
|
|
|
path = g_strdup_printf ("%s%s", home, token + 1);
|
1999-02-21 07:20:54 +08:00
|
|
|
else
|
|
|
|
/* Just ignore the ~ if no HOME ??? */
|
1999-07-24 23:37:03 +08:00
|
|
|
path = g_strdup (token + 1);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1998-12-26 02:22:01 +08:00
|
|
|
path = g_strdup(token);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
1999-02-21 07:20:54 +08:00
|
|
|
entries->filename = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s",
|
|
|
|
path, palette_name);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
g_free (path);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free (local_path);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
entries->filename = NULL;
|
|
|
|
|
|
|
|
entries->name = palette_name; /* don't need to copy because this memory is ours */
|
|
|
|
entries->colors = NULL;
|
|
|
|
entries->n_colors = 0;
|
|
|
|
entries->changed = 1;
|
|
|
|
entries->pixmap = NULL;
|
|
|
|
|
|
|
|
/* Add into the clist */
|
|
|
|
|
|
|
|
list = palette_entries_list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
|
|
|
{
|
|
|
|
p_entries = default_palette_entries;
|
|
|
|
}
|
|
|
|
if (strcmp(p_entries->name, entries->name) > 0)
|
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_entries_list =
|
|
|
|
palette_entries_insert_list (palette_entries_list, entries, pos);
|
|
|
|
palette_insert_clist (palette->clist, palette->shell, palette->gc,
|
|
|
|
entries,pos);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->entries = entries;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_save_palettes ();
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
return entries;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_add_entries_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
gpointer call_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-24 08:08:39 +08:00
|
|
|
PaletteEntriesP entries;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
entries = palette_create_entries (data, call_data);
|
1998-12-24 08:08:39 +08:00
|
|
|
/* Update other selectors on screen */
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select_clist_insert_all (entries);
|
|
|
|
palette_select2_clist_insert_all (entries);
|
|
|
|
palette_scroll_clist_to_current ((PaletteDialog *) data);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_new_entries_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
GtkWidget *qbox;
|
|
|
|
|
|
|
|
qbox = gimp_query_string_box (_("New Palette"),
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/palette_editor/new_palette.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Enter a name for new palette"),
|
|
|
|
NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
palette_add_entries_callback, data);
|
|
|
|
gtk_widget_show (qbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_zoom (PaletteDialog *palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (palette->zoom_factor > 4.0)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
palette->zoom_factor = 4.0;
|
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
else if (palette->zoom_factor < 0.1)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
palette->zoom_factor = 0.1;
|
|
|
|
}
|
|
|
|
|
|
|
|
palette->columns = COLUMNS;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_palette (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_scroll_top_left (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_zoomin (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette = data;
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->zoom_factor += 0.1;
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_zoom (palette);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_zoomout (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette = data;
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->zoom_factor -= 0.1;
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_zoom (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_refresh (PaletteDialog *palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
if (default_palette_entries == palette->entries)
|
|
|
|
default_palette_entries = NULL;
|
|
|
|
palette->entries = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* If a color selection dialog is up, hide it */
|
1999-10-03 21:50:19 +08:00
|
|
|
if (palette->color_notebook_active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
palette->color_notebook_active = FALSE;
|
|
|
|
color_notebook_hide (palette->color_notebook);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
palette_free_palettes (); /* free palettes, don't save any modified versions */
|
|
|
|
palette_init_palettes (FALSE); /* reload palettes */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_freeze (GTK_CLIST (palette->clist));
|
|
|
|
gtk_clist_clear (GTK_CLIST (palette->clist));
|
|
|
|
palette_clist_init (palette->clist, palette->shell, palette->gc);
|
|
|
|
gtk_clist_thaw (GTK_CLIST (palette->clist));
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (palette->entries == NULL)
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->entries = default_palette_entries;
|
|
|
|
|
|
|
|
if(palette->entries == NULL && palette_entries_list)
|
|
|
|
palette->entries = palette_entries_list->data;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_palette (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_scroll_clist_to_current (palette);
|
1998-12-24 08:08:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select_refresh_all ();
|
|
|
|
palette_select2_refresh_all ();
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
palette_free_palettes ();
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_init_palettes (FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_refresh_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_refresh (data);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_small_preview(GdkGC *gc,
|
|
|
|
PaletteEntriesP p_entry)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
guchar rgb_buf[SM_PREVIEW_WIDTH * SM_PREVIEW_HEIGHT * 3];
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *tmp_link;
|
|
|
|
gint index;
|
|
|
|
PaletteEntryP entry;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/*fill_clist_prev(p_entry,rgb_buf,48,16,0.0,1.0);*/
|
1999-07-24 23:37:03 +08:00
|
|
|
memset (rgb_buf, 0x0, sizeof (rgb_buf));
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
gdk_draw_rgb_image (p_entry->pixmap,
|
|
|
|
gc,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
SM_PREVIEW_WIDTH,
|
|
|
|
SM_PREVIEW_HEIGHT,
|
|
|
|
GDK_RGB_DITHER_NORMAL,
|
|
|
|
rgb_buf,
|
|
|
|
SM_PREVIEW_WIDTH*3);
|
|
|
|
|
|
|
|
tmp_link = p_entry->colors;
|
|
|
|
index = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
while (tmp_link)
|
|
|
|
{
|
|
|
|
guchar cell[3*3*3];
|
1999-07-24 23:37:03 +08:00
|
|
|
gint loop;
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
entry = tmp_link->data;
|
|
|
|
tmp_link = tmp_link->next;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
for (loop = 0; loop < 27 ; loop+=3)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
cell[0+loop] = entry->color[0];
|
|
|
|
cell[1+loop] = entry->color[1];
|
|
|
|
cell[2+loop] = entry->color[2];
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
gdk_draw_rgb_image (p_entry->pixmap,
|
|
|
|
gc,
|
|
|
|
1+(index%((SM_PREVIEW_WIDTH-2)/3))*3,
|
|
|
|
1+(index/((SM_PREVIEW_WIDTH-2)/3))*3,
|
|
|
|
3,
|
|
|
|
3,
|
|
|
|
GDK_RGB_DITHER_NORMAL,
|
|
|
|
cell,
|
|
|
|
3);
|
|
|
|
|
|
|
|
index++;
|
|
|
|
if(index >= (((SM_PREVIEW_WIDTH-2)*(SM_PREVIEW_HEIGHT-2))/9))
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-10-03 21:50:19 +08:00
|
|
|
palette_select_callback (gint r,
|
|
|
|
gint g,
|
|
|
|
gint b,
|
|
|
|
ColorNotebookState state,
|
|
|
|
void *data)
|
1999-07-24 23:37:03 +08:00
|
|
|
{
|
|
|
|
PaletteDialog *palette;
|
|
|
|
guchar *color;
|
|
|
|
GSList *list;
|
1998-12-19 08:00:06 +08:00
|
|
|
gint pos = 0;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
if (palette && palette->entries)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
case COLOR_NOTEBOOK_UPDATE:
|
1999-07-24 23:37:03 +08:00
|
|
|
break;
|
1999-10-03 21:50:19 +08:00
|
|
|
case COLOR_NOTEBOOK_OK:
|
1999-07-24 23:37:03 +08:00
|
|
|
if (palette->color)
|
|
|
|
{
|
|
|
|
color = palette->color->color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
color[0] = r;
|
|
|
|
color[1] = g;
|
|
|
|
color[2] = b;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Update either foreground or background colors */
|
|
|
|
if (active_color == FOREGROUND)
|
|
|
|
palette_set_foreground (r, g, b);
|
|
|
|
else if (active_color == BACKGROUND)
|
|
|
|
palette_set_background (r, g, b);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_entries (palette,
|
|
|
|
palette->color->position/(palette->columns),
|
|
|
|
palette->color->position%(palette->columns));
|
|
|
|
palette_draw_small_preview (palette->gc,palette->entries);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Add into the clist */
|
|
|
|
list = palette_entries_list;
|
|
|
|
|
|
|
|
while (list)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
|
|
|
{
|
|
|
|
p_entries = default_palette_entries;
|
|
|
|
}
|
|
|
|
if (p_entries == palette->entries)
|
|
|
|
break;
|
|
|
|
pos++;
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_set_text (GTK_CLIST (palette->clist),
|
|
|
|
pos, 2, p_entries->name);
|
|
|
|
palette_select_set_text_all (palette->entries);
|
|
|
|
palette_select2_set_text_all (palette->entries);
|
|
|
|
}
|
|
|
|
/* Fallthrough */
|
1999-10-03 21:50:19 +08:00
|
|
|
case COLOR_NOTEBOOK_CANCEL:
|
|
|
|
color_notebook_hide (palette->color_notebook);
|
|
|
|
palette->color_notebook_active = FALSE;
|
1999-07-24 23:37:03 +08:00
|
|
|
}
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_scroll_clist_to_current (PaletteDialog *palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *list;
|
|
|
|
gint pos = 0;
|
|
|
|
PaletteEntriesP p_entries;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (palette && palette->entries)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
list = palette_entries_list;
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
while (list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if (p_entries == palette->entries)
|
|
|
|
break;
|
|
|
|
pos++;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_unselect_all (GTK_CLIST (palette->clist));
|
|
|
|
gtk_clist_select_row (GTK_CLIST (palette->clist), pos, -1);
|
|
|
|
gtk_clist_moveto (GTK_CLIST (palette->clist), pos, 0, 0.0, 0.0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_delete_entries_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
PaletteEntriesP entries;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1998-12-19 08:00:06 +08:00
|
|
|
if (palette && palette->entries)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
entries = palette->entries;
|
|
|
|
if (entries && entries->filename)
|
|
|
|
palette_entries_delete (entries->filename);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_entries_list = g_slist_remove (palette_entries_list, entries);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_refresh (palette);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1998-12-19 08:00:06 +08:00
|
|
|
if (palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
if (palette->color_notebook_active)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
palette->color_notebook_active = FALSE;
|
|
|
|
color_notebook_hide (palette->color_notebook);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if(import_dialog)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_destroy (import_dialog->dialog);
|
|
|
|
g_free (import_dialog);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GTK_WIDGET_VISIBLE (palette->shell))
|
|
|
|
gtk_widget_hide (palette->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-21 06:19:45 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
color_name_entry_changed (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-03-21 06:19:45 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
|
|
|
if (palette->color->name)
|
|
|
|
g_free (palette->color->name);
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->entries->changed = 1;
|
1999-07-24 23:37:03 +08:00
|
|
|
palette->color->name =
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (palette->color_name)));
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_edit_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
|
|
|
guchar *color;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = data;
|
1997-11-25 06:05:25 +08:00
|
|
|
if (palette && palette->entries && palette->color)
|
|
|
|
{
|
|
|
|
color = palette->color->color;
|
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
if (!palette->color_notebook)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
palette->color_notebook =
|
|
|
|
color_notebook_new (color[0], color[1], color[2],
|
|
|
|
palette_select_callback, palette,
|
|
|
|
FALSE);
|
|
|
|
palette->color_notebook_active = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
if (!palette->color_notebook_active)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
color_notebook_show (palette->color_notebook);
|
|
|
|
palette->color_notebook_active = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
color_notebook_set_color (palette->color_notebook,
|
|
|
|
color[0], color[1], color[2], 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_popup_menu (PaletteDialog *palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menu_items;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menu = gtk_menu_new ();
|
|
|
|
menu_items = gtk_menu_item_new_with_label (_("Edit"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_items);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_items), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (palette_edit_callback),
|
|
|
|
(gpointer) palette);
|
|
|
|
gtk_widget_show (menu_items);
|
|
|
|
|
|
|
|
menu_items = gtk_menu_item_new_with_label (_("New"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_items);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_items), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (palette_new_callback),
|
|
|
|
(gpointer) palette);
|
|
|
|
gtk_widget_show (menu_items);
|
|
|
|
|
|
|
|
menu_items = gtk_menu_item_new_with_label (_("Delete"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT(menu_items), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (palette_delete_entry),
|
|
|
|
(gpointer) palette);
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_items);
|
|
|
|
gtk_widget_show (menu_items);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
/* Do something interesting when the menuitem is selected */
|
|
|
|
/* gtk_signal_connect_object(GTK_OBJECT(menu_items), "activate", */
|
|
|
|
/* GTK_SIGNAL_FUNC(menuitem_response), (gpointer) g_strdup(buf)); */
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->popup_menu = menu;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette->popup_small_menu = menu = gtk_menu_new ();
|
|
|
|
menu_items = gtk_menu_item_new_with_label (_("New"));
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menu_items);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menu_items), "activate",
|
|
|
|
GTK_SIGNAL_FUNC (palette_new_callback),
|
|
|
|
(gpointer) palette);
|
|
|
|
gtk_widget_show (menu_items);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static gint
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_color_area_events (GtkWidget *widget,
|
|
|
|
GdkEvent *event,
|
|
|
|
PaletteDialog *palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GdkEventButton *bevent;
|
|
|
|
GSList *tmp_link;
|
|
|
|
int r, g, b;
|
|
|
|
int entry_width;
|
|
|
|
int entry_height;
|
|
|
|
int row, col;
|
|
|
|
int pos;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
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:
|
|
|
|
redraw_palette(palette);
|
|
|
|
break;
|
1998-12-19 08:00:06 +08:00
|
|
|
case GDK_BUTTON_PRESS:
|
|
|
|
bevent = (GdkEventButton *) event;
|
|
|
|
entry_width = (ENTRY_WIDTH*palette->zoom_factor)+SPACING;
|
|
|
|
entry_height = (ENTRY_HEIGHT*palette->zoom_factor)+SPACING;
|
|
|
|
col = (bevent->x - 1) / entry_width;
|
|
|
|
row = (bevent->y - 1) / entry_height;
|
|
|
|
pos = row * palette->columns + col;
|
|
|
|
|
|
|
|
if ((bevent->button == 1 || bevent->button == 3) && palette->entries)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
tmp_link = g_slist_nth (palette->entries->colors, pos);
|
|
|
|
if (tmp_link)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
if(palette->color)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->freeze_update = TRUE;
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_entries (palette, -1, -1);
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->freeze_update = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->color = tmp_link->data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Update either foreground or background colors */
|
|
|
|
r = palette->color->color[0];
|
|
|
|
g = palette->color->color[1];
|
|
|
|
b = palette->color->color[2];
|
|
|
|
if (active_color == FOREGROUND)
|
1999-08-24 08:36:57 +08:00
|
|
|
{
|
|
|
|
if (bevent->state & GDK_CONTROL_MASK)
|
|
|
|
palette_set_background (r, g, b);
|
|
|
|
else
|
|
|
|
palette_set_foreground (r, g, b);
|
|
|
|
}
|
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)
|
|
|
|
palette_set_foreground (r, g, b);
|
|
|
|
else
|
|
|
|
palette_set_background (r, g, b);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_entries (palette, row, col);
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Update the active color name */
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (palette->color_name),
|
|
|
|
palette->color->name);
|
1999-01-04 05:21:53 +08:00
|
|
|
gtk_widget_set_sensitive (palette->color_name, TRUE);
|
1998-12-19 08:00:06 +08:00
|
|
|
/* palette_update_current_entry (palette); */
|
1999-07-24 23:37:03 +08:00
|
|
|
if (bevent->button == 3)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
/* Popup the edit menu */
|
|
|
|
gtk_menu_popup (GTK_MENU (palette->popup_menu), NULL, NULL,
|
1999-07-24 23:37:03 +08:00
|
|
|
NULL, NULL, 3,
|
|
|
|
((GdkEventButton *)event)->time);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(bevent->button == 3)
|
|
|
|
{
|
|
|
|
/* Popup the small new menu */
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_menu_popup (GTK_MENU (palette->popup_small_menu),
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL, 3,
|
|
|
|
((GdkEventButton *)event)->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
|
|
|
}
|
|
|
|
|
1998-12-24 08:08:39 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_insert_clist (GtkWidget *clist,
|
|
|
|
GtkWidget *shell,
|
|
|
|
GdkGC *gc,
|
|
|
|
PaletteEntriesP p_entries,
|
|
|
|
gint pos)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
gchar *string[3];
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
string[0] = NULL;
|
1999-07-24 23:37:03 +08:00
|
|
|
string[1] = g_strdup_printf ("%d", p_entries->n_colors);
|
1998-12-19 08:00:06 +08:00
|
|
|
string[2] = p_entries->name;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
gtk_clist_insert (GTK_CLIST (clist), pos, string);
|
|
|
|
|
|
|
|
g_free (string[1]);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (p_entries->pixmap == NULL)
|
|
|
|
p_entries->pixmap = gdk_pixmap_new (shell->window,
|
|
|
|
SM_PREVIEW_WIDTH,
|
|
|
|
SM_PREVIEW_HEIGHT,
|
|
|
|
gtk_widget_get_visual (shell)->depth);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_small_preview (gc, p_entries);
|
|
|
|
gtk_clist_set_pixmap (GTK_CLIST (clist), pos, 0, p_entries->pixmap, NULL);
|
|
|
|
gtk_clist_set_row_data (GTK_CLIST (clist), pos, (gpointer) p_entries);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_clist_init (GtkWidget *clist,
|
|
|
|
GtkWidget *shell,
|
|
|
|
GdkGC *gc)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *list;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
|
|
|
gint pos = 0;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
list = palette_entries_list;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
while (list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
p_entries = default_palette_entries;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
palette_insert_clist (clist, shell, gc, p_entries, pos);
|
1998-12-19 08:00:06 +08:00
|
|
|
pos++;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_color_row (guchar **colors,
|
|
|
|
gint ncolors,
|
|
|
|
gint y,
|
|
|
|
gint column_highlight,
|
|
|
|
guchar *buffer,
|
|
|
|
PaletteDialog *palette)
|
|
|
|
{
|
|
|
|
guchar *p;
|
|
|
|
guchar bcolor;
|
|
|
|
gint width, height;
|
|
|
|
gint entry_width;
|
|
|
|
gint entry_height;
|
|
|
|
gint vsize;
|
|
|
|
gint vspacing;
|
|
|
|
gint i, j;
|
|
|
|
GtkWidget *preview;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
preview = palette->color_area;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
bcolor = 0;
|
|
|
|
|
|
|
|
width = preview->requisition.width;
|
|
|
|
height = preview->requisition.height;
|
1999-07-24 23:37:03 +08:00
|
|
|
entry_width = (ENTRY_WIDTH * palette->zoom_factor);
|
|
|
|
entry_height = (ENTRY_HEIGHT * palette->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
|
|
|
{
|
|
|
|
guchar *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;
|
|
|
|
}
|
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;
|
|
|
|
for (i = 0; i < ncolors; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < SPACING; j++)
|
|
|
|
{
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
*p++ = bcolor;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (j = 0; j < entry_width; j++)
|
|
|
|
{
|
|
|
|
*p++ = colors[i][0];
|
|
|
|
*p++ = colors[i][1];
|
|
|
|
*p++ = colors[i][2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
for (i = 0; i < (palette->columns - ncolors); 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++)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (ncolors == 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
|
|
|
{
|
|
|
|
guchar *ph = &buffer[3*column_highlight*(entry_width+SPACING)];
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
ph += 3*(entry_width);
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
*ph++ = ~bcolor;
|
|
|
|
}
|
|
|
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_entries (PaletteDialog *palette,
|
|
|
|
gint row_start,
|
|
|
|
gint column_highlight)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PaletteEntryP entry;
|
1999-07-24 23:37:03 +08:00
|
|
|
guchar *buffer;
|
|
|
|
guchar **colors;
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *tmp_link;
|
1999-07-24 23:37:03 +08:00
|
|
|
gint width, height;
|
|
|
|
gint entry_width;
|
|
|
|
gint entry_height;
|
|
|
|
gint index, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if (palette && palette->entries)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
width = palette->color_area->requisition.width;
|
|
|
|
height = palette->color_area->requisition.height;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
entry_width = (ENTRY_WIDTH * palette->zoom_factor);
|
|
|
|
entry_height = (ENTRY_HEIGHT * palette->zoom_factor);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
colors = g_malloc (sizeof (guchar *) * palette->columns * 3);
|
1998-12-19 08:00:06 +08:00
|
|
|
buffer = g_malloc (width * 3);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if(row_start < 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
y = 0;
|
|
|
|
tmp_link = palette->entries->colors;
|
|
|
|
column_highlight = -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
y = (entry_height+SPACING)*row_start;
|
|
|
|
tmp_link = g_slist_nth (palette->entries->colors, row_start*palette->columns);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
index = 0;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
while (tmp_link)
|
|
|
|
{
|
|
|
|
entry = tmp_link->data;
|
|
|
|
tmp_link = tmp_link->next;
|
|
|
|
|
|
|
|
colors[index] = entry->color;
|
|
|
|
index++;
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if (index == palette->columns)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
index = 0;
|
1998-12-19 08:00:06 +08:00
|
|
|
y = palette_draw_color_row (colors, palette->columns, y, column_highlight, buffer, palette);
|
|
|
|
if (y >= height || row_start >= 0)
|
|
|
|
{
|
|
|
|
/* This row only */
|
|
|
|
gtk_widget_draw (palette->color_area, NULL);
|
|
|
|
g_free (buffer);
|
|
|
|
g_free (colors);
|
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (y < height)
|
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
y = palette_draw_color_row (colors, index, y, column_highlight, buffer, palette);
|
1997-11-25 06:05:25 +08:00
|
|
|
index = 0;
|
1998-12-19 08:00:06 +08:00
|
|
|
if(row_start >= 0)
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (buffer);
|
1998-12-19 08:00:06 +08:00
|
|
|
g_free (colors);
|
|
|
|
|
|
|
|
if(palette->freeze_update == FALSE)
|
|
|
|
gtk_widget_draw (palette->color_area, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_scroll_top_left (PaletteDialog *palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkAdjustment *hadj;
|
|
|
|
GtkAdjustment *vadj;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* scroll viewport to top left */
|
|
|
|
if(palette && palette->scrolled_window)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
hadj = gtk_scrolled_window_get_hadjustment (GTK_SCROLLED_WINDOW (palette->scrolled_window));
|
|
|
|
vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (palette->scrolled_window));
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
if(hadj)
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_adjustment_set_value (hadj, 0.0);
|
1998-12-19 08:00:06 +08:00
|
|
|
if(vadj)
|
1999-07-24 23:37:03 +08:00
|
|
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_palette (PaletteDialog *palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *parent;
|
1998-12-19 08:00:06 +08:00
|
|
|
gint vsize;
|
|
|
|
gint nrows;
|
|
|
|
gint n_entries;
|
|
|
|
gint new_pre_width;
|
1999-09-12 00:55:40 +08:00
|
|
|
gint entry_width;
|
|
|
|
guint width;
|
|
|
|
gint ncols;
|
|
|
|
|
|
|
|
width = palette->color_area->parent->parent->allocation.width;
|
|
|
|
entry_width = (ENTRY_WIDTH*palette->zoom_factor)+SPACING;
|
|
|
|
ncols = width/entry_width;
|
|
|
|
|
|
|
|
if(ncols <= 0 ||
|
|
|
|
(palette->columns_valid && palette->columns == ncols))
|
|
|
|
return;
|
|
|
|
|
|
|
|
palette->columns_valid = TRUE;
|
|
|
|
palette->columns = ncols;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
n_entries = palette->entries->n_colors;
|
|
|
|
nrows = n_entries / palette->columns;
|
|
|
|
if (n_entries % palette->columns)
|
|
|
|
nrows += 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
vsize = nrows* (SPACING + (gint)(ENTRY_HEIGHT*palette->zoom_factor)) + SPACING;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
parent = palette->color_area->parent;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_ref (palette->color_area);
|
|
|
|
gtk_container_remove (GTK_CONTAINER (parent), palette->color_area);
|
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
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
new_pre_width = (gint) (ENTRY_WIDTH * palette->zoom_factor);
|
|
|
|
new_pre_width = (new_pre_width + SPACING) * palette->columns + SPACING;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_preview_size (GTK_PREVIEW (palette->color_area),
|
|
|
|
new_pre_width, /*PREVIEW_WIDTH,*/
|
|
|
|
vsize);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (parent), palette->color_area);
|
|
|
|
gtk_widget_unref (palette->color_area);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_draw_entries (palette, -1, -1);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_list_item_update (GtkWidget *widget,
|
|
|
|
gint row,
|
|
|
|
gint column,
|
|
|
|
GdkEventButton *event,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
PaletteEntriesP p_entries;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = (PaletteDialog *) data;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
if (palette->color_notebook_active)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-10-03 21:50:19 +08:00
|
|
|
palette->color_notebook_active = FALSE;
|
|
|
|
color_notebook_hide (palette->color_notebook);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-03 21:50:19 +08:00
|
|
|
if (palette->color_notebook)
|
|
|
|
color_notebook_free (palette->color_notebook);
|
|
|
|
palette->color_notebook = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
p_entries =
|
1999-07-24 23:37:03 +08:00
|
|
|
(PaletteEntriesP) gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->entries = p_entries;
|
1999-09-12 00:55:40 +08:00
|
|
|
palette->columns_valid = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
redraw_palette (palette);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_scroll_top_left (palette);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Stop errors in case no colors are selected */
|
|
|
|
gtk_signal_handler_block (GTK_OBJECT (palette->color_name),
|
|
|
|
palette->entry_sig_id);
|
1998-12-24 08:08:39 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (palette->color_name), _("Undefined"));
|
1999-01-04 05:21:53 +08:00
|
|
|
gtk_widget_set_sensitive (palette->color_name, FALSE);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_handler_unblock (GTK_OBJECT (palette->color_name),
|
|
|
|
palette->entry_sig_id);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-01-03 08:12:39 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_edit_palette_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1999-01-03 08:12:39 +08:00
|
|
|
GList *sel_list;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = (PaletteDialog *) data;
|
|
|
|
sel_list = GTK_CLIST (palette->clist)->selection;
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (sel_list)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
|
|
|
while (sel_list)
|
|
|
|
{
|
|
|
|
gint row;
|
|
|
|
|
|
|
|
row = GPOINTER_TO_INT (sel_list->data);
|
|
|
|
|
|
|
|
p_entries =
|
1999-07-24 23:37:03 +08:00
|
|
|
(PaletteEntriesP)gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_create_edit (p_entries);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
|
|
|
/* One only */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *
|
1999-01-03 08:12:39 +08:00
|
|
|
create_palette_dialog (gint vert)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *hbox2;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *scrolledwindow;
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *palette_region;
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *alignment;
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *palette_list;
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *pixmapwid;
|
|
|
|
GdkPixmap *pixmap;
|
|
|
|
GdkBitmap *mask;
|
|
|
|
GtkStyle *style;
|
|
|
|
|
|
|
|
palette = g_new (PaletteDialog, 1);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
palette->entries = default_palette_entries;
|
|
|
|
palette->color = NULL;
|
1999-10-03 21:50:19 +08:00
|
|
|
palette->color_notebook = NULL;
|
|
|
|
palette->color_notebook_active = FALSE;
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->zoom_factor = 1.0;
|
|
|
|
palette->columns = COLUMNS;
|
1999-09-12 00:55:40 +08:00
|
|
|
palette->columns_valid = TRUE;
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->freeze_update = FALSE;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!vert)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
palette->shell =
|
|
|
|
gimp_dialog_new (_("Color Palette Edit"), "color_palette_edit",
|
|
|
|
gimp_standard_help_func,
|
1999-10-04 16:40:33 +08:00
|
|
|
"dialogs/palette_editor/palette_editor.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Save"), palette_save_palettes_callback,
|
|
|
|
palette, NULL, FALSE, FALSE,
|
|
|
|
_("Refresh"), palette_refresh_callback,
|
|
|
|
palette, NULL, FALSE, FALSE,
|
|
|
|
_("Close"), palette_close_callback,
|
|
|
|
palette, NULL, TRUE, TRUE,
|
|
|
|
|
|
|
|
NULL);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_set_usize (palette->shell, 615, 200);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
palette->shell =
|
|
|
|
gimp_dialog_new (_("Color Palette"), "color_palette",
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/palette_selection.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Edit"), palette_edit_palette_callback,
|
|
|
|
palette, NULL, FALSE, FALSE,
|
|
|
|
_("Close"), palette_close_callback,
|
|
|
|
palette, NULL, TRUE, TRUE,
|
|
|
|
|
|
|
|
NULL);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_set_usize (palette->shell, 230, 300);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* The main container widget */
|
|
|
|
if (vert)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
hbox = gtk_notebook_new ();
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 1);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (palette->shell)->vbox), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
if (!vert)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_show (vbox);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
|
|
|
gtk_widget_show (alignment);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette->scrolled_window =
|
|
|
|
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
1998-12-19 08:00:06 +08:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scrolledwindow, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (scrolledwindow);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
palette->color_area = palette_region = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_set_dither (GTK_PREVIEW (palette->color_area),
|
|
|
|
GDK_RGB_DITHER_MAX);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (palette_region), PREVIEW_WIDTH, PREVIEW_HEIGHT);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_widget_set_events (palette_region, PALETTE_EVENT_MASK);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (palette->color_area), "event",
|
|
|
|
(GtkSignalFunc) palette_color_area_events,
|
|
|
|
palette);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), palette_region);
|
|
|
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolledwindow),
|
|
|
|
alignment);
|
1999-08-24 08:36:57 +08:00
|
|
|
gtk_widget_show (palette_region);
|
|
|
|
|
|
|
|
/* dnd stuff */
|
|
|
|
gtk_drag_source_set (palette_region,
|
|
|
|
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
|
|
|
color_palette_target_table, n_color_palette_targets,
|
|
|
|
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
|
|
|
gimp_dnd_color_source_set (palette_region, palette_drag_color, palette);
|
|
|
|
|
|
|
|
gtk_drag_dest_set (alignment,
|
|
|
|
GTK_DEST_DEFAULT_HIGHLIGHT |
|
|
|
|
GTK_DEST_DEFAULT_MOTION |
|
|
|
|
GTK_DEST_DEFAULT_DROP,
|
|
|
|
color_palette_target_table, n_color_palette_targets,
|
|
|
|
GDK_ACTION_COPY);
|
|
|
|
gimp_dnd_color_dest_set (alignment, palette_drop_color, palette);
|
1999-07-24 23:37:03 +08:00
|
|
|
|
|
|
|
/* The color name entry */
|
|
|
|
hbox2 = gtk_hbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(hbox2);
|
|
|
|
|
|
|
|
entry = palette->color_name = gtk_entry_new ();
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), entry, TRUE, TRUE, 0);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), _("Undefined"));
|
|
|
|
palette->entry_sig_id =
|
|
|
|
gtk_signal_connect (GTK_OBJECT (entry), "changed",
|
|
|
|
GTK_SIGNAL_FUNC (color_name_entry_changed),
|
|
|
|
palette);
|
|
|
|
|
|
|
|
/* + and - buttons */
|
|
|
|
gtk_widget_realize (palette->shell);
|
|
|
|
style = gtk_widget_get_style (palette->shell);
|
|
|
|
|
|
|
|
button = gtk_button_new ();
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
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
|
|
|
GTK_SIGNAL_FUNC (palette_zoomin), (gpointer) palette);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
|
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
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
|
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
|
|
|
zoom_in_xpm);
|
|
|
|
pixmapwid = gtk_pixmap_new (pixmap, mask);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
|
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
|
|
|
gtk_widget_show (pixmapwid);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_show (button);
|
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
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
button = gtk_button_new ();
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (palette_zoomout), (gpointer) palette);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox2), button, FALSE, FALSE, 0);
|
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
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
pixmap = gdk_pixmap_create_from_xpm_d (palette->shell->window, &mask,
|
|
|
|
&style->bg[GTK_STATE_NORMAL],
|
|
|
|
zoom_out_xpm);
|
|
|
|
pixmapwid = gtk_pixmap_new (pixmap, mask);
|
|
|
|
gtk_container_add (GTK_CONTAINER (button), pixmapwid);
|
|
|
|
gtk_widget_show (pixmapwid);
|
|
|
|
gtk_widget_show (button);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* clist preview of palettes */
|
|
|
|
scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
|
1998-12-19 08:00:06 +08:00
|
|
|
palette->clist = palette_list = gtk_clist_new (3);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_set_row_height (GTK_CLIST (palette_list), SM_PREVIEW_HEIGHT + 2);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (palette->clist), "select_row",
|
|
|
|
GTK_SIGNAL_FUNC (palette_list_item_update),
|
|
|
|
(gpointer) palette);
|
|
|
|
if (vert)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
|
|
|
gtk_widget_set_usize (palette_list, 203, 90);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (hbox), vbox,
|
|
|
|
gtk_label_new (_("Palette")));
|
|
|
|
gtk_notebook_append_page (GTK_NOTEBOOK (hbox), scrolledwindow,
|
|
|
|
gtk_label_new (_("Select")));
|
1999-01-03 08:12:39 +08:00
|
|
|
gtk_widget_show (palette_list);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (hbox), scrolledwindow);
|
1999-01-03 08:12:39 +08:00
|
|
|
gtk_widget_set_usize (palette_list, 203, -1);
|
|
|
|
gtk_widget_show (palette_list);
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_clist_set_column_title (GTK_CLIST (palette_list), 0, _("Palette"));
|
|
|
|
gtk_clist_set_column_title (GTK_CLIST (palette_list), 1, _("Ncols"));
|
|
|
|
gtk_clist_set_column_title (GTK_CLIST (palette_list), 2, _("Name"));
|
|
|
|
gtk_clist_column_titles_show (GTK_CLIST (palette_list));
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (scrolledwindow), palette->clist);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow),
|
1998-12-19 08:00:06 +08:00
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_ALWAYS);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!vert)
|
|
|
|
gtk_clist_set_selection_mode (GTK_CLIST (palette_list),
|
|
|
|
GTK_SELECTION_EXTENDED);
|
|
|
|
|
|
|
|
gtk_widget_show (scrolledwindow);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
gtk_clist_set_column_width (GTK_CLIST (palette_list), 0, SM_PREVIEW_WIDTH+2);
|
|
|
|
gtk_clist_column_titles_show (GTK_CLIST (palette_list));
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!vert)
|
1999-01-03 08:12:39 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
frame = gtk_frame_new (_("Palette Ops"));
|
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
button = gtk_button_new_with_label (_("New"));
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
1999-01-03 08:12:39 +08:00
|
|
|
(GtkSignalFunc) palette_new_entries_callback,
|
|
|
|
(gpointer) palette);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label (_("Delete"));
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
1999-01-03 08:12:39 +08:00
|
|
|
(GtkSignalFunc) palette_delete_entries_callback,
|
|
|
|
(gpointer) palette);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
1999-01-03 08:12:39 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
button = gtk_button_new_with_label (_("Import"));
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
1999-01-03 08:12:39 +08:00
|
|
|
(GtkSignalFunc) palette_import_dialog_callback,
|
|
|
|
(gpointer) palette);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
button = gtk_button_new_with_label (_("Merge"));
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
1999-01-03 08:12:39 +08:00
|
|
|
(GtkSignalFunc) palette_merge_dialog_callback,
|
|
|
|
(gpointer) palette);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
1999-01-03 08:12:39 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette->gc = gdk_gc_new (palette->shell->window);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_popup_menu (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
return palette;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-08-24 08:36:57 +08:00
|
|
|
static void
|
|
|
|
palette_drag_color (GtkWidget *widget,
|
|
|
|
guchar *r,
|
|
|
|
guchar *g,
|
|
|
|
guchar *b,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PaletteDialog *palette;
|
|
|
|
|
|
|
|
palette = (PaletteDialog *) data;
|
|
|
|
|
1999-09-30 05:18:23 +08:00
|
|
|
if (palette && palette->entries && palette->color)
|
1999-08-24 08:36:57 +08:00
|
|
|
{
|
|
|
|
*r = (guchar) palette->color->color[0];
|
|
|
|
*g = (guchar) palette->color->color[1];
|
|
|
|
*b = (guchar) palette->color->color[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
palette_drop_color (GtkWidget *widget,
|
|
|
|
guchar r,
|
|
|
|
guchar g,
|
|
|
|
guchar b,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
PaletteDialog *palette;
|
|
|
|
gchar *name;
|
|
|
|
gchar *num_buf;
|
|
|
|
GSList *list;
|
|
|
|
gint pos = 0;
|
|
|
|
PaletteEntriesP p_entries = NULL;
|
|
|
|
|
|
|
|
palette = (PaletteDialog *) data;
|
|
|
|
|
|
|
|
if (palette && palette->entries)
|
|
|
|
{
|
1999-08-24 10:52:40 +08:00
|
|
|
name = g_strdup_printf ("#%02x%02x%02x", r, g, b);
|
1999-08-24 08:36:57 +08:00
|
|
|
|
|
|
|
palette->color =
|
|
|
|
palette_add_entry (palette->entries, name, r, g, b);
|
|
|
|
|
|
|
|
g_free (name);
|
|
|
|
|
1999-09-12 00:55:40 +08:00
|
|
|
palette->columns_valid = FALSE;
|
1999-08-24 08:36:57 +08:00
|
|
|
redraw_palette (palette);
|
|
|
|
|
|
|
|
list = palette_entries_list;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
p_entries = (PaletteEntriesP) list->data;
|
|
|
|
list = g_slist_next (list);
|
|
|
|
|
|
|
|
/* to make sure we get something! */
|
|
|
|
if (p_entries == NULL)
|
|
|
|
{
|
|
|
|
p_entries = default_palette_entries;
|
|
|
|
}
|
|
|
|
if (p_entries == palette->entries)
|
|
|
|
break;
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_buf = g_strdup_printf ("%d", p_entries->n_colors);;
|
|
|
|
palette_draw_small_preview (palette->gc, p_entries);
|
|
|
|
gtk_clist_set_text (GTK_CLIST (palette->clist), pos, 1, num_buf);
|
|
|
|
palette_select_set_text_all (palette->entries);
|
|
|
|
palette_select2_set_text_all (palette->entries);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_dialog_select_grad_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Popup grad edit box .... */
|
1999-07-24 23:37:03 +08:00
|
|
|
grad_create_gradient_editor ();
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
import_dialog_close_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_destroy (import_dialog->dialog);
|
|
|
|
g_free (import_dialog);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog = NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_palette_create_from_grad (gchar *name,
|
|
|
|
PaletteDialog *palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1998-12-24 08:08:39 +08:00
|
|
|
PaletteEntriesP entries;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if(curr_gradient)
|
|
|
|
{
|
|
|
|
/* Add names to entry */
|
|
|
|
double dx, cur_x;
|
|
|
|
double r, g, b, a;
|
|
|
|
extern void grad_get_color_at(double, double *, double *, double *, double *);
|
|
|
|
gint sample_sz;
|
|
|
|
gint loop;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
entries = palette_create_entries (palette, name);
|
1998-12-19 08:00:06 +08:00
|
|
|
sample_sz = (gint)import_dialog->sample->value;
|
|
|
|
|
|
|
|
dx = 1.0/ (sample_sz - 1);
|
|
|
|
cur_x = 0;
|
|
|
|
|
|
|
|
for (loop = 0 ; loop < sample_sz; loop++)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
grad_get_color_at(cur_x, &r, &g, &b, &a);
|
|
|
|
r = r * 255.0;
|
|
|
|
g = g * 255.0;
|
|
|
|
b = b * 255.0;
|
|
|
|
cur_x += dx;
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_add_entry (palette->entries, _("Untitled"),
|
|
|
|
(gint) r, (gint) g, (gint) b);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_update_small_preview (palette);
|
|
|
|
redraw_palette (palette);
|
1998-12-24 08:08:39 +08:00
|
|
|
/* Update other selectors on screen */
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select_clist_insert_all (entries);
|
|
|
|
palette_select2_clist_insert_all (entries);
|
|
|
|
palette_scroll_clist_to_current (palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_dialog_import_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
|
|
|
|
|
|
|
palette = data;
|
|
|
|
if (import_dialog)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
guchar *pname;
|
1999-07-24 23:37:03 +08:00
|
|
|
pname = gtk_entry_get_text (GTK_ENTRY (import_dialog->entry));
|
|
|
|
if (!pname || strlen (pname) == 0)
|
|
|
|
pname = g_strdup ("tmp");
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
1999-07-24 23:37:03 +08:00
|
|
|
pname = g_strdup (pname);
|
|
|
|
switch (import_dialog->import_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
case GRAD_IMPORT:
|
1999-07-24 23:37:03 +08:00
|
|
|
import_palette_create_from_grad (pname, palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
break;
|
|
|
|
case IMAGE_IMPORT:
|
1999-07-24 23:37:03 +08:00
|
|
|
import_palette_create_from_image (import_dialog->gimage,
|
|
|
|
pname, palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
import_dialog_close_callback (NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_merge_entries_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
gpointer call_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette;
|
1998-12-19 08:00:06 +08:00
|
|
|
PaletteEntriesP p_entries;
|
|
|
|
PaletteEntriesP new_entries;
|
|
|
|
GList *sel_list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
new_entries = palette_create_entries (data, call_data);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette = (PaletteDialog *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
sel_list = GTK_CLIST (palette->clist)->selection;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (sel_list)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
while (sel_list)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
gint row;
|
|
|
|
GSList *cols;
|
|
|
|
|
|
|
|
row = GPOINTER_TO_INT (sel_list->data);
|
|
|
|
p_entries =
|
1999-07-24 23:37:03 +08:00
|
|
|
(PaletteEntriesP)gtk_clist_get_row_data (GTK_CLIST (palette->clist), row);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Go through each palette and merge the colors */
|
1998-12-19 08:00:06 +08:00
|
|
|
cols = p_entries->colors;
|
1999-07-24 23:37:03 +08:00
|
|
|
while (cols)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
PaletteEntryP entry = cols->data;
|
|
|
|
palette_add_entry (new_entries,
|
1999-07-24 23:37:03 +08:00
|
|
|
g_strdup (entry->name),
|
1998-12-19 08:00:06 +08:00
|
|
|
entry->color[0],
|
|
|
|
entry->color[1],
|
|
|
|
entry->color[2]);
|
|
|
|
cols = cols->next;
|
|
|
|
}
|
|
|
|
sel_list = sel_list->next;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_update_small_preview (palette);
|
|
|
|
redraw_palette (palette);
|
|
|
|
gtk_clist_unselect_all (GTK_CLIST (palette->clist));
|
1998-12-24 08:08:39 +08:00
|
|
|
/* Update other selectors on screen */
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select_clist_insert_all (new_entries);
|
|
|
|
palette_select2_clist_insert_all (new_entries);
|
|
|
|
palette_scroll_clist_to_current (palette);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_merge_dialog_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
GtkWidget *qbox;
|
|
|
|
|
|
|
|
qbox = gimp_query_string_box (_("Merge Palette"),
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/palette_editor/merge_palette.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Enter a name for merged palette"),
|
|
|
|
NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
palette_merge_entries_callback,
|
|
|
|
data);
|
|
|
|
gtk_widget_show (qbox);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_import_dialog_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!import_dialog)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
import_dialog = palette_import_dialog ((PaletteDialog *) data);
|
|
|
|
gtk_widget_show (import_dialog->dialog);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gdk_window_raise (import_dialog->dialog->window);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_import_fill_grad_preview (GtkWidget *preview,
|
|
|
|
gradient_t *gradient)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
guchar buffer[3*IMPORT_PREVIEW_WIDTH];
|
|
|
|
gint loop;
|
|
|
|
guchar *p = buffer;
|
1999-07-24 23:37:03 +08:00
|
|
|
gdouble dx, cur_x;
|
|
|
|
gdouble r, g, b, a;
|
1998-12-19 08:00:06 +08:00
|
|
|
extern void grad_get_color_at(double, double *, double *, double *, double *);
|
|
|
|
gradient_t *last_grad;
|
|
|
|
|
|
|
|
dx = 1.0/ (IMPORT_PREVIEW_WIDTH - 1);
|
|
|
|
cur_x = 0;
|
|
|
|
|
|
|
|
last_grad = curr_gradient;
|
|
|
|
curr_gradient = gradient;
|
|
|
|
for (loop = 0 ; loop < IMPORT_PREVIEW_WIDTH; loop++)
|
|
|
|
{
|
|
|
|
grad_get_color_at(cur_x, &r, &g, &b, &a);
|
|
|
|
*p++ = r * 255.0;
|
|
|
|
*p++ = g * 255.0;
|
|
|
|
*p++ = b * 255.0;
|
|
|
|
cur_x += dx;
|
|
|
|
}
|
|
|
|
curr_gradient = last_grad;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
for (loop = 0 ; loop < IMPORT_PREVIEW_HEIGHT; loop++)
|
|
|
|
{
|
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (preview), buffer, 0, loop, IMPORT_PREVIEW_WIDTH);
|
|
|
|
}
|
|
|
|
gtk_widget_draw (preview, NULL);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
void
|
|
|
|
import_palette_grad_update (gradient_t *grad)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog && import_dialog->import_type == GRAD_IMPORT)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
/* redraw gradient */
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_import_fill_grad_preview (import_dialog->preview, grad);
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), grad->name);
|
|
|
|
}
|
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_grad_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-03-21 06:19:45 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
import_dialog->import_type = GRAD_IMPORT;
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog->image_list)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_hide (import_dialog->image_list);
|
|
|
|
gtk_widget_destroy (import_dialog->image_list);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog->image_list = NULL;
|
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_show (import_dialog->select);
|
|
|
|
palette_import_fill_grad_preview (import_dialog->preview, curr_gradient);
|
gimp-joke-980321
* app/iscissors.c, app/tips_dialog.c, app/gradient.c,
libgimp/gimp.c, plug-ins/AlienMap/AlienMap.c,
plug-ins/bmp/bmp.c, plug-ins/fits/fitsrw.h,
plug-ins/fits/fitsrw.c, plug-ins/flarefx/flarefx.c,
plug-ins/gfig/gfig.c, plug-ins/gfli/gfli.c,
plug-ins/gicon/gicon.c, plug-ins/gqbist/gqbist.c,
plug-ins/gtm/gtm.c, plug-ins/hot/hot.c,
plug-ins/ifscompose/ifscompose.c,
plug-ins/ifscompose/ifscompose_utils.c
plug-ins/max_rgb/max_rgb.c, plug-ins/nlfilt/nlfilt.c,
plug-ins/pat/pat.c, plug-ins/pcx/pcx.c, plug-ins/rotate/rotate.c,
plug-ins/script-fu/script-fu-server.c, plug-ins/snoise/snoise.c,
plug-ins/threshold_alpha/threshold_alpha.c,
plug-ins/zealouscrop/zealouscrop.c :gimp-joke-980321
plug-ins/CML_explorer, plug-ins/autocrop,
plug-ins/align_layers, plug-ins/blinds,
plug-ins/bmp, plug-ins/megawidget: gimp-joke-980322
Applied gimp-joke-980322-0.patch and gimp-joke-980321-0.patch
from Yasuhiro SHIRASAKI <joke@awa.tohoku.ac.jp>. Mostly
portability for DEC osf1's cc. Lots of MAIN();'s, trailing
commas in enums, and guchar/gchar madness.
Gimp now sends mail, cleans vinyl records,
removes stubborn stains, julien fries, and more!
-adrian
1998-03-23 04:44:39 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), curr_gradient->name);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_set_sensitive (import_dialog->threshold_scale, FALSE);
|
|
|
|
gtk_widget_set_sensitive (import_dialog->threshold_text, FALSE);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
gimlist_cb (gpointer im,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GSList** l;
|
|
|
|
|
|
|
|
l = (GSList**) data;
|
|
|
|
*l = g_slist_prepend (*l, im);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_update_image_preview (GimpImage *gimage)
|
1998-03-21 06:19:45 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
TempBuf * preview_buf;
|
|
|
|
gchar *src, *buf;
|
|
|
|
gint x,y,has_alpha;
|
|
|
|
gint sel_width, sel_height;
|
|
|
|
gint pwidth, pheight;
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog->gimage = gimage;
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Calculate preview size */
|
|
|
|
|
|
|
|
sel_width = gimage->width;
|
|
|
|
sel_height = gimage->height;
|
|
|
|
|
|
|
|
if (sel_width > sel_height) {
|
|
|
|
pwidth = MIN(sel_width, IMPORT_PREVIEW_WIDTH);
|
|
|
|
pheight = sel_height * pwidth / sel_width;
|
|
|
|
} else {
|
|
|
|
pheight = MIN(sel_height, IMPORT_PREVIEW_HEIGHT);
|
|
|
|
pwidth = sel_width * pheight / sel_height;
|
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Min size is 2 */
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
preview_buf = gimp_image_construct_composite_preview (gimage,
|
|
|
|
MAX (pwidth, 2),
|
|
|
|
MAX (pheight, 2));
|
|
|
|
|
|
|
|
gtk_preview_size (GTK_PREVIEW (import_dialog->preview),
|
|
|
|
preview_buf->width,
|
|
|
|
preview_buf->height);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
buf = g_new (gchar, IMPORT_PREVIEW_WIDTH * 3);
|
1999-07-24 23:37:03 +08:00
|
|
|
src = (gchar *) temp_buf_data (preview_buf);
|
1998-12-19 08:00:06 +08:00
|
|
|
has_alpha = (preview_buf->bytes == 2 || preview_buf->bytes == 4);
|
|
|
|
for (y = 0; y <preview_buf->height ; y++)
|
|
|
|
{
|
|
|
|
if (preview_buf->bytes == (1+has_alpha))
|
|
|
|
for (x = 0; x < preview_buf->width; x++)
|
|
|
|
{
|
|
|
|
buf[x*3+0] = src[x];
|
|
|
|
buf[x*3+1] = src[x];
|
|
|
|
buf[x*3+2] = src[x];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
for (x = 0; x < preview_buf->width; x++)
|
|
|
|
{
|
|
|
|
gint stride = 3 + has_alpha;
|
|
|
|
buf[x*3+0] = src[x*stride+0];
|
|
|
|
buf[x*3+1] = src[x*stride+1];
|
|
|
|
buf[x*3+2] = src[x*stride+2];
|
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_preview_draw_row (GTK_PREVIEW (import_dialog->preview),
|
|
|
|
(guchar *)buf, 0, y, preview_buf->width);
|
1998-12-19 08:00:06 +08:00
|
|
|
src += preview_buf->width * preview_buf->bytes;
|
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
g_free (buf);
|
|
|
|
temp_buf_free (preview_buf);
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_hide (import_dialog->preview);
|
|
|
|
gtk_widget_draw (import_dialog->preview, NULL);
|
|
|
|
gtk_widget_show (import_dialog->preview);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1998-03-21 06:19:45 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_sel_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
gchar *lab;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gimage = GIMP_IMAGE (data);
|
|
|
|
import_image_update_image_preview (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
lab = g_strdup_printf ("%s-%d",
|
|
|
|
g_basename (gimage_filename (import_dialog->gimage)),
|
|
|
|
pdb_image_to_id (import_dialog->gimage));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_menu_add (GimpImage *gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar *lab = g_strdup_printf ("%s-%d",
|
|
|
|
g_basename (gimage_filename (gimage)),
|
|
|
|
pdb_image_to_id (gimage));
|
|
|
|
menuitem = gtk_menu_item_new_with_label (lab);
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_widget_show (menuitem);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
(GtkSignalFunc) import_image_sel_callback,
|
|
|
|
gimage);
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_menu_append (GTK_MENU (import_dialog->optionmenu1_menu), menuitem);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Last Param gives us control over what goes in the menu on a delete oper */
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_menu_activate (gint redo,
|
|
|
|
GimpImage *del_image)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *list=NULL;
|
|
|
|
gint num_images;
|
|
|
|
GimpImage *last_img = NULL;
|
|
|
|
GimpImage *first_img = NULL;
|
|
|
|
gint act_num = -1;
|
|
|
|
gint count = 0;
|
|
|
|
gchar *lab;
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog->import_type == IMAGE_IMPORT)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!redo)
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog->image_list)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
last_img = import_dialog->gimage;
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_hide (import_dialog->image_list);
|
|
|
|
gtk_widget_destroy (import_dialog->image_list);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog->image_list = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
import_dialog->import_type = IMAGE_IMPORT;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Get list of images */
|
1999-07-24 23:37:03 +08:00
|
|
|
gimage_foreach (gimlist_cb, &list);
|
1998-12-19 08:00:06 +08:00
|
|
|
num_images = g_slist_length (list);
|
|
|
|
|
|
|
|
if (num_images)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gint i;
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *optionmenu1;
|
|
|
|
GtkWidget *optionmenu1_menu;
|
|
|
|
|
|
|
|
import_dialog->image_list = optionmenu1 = gtk_option_menu_new ();
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_set_usize (optionmenu1, IMPORT_PREVIEW_WIDTH, -1);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog->optionmenu1_menu = optionmenu1_menu = gtk_menu_new ();
|
|
|
|
|
|
|
|
for (i = 0; i < num_images; i++, list = g_slist_next (list))
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (GIMP_IMAGE (list->data) != del_image)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (first_img == NULL)
|
|
|
|
first_img = GIMP_IMAGE (list->data);
|
|
|
|
import_image_menu_add (GIMP_IMAGE (list->data));
|
|
|
|
if (last_img == GIMP_IMAGE (list->data))
|
1998-12-19 08:00:06 +08:00
|
|
|
act_num = count;
|
|
|
|
else
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu1),
|
|
|
|
optionmenu1_menu);
|
|
|
|
gtk_widget_hide (import_dialog->select);
|
|
|
|
gtk_box_pack_start (GTK_BOX (import_dialog->select_area),
|
|
|
|
optionmenu1, FALSE, FALSE, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if(last_img != NULL && last_img != del_image)
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_update_image_preview (last_img);
|
|
|
|
else if (first_img != NULL)
|
|
|
|
import_image_update_image_preview (first_img);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_widget_show (optionmenu1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* reset to last one */
|
|
|
|
if(redo && act_num >= 0)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gchar *lab =
|
|
|
|
g_strdup_printf ("%s-%d",
|
|
|
|
g_basename (gimage_filename (import_dialog->gimage)),
|
|
|
|
pdb_image_to_id (import_dialog->gimage));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu1), act_num);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
1999-07-24 23:37:03 +08:00
|
|
|
g_slist_free (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
lab =
|
|
|
|
g_strdup_printf ("%s-%d",
|
|
|
|
g_basename (gimage_filename (import_dialog->gimage)),
|
|
|
|
pdb_image_to_id (import_dialog->gimage));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (import_dialog->entry), lab);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_menu_activate (FALSE, NULL);
|
|
|
|
gtk_widget_set_sensitive (import_dialog->threshold_scale, TRUE);
|
|
|
|
gtk_widget_set_sensitive (import_dialog->threshold_text, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static gint
|
1999-07-24 23:37:03 +08:00
|
|
|
image_count ()
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
GSList *list=NULL;
|
|
|
|
gint num_images = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gimage_foreach (gimlist_cb, &list);
|
1998-12-19 08:00:06 +08:00
|
|
|
num_images = g_slist_length (list);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
g_slist_free (list);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
return num_images;
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static ImportDialog *
|
|
|
|
palette_import_dialog (PaletteDialog *palette)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *frame;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *button;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *optionmenu;
|
|
|
|
GtkWidget *optionmenu_menu;
|
1998-12-19 08:00:06 +08:00
|
|
|
GtkWidget *menuitem;
|
1999-07-24 23:37:03 +08:00
|
|
|
GtkWidget *image;
|
|
|
|
GtkWidget *hscale;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
import_dialog = g_new (ImportDialog, 1);
|
|
|
|
import_dialog->image_list = NULL;
|
|
|
|
import_dialog->gimage = NULL;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
import_dialog->dialog = dialog =
|
|
|
|
gimp_dialog_new (_("Import Palette"), "import_palette",
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/palette_editor/import_palette.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_NONE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Import"), import_dialog_import_callback,
|
|
|
|
palette, NULL, FALSE, FALSE,
|
|
|
|
_("Close"), import_dialog_close_callback,
|
|
|
|
palette, NULL, TRUE, TRUE,
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
NULL);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* The main hbox */
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
|
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), hbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
|
|
|
/* The "Import" frame */
|
|
|
|
frame = gtk_frame_new (_("Import"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
table = gtk_table_new (4, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
/* The source's name */
|
|
|
|
label = gtk_label_new (_("Name:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
1998-12-19 08:00:06 +08:00
|
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
entry = import_dialog->entry = gtk_entry_new ();
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), entry, 1, 2, 0, 1);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry),
|
|
|
|
curr_gradient ? curr_gradient->name : _("new_import"));
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
|
|
|
/* The source type */
|
|
|
|
label = gtk_label_new (_("Source:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
|
1998-12-19 08:00:06 +08:00
|
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
optionmenu = import_dialog->type_option = gtk_option_menu_new ();
|
|
|
|
optionmenu_menu = gtk_menu_new ();
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), optionmenu, 1, 2, 1, 2);
|
|
|
|
menuitem = import_dialog->image_menu_item_gradient =
|
|
|
|
gtk_menu_item_new_with_label (_("Gradient"));
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
(GtkSignalFunc) import_grad_callback,
|
|
|
|
NULL);
|
|
|
|
gtk_menu_append (GTK_MENU (optionmenu_menu), menuitem);
|
1998-12-19 08:00:06 +08:00
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
menuitem = import_dialog->image_menu_item_image =
|
|
|
|
gtk_menu_item_new_with_label ("Image");
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
(GtkSignalFunc) import_image_callback,
|
|
|
|
(gpointer) import_dialog);
|
|
|
|
gtk_menu_append (GTK_MENU (optionmenu_menu), menuitem);
|
|
|
|
gtk_widget_show (menuitem);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), optionmenu_menu);
|
|
|
|
gtk_widget_set_sensitive (menuitem, image_count() > 0);
|
|
|
|
gtk_widget_show (optionmenu);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* The sample size */
|
|
|
|
label = gtk_label_new (_("Sample Size:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
import_dialog->sample =
|
|
|
|
GTK_ADJUSTMENT(gtk_adjustment_new (256, 2, 10000, 1, 10, 10));
|
|
|
|
spinbutton = gtk_spin_button_new (import_dialog->sample, 1, 0);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 1, 2, 2, 3);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
/* The interval */
|
|
|
|
label = import_dialog->threshold_text = gtk_label_new (_("Interval:"));
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 1.0);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_set_sensitive(label, FALSE);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
import_dialog->threshold =
|
|
|
|
GTK_ADJUSTMENT (gtk_adjustment_new (1, 1, 128, 1, 1, 1));
|
|
|
|
hscale = import_dialog->threshold_scale =
|
|
|
|
gtk_hscale_new (import_dialog->threshold);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (hscale), GTK_POS_TOP);
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (hscale), 0);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hscale, 1, 2, 3, 4);
|
|
|
|
gtk_widget_set_sensitive (hscale, FALSE);
|
|
|
|
gtk_widget_show (hscale);
|
|
|
|
|
|
|
|
/* The preview frame */
|
|
|
|
frame = gtk_frame_new (_("Preview"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
vbox = import_dialog->select_area = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
image = import_dialog->preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
|
|
|
gtk_preview_set_dither (GTK_PREVIEW (image), GDK_RGB_DITHER_MAX);
|
|
|
|
gtk_preview_size (GTK_PREVIEW (image),
|
|
|
|
IMPORT_PREVIEW_WIDTH, IMPORT_PREVIEW_HEIGHT);
|
|
|
|
gtk_widget_set_usize (image, IMPORT_PREVIEW_WIDTH, IMPORT_PREVIEW_HEIGHT);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), image, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (image);
|
|
|
|
|
|
|
|
button = import_dialog->select = gtk_button_new_with_label (_("Select"));
|
|
|
|
GTK_WIDGET_UNSET_FLAGS (button, GTK_RECEIVES_DEFAULT);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
|
|
|
GTK_SIGNAL_FUNC (import_dialog_select_grad_callback),
|
|
|
|
(gpointer) image);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
/* Fill with the selected gradient */
|
|
|
|
palette_import_fill_grad_preview (image, curr_gradient);
|
1998-12-19 08:00:06 +08:00
|
|
|
import_dialog->import_type = GRAD_IMPORT;
|
|
|
|
return import_dialog;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Stuff to keep dialog uptodate */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_import_image_new (GimpImage * gimage)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!import_dialog)
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!GTK_WIDGET_IS_SENSITIVE (import_dialog->image_menu_item_image))
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_widget_set_sensitive (import_dialog->image_menu_item_image, TRUE);
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Now fill in the names if image menu shown */
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog->import_type == IMAGE_IMPORT)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_menu_activate (TRUE, NULL);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_import_image_destroyed (GimpImage* gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Now fill in the names if image menu shown */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (!import_dialog)
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (image_count() <= 1)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
/* Back to gradient type */
|
1999-07-24 23:37:03 +08:00
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (import_dialog->type_option), 0);
|
|
|
|
import_grad_callback (NULL, NULL);
|
|
|
|
if (import_dialog->image_menu_item_image)
|
|
|
|
gtk_widget_set_sensitive (import_dialog->image_menu_item_image, FALSE);
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (import_dialog->import_type == IMAGE_IMPORT)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_menu_activate (TRUE, gimage);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
void
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_import_image_renamed (GimpImage* gimage)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Now fill in the names if image menu shown */
|
|
|
|
if(import_dialog && import_dialog->import_type == IMAGE_IMPORT)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_menu_activate (TRUE, NULL);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
typedef struct _ImgColors ImgColors;
|
|
|
|
|
|
|
|
struct _ImgColors
|
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
guint count;
|
|
|
|
guint r_adj;
|
|
|
|
guint g_adj;
|
|
|
|
guint b_adj;
|
|
|
|
guchar r;
|
|
|
|
guchar g;
|
|
|
|
guchar b;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
static gint count_color_entries = 0;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
create_storted_list (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer user_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
GSList **sorted_list = (GSList**) user_data;
|
|
|
|
ImgColors *color_tab = (ImgColors *) value;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
*sorted_list = g_slist_prepend (*sorted_list, color_tab);
|
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
|
1999-07-24 23:37:03 +08:00
|
|
|
create_image_palette (gpointer data,
|
|
|
|
gpointer user_data)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
PaletteDialog *palette = (PaletteDialog *) user_data;
|
|
|
|
ImgColors *color_tab = (ImgColors *) data;
|
1998-12-19 08:00:06 +08:00
|
|
|
gint sample_sz;
|
|
|
|
gchar *lab;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
sample_sz = (gint) import_dialog->sample->value;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (palette->entries->n_colors >= sample_sz)
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
lab = g_strdup_printf ("%s (occurs %u)", _("Untitled"), color_tab->count);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
/* Adjust the colors to the mean of the the sample */
|
1998-12-19 08:00:06 +08:00
|
|
|
palette_add_entry (palette->entries, lab,
|
1999-07-24 23:37:03 +08:00
|
|
|
(gint)color_tab->r + (color_tab->r_adj/color_tab->count),
|
|
|
|
(gint)color_tab->g + (color_tab->g_adj/color_tab->count),
|
|
|
|
(gint)color_tab->b + (color_tab->b_adj/color_tab->count));
|
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 gboolean
|
1999-07-24 23:37:03 +08:00
|
|
|
color_print_remove (gpointer key,
|
|
|
|
gpointer value,
|
|
|
|
gpointer user_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
g_free (value);
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static gint
|
1999-07-24 23:37:03 +08:00
|
|
|
sort_colors (gconstpointer a,
|
|
|
|
gconstpointer b)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
ImgColors *s1 = (ImgColors *) a;
|
|
|
|
ImgColors *s2 = (ImgColors *) b;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
if(s1->count > s2->count)
|
|
|
|
return -1;
|
|
|
|
if(s1->count < s2->count)
|
|
|
|
return 1;
|
1999-07-24 23:37:03 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_make_palette (GHashTable *h_array,
|
|
|
|
guchar *name,
|
|
|
|
PaletteDialog *palette)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
GSList * sorted_list = NULL;
|
1998-12-24 08:08:39 +08:00
|
|
|
PaletteEntriesP entries;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
g_hash_table_foreach (h_array, create_storted_list, &sorted_list);
|
|
|
|
sorted_list = g_slist_sort (sorted_list, sort_colors);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
entries = palette_create_entries (palette, name);
|
|
|
|
g_slist_foreach (sorted_list, create_image_palette, palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
/* Free up used memory */
|
|
|
|
/* Note the same structure is on both the hash list and the sorted
|
|
|
|
* list. So only delete it once.
|
|
|
|
*/
|
1999-07-24 23:37:03 +08:00
|
|
|
g_hash_table_freeze (h_array);
|
|
|
|
g_hash_table_foreach_remove (h_array, color_print_remove, NULL);
|
|
|
|
g_hash_table_thaw (h_array);
|
|
|
|
g_hash_table_destroy (h_array);
|
|
|
|
g_slist_free (sorted_list);
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
/* Redraw with new palette */
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_update_small_preview (palette);
|
|
|
|
redraw_palette (palette);
|
1998-12-24 08:08:39 +08:00
|
|
|
/* Update other selectors on screen */
|
1999-07-24 23:37:03 +08:00
|
|
|
palette_select_clist_insert_all (entries);
|
|
|
|
palette_select2_clist_insert_all (entries);
|
|
|
|
palette_scroll_clist_to_current (palette);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
static GHashTable *
|
1999-07-24 23:37:03 +08:00
|
|
|
store_colors (GHashTable *h_array,
|
|
|
|
guchar *colors,
|
|
|
|
guchar *colors_real,
|
|
|
|
gint sample_sz)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
gpointer found_color = NULL;
|
|
|
|
ImgColors *new_color;
|
|
|
|
guint key_colors = colors[0]*256*256+colors[1]*256+colors[2];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if(h_array == NULL)
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
h_array = g_hash_table_new (g_direct_hash, g_direct_equal);
|
|
|
|
count_color_entries = 0;
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
found_color = g_hash_table_lookup (h_array, (gpointer) key_colors);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (found_color == NULL)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
if (count_color_entries > MAX_IMAGE_COLORS)
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
/* Don't add any more new ones */
|
|
|
|
return h_array;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
count_color_entries++;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
new_color = g_new (ImgColors, 1);
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
new_color->count = 1;
|
|
|
|
new_color->r_adj = 0;
|
|
|
|
new_color->g_adj = 0;
|
|
|
|
new_color->b_adj = 0;
|
|
|
|
new_color->r = colors[0];
|
|
|
|
new_color->g = colors[1];
|
|
|
|
new_color->b = colors[2];
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
g_hash_table_insert (h_array, (gpointer) key_colors, new_color);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-07-24 23:37:03 +08:00
|
|
|
new_color = (ImgColors *) found_color;
|
|
|
|
if(new_color->count < (G_MAXINT - 1))
|
|
|
|
new_color->count++;
|
1998-12-19 08:00:06 +08:00
|
|
|
|
|
|
|
/* Now do the adjustments ...*/
|
1999-07-24 23:37:03 +08:00
|
|
|
new_color->r_adj += (colors_real[0] - colors[0]);
|
|
|
|
new_color->g_adj += (colors_real[1] - colors[1]);
|
|
|
|
new_color->b_adj += (colors_real[2] - colors[2]);
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Boundary conditions */
|
1999-07-24 23:37:03 +08:00
|
|
|
if(new_color->r_adj > (G_MAXINT - 255))
|
|
|
|
new_color->r_adj /= new_color->count;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if(new_color->g_adj > (G_MAXINT - 255))
|
|
|
|
new_color->g_adj /= new_color->count;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if(new_color->b_adj > (G_MAXINT - 255))
|
|
|
|
new_color->b_adj /= new_color->count;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return h_array;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-24 23:37:03 +08:00
|
|
|
import_palette_create_from_image (GImage *gimage,
|
|
|
|
guchar *pname,
|
|
|
|
PaletteDialog *palette)
|
1998-03-02 03:38:25 +08:00
|
|
|
{
|
1998-12-19 08:00:06 +08:00
|
|
|
PixelRegion imagePR;
|
1999-07-24 23:37:03 +08:00
|
|
|
guchar *image_data;
|
|
|
|
guchar *idata;
|
|
|
|
guchar rgb[MAX_CHANNELS];
|
|
|
|
guchar rgb_real[MAX_CHANNELS];
|
|
|
|
gint has_alpha, indexed;
|
|
|
|
gint width, height;
|
|
|
|
gint bytes, alpha;
|
|
|
|
gint i, j;
|
1998-12-19 08:00:06 +08:00
|
|
|
void * pr;
|
1999-07-24 23:37:03 +08:00
|
|
|
gint d_type;
|
1998-12-19 08:00:06 +08:00
|
|
|
GHashTable *store_array = NULL;
|
|
|
|
gint sample_sz;
|
|
|
|
gint threshold = 1;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
sample_sz = (gint) import_dialog->sample->value;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
if (gimage == NULL)
|
1998-12-19 08:00:06 +08:00
|
|
|
return;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* Get the image information */
|
|
|
|
bytes = gimage_composite_bytes (gimage);
|
|
|
|
d_type = gimage_composite_type (gimage);
|
|
|
|
has_alpha = (d_type == RGBA_GIMAGE ||
|
|
|
|
d_type == GRAYA_GIMAGE ||
|
|
|
|
d_type == INDEXEDA_GIMAGE);
|
|
|
|
indexed = d_type == INDEXEDA_GIMAGE || d_type == INDEXED_GIMAGE;
|
|
|
|
width = gimage->width;
|
|
|
|
height = gimage->height;
|
1999-07-24 23:37:03 +08:00
|
|
|
pixel_region_init (&imagePR, gimage_composite (gimage), 0, 0,
|
|
|
|
width, height, FALSE);
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
alpha = bytes - 1;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
threshold = (gint) import_dialog->threshold->value;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
if(threshold < 1)
|
|
|
|
threshold = 1;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
/* iterate over the entire image */
|
1999-07-24 23:37:03 +08:00
|
|
|
for (pr = pixel_regions_register (1, &imagePR);
|
|
|
|
pr != NULL;
|
|
|
|
pr = pixel_regions_process (pr))
|
1998-12-19 08:00:06 +08:00
|
|
|
{
|
|
|
|
image_data = imagePR.data;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
for (i = 0; i < imagePR.h; i++)
|
|
|
|
{
|
|
|
|
idata = image_data;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
for (j = 0; j < imagePR.w; j++)
|
|
|
|
{
|
|
|
|
/* Get the rgb values for the color */
|
|
|
|
gimage_get_color (gimage, d_type, rgb, idata);
|
1999-07-24 23:37:03 +08:00
|
|
|
memcpy (rgb_real, rgb, MAX_CHANNELS); /* Structure copy */
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
rgb[0] = (rgb[0] / threshold) * threshold;
|
|
|
|
rgb[1] = (rgb[1] / threshold) * threshold;
|
|
|
|
rgb[2] = (rgb[2] / threshold) * threshold;
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1999-07-24 23:37:03 +08:00
|
|
|
store_array =
|
|
|
|
store_colors (store_array, rgb, rgb_real, sample_sz);
|
1998-03-02 03:38:25 +08:00
|
|
|
|
1998-12-19 08:00:06 +08:00
|
|
|
idata += bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
image_data += imagePR.rowstride;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make palette from the store_array */
|
1999-07-24 23:37:03 +08:00
|
|
|
import_image_make_palette (store_array, pname, palette);
|
1998-12-19 08:00:06 +08:00
|
|
|
}
|