mirror of https://github.com/GNOME/gimp.git
libgimp/gimpcolorbutton.c libgimp/gimpcolorbutton.h added dnd and a popup
* libgimp/gimpcolorbutton.c * libgimp/gimpcolorbutton.h * po/POTFILES.in: added dnd and a popup window on right-click that allows to load the current fg and bg colors. * po-plug-ins/POTFILES.in * plug-ins/common/Makefile.am * plug-ins/common/colortoalpha.c * plug-ins/common/plugin-defs.pl * plug-ins/script-fu/script-fu-scripts.c: made script-fu and the new colortoalpha plug-in use gimp_color_button * plug-ins/common/rotate.c: add " degrees" to the menu entries --Sven
This commit is contained in:
parent
a1da35a9df
commit
148ef7b28e
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
Mon Nov 15 19:31:13 MET 1999 Sven Neumann <sven.gimp.org>
|
||||
|
||||
* libgimp/gimpcolorbutton.c
|
||||
* libgimp/gimpcolorbutton.h
|
||||
* po/POTFILES.in: added dnd and a popup window on right-click that
|
||||
allows to load the current fg and bg colors.
|
||||
|
||||
* po-plug-ins/POTFILES.in
|
||||
* plug-ins/common/Makefile.am
|
||||
* plug-ins/common/colortoalpha.c
|
||||
* plug-ins/common/plugin-defs.pl
|
||||
* plug-ins/script-fu/script-fu-scripts.c: made script-fu and the new
|
||||
colortoalpha plug-in use gimp_color_button
|
||||
|
||||
* plug-ins/common/rotate.c: add " degrees" to the menu entries
|
||||
|
||||
Mon Nov 15 11:48:59 1999 ape@spacetec.no (Asbjorn Pettersen)
|
||||
|
||||
* modules/colorsel_gtk.c (module_init): Removed most of the
|
||||
|
|
|
@ -21,18 +21,66 @@
|
|||
*/
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* add DND -- this will be trivial as soon as gimpdnd.[ch] is moved into libgimp
|
||||
*
|
||||
* handle bytes != 3|4 -- would we have to provide a special color select dialog
|
||||
* for that case? Another possibility could be to destroy
|
||||
* all color-related widgets in the gtk colorselector.
|
||||
* for that case? Another possibility could be to hide or
|
||||
* destroy all color-related widgets in the gtk colorselector.
|
||||
*/
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpcolorbutton.h"
|
||||
#include "gimpintl.h"
|
||||
#include "gimplimits.h"
|
||||
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
#define DRAG_ICON_OFFSET -8
|
||||
|
||||
static void gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
|
||||
|
||||
/* end of DND */
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
gint width;
|
||||
gint height;
|
||||
guchar *color;
|
||||
gint bpp;
|
||||
|
||||
gdouble *dcolor;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_color_button_destroy (GtkObject *object);
|
||||
static void gimp_color_button_clicked (GtkButton *button);
|
||||
static void gimp_color_button_paint (GimpColorButton *gcb);
|
||||
|
@ -40,6 +88,20 @@ static void gimp_color_button_paint (GimpColorButton *gcb);
|
|||
static void gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data);
|
||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget, gpointer data);
|
||||
|
||||
static void gimp_color_button_use_fg (gpointer callback_data, guint callback_action, GtkWidget *widget);
|
||||
static void gimp_color_button_use_bg (gpointer callback_data, guint callback_action, GtkWidget *widget);
|
||||
|
||||
static gint gimp_color_button_menu_popup (GtkWidget *widget, GdkEvent *event, gpointer data);
|
||||
static gchar* gimp_color_button_menu_translate (const gchar *path, gpointer func_data);
|
||||
|
||||
|
||||
static GtkItemFactoryEntry menu_items[] = {
|
||||
{ N_("/Use Foreground Color"), NULL, gimp_color_button_use_fg, 2, NULL },
|
||||
{ N_("/Use Background Color"), NULL, gimp_color_button_use_bg, 2, NULL }
|
||||
};
|
||||
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
|
||||
|
||||
|
||||
enum {
|
||||
COLOR_CHANGED,
|
||||
LAST_SIGNAL
|
||||
|
@ -177,9 +239,95 @@ gimp_color_button_new (gchar *title,
|
|||
gtk_widget_show (gcb->preview);
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
/* right-click opens a popup */
|
||||
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
||||
gtk_item_factory_set_translate_func (gcb->item_factory, gimp_color_button_menu_translate,
|
||||
NULL, NULL);
|
||||
gtk_item_factory_create_items (gcb->item_factory, nmenu_items, menu_items, gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb),
|
||||
"button_press_event",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
|
||||
gcb);
|
||||
|
||||
/* DND -- to be changed as soon as gimpdnd is in libgimp */
|
||||
gtk_drag_dest_set (gcb->preview,
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (gcb->preview,
|
||||
GDK_BUTTON2_MASK,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_begin",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_begin),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_end",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_end),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_data_get",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_handle),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_data_received",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drop_handle),
|
||||
gcb);
|
||||
/* end of DND */
|
||||
|
||||
return (GTK_WIDGET (gcb));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_button_update (GimpColorButton *gcb)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
gcb->dcolor[i] = (gdouble)gcb->color[i] / 255.0;
|
||||
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
if (gcb->dialog)
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel),
|
||||
gcb->dcolor);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_color_button_menu_popup (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
GdkEventButton *bevent;
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (data), FALSE);
|
||||
gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS)
|
||||
return FALSE;
|
||||
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button != 3)
|
||||
return FALSE;
|
||||
|
||||
gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);
|
||||
gtk_item_factory_popup (gcb->item_factory,
|
||||
x + bevent->x, y + bevent->y,
|
||||
bevent->button, bevent->time);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_clicked (GtkButton *button)
|
||||
{
|
||||
|
@ -287,11 +435,12 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
|
|||
|
||||
gtk_widget_destroy (gcb->dialog);
|
||||
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
if (color_changed)
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -307,4 +456,148 @@ gimp_color_button_dialog_cancel (GtkWidget *widget,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_use_fg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
|
||||
gimp_palette_get_foreground (gcb->color, gcb->color+1, gcb->color+2);
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
|
||||
gimp_palette_get_background (gcb->color, gcb->color+1, gcb->color+2);
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gimp_color_button_menu_translate (const gchar *path,
|
||||
gpointer func_data)
|
||||
{
|
||||
return (gettext (path));
|
||||
}
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
GtkWidget *window;
|
||||
GdkColor bg;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_widget_realize (window);
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"gimp-color-button-drag-window",
|
||||
window,
|
||||
(GtkDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
bg.red = 0xffff * gcb->dcolor[0];
|
||||
bg.green = 0xffff * gcb->dcolor[1];
|
||||
bg.blue = 0xffff * gcb->dcolor[2];
|
||||
|
||||
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
|
||||
gdk_window_set_background (window->window, &bg);
|
||||
|
||||
gtk_drag_set_icon_widget (context, window, DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_object_set_data (GTK_OBJECT (widget), "gimp-color-button-drag-window", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 *vals;
|
||||
guchar new_color[4];
|
||||
gboolean color_changed = FALSE;
|
||||
gint i;
|
||||
|
||||
if (selection_data->length < 0)
|
||||
return;
|
||||
|
||||
if ((selection_data->format != 16) ||
|
||||
(selection_data->length != 8))
|
||||
{
|
||||
g_warning ("Received invalid color data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
vals = (guint16 *)selection_data->data;
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
gcb->dcolor[i] = (gdouble)vals[i] / 0xffff;
|
||||
new_color[i] = gcb->dcolor[i] * 255.999;
|
||||
if (new_color[i] != gcb->color[i])
|
||||
color_changed = TRUE;
|
||||
gcb->color[i] = new_color[i];
|
||||
}
|
||||
|
||||
if (color_changed)
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 vals[4];
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
vals[i] = gcb->dcolor[i] * 0xffff;
|
||||
|
||||
if (i == 3)
|
||||
vals[3] = 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gdk_atom_intern ("application/x-color", FALSE),
|
||||
16, (guchar *)vals, 8);
|
||||
}
|
||||
|
||||
/* end of DND */
|
||||
|
|
|
@ -45,24 +45,6 @@ extern "C" {
|
|||
typedef struct _GimpColorButton GimpColorButton;
|
||||
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
gint width;
|
||||
gint height;
|
||||
guchar *color;
|
||||
gint bpp;
|
||||
|
||||
gdouble *dcolor;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *dialog;
|
||||
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
};
|
||||
|
||||
struct _GimpColorButtonClass
|
||||
{
|
||||
GtkButtonClass parent_class;
|
||||
|
@ -77,6 +59,7 @@ GtkWidget* gimp_color_button_new (gchar *title,
|
|||
gint height,
|
||||
guchar *color,
|
||||
gint bpp);
|
||||
void gimp_color_button_update (GimpColorButton *gcb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -21,18 +21,66 @@
|
|||
*/
|
||||
|
||||
/* TODO:
|
||||
*
|
||||
* add DND -- this will be trivial as soon as gimpdnd.[ch] is moved into libgimp
|
||||
*
|
||||
* handle bytes != 3|4 -- would we have to provide a special color select dialog
|
||||
* for that case? Another possibility could be to destroy
|
||||
* all color-related widgets in the gtk colorselector.
|
||||
* for that case? Another possibility could be to hide or
|
||||
* destroy all color-related widgets in the gtk colorselector.
|
||||
*/
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpcolorbutton.h"
|
||||
#include "gimpintl.h"
|
||||
#include "gimplimits.h"
|
||||
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
#define DRAG_PREVIEW_SIZE 32
|
||||
#define DRAG_ICON_OFFSET -8
|
||||
|
||||
static void gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
static void gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data);
|
||||
static const GtkTargetEntry targets[] = { { "application/x-color", 0 } };
|
||||
|
||||
/* end of DND */
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
gint width;
|
||||
gint height;
|
||||
guchar *color;
|
||||
gint bpp;
|
||||
|
||||
gdouble *dcolor;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *dialog;
|
||||
GtkItemFactory *item_factory;
|
||||
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
};
|
||||
|
||||
|
||||
static void gimp_color_button_destroy (GtkObject *object);
|
||||
static void gimp_color_button_clicked (GtkButton *button);
|
||||
static void gimp_color_button_paint (GimpColorButton *gcb);
|
||||
|
@ -40,6 +88,20 @@ static void gimp_color_button_paint (GimpColorButton *gcb);
|
|||
static void gimp_color_button_dialog_ok (GtkWidget *widget, gpointer data);
|
||||
static void gimp_color_button_dialog_cancel (GtkWidget *widget, gpointer data);
|
||||
|
||||
static void gimp_color_button_use_fg (gpointer callback_data, guint callback_action, GtkWidget *widget);
|
||||
static void gimp_color_button_use_bg (gpointer callback_data, guint callback_action, GtkWidget *widget);
|
||||
|
||||
static gint gimp_color_button_menu_popup (GtkWidget *widget, GdkEvent *event, gpointer data);
|
||||
static gchar* gimp_color_button_menu_translate (const gchar *path, gpointer func_data);
|
||||
|
||||
|
||||
static GtkItemFactoryEntry menu_items[] = {
|
||||
{ N_("/Use Foreground Color"), NULL, gimp_color_button_use_fg, 2, NULL },
|
||||
{ N_("/Use Background Color"), NULL, gimp_color_button_use_bg, 2, NULL }
|
||||
};
|
||||
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
|
||||
|
||||
|
||||
enum {
|
||||
COLOR_CHANGED,
|
||||
LAST_SIGNAL
|
||||
|
@ -177,9 +239,95 @@ gimp_color_button_new (gchar *title,
|
|||
gtk_widget_show (gcb->preview);
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
/* right-click opens a popup */
|
||||
gcb->item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<popup>", NULL);
|
||||
gtk_item_factory_set_translate_func (gcb->item_factory, gimp_color_button_menu_translate,
|
||||
NULL, NULL);
|
||||
gtk_item_factory_create_items (gcb->item_factory, nmenu_items, menu_items, gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb),
|
||||
"button_press_event",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_menu_popup),
|
||||
gcb);
|
||||
|
||||
/* DND -- to be changed as soon as gimpdnd is in libgimp */
|
||||
gtk_drag_dest_set (gcb->preview,
|
||||
GTK_DEST_DEFAULT_HIGHLIGHT |
|
||||
GTK_DEST_DEFAULT_MOTION |
|
||||
GTK_DEST_DEFAULT_DROP,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY);
|
||||
gtk_drag_source_set (gcb->preview,
|
||||
GDK_BUTTON2_MASK,
|
||||
targets, 1,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_begin",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_begin),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_end",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_end),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_data_get",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drag_handle),
|
||||
gcb);
|
||||
gtk_signal_connect (GTK_OBJECT (gcb->preview),
|
||||
"drag_data_received",
|
||||
GTK_SIGNAL_FUNC (gimp_color_button_drop_handle),
|
||||
gcb);
|
||||
/* end of DND */
|
||||
|
||||
return (GTK_WIDGET (gcb));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_color_button_update (GimpColorButton *gcb)
|
||||
{
|
||||
gint i;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (gcb));
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
gcb->dcolor[i] = (gdouble)gcb->color[i] / 255.0;
|
||||
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
if (gcb->dialog)
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (gcb->dialog)->colorsel),
|
||||
gcb->dcolor);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_color_button_menu_popup (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
GdkEventButton *bevent;
|
||||
gint x;
|
||||
gint y;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_BUTTON (data), FALSE);
|
||||
gcb = GIMP_COLOR_BUTTON (data);
|
||||
|
||||
if (event->type != GDK_BUTTON_PRESS)
|
||||
return FALSE;
|
||||
|
||||
bevent = (GdkEventButton *) event;
|
||||
|
||||
if (bevent->button != 3)
|
||||
return FALSE;
|
||||
|
||||
gdk_window_get_origin (GTK_WIDGET (widget)->window, &x, &y);
|
||||
gtk_item_factory_popup (gcb->item_factory,
|
||||
x + bevent->x, y + bevent->y,
|
||||
bevent->button, bevent->time);
|
||||
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_clicked (GtkButton *button)
|
||||
{
|
||||
|
@ -287,11 +435,12 @@ gimp_color_button_dialog_ok (GtkWidget *widget,
|
|||
|
||||
gtk_widget_destroy (gcb->dialog);
|
||||
|
||||
gimp_color_button_paint (gcb);
|
||||
|
||||
if (color_changed)
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -307,4 +456,148 @@ gimp_color_button_dialog_cancel (GtkWidget *widget,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_use_fg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
|
||||
gimp_palette_get_foreground (gcb->color, gcb->color+1, gcb->color+2);
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_color_button_use_bg (gpointer callback_data,
|
||||
guint callback_action,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
GimpColorButton *gcb;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_BUTTON (callback_data));
|
||||
gcb = GIMP_COLOR_BUTTON (callback_data);
|
||||
|
||||
gimp_palette_get_background (gcb->color, gcb->color+1, gcb->color+2);
|
||||
|
||||
gimp_color_button_update (gcb);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
gimp_color_button_menu_translate (const gchar *path,
|
||||
gpointer func_data)
|
||||
{
|
||||
return (gettext (path));
|
||||
}
|
||||
|
||||
/* DND -- remove as soon as gimpdnd is in libgimp */
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_begin (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
GtkWidget *window;
|
||||
GdkColor bg;
|
||||
|
||||
window = gtk_window_new (GTK_WINDOW_POPUP);
|
||||
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
|
||||
gtk_widget_set_usize (window, DRAG_PREVIEW_SIZE, DRAG_PREVIEW_SIZE);
|
||||
gtk_widget_realize (window);
|
||||
gtk_object_set_data_full (GTK_OBJECT (widget),
|
||||
"gimp-color-button-drag-window",
|
||||
window,
|
||||
(GtkDestroyNotify) gtk_widget_destroy);
|
||||
|
||||
bg.red = 0xffff * gcb->dcolor[0];
|
||||
bg.green = 0xffff * gcb->dcolor[1];
|
||||
bg.blue = 0xffff * gcb->dcolor[2];
|
||||
|
||||
gdk_color_alloc (gtk_widget_get_colormap (window), &bg);
|
||||
gdk_window_set_background (window->window, &bg);
|
||||
|
||||
gtk_drag_set_icon_widget (context, window, DRAG_ICON_OFFSET, DRAG_ICON_OFFSET);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_end (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_object_set_data (GTK_OBJECT (widget), "gimp-color-button-drag-window", NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drop_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 *vals;
|
||||
guchar new_color[4];
|
||||
gboolean color_changed = FALSE;
|
||||
gint i;
|
||||
|
||||
if (selection_data->length < 0)
|
||||
return;
|
||||
|
||||
if ((selection_data->format != 16) ||
|
||||
(selection_data->length != 8))
|
||||
{
|
||||
g_warning ("Received invalid color data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
vals = (guint16 *)selection_data->data;
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
{
|
||||
gcb->dcolor[i] = (gdouble)vals[i] / 0xffff;
|
||||
new_color[i] = gcb->dcolor[i] * 255.999;
|
||||
if (new_color[i] != gcb->color[i])
|
||||
color_changed = TRUE;
|
||||
gcb->color[i] = new_color[i];
|
||||
}
|
||||
|
||||
if (color_changed)
|
||||
{
|
||||
gimp_color_button_paint (gcb);
|
||||
gtk_signal_emit (GTK_OBJECT (gcb),
|
||||
gimp_color_button_signals[COLOR_CHANGED]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_button_drag_handle (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time,
|
||||
gpointer data)
|
||||
{
|
||||
GimpColorButton *gcb = data;
|
||||
guint16 vals[4];
|
||||
gint i;
|
||||
|
||||
for (i = 0; i < gcb->bpp; i++)
|
||||
vals[i] = gcb->dcolor[i] * 0xffff;
|
||||
|
||||
if (i == 3)
|
||||
vals[3] = 0xffff;
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gdk_atom_intern ("application/x-color", FALSE),
|
||||
16, (guchar *)vals, 8);
|
||||
}
|
||||
|
||||
/* end of DND */
|
||||
|
|
|
@ -45,24 +45,6 @@ extern "C" {
|
|||
typedef struct _GimpColorButton GimpColorButton;
|
||||
typedef struct _GimpColorButtonClass GimpColorButtonClass;
|
||||
|
||||
struct _GimpColorButton
|
||||
{
|
||||
GtkButton button;
|
||||
|
||||
gchar *title;
|
||||
gint width;
|
||||
gint height;
|
||||
guchar *color;
|
||||
gint bpp;
|
||||
|
||||
gdouble *dcolor;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *dialog;
|
||||
|
||||
guchar *even;
|
||||
guchar *odd;
|
||||
};
|
||||
|
||||
struct _GimpColorButtonClass
|
||||
{
|
||||
GtkButtonClass parent_class;
|
||||
|
@ -77,6 +59,7 @@ GtkWidget* gimp_color_button_new (gchar *title,
|
|||
gint height,
|
||||
guchar *color,
|
||||
gint bpp);
|
||||
void gimp_color_button_update (GimpColorButton *gcb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ c_astretch
|
|||
checkerboard
|
||||
color_enhance
|
||||
colorify
|
||||
colortoalpha
|
||||
compose
|
||||
convmatrix
|
||||
csource
|
||||
|
|
|
@ -301,6 +301,7 @@ colortoalpha_SOURCES = \
|
|||
colortoalpha.c
|
||||
|
||||
colortoalpha_LDADD = \
|
||||
$(top_builddir)/libgimp/libgimpui.la \
|
||||
$(top_builddir)/libgimp/libgimp.la \
|
||||
$(GTK_LIBS) \
|
||||
$(INTLLIBS)
|
||||
|
|
|
@ -21,13 +21,12 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* TODO:
|
||||
* Add fg/bg buttons!
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "gtk/gtk.h"
|
||||
#include "libgimp/gimp.h"
|
||||
#include "libgimp/gimpui.h"
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
#define PRV_WIDTH 40
|
||||
#define PRV_HEIGHT 20
|
||||
|
@ -41,18 +40,9 @@ typedef struct {
|
|||
} C2AInterface;
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *preview;
|
||||
GtkWidget *color_button;
|
||||
} C2APreview;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *activate; /* The button that activates the color sel. dialog */
|
||||
GtkWidget *colselect; /* The colour selection dialog itself */
|
||||
GtkWidget *preview; /* The colour preview */
|
||||
unsigned char color[3];/* The selected colour */
|
||||
} CSEL;
|
||||
|
||||
|
||||
/* Declare local functions.
|
||||
*/
|
||||
static void query (void);
|
||||
|
@ -70,15 +60,9 @@ static void toalpha_render_row (const guchar *src_row,
|
|||
const gint bytes);
|
||||
/* UI stuff */
|
||||
static gint colortoalpha_dialog (GDrawable *drawable);
|
||||
static void C2A_color_button_callback (GtkWidget *widget, gpointer data);
|
||||
static void C2A_close_callback (GtkWidget *widget, gpointer data);
|
||||
static void C2A_ok_callback (GtkWidget *widget, gpointer data);
|
||||
static void C2A_bg_button_callback (GtkWidget *widget, gpointer data);
|
||||
static void C2A_fg_button_callback (GtkWidget *widget, gpointer data);
|
||||
static void C2A_close_callback (GtkWidget *widget, gpointer data);
|
||||
static void C2A_ok_callback (GtkWidget *widget, gpointer data);
|
||||
|
||||
static void color_preview_show(GtkWidget *widget, guchar *color);
|
||||
static void color_select_ok_callback(GtkWidget *widget, gpointer data);
|
||||
static void color_select_cancel_callback(GtkWidget *widget, gpointer data);
|
||||
static GRunModeType run_mode;
|
||||
|
||||
GPlugInInfo PLUG_IN_INFO =
|
||||
|
@ -208,15 +192,14 @@ run (char *name,
|
|||
}
|
||||
|
||||
void
|
||||
colortoalpha(float *a1,
|
||||
float *a2,
|
||||
float *a3,
|
||||
float *a4,
|
||||
float c1,
|
||||
float c2,
|
||||
float c3)
|
||||
colortoalpha (float *a1,
|
||||
float *a2,
|
||||
float *a3,
|
||||
float *a4,
|
||||
float c1,
|
||||
float c2,
|
||||
float c3)
|
||||
{
|
||||
|
||||
float alpha1, alpha2, alpha3;
|
||||
|
||||
if ( *a1 > c1 )
|
||||
|
@ -285,9 +268,9 @@ colortoalpha(float *a1,
|
|||
|
||||
static void
|
||||
toalpha_render_row (const guchar *src_data,
|
||||
guchar *dest_data,
|
||||
gint col, /* row width in pixels */
|
||||
const gint bytes)
|
||||
guchar *dest_data,
|
||||
gint col, /* row width in pixels */
|
||||
const gint bytes)
|
||||
{
|
||||
while (col--)
|
||||
{
|
||||
|
@ -385,11 +368,11 @@ toalpha (GDrawable *drawable)
|
|||
}
|
||||
|
||||
static gint
|
||||
colortoalpha_dialog (GDrawable * drawable)
|
||||
colortoalpha_dialog (GDrawable *drawable)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *dlg;
|
||||
GtkWidget *preview;
|
||||
GtkWidget *hbbox;
|
||||
GtkWidget *button;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
|
||||
|
@ -415,209 +398,77 @@ colortoalpha_dialog (GDrawable * drawable)
|
|||
gtk_widget_set_default_colormap (gtk_preview_get_cmap ());
|
||||
|
||||
dlg = gtk_dialog_new ();
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), "Color To Alpha");
|
||||
gtk_window_set_title (GTK_WINDOW (dlg), _("Color To Alpha"));
|
||||
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
|
||||
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
|
||||
(GtkSignalFunc) C2A_close_callback,
|
||||
NULL);
|
||||
/* Action area */
|
||||
button = gtk_button_new_with_label ("OK");
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 2);
|
||||
gtk_box_set_homogeneous (GTK_BOX (GTK_DIALOG (dlg)->action_area), FALSE);
|
||||
hbbox = gtk_hbutton_box_new ();
|
||||
gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbbox), 4);
|
||||
gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dlg)->action_area), hbbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbbox);
|
||||
|
||||
button = gtk_button_new_with_label (_("OK"));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) C2A_ok_callback,
|
||||
dlg);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
|
||||
(GtkSignalFunc) C2A_ok_callback,
|
||||
dlg);
|
||||
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
button = gtk_button_new_with_label ("Cancel");
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (dlg));
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area), button, TRUE, TRUE, 0);
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (dlg));
|
||||
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
table = gtk_table_new(2,6,FALSE);
|
||||
button = gtk_button_new ();
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) C2A_color_button_callback,
|
||||
NULL);
|
||||
gtk_widget_set_usize(button, PRV_WIDTH+9, PRV_HEIGHT+9);
|
||||
preview = gtk_preview_new(GTK_PREVIEW_COLOR);
|
||||
ppreview.preview = preview; /* save in a global structure */
|
||||
table = gtk_table_new (1, 3, FALSE);
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview), PRV_WIDTH, PRV_HEIGHT);
|
||||
gtk_container_add (GTK_CONTAINER (button), preview);
|
||||
gtk_widget_show(preview);
|
||||
color_preview_show(preview, pvals.color);
|
||||
gtk_widget_show(button);
|
||||
|
||||
gtk_table_attach( GTK_TABLE(table), button, 2, 4, 0, 1,
|
||||
label = gtk_label_new (_("From:"));
|
||||
gtk_table_attach_defaults ( GTK_TABLE(table), label, 0, 1, 0, 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
button = gimp_color_button_new (_("Color To Alpha Color Picker"),
|
||||
PRV_WIDTH, PRV_HEIGHT,
|
||||
pvals.color, 3);
|
||||
gtk_table_attach( GTK_TABLE(table), button, 1, 2, 0, 1,
|
||||
GTK_EXPAND, GTK_SHRINK, 4, 4) ;
|
||||
label = gtk_label_new("From:");
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach_defaults ( GTK_TABLE(table), label, 1, 2, 0, 1);
|
||||
|
||||
label = gtk_label_new("to alpha");
|
||||
gtk_widget_show(label);
|
||||
gtk_table_attach_defaults ( GTK_TABLE(table), label, 4, 5, 0, 1);
|
||||
gtk_widget_show(table);
|
||||
gtk_box_pack_start( GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
|
||||
gtk_widget_show(button);
|
||||
ppreview.color_button = button;
|
||||
|
||||
button = gtk_button_new_with_label("Foreground");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) C2A_fg_button_callback,
|
||||
NULL);
|
||||
gtk_widget_show(button);
|
||||
gtk_table_attach( GTK_TABLE(table), button, 1, 3, 1, 2,
|
||||
GTK_EXPAND, GTK_SHRINK, 4, 0) ;
|
||||
|
||||
button = gtk_button_new_with_label("Background");
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) C2A_bg_button_callback,
|
||||
NULL);
|
||||
gtk_widget_show(button);
|
||||
gtk_table_attach( GTK_TABLE(table), button, 3, 5, 1, 2,
|
||||
GTK_EXPAND, GTK_SHRINK, 4, 0) ;
|
||||
label = gtk_label_new (_("to alpha"));
|
||||
gtk_table_attach_defaults ( GTK_TABLE(table), label, 2, 3, 0, 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), table, TRUE, TRUE, 0);
|
||||
gtk_widget_show (table);
|
||||
|
||||
gtk_widget_show(dlg);
|
||||
gtk_widget_show (dlg);
|
||||
|
||||
gtk_main();
|
||||
gdk_flush();
|
||||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
return pint.run;
|
||||
}
|
||||
|
||||
static void
|
||||
color_preview_show (GtkWidget *widget,
|
||||
unsigned char *rgb)
|
||||
|
||||
{guchar *buf, *bp;
|
||||
int j, width, height;
|
||||
|
||||
width = PRV_WIDTH;
|
||||
height = PRV_HEIGHT;
|
||||
|
||||
bp = buf = g_malloc (width*3);
|
||||
if (buf == NULL) return;
|
||||
|
||||
for (j = 0; j < width; j++)
|
||||
{
|
||||
*(bp++) = rgb[0];
|
||||
*(bp++) = rgb[1];
|
||||
*(bp++) = rgb[2];
|
||||
}
|
||||
for (j = 0; j < height; j++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (widget), buf, 0, j, width);
|
||||
|
||||
gtk_widget_draw (widget, NULL);
|
||||
|
||||
g_free (buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
C2A_close_callback(GtkWidget *widget,
|
||||
gpointer data)
|
||||
C2A_close_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
static void
|
||||
C2A_ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
gpointer data)
|
||||
{
|
||||
pint.run = TRUE;
|
||||
gtk_widget_destroy (GTK_WIDGET (data));
|
||||
}
|
||||
|
||||
static void
|
||||
C2A_color_button_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorSelectionDialog *csd;
|
||||
GtkWidget *dialog;
|
||||
gdouble color[3];
|
||||
gint i;
|
||||
for (i=0;i<3;i++)
|
||||
color[i] = (gdouble) pvals.color[i] / 255.0;
|
||||
|
||||
dialog = gtk_color_selection_dialog_new("Color To Alpha Color Picker");
|
||||
csd = GTK_COLOR_SELECTION_DIALOG (dialog);
|
||||
|
||||
gtk_widget_destroy (csd->help_button);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
|
||||
(GtkSignalFunc) color_select_cancel_callback, dialog);
|
||||
gtk_signal_connect (GTK_OBJECT (csd->ok_button), "clicked",
|
||||
(GtkSignalFunc) color_select_ok_callback, dialog);
|
||||
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
|
||||
(GtkSignalFunc) color_select_cancel_callback, dialog);
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel), color);
|
||||
|
||||
gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_widget_show (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
color_select_ok_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
||||
{gdouble color[3];
|
||||
GtkWidget *dialog;
|
||||
gint j;
|
||||
|
||||
dialog = (GtkWidget *) data;
|
||||
gtk_color_selection_get_color (
|
||||
GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (dialog)->colorsel),
|
||||
color);
|
||||
|
||||
for (j = 0; j < 3; j++)
|
||||
pvals.color[j] = (unsigned char)(color[j]*255.0);
|
||||
|
||||
color_preview_show (ppreview.preview, pvals.color);
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
color_select_cancel_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *dialog;
|
||||
|
||||
dialog = (GtkWidget *)data;
|
||||
gtk_widget_destroy (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
C2A_fg_button_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
||||
{
|
||||
guchar color[3];
|
||||
int i;
|
||||
gimp_palette_get_foreground(color, color+1, color+2);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
pvals.color[i] = color[i];
|
||||
|
||||
color_preview_show (ppreview.preview, pvals.color);
|
||||
}
|
||||
|
||||
static void
|
||||
C2A_bg_button_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
||||
{
|
||||
guchar color[3];
|
||||
int i;
|
||||
gimp_palette_get_background(color, color+1, color+2);
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
pvals.color[i] = color[i];
|
||||
|
||||
color_preview_show (ppreview.preview, pvals.color);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
'c_astretch' => { libdep => 'glib' },
|
||||
'checkerboard' => { libdep => 'gtk' },
|
||||
'color_enhance' => { libdep => 'gtk', ui => 1 },
|
||||
'colortoalpha' => { libdep => 'gtk' },
|
||||
'colortoalpha' => { libdep => 'gtk', ui => 1 },
|
||||
'colorify' => { libdep => 'gtk' },
|
||||
'compose' => { libdep => 'gtk', ui => 1 },
|
||||
'convmatrix' => { libdep => 'gtk' },
|
||||
|
|
|
@ -161,7 +161,7 @@ gimp_install_procedure ("plug_in_layer_rot90",
|
|||
PLUG_IN_AUTHOR,
|
||||
PLUG_IN_COPYRIGHT,
|
||||
PLUG_IN_VERSION,
|
||||
N_("<Image>/Layers/Rotate/90"),
|
||||
N_("<Image>/Layers/Rotate/90 degrees"),
|
||||
PLUG_IN_IMAGE_TYPES,
|
||||
PROC_PLUG_IN,
|
||||
nmenuargs, nreturn_vals,
|
||||
|
@ -172,7 +172,7 @@ gimp_install_procedure ("plug_in_layer_rot180",
|
|||
PLUG_IN_AUTHOR,
|
||||
PLUG_IN_COPYRIGHT,
|
||||
PLUG_IN_VERSION,
|
||||
N_("<Image>/Layers/Rotate/180"),
|
||||
N_("<Image>/Layers/Rotate/180 degrees"),
|
||||
PLUG_IN_IMAGE_TYPES,
|
||||
PROC_PLUG_IN,
|
||||
nmenuargs, nreturn_vals,
|
||||
|
@ -183,7 +183,7 @@ gimp_install_procedure ("plug_in_layer_rot270",
|
|||
PLUG_IN_AUTHOR,
|
||||
PLUG_IN_COPYRIGHT,
|
||||
PLUG_IN_VERSION,
|
||||
N_("<Image>/Layers/Rotate/270"),
|
||||
N_("<Image>/Layers/Rotate/270 degrees"),
|
||||
PLUG_IN_IMAGE_TYPES,
|
||||
PROC_PLUG_IN,
|
||||
nmenuargs, nreturn_vals,
|
||||
|
@ -195,7 +195,7 @@ gimp_install_procedure ("plug_in_image_rot90",
|
|||
PLUG_IN_AUTHOR,
|
||||
PLUG_IN_COPYRIGHT,
|
||||
PLUG_IN_VERSION,
|
||||
N_("<Image>/Image/Transforms/Rotate/90"),
|
||||
N_("<Image>/Image/Transforms/Rotate/90 degrees"),
|
||||
PLUG_IN_IMAGE_TYPES,
|
||||
PROC_PLUG_IN,
|
||||
nmenuargs, nreturn_vals,
|
||||
|
@ -206,7 +206,7 @@ gimp_install_procedure ("plug_in_image_rot180",
|
|||
PLUG_IN_AUTHOR,
|
||||
PLUG_IN_COPYRIGHT,
|
||||
PLUG_IN_VERSION,
|
||||
N_("<Image>/Image/Transforms/Rotate/180"),
|
||||
N_("<Image>/Image/Transforms/Rotate/180 degrees"),
|
||||
PLUG_IN_IMAGE_TYPES,
|
||||
PROC_PLUG_IN,
|
||||
nmenuargs, nreturn_vals,
|
||||
|
@ -217,7 +217,7 @@ gimp_install_procedure ("plug_in_image_rot270",
|
|||
PLUG_IN_AUTHOR,
|
||||
PLUG_IN_COPYRIGHT,
|
||||
PLUG_IN_VERSION,
|
||||
N_("<Image>/Image/Transforms/Rotate/270"),
|
||||
N_("<Image>/Image/Transforms/Rotate/270 degrees"),
|
||||
PLUG_IN_IMAGE_TYPES,
|
||||
PROC_PLUG_IN,
|
||||
nmenuargs, nreturn_vals,
|
||||
|
|
|
@ -76,13 +76,6 @@
|
|||
|
||||
#define MAX_STRING_LENGTH 4096
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GtkWidget *dialog;
|
||||
gdouble color[3];
|
||||
gdouble old_color[3];
|
||||
} SFColor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -124,7 +117,7 @@ typedef union
|
|||
gint32 sfa_drawable;
|
||||
gint32 sfa_layer;
|
||||
gint32 sfa_channel;
|
||||
SFColor sfa_color;
|
||||
guchar sfa_color[3];
|
||||
gint32 sfa_toggle;
|
||||
gchar * sfa_value;
|
||||
SFAdjustment sfa_adjustment;
|
||||
|
@ -179,8 +172,6 @@ static void script_fu_free_script (SFScript *script);
|
|||
static void script_fu_enable_cc (void);
|
||||
static void script_fu_disable_cc (gint err_msg);
|
||||
static void script_fu_interface (SFScript *script);
|
||||
static void script_fu_color_preview (GtkWidget *preview,
|
||||
gdouble *color);
|
||||
static void script_fu_font_preview (GtkWidget *preview,
|
||||
gchar *fontname);
|
||||
static void script_fu_cleanup_widgets (SFScript *script);
|
||||
|
@ -198,15 +189,6 @@ static void script_fu_menu_callback (gint32 id,
|
|||
gpointer data);
|
||||
static void script_fu_toggle_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_color_preview_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_color_preview_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_color_preview_cancel (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static gint script_fu_color_preview_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void script_fu_file_selection_callback(GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_font_preview_callback (GtkWidget *widget,
|
||||
|
@ -414,7 +396,7 @@ script_fu_add_script (LISP a)
|
|||
GParamDef *args;
|
||||
char *val;
|
||||
int i;
|
||||
gdouble color[3];
|
||||
guchar color[3];
|
||||
LISP color_list;
|
||||
LISP adj_list;
|
||||
LISP brush_list;
|
||||
|
@ -554,15 +536,13 @@ script_fu_add_script (LISP a)
|
|||
if (!TYPEP (car (a), tc_cons))
|
||||
return my_err ("script-fu-register: color defaults must be a list of 3 integers", NIL);
|
||||
color_list = car (a);
|
||||
color[0] = (gdouble) get_c_long (car (color_list)) / 255.0;
|
||||
color[0] = (guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
color_list = cdr (color_list);
|
||||
color[1] = (gdouble) get_c_long (car (color_list)) / 255.0;
|
||||
color[1] = (guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
color_list = cdr (color_list);
|
||||
color[2] = (gdouble) get_c_long (car (color_list)) / 255.0;
|
||||
memcpy (script->arg_defaults[i].sfa_color.color, color, sizeof (gdouble) * 3);
|
||||
memcpy (script->arg_values[i].sfa_color.color, color, sizeof (gdouble) * 3);
|
||||
script->arg_values[i].sfa_color.preview = NULL;
|
||||
script->arg_values[i].sfa_color.dialog = NULL;
|
||||
color[2] = (guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
memcpy (script->arg_defaults[i].sfa_color, color, sizeof (guchar) * 3);
|
||||
memcpy (script->arg_values[i].sfa_color, color, sizeof (guchar) * 3);
|
||||
|
||||
args[i + 1].type = PARAM_COLOR;
|
||||
args[i + 1].name = "color";
|
||||
|
@ -1220,22 +1200,10 @@ script_fu_interface (SFScript *script)
|
|||
break;
|
||||
|
||||
case SF_COLOR:
|
||||
script->args_widgets[i] = gtk_button_new ();
|
||||
script->args_widgets[i] = gimp_color_button_new (_("Script-Fu Color Selection"),
|
||||
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
|
||||
script->arg_values[i].sfa_color, 3);
|
||||
|
||||
script->arg_values[i].sfa_color.preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
script->arg_values[i].sfa_color.dialog = NULL;
|
||||
gtk_preview_size (GTK_PREVIEW (script->arg_values[i].sfa_color.preview),
|
||||
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT);
|
||||
gtk_container_add (GTK_CONTAINER (script->args_widgets[i]),
|
||||
script->arg_values[i].sfa_color.preview);
|
||||
gtk_widget_show (script->arg_values[i].sfa_color.preview);
|
||||
|
||||
script_fu_color_preview (script->arg_values[i].sfa_color.preview,
|
||||
script->arg_values[i].sfa_color.color);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (script->args_widgets[i]), "clicked",
|
||||
(GtkSignalFunc) script_fu_color_preview_callback,
|
||||
&script->arg_values[i].sfa_color);
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
@ -1431,26 +1399,6 @@ script_fu_interface (SFScript *script)
|
|||
gdk_flush ();
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_color_preview (GtkWidget *preview,
|
||||
gdouble *color)
|
||||
{
|
||||
gint i;
|
||||
guchar buf[3 * COLOR_SAMPLE_WIDTH];
|
||||
|
||||
for (i = 0; i < COLOR_SAMPLE_WIDTH; i++)
|
||||
{
|
||||
buf[3*i] = (guint) (255.999 * color[0]);
|
||||
buf[3*i+1] = (guint) (255.999 * color[1]);
|
||||
buf[3*i+2] = (guint) (255.999 * color[2]);
|
||||
}
|
||||
for (i = 0; i < COLOR_SAMPLE_HEIGHT; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), buf, 0, i, COLOR_SAMPLE_WIDTH);
|
||||
|
||||
gtk_widget_draw (preview, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
script_fu_pattern_preview (gchar *name,
|
||||
gint width,
|
||||
|
@ -1547,11 +1495,6 @@ script_fu_cleanup_widgets (SFScript *script)
|
|||
switch (script->arg_types[i])
|
||||
{
|
||||
case SF_COLOR:
|
||||
if (script->arg_values[i].sfa_color.dialog != NULL)
|
||||
{
|
||||
gtk_widget_destroy (script->arg_values[i].sfa_color.dialog);
|
||||
script->arg_values[i].sfa_color.dialog = NULL;
|
||||
}
|
||||
break;
|
||||
case SF_FILENAME:
|
||||
break;
|
||||
|
@ -1674,9 +1617,9 @@ script_fu_ok_callback (GtkWidget *widget,
|
|||
break;
|
||||
case SF_COLOR:
|
||||
sprintf (buffer, "'(%d %d %d)",
|
||||
(gint32) (script->arg_values[i].sfa_color.color[0] * 255.999),
|
||||
(gint32) (script->arg_values[i].sfa_color.color[1] * 255.999),
|
||||
(gint32) (script->arg_values[i].sfa_color.color[2] * 255.999));
|
||||
script->arg_values[i].sfa_color[0],
|
||||
script->arg_values[i].sfa_color[1],
|
||||
script->arg_values[i].sfa_color[2]);
|
||||
text = buffer;
|
||||
break;
|
||||
case SF_TOGGLE:
|
||||
|
@ -1950,12 +1893,11 @@ script_fu_reset_callback (GtkWidget *widget,
|
|||
case SF_CHANNEL:
|
||||
break;
|
||||
case SF_COLOR:
|
||||
for (j = 0; j < 4; j++)
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
script->arg_values[i].sfa_color.color[j] = script->arg_defaults[i].sfa_color.color[j];
|
||||
script->arg_values[i].sfa_color[j] = script->arg_defaults[i].sfa_color[j];
|
||||
}
|
||||
script_fu_color_preview (script->arg_values[i].sfa_color.preview,
|
||||
script->arg_values[i].sfa_color.color);
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (script->args_widgets[i]));
|
||||
break;
|
||||
case SF_TOGGLE:
|
||||
script->arg_values[i].sfa_toggle = script->arg_defaults[i].sfa_toggle;
|
||||
|
@ -2028,94 +1970,6 @@ script_fu_toggle_update (GtkWidget *widget,
|
|||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
script_fu_color_preview_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorSelectionDialog *csd;
|
||||
SFColor *color;
|
||||
|
||||
color = (SFColor *) data;
|
||||
color->old_color[0] = color->color[0];
|
||||
color->old_color[1] = color->color[1];
|
||||
color->old_color[2] = color->color[2];
|
||||
|
||||
if (!color->dialog)
|
||||
{
|
||||
color->dialog =
|
||||
gtk_color_selection_dialog_new (_("Script-Fu Color Picker"));
|
||||
csd = GTK_COLOR_SELECTION_DIALOG (color->dialog);
|
||||
|
||||
gtk_widget_destroy (csd->help_button);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (csd->ok_button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_hide,
|
||||
GTK_OBJECT (color->dialog));
|
||||
gtk_signal_connect (GTK_OBJECT (csd), "delete_event",
|
||||
(GtkSignalFunc) script_fu_color_preview_delete,
|
||||
color);
|
||||
gtk_signal_connect (GTK_OBJECT (csd), "destroy",
|
||||
gtk_widget_destroyed, &color->dialog);
|
||||
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
|
||||
(GtkSignalFunc) script_fu_color_preview_cancel,
|
||||
color);
|
||||
gtk_signal_connect (GTK_OBJECT (csd->colorsel), "color_changed",
|
||||
(GtkSignalFunc) script_fu_color_preview_changed,
|
||||
color);
|
||||
|
||||
/* call here so the old color is set */
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel),
|
||||
color->color);
|
||||
}
|
||||
else
|
||||
csd = GTK_COLOR_SELECTION_DIALOG (color->dialog);
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel),
|
||||
color->color);
|
||||
|
||||
gtk_window_position (GTK_WINDOW (color->dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_widget_show (color->dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_color_preview_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
SFColor *color;
|
||||
|
||||
color = (SFColor *) data;
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color->dialog)->colorsel),
|
||||
color->color);
|
||||
script_fu_color_preview (color->preview, color->color);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_color_preview_cancel (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
SFColor *color;
|
||||
|
||||
color = (SFColor *) data;
|
||||
|
||||
gtk_widget_hide (color->dialog);
|
||||
|
||||
color->color[0] = color->old_color[0];
|
||||
color->color[1] = color->old_color[1];
|
||||
color->color[2] = color->old_color[2];
|
||||
|
||||
script_fu_color_preview (color->preview, color->color);
|
||||
}
|
||||
|
||||
static gint
|
||||
script_fu_color_preview_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
script_fu_color_preview_cancel (widget, data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_file_selection_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
|
|
@ -76,13 +76,6 @@
|
|||
|
||||
#define MAX_STRING_LENGTH 4096
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GtkWidget *dialog;
|
||||
gdouble color[3];
|
||||
gdouble old_color[3];
|
||||
} SFColor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -124,7 +117,7 @@ typedef union
|
|||
gint32 sfa_drawable;
|
||||
gint32 sfa_layer;
|
||||
gint32 sfa_channel;
|
||||
SFColor sfa_color;
|
||||
guchar sfa_color[3];
|
||||
gint32 sfa_toggle;
|
||||
gchar * sfa_value;
|
||||
SFAdjustment sfa_adjustment;
|
||||
|
@ -179,8 +172,6 @@ static void script_fu_free_script (SFScript *script);
|
|||
static void script_fu_enable_cc (void);
|
||||
static void script_fu_disable_cc (gint err_msg);
|
||||
static void script_fu_interface (SFScript *script);
|
||||
static void script_fu_color_preview (GtkWidget *preview,
|
||||
gdouble *color);
|
||||
static void script_fu_font_preview (GtkWidget *preview,
|
||||
gchar *fontname);
|
||||
static void script_fu_cleanup_widgets (SFScript *script);
|
||||
|
@ -198,15 +189,6 @@ static void script_fu_menu_callback (gint32 id,
|
|||
gpointer data);
|
||||
static void script_fu_toggle_update (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_color_preview_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_color_preview_changed (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_color_preview_cancel (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static gint script_fu_color_preview_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data);
|
||||
static void script_fu_file_selection_callback(GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void script_fu_font_preview_callback (GtkWidget *widget,
|
||||
|
@ -414,7 +396,7 @@ script_fu_add_script (LISP a)
|
|||
GParamDef *args;
|
||||
char *val;
|
||||
int i;
|
||||
gdouble color[3];
|
||||
guchar color[3];
|
||||
LISP color_list;
|
||||
LISP adj_list;
|
||||
LISP brush_list;
|
||||
|
@ -554,15 +536,13 @@ script_fu_add_script (LISP a)
|
|||
if (!TYPEP (car (a), tc_cons))
|
||||
return my_err ("script-fu-register: color defaults must be a list of 3 integers", NIL);
|
||||
color_list = car (a);
|
||||
color[0] = (gdouble) get_c_long (car (color_list)) / 255.0;
|
||||
color[0] = (guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
color_list = cdr (color_list);
|
||||
color[1] = (gdouble) get_c_long (car (color_list)) / 255.0;
|
||||
color[1] = (guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
color_list = cdr (color_list);
|
||||
color[2] = (gdouble) get_c_long (car (color_list)) / 255.0;
|
||||
memcpy (script->arg_defaults[i].sfa_color.color, color, sizeof (gdouble) * 3);
|
||||
memcpy (script->arg_values[i].sfa_color.color, color, sizeof (gdouble) * 3);
|
||||
script->arg_values[i].sfa_color.preview = NULL;
|
||||
script->arg_values[i].sfa_color.dialog = NULL;
|
||||
color[2] = (guchar)(CLAMP (get_c_long (car (color_list)), 0, 255));
|
||||
memcpy (script->arg_defaults[i].sfa_color, color, sizeof (guchar) * 3);
|
||||
memcpy (script->arg_values[i].sfa_color, color, sizeof (guchar) * 3);
|
||||
|
||||
args[i + 1].type = PARAM_COLOR;
|
||||
args[i + 1].name = "color";
|
||||
|
@ -1220,22 +1200,10 @@ script_fu_interface (SFScript *script)
|
|||
break;
|
||||
|
||||
case SF_COLOR:
|
||||
script->args_widgets[i] = gtk_button_new ();
|
||||
script->args_widgets[i] = gimp_color_button_new (_("Script-Fu Color Selection"),
|
||||
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT,
|
||||
script->arg_values[i].sfa_color, 3);
|
||||
|
||||
script->arg_values[i].sfa_color.preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
script->arg_values[i].sfa_color.dialog = NULL;
|
||||
gtk_preview_size (GTK_PREVIEW (script->arg_values[i].sfa_color.preview),
|
||||
COLOR_SAMPLE_WIDTH, COLOR_SAMPLE_HEIGHT);
|
||||
gtk_container_add (GTK_CONTAINER (script->args_widgets[i]),
|
||||
script->arg_values[i].sfa_color.preview);
|
||||
gtk_widget_show (script->arg_values[i].sfa_color.preview);
|
||||
|
||||
script_fu_color_preview (script->arg_values[i].sfa_color.preview,
|
||||
script->arg_values[i].sfa_color.color);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (script->args_widgets[i]), "clicked",
|
||||
(GtkSignalFunc) script_fu_color_preview_callback,
|
||||
&script->arg_values[i].sfa_color);
|
||||
break;
|
||||
|
||||
case SF_TOGGLE:
|
||||
|
@ -1431,26 +1399,6 @@ script_fu_interface (SFScript *script)
|
|||
gdk_flush ();
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_color_preview (GtkWidget *preview,
|
||||
gdouble *color)
|
||||
{
|
||||
gint i;
|
||||
guchar buf[3 * COLOR_SAMPLE_WIDTH];
|
||||
|
||||
for (i = 0; i < COLOR_SAMPLE_WIDTH; i++)
|
||||
{
|
||||
buf[3*i] = (guint) (255.999 * color[0]);
|
||||
buf[3*i+1] = (guint) (255.999 * color[1]);
|
||||
buf[3*i+2] = (guint) (255.999 * color[2]);
|
||||
}
|
||||
for (i = 0; i < COLOR_SAMPLE_HEIGHT; i++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), buf, 0, i, COLOR_SAMPLE_WIDTH);
|
||||
|
||||
gtk_widget_draw (preview, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
script_fu_pattern_preview (gchar *name,
|
||||
gint width,
|
||||
|
@ -1547,11 +1495,6 @@ script_fu_cleanup_widgets (SFScript *script)
|
|||
switch (script->arg_types[i])
|
||||
{
|
||||
case SF_COLOR:
|
||||
if (script->arg_values[i].sfa_color.dialog != NULL)
|
||||
{
|
||||
gtk_widget_destroy (script->arg_values[i].sfa_color.dialog);
|
||||
script->arg_values[i].sfa_color.dialog = NULL;
|
||||
}
|
||||
break;
|
||||
case SF_FILENAME:
|
||||
break;
|
||||
|
@ -1674,9 +1617,9 @@ script_fu_ok_callback (GtkWidget *widget,
|
|||
break;
|
||||
case SF_COLOR:
|
||||
sprintf (buffer, "'(%d %d %d)",
|
||||
(gint32) (script->arg_values[i].sfa_color.color[0] * 255.999),
|
||||
(gint32) (script->arg_values[i].sfa_color.color[1] * 255.999),
|
||||
(gint32) (script->arg_values[i].sfa_color.color[2] * 255.999));
|
||||
script->arg_values[i].sfa_color[0],
|
||||
script->arg_values[i].sfa_color[1],
|
||||
script->arg_values[i].sfa_color[2]);
|
||||
text = buffer;
|
||||
break;
|
||||
case SF_TOGGLE:
|
||||
|
@ -1950,12 +1893,11 @@ script_fu_reset_callback (GtkWidget *widget,
|
|||
case SF_CHANNEL:
|
||||
break;
|
||||
case SF_COLOR:
|
||||
for (j = 0; j < 4; j++)
|
||||
for (j = 0; j < 3; j++)
|
||||
{
|
||||
script->arg_values[i].sfa_color.color[j] = script->arg_defaults[i].sfa_color.color[j];
|
||||
script->arg_values[i].sfa_color[j] = script->arg_defaults[i].sfa_color[j];
|
||||
}
|
||||
script_fu_color_preview (script->arg_values[i].sfa_color.preview,
|
||||
script->arg_values[i].sfa_color.color);
|
||||
gimp_color_button_update (GIMP_COLOR_BUTTON (script->args_widgets[i]));
|
||||
break;
|
||||
case SF_TOGGLE:
|
||||
script->arg_values[i].sfa_toggle = script->arg_defaults[i].sfa_toggle;
|
||||
|
@ -2028,94 +1970,6 @@ script_fu_toggle_update (GtkWidget *widget,
|
|||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
script_fu_color_preview_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GtkColorSelectionDialog *csd;
|
||||
SFColor *color;
|
||||
|
||||
color = (SFColor *) data;
|
||||
color->old_color[0] = color->color[0];
|
||||
color->old_color[1] = color->color[1];
|
||||
color->old_color[2] = color->color[2];
|
||||
|
||||
if (!color->dialog)
|
||||
{
|
||||
color->dialog =
|
||||
gtk_color_selection_dialog_new (_("Script-Fu Color Picker"));
|
||||
csd = GTK_COLOR_SELECTION_DIALOG (color->dialog);
|
||||
|
||||
gtk_widget_destroy (csd->help_button);
|
||||
|
||||
gtk_signal_connect_object (GTK_OBJECT (csd->ok_button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_hide,
|
||||
GTK_OBJECT (color->dialog));
|
||||
gtk_signal_connect (GTK_OBJECT (csd), "delete_event",
|
||||
(GtkSignalFunc) script_fu_color_preview_delete,
|
||||
color);
|
||||
gtk_signal_connect (GTK_OBJECT (csd), "destroy",
|
||||
gtk_widget_destroyed, &color->dialog);
|
||||
gtk_signal_connect (GTK_OBJECT (csd->cancel_button), "clicked",
|
||||
(GtkSignalFunc) script_fu_color_preview_cancel,
|
||||
color);
|
||||
gtk_signal_connect (GTK_OBJECT (csd->colorsel), "color_changed",
|
||||
(GtkSignalFunc) script_fu_color_preview_changed,
|
||||
color);
|
||||
|
||||
/* call here so the old color is set */
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel),
|
||||
color->color);
|
||||
}
|
||||
else
|
||||
csd = GTK_COLOR_SELECTION_DIALOG (color->dialog);
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (csd->colorsel),
|
||||
color->color);
|
||||
|
||||
gtk_window_position (GTK_WINDOW (color->dialog), GTK_WIN_POS_MOUSE);
|
||||
gtk_widget_show (color->dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_color_preview_changed (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
SFColor *color;
|
||||
|
||||
color = (SFColor *) data;
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (GTK_COLOR_SELECTION_DIALOG (color->dialog)->colorsel),
|
||||
color->color);
|
||||
script_fu_color_preview (color->preview, color->color);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_color_preview_cancel (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
SFColor *color;
|
||||
|
||||
color = (SFColor *) data;
|
||||
|
||||
gtk_widget_hide (color->dialog);
|
||||
|
||||
color->color[0] = color->old_color[0];
|
||||
color->color[1] = color->old_color[1];
|
||||
color->color[2] = color->old_color[2];
|
||||
|
||||
script_fu_color_preview (color->preview, color->color);
|
||||
}
|
||||
|
||||
static gint
|
||||
script_fu_color_preview_delete (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
gpointer data)
|
||||
{
|
||||
script_fu_color_preview_cancel (widget, data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_file_selection_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
|
|
@ -23,6 +23,7 @@ plug-ins/common/c_astretch.c
|
|||
plug-ins/common/checkerboard.c
|
||||
plug-ins/common/colorify.c
|
||||
plug-ins/common/color_enhance.c
|
||||
plug-ins/common/colortoalpha.c
|
||||
plug-ins/common/compose.c
|
||||
plug-ins/common/convmatrix.c
|
||||
plug-ins/common/cubism.c
|
||||
|
|
|
@ -121,10 +121,10 @@ app/transform_tool.c
|
|||
app/undo_history.c
|
||||
app/undo.c
|
||||
app/xcf.c
|
||||
libgimp/gimpintl.h
|
||||
libgimp/gimpunit.c
|
||||
libgimp/gimpfileselection.c
|
||||
libgimp/gimpcolorbutton.c
|
||||
libgimp/gimpenv.c
|
||||
libgimp/gimpunitmenu.c
|
||||
libgimp/gimpexport.c
|
||||
libgimp/gimpfileselection.c
|
||||
libgimp/gimpunit.c
|
||||
libgimp/gimpunitmenu.c
|
||||
|
||||
|
|
Loading…
Reference in New Issue