mirror of https://github.com/GNOME/gimp.git
libgimp/Makefile.am libgimp/gimp.h libgimp/gimpui.h
2004-07-27 Michael Natterer <mitch@gimp.org> * libgimp/Makefile.am * libgimp/gimp.h * libgimp/gimpui.h * libgimp/gimppalettemenu.[ch] * libgimp/gimppaletteselect.[ch]: added palette select wrapper and widget (straight copy & string replace of the font select stuff). Fixes bug #136130. * plug-ins/script-fu/script-fu-enums.h * plug-ins/script-fu/script-fu-scripts.c * plug-ins/script-fu/siod-wrapper.c: added SF_PALETTE so it can be used in scripts. * plug-ins/script-fu/scripts/test-sphere.scm: added a palette parameter to the test script.
This commit is contained in:
parent
9b5862e79b
commit
820b4d247b
18
ChangeLog
18
ChangeLog
|
@ -1,3 +1,21 @@
|
|||
2004-07-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* libgimp/Makefile.am
|
||||
* libgimp/gimp.h
|
||||
* libgimp/gimpui.h
|
||||
* libgimp/gimppalettemenu.[ch]
|
||||
* libgimp/gimppaletteselect.[ch]: added palette select wrapper and
|
||||
widget (straight copy & string replace of the font select stuff).
|
||||
Fixes bug #136130.
|
||||
|
||||
* plug-ins/script-fu/script-fu-enums.h
|
||||
* plug-ins/script-fu/script-fu-scripts.c
|
||||
* plug-ins/script-fu/siod-wrapper.c: added SF_PALETTE so it can
|
||||
be used in scripts.
|
||||
|
||||
* plug-ins/script-fu/scripts/test-sphere.scm: added a palette
|
||||
parameter to the test script.
|
||||
|
||||
2004-07-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage.c (gimp_image_finalize): remove the image
|
||||
|
|
|
@ -175,6 +175,8 @@ libgimp_2_0_la_SOURCES = \
|
|||
gimpimage.h \
|
||||
gimplayer.c \
|
||||
gimplayer.h \
|
||||
gimppaletteselect.c \
|
||||
gimppaletteselect.h \
|
||||
gimppatternselect.c \
|
||||
gimppatternselect.h \
|
||||
gimppixelfetcher.c \
|
||||
|
@ -208,6 +210,8 @@ libgimpui_2_0_la_SOURCES = \
|
|||
gimpfontmenu.h \
|
||||
gimpgradientmenu.c \
|
||||
gimpgradientmenu.h \
|
||||
gimppalettemenu.c \
|
||||
gimppalettemenu.h \
|
||||
gimppatternmenu.c \
|
||||
gimppatternmenu.h \
|
||||
gimpdrawablecombobox.c \
|
||||
|
@ -232,6 +236,7 @@ gimpinclude_HEADERS = \
|
|||
gimpgradientselect.h \
|
||||
gimpimage.h \
|
||||
gimplayer.h \
|
||||
gimppaletteselect.h \
|
||||
gimppatternselect.h \
|
||||
gimppixelfetcher.h \
|
||||
gimppixelrgn.h \
|
||||
|
@ -247,6 +252,7 @@ gimpinclude_HEADERS = \
|
|||
gimpbrushmenu.h \
|
||||
gimpfontmenu.h \
|
||||
gimpgradientmenu.h \
|
||||
gimppalettemenu.h \
|
||||
gimppatternmenu.h \
|
||||
gimppixbuf.h \
|
||||
gimpdrawablecombobox.h \
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include <libgimp/gimpgradientselect.h>
|
||||
#include <libgimp/gimpimage.h>
|
||||
#include <libgimp/gimplayer.h>
|
||||
#include <libgimp/gimppaletteselect.h>
|
||||
#include <libgimp/gimppatternselect.h>
|
||||
#include <libgimp/gimppixelfetcher.h>
|
||||
#include <libgimp/gimppixelrgn.h>
|
||||
|
|
|
@ -0,0 +1,228 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimppalettemenu.c
|
||||
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpui.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
|
||||
#define PALETTE_SELECT_DATA_KEY "gimp-palette-selct-data"
|
||||
|
||||
|
||||
typedef struct _PaletteSelect PaletteSelect;
|
||||
|
||||
struct _PaletteSelect
|
||||
{
|
||||
gchar *title;
|
||||
GimpRunPaletteCallback callback;
|
||||
gpointer data;
|
||||
|
||||
GtkWidget *button;
|
||||
GtkWidget *label;
|
||||
|
||||
gchar *palette_name; /* Local copy */
|
||||
|
||||
const gchar *temp_palette_callback;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_palette_select_widget_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void gimp_palette_select_widget_clicked (GtkWidget *widget,
|
||||
PaletteSelect *palette_sel);
|
||||
static void gimp_palette_select_widget_destroy (GtkWidget *widget,
|
||||
PaletteSelect *palette_sel);
|
||||
|
||||
|
||||
/**
|
||||
* gimp_palette_select_widget_new:
|
||||
* @title: Title of the dialog to use or %NULL means to use the default
|
||||
* title.
|
||||
* @palette_name: Initial palette name.
|
||||
* @callback: A function to call when the selected palette changes.
|
||||
* @data: A pointer to arbitary data to be used in the call to @callback.
|
||||
*
|
||||
* Creates a new #GtkWidget that completely controls the selection of
|
||||
* a palette. This widget is suitable for placement in a table in a
|
||||
* plug-in dialog.
|
||||
*
|
||||
* Returns: A #GtkWidget that you can use in your UI.
|
||||
*/
|
||||
GtkWidget *
|
||||
gimp_palette_select_widget_new (const gchar *title,
|
||||
const gchar *palette_name,
|
||||
GimpRunPaletteCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
PaletteSelect *palette_sel;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *image;
|
||||
|
||||
g_return_val_if_fail (callback != NULL, NULL);
|
||||
|
||||
if (! title)
|
||||
title = _("Palette Selection");
|
||||
|
||||
palette_sel = g_new0 (PaletteSelect, 1);
|
||||
|
||||
palette_sel->title = g_strdup (title);
|
||||
palette_sel->callback = callback;
|
||||
palette_sel->data = data;
|
||||
|
||||
palette_sel->palette_name = g_strdup (palette_name);
|
||||
|
||||
palette_sel->button = gtk_button_new ();
|
||||
|
||||
g_signal_connect (palette_sel->button, "clicked",
|
||||
G_CALLBACK (gimp_palette_select_widget_clicked),
|
||||
palette_sel);
|
||||
g_signal_connect (palette_sel->button, "destroy",
|
||||
G_CALLBACK (gimp_palette_select_widget_destroy),
|
||||
palette_sel);
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 4);
|
||||
gtk_container_add (GTK_CONTAINER (palette_sel->button), hbox);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
palette_sel->label = gtk_label_new (palette_name);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), palette_sel->label, TRUE, TRUE, 4);
|
||||
gtk_widget_show (palette_sel->label);
|
||||
|
||||
image = gtk_image_new_from_stock (GIMP_STOCK_PALETTE, GTK_ICON_SIZE_BUTTON);
|
||||
gtk_box_pack_end (GTK_BOX (hbox), image, FALSE, FALSE, 4);
|
||||
gtk_widget_show (image);
|
||||
|
||||
g_object_set_data (G_OBJECT (palette_sel->button),
|
||||
PALETTE_SELECT_DATA_KEY, palette_sel);
|
||||
|
||||
return palette_sel->button;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_palette_select_widget_close:
|
||||
* @widget: A palette select widget.
|
||||
*
|
||||
* Closes the popup window associated with @widget.
|
||||
*/
|
||||
void
|
||||
gimp_palette_select_widget_close (GtkWidget *widget)
|
||||
{
|
||||
PaletteSelect *palette_sel;
|
||||
|
||||
palette_sel = g_object_get_data (G_OBJECT (widget), PALETTE_SELECT_DATA_KEY);
|
||||
|
||||
g_return_if_fail (palette_sel != NULL);
|
||||
|
||||
if (palette_sel->temp_palette_callback)
|
||||
{
|
||||
gimp_palette_select_destroy (palette_sel->temp_palette_callback);
|
||||
palette_sel->temp_palette_callback = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_palette_select_widget_set;
|
||||
* @widget: A palette select widget.
|
||||
* @palette_name: Palette name to set; %NULL means no change.
|
||||
*
|
||||
* Sets the current palette for the palette select widget. Calls the
|
||||
* callback function if one was supplied in the call to
|
||||
* gimp_palette_select_widget_new().
|
||||
*/
|
||||
void
|
||||
gimp_palette_select_widget_set (GtkWidget *widget,
|
||||
const gchar *palette_name)
|
||||
{
|
||||
PaletteSelect *palette_sel;
|
||||
|
||||
palette_sel = g_object_get_data (G_OBJECT (widget), PALETTE_SELECT_DATA_KEY);
|
||||
|
||||
g_return_if_fail (palette_sel != NULL);
|
||||
|
||||
if (palette_sel->temp_palette_callback)
|
||||
gimp_palettes_set_popup (palette_sel->temp_palette_callback, palette_name);
|
||||
else
|
||||
gimp_palette_select_widget_callback (palette_name, FALSE, palette_sel);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_palette_select_widget_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
PaletteSelect *palette_sel = (PaletteSelect *) data;
|
||||
|
||||
g_free (palette_sel->palette_name);
|
||||
palette_sel->palette_name = g_strdup (name);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (palette_sel->label), name);
|
||||
|
||||
if (palette_sel->callback)
|
||||
palette_sel->callback (name, closing, palette_sel->data);
|
||||
|
||||
if (closing)
|
||||
palette_sel->temp_palette_callback = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_select_widget_clicked (GtkWidget *widget,
|
||||
PaletteSelect *palette_sel)
|
||||
{
|
||||
if (palette_sel->temp_palette_callback)
|
||||
{
|
||||
/* calling gimp_palettes_set_popup() raises the dialog */
|
||||
gimp_palettes_set_popup (palette_sel->temp_palette_callback,
|
||||
palette_sel->palette_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
palette_sel->temp_palette_callback =
|
||||
gimp_palette_select_new (palette_sel->title,
|
||||
palette_sel->palette_name,
|
||||
gimp_palette_select_widget_callback,
|
||||
palette_sel);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_palette_select_widget_destroy (GtkWidget *widget,
|
||||
PaletteSelect *palette_sel)
|
||||
{
|
||||
if (palette_sel->temp_palette_callback)
|
||||
{
|
||||
gimp_palette_select_destroy (palette_sel->temp_palette_callback);
|
||||
palette_sel->temp_palette_callback = NULL;
|
||||
}
|
||||
|
||||
g_free (palette_sel->title);
|
||||
g_free (palette_sel->palette_name);
|
||||
g_free (palette_sel);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimppalettemenu.h
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PALETTE_MENU_H__
|
||||
#define __GIMP_PALETTE_MENU_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
GtkWidget * gimp_palette_select_widget_new (const gchar *title,
|
||||
const gchar *palette_name,
|
||||
GimpRunPaletteCallback callback,
|
||||
gpointer data);
|
||||
|
||||
void gimp_palette_select_widget_close (GtkWidget *widget);
|
||||
void gimp_palette_select_widget_set (GtkWidget *widget,
|
||||
const gchar *palette_name);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_PALETTE_MENU_H__ */
|
|
@ -0,0 +1,201 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimppaletteselect.c
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
|
||||
|
||||
typedef struct _GimpPaletteData GimpPaletteData;
|
||||
|
||||
struct _GimpPaletteData
|
||||
{
|
||||
gchar *palette_callback;
|
||||
guint idle_id;
|
||||
gchar *palette_name;
|
||||
GimpRunPaletteCallback callback;
|
||||
gboolean closing;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_temp_palette_run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
static gboolean gimp_temp_palette_run_idle (GimpPaletteData *palette_data);
|
||||
|
||||
|
||||
/* private variables */
|
||||
|
||||
static GHashTable *gimp_palette_select_ht = NULL;
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
const gchar *
|
||||
gimp_palette_select_new (const gchar *title,
|
||||
const gchar *palette_name,
|
||||
GimpRunPaletteCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
static GimpParamDef args[] =
|
||||
{
|
||||
{ GIMP_PDB_STRING, "str", "String" },
|
||||
{ GIMP_PDB_INT32, "dialog status", "If the dialog was closing "
|
||||
"[0 = No, 1 = Yes]" },
|
||||
};
|
||||
|
||||
gchar *palette_callback = gimp_procedural_db_temp_name ();
|
||||
|
||||
gimp_install_temp_proc (palette_callback,
|
||||
"Temporary palette popup callback procedure",
|
||||
"",
|
||||
"Michael Natterer",
|
||||
"Michael Natterer",
|
||||
"2004",
|
||||
NULL,
|
||||
"RGB*, GRAY*",
|
||||
GIMP_TEMPORARY,
|
||||
G_N_ELEMENTS (args), 0,
|
||||
args, NULL,
|
||||
gimp_temp_palette_run);
|
||||
|
||||
if (gimp_palettes_popup (palette_callback, title, palette_name))
|
||||
{
|
||||
GimpPaletteData *palette_data;
|
||||
|
||||
gimp_extension_enable (); /* Allow callbacks to be watched */
|
||||
|
||||
/* Now add to hash table so we can find it again */
|
||||
if (! gimp_palette_select_ht)
|
||||
gimp_palette_select_ht = g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, g_free);
|
||||
|
||||
palette_data = g_new0 (GimpPaletteData, 1);
|
||||
|
||||
palette_data->palette_callback = palette_callback;
|
||||
palette_data->callback = callback;
|
||||
palette_data->data = data;
|
||||
|
||||
g_hash_table_insert (gimp_palette_select_ht,
|
||||
palette_callback, palette_data);
|
||||
|
||||
return palette_callback;
|
||||
}
|
||||
|
||||
gimp_uninstall_temp_proc (palette_callback);
|
||||
g_free (palette_callback);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_palette_select_destroy (const gchar *palette_callback)
|
||||
{
|
||||
GimpPaletteData *palette_data;
|
||||
|
||||
g_return_if_fail (palette_callback != NULL);
|
||||
g_return_if_fail (gimp_palette_select_ht != NULL);
|
||||
|
||||
palette_data = g_hash_table_lookup (gimp_palette_select_ht, palette_callback);
|
||||
|
||||
if (! palette_data)
|
||||
{
|
||||
g_warning ("Can't find internal palette data");
|
||||
return;
|
||||
}
|
||||
|
||||
if (palette_data->idle_id)
|
||||
{
|
||||
g_source_remove (palette_data->idle_id);
|
||||
g_free (palette_data->palette_name);
|
||||
}
|
||||
|
||||
if (palette_data->palette_callback)
|
||||
gimp_palettes_close_popup (palette_data->palette_callback);
|
||||
|
||||
gimp_uninstall_temp_proc (palette_callback);
|
||||
|
||||
g_hash_table_remove (gimp_palette_select_ht, palette_callback);
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
gimp_temp_palette_run (const gchar *name,
|
||||
gint nparams,
|
||||
const GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[1];
|
||||
GimpPaletteData *palette_data;
|
||||
|
||||
palette_data = g_hash_table_lookup (gimp_palette_select_ht, name);
|
||||
|
||||
if (! palette_data)
|
||||
{
|
||||
g_warning ("Can't find internal palette data");
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (palette_data->palette_name);
|
||||
|
||||
palette_data->palette_name = g_strdup (param[0].data.d_string);
|
||||
palette_data->closing = param[1].data.d_int32;
|
||||
|
||||
if (! palette_data->idle_id)
|
||||
palette_data->idle_id = g_idle_add ((GSourceFunc) gimp_temp_palette_run_idle,
|
||||
palette_data);
|
||||
}
|
||||
|
||||
*nreturn_vals = 1;
|
||||
*return_vals = values;
|
||||
|
||||
values[0].type = GIMP_PDB_STATUS;
|
||||
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_temp_palette_run_idle (GimpPaletteData *palette_data)
|
||||
{
|
||||
palette_data->idle_id = 0;
|
||||
|
||||
if (palette_data->callback)
|
||||
palette_data->callback (palette_data->palette_name,
|
||||
palette_data->closing,
|
||||
palette_data->data);
|
||||
|
||||
if (palette_data->closing)
|
||||
{
|
||||
gchar *palette_callback = palette_data->palette_callback;
|
||||
|
||||
palette_data->palette_callback = NULL;
|
||||
gimp_palette_select_destroy (palette_callback);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimppaletteselect.h
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_PALETTE_SELECT_H__
|
||||
#define __GIMP_PALETTE_SELECT_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
typedef void (* GimpRunPaletteCallback) (const gchar *palette_name,
|
||||
gboolean dialog_closing,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
const gchar * gimp_palette_select_new (const gchar *title,
|
||||
const gchar *palette_name,
|
||||
GimpRunPaletteCallback callback,
|
||||
gpointer data);
|
||||
void gimp_palette_select_destroy (const gchar *palette_callback);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_PALETTE_SELECT_H__ */
|
|
@ -31,6 +31,7 @@
|
|||
#include <libgimp/gimpbrushmenu.h>
|
||||
#include <libgimp/gimpfontmenu.h>
|
||||
#include <libgimp/gimpgradientmenu.h>
|
||||
#include <libgimp/gimppalettemenu.h>
|
||||
#include <libgimp/gimppatternmenu.h>
|
||||
#include <libgimp/gimppixbuf.h>
|
||||
#include <libgimp/gimpdrawablecombobox.h>
|
||||
|
|
|
@ -397,6 +397,7 @@ init_constants (void)
|
|||
setvar (cintern ("SF-BRUSH"), flocons (SF_BRUSH), NIL);
|
||||
setvar (cintern ("SF-GRADIENT"), flocons (SF_GRADIENT), NIL);
|
||||
setvar (cintern ("SF-OPTION"), flocons (SF_OPTION), NIL);
|
||||
setvar (cintern ("SF-PALETTE"), flocons (SF_PALETTE), NIL);
|
||||
|
||||
/* for SF_ADJUSTMENT */
|
||||
setvar (cintern ("SF-SLIDER"), flocons (SF_SLIDER), NIL);
|
||||
|
|
|
@ -38,13 +38,14 @@ typedef enum
|
|||
SF_GRADIENT,
|
||||
SF_FILENAME,
|
||||
SF_DIRNAME,
|
||||
SF_OPTION
|
||||
SF_OPTION,
|
||||
SF_PALETTE
|
||||
} SFArgType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SF_SLIDER = 0,
|
||||
SF_SPINNER
|
||||
SF_SPINNER
|
||||
} SFAdjustmentType;
|
||||
|
||||
#endif /* __SCRIPT_FU_ENUMS__ */
|
||||
|
|
|
@ -100,6 +100,7 @@ typedef union
|
|||
SFFilename sfa_file;
|
||||
gchar *sfa_font;
|
||||
gchar *sfa_gradient;
|
||||
gchar *sfa_palette;
|
||||
gchar *sfa_pattern;
|
||||
SFBrush sfa_brush;
|
||||
SFOption sfa_option;
|
||||
|
@ -191,6 +192,9 @@ static void script_fu_gradient_callback (const gchar *name,
|
|||
static void script_fu_font_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_palette_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
gint spacing,
|
||||
|
@ -539,6 +543,19 @@ script_fu_add_script (LISP a)
|
|||
args[i + 1].description = script->arg_labels[i];
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
if (!TYPEP (car (a), tc_string))
|
||||
return my_err ("script-fu-register: palette defaults must be string values", NIL);
|
||||
script->arg_defaults[i].sfa_palette =
|
||||
g_strdup (get_c_string (car (a)));
|
||||
script->arg_values[i].sfa_palette =
|
||||
g_strdup (script->arg_defaults[i].sfa_palette);
|
||||
|
||||
args[i + 1].type = GIMP_PDB_STRING;
|
||||
args[i + 1].name = "palette";
|
||||
args[i + 1].description = script->arg_labels[i];
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
if (!TYPEP (car (a), tc_string))
|
||||
return my_err ("script-fu-register: pattern defaults must be string values", NIL);
|
||||
|
@ -835,6 +852,7 @@ script_fu_script_proc (const gchar *name,
|
|||
break;
|
||||
|
||||
case SF_FONT:
|
||||
case SF_PALETTE:
|
||||
case SF_PATTERN:
|
||||
case SF_GRADIENT:
|
||||
case SF_BRUSH:
|
||||
|
@ -905,6 +923,7 @@ script_fu_script_proc (const gchar *name,
|
|||
break;
|
||||
|
||||
case SF_FONT:
|
||||
case SF_PALETTE:
|
||||
case SF_PATTERN:
|
||||
case SF_GRADIENT:
|
||||
case SF_BRUSH:
|
||||
|
@ -1034,6 +1053,11 @@ script_fu_free_script (SFScript *script)
|
|||
g_free (script->arg_values[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
g_free (script->arg_defaults[i].sfa_palette);
|
||||
g_free (script->arg_values[i].sfa_palette);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
g_free (script->arg_defaults[i].sfa_pattern);
|
||||
g_free (script->arg_values[i].sfa_pattern);
|
||||
|
@ -1329,6 +1353,13 @@ script_fu_interface (SFScript *script)
|
|||
&script->arg_values[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
widget = gimp_palette_select_widget_new (_("Script-Fu Palette Selection"),
|
||||
script->arg_values[i].sfa_palette,
|
||||
script_fu_palette_callback,
|
||||
&script->arg_values[i].sfa_palette);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
leftalign = TRUE;
|
||||
widget = gimp_pattern_select_widget_new (_("Script-fu Pattern Selection"),
|
||||
|
@ -1418,6 +1449,10 @@ script_fu_interface_quit (SFScript *script)
|
|||
gimp_font_select_widget_close (sf_interface->args_widgets[i]);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
gimp_palette_select_widget_close (sf_interface->args_widgets[i]);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
gimp_pattern_select_widget_close (sf_interface->args_widgets[i]);
|
||||
break;
|
||||
|
@ -1488,6 +1523,17 @@ script_fu_font_callback (const gchar *name,
|
|||
*fname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_palette_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **fname = data;
|
||||
|
||||
g_free (*fname);
|
||||
*fname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
|
@ -1592,6 +1638,10 @@ script_fu_ok (SFScript *script)
|
|||
length += strlen (script->arg_values[i].sfa_font) + 3;
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
length += strlen (script->arg_values[i].sfa_palette) + 3;
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
length += strlen (script->arg_values[i].sfa_pattern) + 3;
|
||||
break;
|
||||
|
@ -1698,6 +1748,12 @@ script_fu_ok (SFScript *script)
|
|||
text = buffer;
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
||||
script->arg_values[i].sfa_palette);
|
||||
text = buffer;
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
||||
script->arg_values[i].sfa_pattern);
|
||||
|
@ -1813,6 +1869,11 @@ script_fu_reset (SFScript *script)
|
|||
script->arg_defaults[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
gimp_palette_select_widget_set (widget,
|
||||
script->arg_defaults[i].sfa_palette);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
gimp_pattern_select_widget_set (widget,
|
||||
script->arg_defaults[i].sfa_pattern);
|
||||
|
|
|
@ -100,6 +100,7 @@ typedef union
|
|||
SFFilename sfa_file;
|
||||
gchar *sfa_font;
|
||||
gchar *sfa_gradient;
|
||||
gchar *sfa_palette;
|
||||
gchar *sfa_pattern;
|
||||
SFBrush sfa_brush;
|
||||
SFOption sfa_option;
|
||||
|
@ -191,6 +192,9 @@ static void script_fu_gradient_callback (const gchar *name,
|
|||
static void script_fu_font_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_palette_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data);
|
||||
static void script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
gint spacing,
|
||||
|
@ -539,6 +543,19 @@ script_fu_add_script (LISP a)
|
|||
args[i + 1].description = script->arg_labels[i];
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
if (!TYPEP (car (a), tc_string))
|
||||
return my_err ("script-fu-register: palette defaults must be string values", NIL);
|
||||
script->arg_defaults[i].sfa_palette =
|
||||
g_strdup (get_c_string (car (a)));
|
||||
script->arg_values[i].sfa_palette =
|
||||
g_strdup (script->arg_defaults[i].sfa_palette);
|
||||
|
||||
args[i + 1].type = GIMP_PDB_STRING;
|
||||
args[i + 1].name = "palette";
|
||||
args[i + 1].description = script->arg_labels[i];
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
if (!TYPEP (car (a), tc_string))
|
||||
return my_err ("script-fu-register: pattern defaults must be string values", NIL);
|
||||
|
@ -835,6 +852,7 @@ script_fu_script_proc (const gchar *name,
|
|||
break;
|
||||
|
||||
case SF_FONT:
|
||||
case SF_PALETTE:
|
||||
case SF_PATTERN:
|
||||
case SF_GRADIENT:
|
||||
case SF_BRUSH:
|
||||
|
@ -905,6 +923,7 @@ script_fu_script_proc (const gchar *name,
|
|||
break;
|
||||
|
||||
case SF_FONT:
|
||||
case SF_PALETTE:
|
||||
case SF_PATTERN:
|
||||
case SF_GRADIENT:
|
||||
case SF_BRUSH:
|
||||
|
@ -1034,6 +1053,11 @@ script_fu_free_script (SFScript *script)
|
|||
g_free (script->arg_values[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
g_free (script->arg_defaults[i].sfa_palette);
|
||||
g_free (script->arg_values[i].sfa_palette);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
g_free (script->arg_defaults[i].sfa_pattern);
|
||||
g_free (script->arg_values[i].sfa_pattern);
|
||||
|
@ -1329,6 +1353,13 @@ script_fu_interface (SFScript *script)
|
|||
&script->arg_values[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
widget = gimp_palette_select_widget_new (_("Script-Fu Palette Selection"),
|
||||
script->arg_values[i].sfa_palette,
|
||||
script_fu_palette_callback,
|
||||
&script->arg_values[i].sfa_palette);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
leftalign = TRUE;
|
||||
widget = gimp_pattern_select_widget_new (_("Script-fu Pattern Selection"),
|
||||
|
@ -1418,6 +1449,10 @@ script_fu_interface_quit (SFScript *script)
|
|||
gimp_font_select_widget_close (sf_interface->args_widgets[i]);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
gimp_palette_select_widget_close (sf_interface->args_widgets[i]);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
gimp_pattern_select_widget_close (sf_interface->args_widgets[i]);
|
||||
break;
|
||||
|
@ -1488,6 +1523,17 @@ script_fu_font_callback (const gchar *name,
|
|||
*fname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_palette_callback (const gchar *name,
|
||||
gboolean closing,
|
||||
gpointer data)
|
||||
{
|
||||
gchar **fname = data;
|
||||
|
||||
g_free (*fname);
|
||||
*fname = g_strdup (name);
|
||||
}
|
||||
|
||||
static void
|
||||
script_fu_brush_callback (const gchar *name,
|
||||
gdouble opacity,
|
||||
|
@ -1592,6 +1638,10 @@ script_fu_ok (SFScript *script)
|
|||
length += strlen (script->arg_values[i].sfa_font) + 3;
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
length += strlen (script->arg_values[i].sfa_palette) + 3;
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
length += strlen (script->arg_values[i].sfa_pattern) + 3;
|
||||
break;
|
||||
|
@ -1698,6 +1748,12 @@ script_fu_ok (SFScript *script)
|
|||
text = buffer;
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
||||
script->arg_values[i].sfa_palette);
|
||||
text = buffer;
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
g_snprintf (buffer, sizeof (buffer), "\"%s\"",
|
||||
script->arg_values[i].sfa_pattern);
|
||||
|
@ -1813,6 +1869,11 @@ script_fu_reset (SFScript *script)
|
|||
script->arg_defaults[i].sfa_font);
|
||||
break;
|
||||
|
||||
case SF_PALETTE:
|
||||
gimp_palette_select_widget_set (widget,
|
||||
script->arg_defaults[i].sfa_palette);
|
||||
break;
|
||||
|
||||
case SF_PATTERN:
|
||||
gimp_pattern_select_widget_set (widget,
|
||||
script->arg_defaults[i].sfa_pattern);
|
||||
|
|
|
@ -229,6 +229,7 @@
|
|||
SF-TOGGLE "Gradient reverse" FALSE
|
||||
SF-FONT "Font" "Agate"
|
||||
SF-ADJUSTMENT "Font size (pixels)" '(50 1 1000 1 10 0 1)
|
||||
SF-PALETTE "Palette" "Default"
|
||||
SF-FILENAME "Environment map"
|
||||
(string-append ""
|
||||
gimp-data-dir
|
||||
|
|
|
@ -397,6 +397,7 @@ init_constants (void)
|
|||
setvar (cintern ("SF-BRUSH"), flocons (SF_BRUSH), NIL);
|
||||
setvar (cintern ("SF-GRADIENT"), flocons (SF_GRADIENT), NIL);
|
||||
setvar (cintern ("SF-OPTION"), flocons (SF_OPTION), NIL);
|
||||
setvar (cintern ("SF-PALETTE"), flocons (SF_PALETTE), NIL);
|
||||
|
||||
/* for SF_ADJUSTMENT */
|
||||
setvar (cintern ("SF-SLIDER"), flocons (SF_SLIDER), NIL);
|
||||
|
|
Loading…
Reference in New Issue