mirror of https://github.com/GNOME/gimp.git
Allow plug-ins to register in <Layers>, <Channels>, <Vectors> and
2006-06-16 Michael Natterer <mitch@gimp.org> Allow plug-ins to register in <Layers>, <Channels>, <Vectors> and <ColormapEditor>: * app/pdb/gimppluginprocedure.c (gimp_plug_in_procedure_add_menu_path): added the argument type checks for the new locations. Factored out duplicated code. * app/menus/menus.c (menus_init): add the "plug-in" action group to the resp. UI managers. * app/menus/plug-in-menus.c (plug_in_menus_menu_path_added): support them here too. * app/widgets/gimpimageeditor.[ch] * app/widgets/gimpitemtreeview.[ch]: added get_image() functions. * app/actions/plug-in-commands.c: added new utility functions which collect plug-in arguments from GimpImageEditor and GimpItemTreeView widgets. * menus/channels-menu.xml * menus/colormap-editor-menu.xml * menus/layers-menu.xml * menus/vectors-menu.xml: added separators. * menus/image-menu.xml.in: added a "Colormap" placeholder in Colors/Map * plug-ins/common/colormap-remap.c (query): register a menu entry in <ColormapEditor> and moved the existing one to the "Colormap" placeholder. Also register an icon to make this menu item clearly distinct from the others in that menu. Unrelated: * plug-ins/common/colormap-remap.c (run): cleaned up quite a bit. Fixed last-vals code and simplified map handling. (remap_swap): removed, folded into run(). (remap_dialog): use the passed map to initialize the dialog so it starts with the last-vals. Tweaked layout to have 16 columns and simplified cell renderer creation.
This commit is contained in:
parent
f548b65329
commit
88dedcc424
46
ChangeLog
46
ChangeLog
|
@ -1,3 +1,49 @@
|
|||
2006-06-16 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Allow plug-ins to register in <Layers>, <Channels>, <Vectors> and
|
||||
<ColormapEditor>:
|
||||
|
||||
* app/pdb/gimppluginprocedure.c
|
||||
(gimp_plug_in_procedure_add_menu_path): added the argument type
|
||||
checks for the new locations. Factored out duplicated code.
|
||||
|
||||
* app/menus/menus.c (menus_init): add the "plug-in" action
|
||||
group to the resp. UI managers.
|
||||
|
||||
* app/menus/plug-in-menus.c (plug_in_menus_menu_path_added):
|
||||
support them here too.
|
||||
|
||||
* app/widgets/gimpimageeditor.[ch]
|
||||
* app/widgets/gimpitemtreeview.[ch]: added get_image() functions.
|
||||
|
||||
* app/actions/plug-in-commands.c: added new utility functions
|
||||
which collect plug-in arguments from GimpImageEditor and
|
||||
GimpItemTreeView widgets.
|
||||
|
||||
* menus/channels-menu.xml
|
||||
* menus/colormap-editor-menu.xml
|
||||
* menus/layers-menu.xml
|
||||
* menus/vectors-menu.xml: added separators.
|
||||
|
||||
* menus/image-menu.xml.in: added a "Colormap" placeholder in
|
||||
Colors/Map
|
||||
|
||||
* plug-ins/common/colormap-remap.c (query): register a menu
|
||||
entry in <ColormapEditor> and moved the existing one to the
|
||||
"Colormap" placeholder. Also register an icon to make this
|
||||
menu item clearly distinct from the others in that menu.
|
||||
|
||||
Unrelated:
|
||||
|
||||
* plug-ins/common/colormap-remap.c (run): cleaned up quite a
|
||||
bit. Fixed last-vals code and simplified map handling.
|
||||
|
||||
(remap_swap): removed, folded into run().
|
||||
|
||||
(remap_dialog): use the passed map to initialize the dialog so it
|
||||
starts with the last-vals. Tweaked layout to have 16 columns
|
||||
and simplified cell renderer creation.
|
||||
|
||||
2006-06-16 Manish Singh <yosh@gimp.org>
|
||||
|
||||
* app/errors.c
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
#include "widgets/gimpdatafactoryview.h"
|
||||
#include "widgets/gimpfontview.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpimageeditor.h"
|
||||
#include "widgets/gimpitemtreeview.h"
|
||||
#include "widgets/gimpmessagebox.h"
|
||||
#include "widgets/gimpmessagedialog.h"
|
||||
|
||||
|
@ -59,17 +61,26 @@
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static gint plug_in_collect_data_args (GtkAction *action,
|
||||
GimpObject *object,
|
||||
GValueArray *args,
|
||||
gint n_args);
|
||||
static gint plug_in_collect_image_args (GtkAction *action,
|
||||
GimpDisplay *display,
|
||||
GValueArray *args,
|
||||
gint n_args);
|
||||
static void plug_in_reset_all_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
Gimp *gimp);
|
||||
static gint plug_in_collect_data_args (GtkAction *action,
|
||||
GimpObject *object,
|
||||
GValueArray *args,
|
||||
gint n_args);
|
||||
static gint plug_in_collect_image_args (GtkAction *action,
|
||||
GimpImage *image,
|
||||
GValueArray *args,
|
||||
gint n_args);
|
||||
static gint plug_in_collect_item_args (GtkAction *action,
|
||||
GimpImage *image,
|
||||
GimpItem *item,
|
||||
GValueArray *args,
|
||||
gint n_args);
|
||||
static gint plug_in_collect_drawable_args (GtkAction *action,
|
||||
GimpImage *image,
|
||||
GValueArray *args,
|
||||
gint n_args);
|
||||
static void plug_in_reset_all_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
Gimp *gimp);
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
@ -117,12 +128,45 @@ plug_in_run_cmd_callback (GtkAction *action,
|
|||
n_args = plug_in_collect_data_args (action, object,
|
||||
args, n_args);
|
||||
}
|
||||
else if (GIMP_IS_IMAGE_EDITOR (data))
|
||||
{
|
||||
GimpImageEditor *editor = GIMP_IMAGE_EDITOR (data);
|
||||
GimpImage *image;
|
||||
|
||||
image = gimp_image_editor_get_image (editor);
|
||||
|
||||
n_args = plug_in_collect_image_args (action, image,
|
||||
args, n_args);
|
||||
}
|
||||
else if (GIMP_IS_ITEM_TREE_VIEW (data))
|
||||
{
|
||||
GimpItemTreeView *view = GIMP_ITEM_TREE_VIEW (data);
|
||||
GimpImage *image;
|
||||
GimpItem *item;
|
||||
|
||||
image = gimp_item_tree_view_get_image (view);
|
||||
|
||||
if (image)
|
||||
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (image);
|
||||
else
|
||||
item = NULL;
|
||||
|
||||
n_args = plug_in_collect_item_args (action, image, item,
|
||||
args, n_args);
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpImage *image;
|
||||
|
||||
display = action_data_get_display (data);
|
||||
|
||||
n_args = plug_in_collect_image_args (action, display,
|
||||
args, n_args);
|
||||
if (display)
|
||||
image = display->image;
|
||||
else
|
||||
image = NULL;
|
||||
|
||||
n_args = plug_in_collect_drawable_args (action, image,
|
||||
args, n_args);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -261,24 +305,81 @@ plug_in_collect_data_args (GtkAction *action,
|
|||
|
||||
static gint
|
||||
plug_in_collect_image_args (GtkAction *action,
|
||||
GimpDisplay *display,
|
||||
GimpImage *image,
|
||||
GValueArray *args,
|
||||
gint n_args)
|
||||
{
|
||||
if (args->n_values > n_args &&
|
||||
GIMP_VALUE_HOLDS_IMAGE_ID (&args->values[n_args]))
|
||||
{
|
||||
if (display)
|
||||
if (image)
|
||||
{
|
||||
gimp_value_set_image (&args->values[n_args], display->image);
|
||||
gimp_value_set_image (&args->values[n_args], image);
|
||||
n_args++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Uh-oh, no active image for the plug-in!");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return n_args;
|
||||
}
|
||||
|
||||
static gint
|
||||
plug_in_collect_item_args (GtkAction *action,
|
||||
GimpImage *image,
|
||||
GimpItem *item,
|
||||
GValueArray *args,
|
||||
gint n_args)
|
||||
{
|
||||
if (args->n_values > n_args &&
|
||||
GIMP_VALUE_HOLDS_IMAGE_ID (&args->values[n_args]))
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
gimp_value_set_image (&args->values[n_args], image);
|
||||
n_args++;
|
||||
|
||||
if (args->n_values > n_args &&
|
||||
GIMP_VALUE_HOLDS_ITEM_ID (&args->values[n_args]))
|
||||
{
|
||||
if (item)
|
||||
{
|
||||
gimp_value_set_item (&args->values[n_args], item);
|
||||
n_args++;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning ("Uh-oh, no active item for the plug-in!");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return n_args;
|
||||
}
|
||||
|
||||
static gint
|
||||
plug_in_collect_drawable_args (GtkAction *action,
|
||||
GimpImage *image,
|
||||
GValueArray *args,
|
||||
gint n_args)
|
||||
{
|
||||
if (args->n_values > n_args &&
|
||||
GIMP_VALUE_HOLDS_IMAGE_ID (&args->values[n_args]))
|
||||
{
|
||||
if (image)
|
||||
{
|
||||
gimp_value_set_image (&args->values[n_args], image);
|
||||
n_args++;
|
||||
|
||||
if (args->n_values > n_args &&
|
||||
GIMP_VALUE_HOLDS_DRAWABLE_ID (&args->values[n_args]))
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
|
||||
drawable = gimp_image_active_drawable (display->image);
|
||||
GimpDrawable *drawable = gimp_image_active_drawable (image);
|
||||
|
||||
if (drawable)
|
||||
{
|
||||
|
|
|
@ -157,23 +157,26 @@ menus_init (Gimp *gimp,
|
|||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<Layers>",
|
||||
"layers",
|
||||
"plug-in",
|
||||
NULL,
|
||||
"/layers-popup",
|
||||
"layers-menu.xml", NULL,
|
||||
"layers-menu.xml", plug_in_menus_setup,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<Channels>",
|
||||
"channels",
|
||||
"plug-in",
|
||||
NULL,
|
||||
"/channels-popup",
|
||||
"channels-menu.xml", NULL,
|
||||
"channels-menu.xml", plug_in_menus_setup,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<Vectors>",
|
||||
"vectors",
|
||||
"plug-in",
|
||||
NULL,
|
||||
"/vectors-popup",
|
||||
"vectors-menu.xml", NULL,
|
||||
"vectors-menu.xml", plug_in_menus_setup,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<Dockable>",
|
||||
|
@ -283,9 +286,10 @@ menus_init (Gimp *gimp,
|
|||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<ColormapEditor>",
|
||||
"colormap-editor",
|
||||
"plug-in",
|
||||
NULL,
|
||||
"/colormap-editor-popup",
|
||||
"colormap-editor-menu.xml", NULL,
|
||||
"colormap-editor-menu.xml", plug_in_menus_setup,
|
||||
NULL);
|
||||
|
||||
gimp_menu_factory_manager_register (global_menu_factory, "<SelectionEditor>",
|
||||
|
|
|
@ -304,6 +304,26 @@ plug_in_menus_menu_path_added (GimpPlugInProcedure *plug_in_proc,
|
|||
plug_in_menus_add_proc (manager, "/toolbox-menubar",
|
||||
plug_in_proc, menu_path);
|
||||
}
|
||||
else if (! strcmp (manager->name, "<Layers>"))
|
||||
{
|
||||
plug_in_menus_add_proc (manager, "/layers-popup",
|
||||
plug_in_proc, menu_path);
|
||||
}
|
||||
else if (! strcmp (manager->name, "<Channels>"))
|
||||
{
|
||||
plug_in_menus_add_proc (manager, "/channels-popup",
|
||||
plug_in_proc, menu_path);
|
||||
}
|
||||
else if (! strcmp (manager->name, "<Vectors>"))
|
||||
{
|
||||
plug_in_menus_add_proc (manager, "/vectors-popup",
|
||||
plug_in_proc, menu_path);
|
||||
}
|
||||
else if (! strcmp (manager->name, "<ColormapEditor>"))
|
||||
{
|
||||
plug_in_menus_add_proc (manager, "/colormap-editor-popup",
|
||||
plug_in_proc, menu_path);
|
||||
}
|
||||
else if (! strcmp (manager->name, "<Brushes>"))
|
||||
{
|
||||
plug_in_menus_add_proc (manager, "/brushes-popup",
|
||||
|
|
|
@ -297,6 +297,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
GimpProcedure *procedure;
|
||||
gchar *basename = NULL;
|
||||
gchar *prefix;
|
||||
const gchar *required = NULL;
|
||||
gchar *p;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), FALSE);
|
||||
|
@ -317,16 +318,40 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
if ((procedure->num_args < 1) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install %s procedure \"%s\" "
|
||||
"which does not take the standard %s Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
prefix, GIMP_OBJECT (proc)->name, prefix);
|
||||
required = "INT32";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
else if (strcmp (prefix, "<Layers>") == 0 ||
|
||||
strcmp (prefix, "<Channels>") == 0)
|
||||
{
|
||||
if ((procedure->num_args < 3) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]) ||
|
||||
! GIMP_IS_PARAM_SPEC_DRAWABLE_ID (procedure->args[2]))
|
||||
{
|
||||
required = "INT32, IMAGE, DRAWABLE";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
else if (strcmp (prefix, "<Vectors>") == 0)
|
||||
{
|
||||
if ((procedure->num_args < 3) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]) ||
|
||||
! GIMP_IS_PARAM_SPEC_VECTORS_ID (procedure->args[2]))
|
||||
{
|
||||
required = "INT32, IMAGE, VECTORS";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
else if (strcmp (prefix, "<ColormapEditor>") == 0)
|
||||
{
|
||||
if ((procedure->num_args < 2) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]))
|
||||
{
|
||||
required = "INT32, IMAGE";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -337,32 +362,14 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
|
||||
! G_IS_PARAM_SPEC_STRING (procedure->args[2]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install <Load> procedure \"%s\" "
|
||||
"which does not take the standard <Load> Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32, STRING, STRING)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name);
|
||||
required = "INT32, STRING, STRING";
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if ((procedure->num_values < 1) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->values[0]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install <Load> procedure \"%s\" "
|
||||
"which does not return the standard <Load> Plug-In "
|
||||
"values.\n"
|
||||
"(IMAGE)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name);
|
||||
required = "IMAGE";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -375,16 +382,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
! G_IS_PARAM_SPEC_STRING (procedure->args[3]) ||
|
||||
! G_IS_PARAM_SPEC_STRING (procedure->args[4]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install <Save> procedure \"%s\" "
|
||||
"which does not take the standard <Save> Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32, IMAGE, DRAWABLE, STRING, STRING)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name);
|
||||
required = "INT32, IMAGE, DRAWABLE, STRING, STRING";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -398,16 +396,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
if ((procedure->num_args < 1) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install %s procedure \"%s\" "
|
||||
"which does not take the standard %s Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
prefix, GIMP_OBJECT (proc)->name, prefix);
|
||||
required = "INT32";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -420,9 +409,10 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
"attempted to install procedure \"%s\" "
|
||||
"in the invalid menu location \"%s\".\n"
|
||||
"Use either \"<Toolbox>\", \"<Image>\", "
|
||||
"\"<Load>\", \"<Save>\", \"<Brushes>\", "
|
||||
"\"<Gradients>\", \"<Palettes>\", \"<Patterns>\" or "
|
||||
"\"<Buffers>\".",
|
||||
"\"<Layers>\", \"<Channels>\", \"<Vectors>\", "
|
||||
"\"<ColormapEditor>\", \"<Load>\", \"<Save>\", "
|
||||
"\"<Brushes>\", \"<Gradients>\", \"<Palettes>\", "
|
||||
"\"<Patterns>\" or \"<Buffers>\".",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name,
|
||||
menu_path);
|
||||
|
@ -458,6 +448,21 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
return TRUE;
|
||||
|
||||
failure:
|
||||
if (required)
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install %s procedure \"%s\" "
|
||||
"which does not take the standard %s Plug-In "
|
||||
"arguments.\n"
|
||||
"(%s)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
prefix, GIMP_OBJECT (proc)->name, prefix,
|
||||
required);
|
||||
}
|
||||
|
||||
g_free (prefix);
|
||||
g_free (basename);
|
||||
|
||||
|
|
|
@ -297,6 +297,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
GimpProcedure *procedure;
|
||||
gchar *basename = NULL;
|
||||
gchar *prefix;
|
||||
const gchar *required = NULL;
|
||||
gchar *p;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PLUG_IN_PROCEDURE (proc), FALSE);
|
||||
|
@ -317,16 +318,40 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
if ((procedure->num_args < 1) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install %s procedure \"%s\" "
|
||||
"which does not take the standard %s Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
prefix, GIMP_OBJECT (proc)->name, prefix);
|
||||
required = "INT32";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
else if (strcmp (prefix, "<Layers>") == 0 ||
|
||||
strcmp (prefix, "<Channels>") == 0)
|
||||
{
|
||||
if ((procedure->num_args < 3) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]) ||
|
||||
! GIMP_IS_PARAM_SPEC_DRAWABLE_ID (procedure->args[2]))
|
||||
{
|
||||
required = "INT32, IMAGE, DRAWABLE";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
else if (strcmp (prefix, "<Vectors>") == 0)
|
||||
{
|
||||
if ((procedure->num_args < 3) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]) ||
|
||||
! GIMP_IS_PARAM_SPEC_VECTORS_ID (procedure->args[2]))
|
||||
{
|
||||
required = "INT32, IMAGE, VECTORS";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
else if (strcmp (prefix, "<ColormapEditor>") == 0)
|
||||
{
|
||||
if ((procedure->num_args < 2) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->args[1]))
|
||||
{
|
||||
required = "INT32, IMAGE";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -337,32 +362,14 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
! G_IS_PARAM_SPEC_STRING (procedure->args[1]) ||
|
||||
! G_IS_PARAM_SPEC_STRING (procedure->args[2]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install <Load> procedure \"%s\" "
|
||||
"which does not take the standard <Load> Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32, STRING, STRING)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name);
|
||||
required = "INT32, STRING, STRING";
|
||||
goto failure;
|
||||
}
|
||||
|
||||
if ((procedure->num_values < 1) ||
|
||||
! GIMP_IS_PARAM_SPEC_IMAGE_ID (procedure->values[0]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install <Load> procedure \"%s\" "
|
||||
"which does not return the standard <Load> Plug-In "
|
||||
"values.\n"
|
||||
"(IMAGE)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name);
|
||||
required = "IMAGE";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -375,16 +382,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
! G_IS_PARAM_SPEC_STRING (procedure->args[3]) ||
|
||||
! G_IS_PARAM_SPEC_STRING (procedure->args[4]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install <Save> procedure \"%s\" "
|
||||
"which does not take the standard <Save> Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32, IMAGE, DRAWABLE, STRING, STRING)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name);
|
||||
required = "INT32, IMAGE, DRAWABLE, STRING, STRING";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -398,16 +396,7 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
if ((procedure->num_args < 1) ||
|
||||
! GIMP_IS_PARAM_SPEC_INT32 (procedure->args[0]))
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install %s procedure \"%s\" "
|
||||
"which does not take the standard %s Plug-In "
|
||||
"arguments.\n"
|
||||
"(INT32)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
prefix, GIMP_OBJECT (proc)->name, prefix);
|
||||
required = "INT32";
|
||||
goto failure;
|
||||
}
|
||||
}
|
||||
|
@ -420,9 +409,10 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
"attempted to install procedure \"%s\" "
|
||||
"in the invalid menu location \"%s\".\n"
|
||||
"Use either \"<Toolbox>\", \"<Image>\", "
|
||||
"\"<Load>\", \"<Save>\", \"<Brushes>\", "
|
||||
"\"<Gradients>\", \"<Palettes>\", \"<Patterns>\" or "
|
||||
"\"<Buffers>\".",
|
||||
"\"<Layers>\", \"<Channels>\", \"<Vectors>\", "
|
||||
"\"<ColormapEditor>\", \"<Load>\", \"<Save>\", "
|
||||
"\"<Brushes>\", \"<Gradients>\", \"<Palettes>\", "
|
||||
"\"<Patterns>\" or \"<Buffers>\".",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
GIMP_OBJECT (proc)->name,
|
||||
menu_path);
|
||||
|
@ -458,6 +448,21 @@ gimp_plug_in_procedure_add_menu_path (GimpPlugInProcedure *proc,
|
|||
return TRUE;
|
||||
|
||||
failure:
|
||||
if (required)
|
||||
{
|
||||
basename = g_filename_display_basename (proc->prog);
|
||||
|
||||
g_set_error (error, 0, 0,
|
||||
"Plug-In \"%s\"\n(%s)\n\n"
|
||||
"attempted to install %s procedure \"%s\" "
|
||||
"which does not take the standard %s Plug-In "
|
||||
"arguments.\n"
|
||||
"(%s)",
|
||||
basename, gimp_filename_to_utf8 (proc->prog),
|
||||
prefix, GIMP_OBJECT (proc)->name, prefix,
|
||||
required);
|
||||
}
|
||||
|
||||
g_free (prefix);
|
||||
g_free (basename);
|
||||
|
||||
|
|
|
@ -148,6 +148,14 @@ gimp_image_editor_set_image (GimpImageEditor *editor,
|
|||
}
|
||||
}
|
||||
|
||||
GimpImage *
|
||||
gimp_image_editor_get_image (GimpImageEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE_EDITOR (editor), NULL);
|
||||
|
||||
return editor->image;
|
||||
}
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
|
|
|
@ -51,10 +51,11 @@ struct _GimpImageEditorClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_image_editor_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_image_editor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void gimp_image_editor_set_image (GimpImageEditor *editor,
|
||||
GimpImage *image);
|
||||
void gimp_image_editor_set_image (GimpImageEditor *editor,
|
||||
GimpImage *image);
|
||||
GimpImage * gimp_image_editor_get_image (GimpImageEditor *editor);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_EDITOR_H__ */
|
||||
|
|
|
@ -477,6 +477,14 @@ gimp_item_tree_view_set_image (GimpItemTreeView *view,
|
|||
gimp_ui_manager_update (GIMP_EDITOR (view)->ui_manager, view);
|
||||
}
|
||||
|
||||
GimpImage *
|
||||
gimp_item_tree_view_get_image (GimpItemTreeView *view)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_ITEM_TREE_VIEW (view), NULL);
|
||||
|
||||
return view->image;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_item_tree_view_real_set_image (GimpItemTreeView *view,
|
||||
GimpImage *image)
|
||||
|
|
|
@ -115,18 +115,19 @@ struct _GimpItemTreeViewClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_item_tree_view_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_item_tree_view_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_item_tree_view_new (GType view_type,
|
||||
gint view_size,
|
||||
gint view_border_width,
|
||||
GimpImage *image,
|
||||
GimpMenuFactory *menu_facotry,
|
||||
const gchar *menu_identifier,
|
||||
const gchar *ui_identifier);
|
||||
GtkWidget * gimp_item_tree_view_new (GType view_type,
|
||||
gint view_size,
|
||||
gint view_border_width,
|
||||
GimpImage *image,
|
||||
GimpMenuFactory *menu_facotry,
|
||||
const gchar *menu_identifier,
|
||||
const gchar *ui_identifier);
|
||||
|
||||
void gimp_item_tree_view_set_image (GimpItemTreeView *view,
|
||||
GimpImage *image);
|
||||
void gimp_item_tree_view_set_image (GimpItemTreeView *view,
|
||||
GimpImage *image);
|
||||
GimpImage * gimp_item_tree_view_get_image (GimpItemTreeView *view);
|
||||
|
||||
|
||||
#endif /* __GIMP_ITEM_TREE_VIEW_H__ */
|
||||
|
|
|
@ -15,5 +15,6 @@
|
|||
<menuitem action="channels-selection-add" />
|
||||
<menuitem action="channels-selection-subtract" />
|
||||
<menuitem action="channels-selection-intersect" />
|
||||
<separator />
|
||||
</popup>
|
||||
</ui>
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
<menuitem action="colormap-editor-edit-color" />
|
||||
<menuitem action="colormap-editor-add-color-from-fg" />
|
||||
<menuitem action="colormap-editor-add-color-from-bg" />
|
||||
<separator />
|
||||
</popup>
|
||||
</ui>
|
||||
|
|
|
@ -6,5 +6,6 @@
|
|||
<menuitem action="colormap-editor-edit-color" />
|
||||
<menuitem action="colormap-editor-add-color-from-fg" />
|
||||
<menuitem action="colormap-editor-add-color-from-bg" />
|
||||
<separator />
|
||||
</popup>
|
||||
</ui>
|
||||
|
|
|
@ -467,7 +467,10 @@
|
|||
<menuitem action="drawable-levels-stretch" />
|
||||
</menu>
|
||||
<menu action="colors-components-menu" name="Components" />
|
||||
<menu action="colors-map-menu" name="Map" />
|
||||
<menu action="colors-map-menu" name="Map">
|
||||
<placeholder name="Colormap" />
|
||||
<separator />
|
||||
</menu>
|
||||
<menu action="colors-info-menu" name="Info">
|
||||
<menuitem action="dialogs-histogram" />
|
||||
</menu>
|
||||
|
|
|
@ -42,5 +42,6 @@
|
|||
<separator />
|
||||
<menuitem action="layers-merge-layers" />
|
||||
<menuitem action="layers-flatten-image" />
|
||||
<separator />
|
||||
</popup>
|
||||
</ui>
|
||||
|
|
|
@ -24,5 +24,6 @@
|
|||
<menuitem action="vectors-paste" />
|
||||
<menuitem action="vectors-export" />
|
||||
<menuitem action="vectors-import" />
|
||||
<separator />
|
||||
</popup>
|
||||
</ui>
|
||||
|
|
|
@ -53,15 +53,9 @@ static void run (const gchar *name,
|
|||
GimpParam **return_vals);
|
||||
|
||||
static gboolean remap (gint32 image_ID,
|
||||
gboolean is_non_interactive,
|
||||
gint num_colors,
|
||||
guchar *map);
|
||||
|
||||
static gboolean remap_swap (gint32 image_ID,
|
||||
guchar *map,
|
||||
guchar index1,
|
||||
guchar index2);
|
||||
|
||||
static gboolean remap_dialog (gint32 image_ID,
|
||||
guchar *map);
|
||||
|
||||
|
@ -92,7 +86,7 @@ query (void)
|
|||
|
||||
static const GimpParamDef swap_args[] =
|
||||
{
|
||||
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
|
||||
{ GIMP_PDB_INT32, "run-mode", "Non-interactive" },
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image" },
|
||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
||||
{ GIMP_PDB_INT8, "index1", "First index in the colormap" },
|
||||
|
@ -107,13 +101,17 @@ query (void)
|
|||
"Mukund Sivaraman <muks@mukund.org>",
|
||||
"Mukund Sivaraman <muks@mukund.org>",
|
||||
"14th June 2006",
|
||||
N_("_Rearrange Colormap..."),
|
||||
N_("R_earrange Colormap..."),
|
||||
"INDEXED*",
|
||||
GIMP_PLUGIN,
|
||||
G_N_ELEMENTS (remap_args), 0,
|
||||
remap_args, NULL);
|
||||
|
||||
gimp_plugin_menu_register (PLUG_IN_PROC_REMAP, "<Image>/Colors/Map");
|
||||
gimp_plugin_menu_register (PLUG_IN_PROC_REMAP, "<Image>/Colors/Map/Colormap");
|
||||
gimp_plugin_menu_register (PLUG_IN_PROC_REMAP, "<ColormapEditor>");
|
||||
gimp_plugin_icon_register (PLUG_IN_PROC_REMAP,
|
||||
GIMP_ICON_TYPE_STOCK_ID,
|
||||
(const guchar *) GIMP_STOCK_COLORMAP);
|
||||
|
||||
gimp_install_procedure (PLUG_IN_PROC_SWAP,
|
||||
N_("Swap two colors in the colormap"),
|
||||
|
@ -141,10 +139,7 @@ run (const gchar *name,
|
|||
gint32 image_ID;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
GimpRunMode run_mode;
|
||||
guchar ui_map[256];
|
||||
gint num_colors = 256;
|
||||
gboolean is_non_interactive = FALSE;
|
||||
guchar *map = ui_map;
|
||||
guchar map[256];
|
||||
gint i;
|
||||
|
||||
INIT_I18N ();
|
||||
|
@ -159,109 +154,108 @@ run (const gchar *name,
|
|||
|
||||
image_ID = param[1].data.d_image;
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
map[i] = i;
|
||||
|
||||
if (strcmp (name, PLUG_IN_PROC_REMAP) == 0)
|
||||
{
|
||||
/* Make sure that the drawable is indexed */
|
||||
if (gimp_image_base_type (image_ID) == GIMP_INDEXED)
|
||||
/* Make sure that the image is indexed */
|
||||
if (gimp_image_base_type (image_ID) != GIMP_INDEXED)
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
ui_map[i] = i;
|
||||
gint n_cols;
|
||||
|
||||
g_free (gimp_image_get_colormap (image_ID, &n_cols));
|
||||
|
||||
switch (run_mode)
|
||||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
if (! remap_dialog (image_ID, ui_map))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
gimp_get_data (PLUG_IN_PROC_REMAP, map);
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
is_non_interactive = TRUE;
|
||||
num_colors = param[3].data.d_int32;
|
||||
map = (guchar *) param[4].data.d_int8array;
|
||||
break;
|
||||
if (! remap_dialog (image_ID, map))
|
||||
status = GIMP_PDB_CANCEL;
|
||||
break;
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
gimp_get_data (PLUG_IN_PROC_REMAP, &ui_map);
|
||||
if (ui_map == NULL)
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
if (nparams != 5)
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
if (n_cols != param[3].data.d_int32)
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
for (i = 0; i < n_cols; i++)
|
||||
map[i] = (guchar) param[4].data.d_int8array[i];
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
gimp_get_data (PLUG_IN_PROC_REMAP, map);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
if (! remap (image_ID, is_non_interactive, num_colors, map))
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
else if (run_mode != GIMP_RUN_WITH_LAST_VALS)
|
||||
{
|
||||
if (map == ui_map)
|
||||
{
|
||||
gimp_set_data (PLUG_IN_PROC_REMAP,
|
||||
&ui_map, sizeof (ui_map));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < num_colors; i++)
|
||||
ui_map[i] = map[i];
|
||||
if (! remap (image_ID, n_cols, map))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
gimp_set_data (PLUG_IN_PROC_REMAP,
|
||||
&ui_map, sizeof (ui_map));
|
||||
}
|
||||
}
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data (PLUG_IN_PROC_REMAP, map, sizeof (map));
|
||||
|
||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||
gimp_displays_flush ();
|
||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||
gimp_displays_flush ();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
else if (strcmp (name, PLUG_IN_PROC_SWAP) == 0)
|
||||
{
|
||||
/* Make sure that the drawable is indexed */
|
||||
if (gimp_image_base_type (image_ID) == GIMP_INDEXED)
|
||||
/* Make sure that the image is indexed */
|
||||
if (gimp_image_base_type (image_ID) != GIMP_INDEXED)
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
for (i = 0; i < 256; i++)
|
||||
ui_map[i] = i;
|
||||
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
else if (run_mode == GIMP_RUN_WITH_LAST_VALS)
|
||||
{
|
||||
gimp_get_data (PLUG_IN_PROC_REMAP, &ui_map);
|
||||
|
||||
if (ui_map == NULL)
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
else if (! remap (image_ID, FALSE, 256, ui_map))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
else
|
||||
if (run_mode == GIMP_RUN_NONINTERACTIVE && nparams == 5)
|
||||
{
|
||||
guchar index1 = param[3].data.d_int8;
|
||||
guchar index2 = param[4].data.d_int8;
|
||||
gint n_cols;
|
||||
|
||||
if (! remap_swap (image_ID, ui_map, index1, index2))
|
||||
g_free (gimp_image_get_colormap (image_ID, &n_cols));
|
||||
|
||||
if (index1 >= n_cols || index2 >= n_cols)
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
|
||||
if (! remap (image_ID, FALSE, 256, ui_map))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
else
|
||||
gimp_set_data (PLUG_IN_PROC_SWAP, &ui_map, sizeof (ui_map));
|
||||
if (status == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
guchar tmp;
|
||||
|
||||
tmp = map[index1];
|
||||
map[index1] = map[index2];
|
||||
map[index2] = tmp;
|
||||
|
||||
if (! remap (image_ID, n_cols, map))
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
status = GIMP_PDB_EXECUTION_ERROR;
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
|
||||
values[0].data.d_status = status;
|
||||
|
@ -269,10 +263,9 @@ run (const gchar *name,
|
|||
|
||||
|
||||
static gboolean
|
||||
remap (gint32 image_ID,
|
||||
gboolean is_non_interactive,
|
||||
gint num_colors,
|
||||
guchar *map)
|
||||
remap (gint32 image_ID,
|
||||
gint num_colors,
|
||||
guchar *map)
|
||||
{
|
||||
guchar *cmap, *new_cmap;
|
||||
guchar *new_cmap_i;
|
||||
|
@ -290,7 +283,7 @@ remap (gint32 image_ID,
|
|||
g_return_val_if_fail (cmap != NULL, FALSE);
|
||||
g_return_val_if_fail (ncols > 0, FALSE);
|
||||
|
||||
if (is_non_interactive && (num_colors != ncols))
|
||||
if (num_colors != ncols)
|
||||
{
|
||||
g_message (_("Invalid remap array was passed to remap function"));
|
||||
return FALSE;
|
||||
|
@ -416,28 +409,6 @@ remap (gint32 image_ID,
|
|||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
remap_swap (gint32 image_ID,
|
||||
guchar *map,
|
||||
guchar index1,
|
||||
guchar index2)
|
||||
{
|
||||
gint ncols;
|
||||
guchar tmp;
|
||||
|
||||
g_free (gimp_image_get_colormap (image_ID, &ncols));
|
||||
|
||||
g_return_val_if_fail (ncols > 0, FALSE);
|
||||
g_return_val_if_fail (index1 < ncols, FALSE);
|
||||
g_return_val_if_fail (index2 < ncols, FALSE);
|
||||
|
||||
tmp = map[index1];
|
||||
map[index1] = map[index2];
|
||||
map[index2] = tmp;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
COLOR_INDEX,
|
||||
|
@ -452,21 +423,15 @@ remap_dialog (gint32 image_ID,
|
|||
{
|
||||
GtkWidget *dialog;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *iconview;
|
||||
GtkListStore *store;
|
||||
gboolean run;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeIter iter;
|
||||
guchar *cmap;
|
||||
gint ncols, i;
|
||||
GtkTreeIter iter;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkWidget *label;
|
||||
PangoAttrList *pango_attr_list;
|
||||
PangoAttribute *pango_attr;
|
||||
gboolean valid;
|
||||
|
||||
cmap = gimp_image_get_colormap (image_ID, &ncols);
|
||||
|
||||
g_return_val_if_fail (cmap != NULL, FALSE);
|
||||
gboolean run;
|
||||
|
||||
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
||||
|
||||
|
@ -496,22 +461,27 @@ remap_dialog (gint32 image_ID,
|
|||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
||||
-1);
|
||||
gtk_container_add (GTK_CONTAINER (vbox), label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
|
||||
store = gtk_list_store_new (NUM_COLS,
|
||||
G_TYPE_INT, G_TYPE_STRING, GIMP_TYPE_RGB);
|
||||
|
||||
cmap = gimp_image_get_colormap (image_ID, &ncols);
|
||||
|
||||
for (i = 0; i < ncols; i++)
|
||||
{
|
||||
GimpRGB color;
|
||||
gchar *text = g_strdup_printf ("%d", i);
|
||||
gint index = map[i];
|
||||
gchar *text = g_strdup_printf ("%d", index);
|
||||
|
||||
gimp_rgb_set_uchar (&color,
|
||||
cmap[(i * 3)], cmap[(i * 3) + 1], cmap[(i * 3) + 2]);
|
||||
cmap[index * 3],
|
||||
cmap[index * 3 + 1],
|
||||
cmap[index * 3 + 2]);
|
||||
|
||||
gtk_list_store_append (store, &iter);
|
||||
gtk_list_store_set (store, &iter,
|
||||
COLOR_INDEX, i,
|
||||
COLOR_INDEX, index,
|
||||
COLOR_INDEX_TEXT, text,
|
||||
COLOR_RGB, &color,
|
||||
-1);
|
||||
|
@ -519,6 +489,8 @@ remap_dialog (gint32 image_ID,
|
|||
g_free (text);
|
||||
}
|
||||
|
||||
g_free (cmap);
|
||||
|
||||
iconview = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store));
|
||||
g_object_unref (store);
|
||||
|
||||
|
@ -528,16 +500,20 @@ remap_dialog (gint32 image_ID,
|
|||
GTK_SELECTION_SINGLE);
|
||||
gtk_icon_view_set_orientation (GTK_ICON_VIEW (iconview),
|
||||
GTK_ORIENTATION_VERTICAL);
|
||||
gtk_icon_view_set_columns (GTK_ICON_VIEW (iconview), 24);
|
||||
gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (iconview), 1);
|
||||
gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (iconview), 1);
|
||||
gtk_icon_view_set_columns (GTK_ICON_VIEW (iconview), 16);
|
||||
gtk_icon_view_set_row_spacing (GTK_ICON_VIEW (iconview), 0);
|
||||
gtk_icon_view_set_column_spacing (GTK_ICON_VIEW (iconview), 0);
|
||||
gtk_icon_view_set_reorderable (GTK_ICON_VIEW (iconview), TRUE);
|
||||
|
||||
renderer = gimp_cell_renderer_color_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), renderer, TRUE);
|
||||
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (iconview), renderer,
|
||||
"color", COLOR_RGB,
|
||||
NULL);
|
||||
"color", COLOR_RGB,
|
||||
NULL);
|
||||
|
||||
g_object_set (renderer,
|
||||
"width", 24,
|
||||
NULL);
|
||||
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (iconview), renderer, TRUE);
|
||||
|
@ -545,26 +521,16 @@ remap_dialog (gint32 image_ID,
|
|||
"text", COLOR_INDEX_TEXT,
|
||||
NULL);
|
||||
|
||||
pango_attr_list = pango_attr_list_new ();
|
||||
|
||||
pango_attr = pango_attr_size_new (5000);
|
||||
pango_attr->start_index = 0;
|
||||
pango_attr->end_index = -1;
|
||||
pango_attr_list_insert (pango_attr_list, pango_attr);
|
||||
|
||||
g_object_set (renderer,
|
||||
"attributes", pango_attr_list,
|
||||
"xalign", 0.5,
|
||||
"size-points", 6.0,
|
||||
"xalign", 0.5,
|
||||
"ypad", 0,
|
||||
NULL);
|
||||
|
||||
pango_attr_list_unref (pango_attr_list);
|
||||
|
||||
gtk_widget_show_all (dialog);
|
||||
|
||||
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
||||
|
||||
valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
|
||||
|
||||
i = 0;
|
||||
|
||||
for (valid = gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
|
||||
|
@ -573,15 +539,13 @@ remap_dialog (gint32 image_ID,
|
|||
{
|
||||
gint index;
|
||||
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (store),
|
||||
&iter, COLOR_INDEX, &index, -1);
|
||||
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter,
|
||||
COLOR_INDEX, &index,
|
||||
-1);
|
||||
map[i++] = index;
|
||||
}
|
||||
|
||||
gtk_widget_destroy (dialog);
|
||||
|
||||
g_free (cmap);
|
||||
|
||||
return run;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue