2002-02-26 01:58:50 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-28 08:10:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "gui-types.h"
|
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpchannel.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-11-08 01:29:02 +08:00
|
|
|
#include "core/gimpimage-merge.h"
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-05-15 22:31:22 +08:00
|
|
|
#include "pdb/procedural_db.h"
|
|
|
|
|
|
|
|
#include "plug-in/plug-in-run.h"
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
2003-09-11 07:00:44 +08:00
|
|
|
#include "vectors/gimpvectors-export.h"
|
2003-09-11 00:52:45 +08:00
|
|
|
#include "vectors/gimpvectors-import.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2003-03-16 19:14:29 +08:00
|
|
|
#include "widgets/gimpitemtreeview.h"
|
2002-08-31 05:00:42 +08:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2002-02-26 13:42:14 +08:00
|
|
|
#include "tools/gimppainttool.h"
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "tools/gimpvectortool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2003-09-30 10:44:17 +08:00
|
|
|
#include "stroke-dialog.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "vectors-commands.h"
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#define return_if_no_image(gimage,data) \
|
2003-01-12 20:35:00 +08:00
|
|
|
if (GIMP_IS_DISPLAY (data)) \
|
|
|
|
gimage = ((GimpDisplay *) data)->gimage; \
|
|
|
|
else if (GIMP_IS_GIMP (data)) \
|
|
|
|
gimage = gimp_context_get_image (gimp_get_user_context (GIMP (data))); \
|
2003-03-16 19:14:29 +08:00
|
|
|
else if (GIMP_IS_ITEM_TREE_VIEW (data)) \
|
|
|
|
gimage = ((GimpItemTreeView *) data)->gimage; \
|
2003-01-12 20:35:00 +08:00
|
|
|
else \
|
|
|
|
gimage = NULL; \
|
|
|
|
\
|
2002-02-27 00:30:14 +08:00
|
|
|
if (! gimage) \
|
|
|
|
return
|
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#define return_if_no_vectors(gimage,vectors,data) \
|
|
|
|
return_if_no_image (gimage,data); \
|
2002-02-27 00:30:14 +08:00
|
|
|
vectors = gimp_image_get_active_vectors (gimage); \
|
|
|
|
if (! vectors) \
|
|
|
|
return
|
|
|
|
|
|
|
|
|
2003-11-10 06:05:37 +08:00
|
|
|
static void vectors_import_query (GimpImage *gimage,
|
|
|
|
GtkWidget *parent);
|
2003-09-13 10:33:30 +08:00
|
|
|
static void vectors_export_query (GimpImage *gimage,
|
2003-11-10 06:05:37 +08:00
|
|
|
GimpVectors *vectors,
|
|
|
|
GtkWidget *parent);
|
2003-09-13 10:33:30 +08:00
|
|
|
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_new_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-08 23:29:47 +08:00
|
|
|
vectors_new_vectors_query (gimage, NULL, TRUE, widget);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_raise_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_raise_vectors (gimage, active_vectors);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_lower_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_lower_vectors (gimage, active_vectors);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_duplicate_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
|
|
|
GimpVectors *new_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2003-02-11 21:52:47 +08:00
|
|
|
new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (active_vectors),
|
|
|
|
G_TYPE_FROM_INSTANCE (active_vectors),
|
|
|
|
TRUE));
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_add_vectors (gimage, new_vectors, -1);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_delete_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_remove_vectors (gimage, active_vectors);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2003-11-07 21:20:52 +08:00
|
|
|
void
|
|
|
|
vectors_merge_visible_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
|
|
|
|
|
|
|
gimp_image_merge_visible_vectors (gimage);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
|
|
|
vectors_to_selection_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data,
|
|
|
|
guint action)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-08-27 08:52:00 +08:00
|
|
|
GimpChannelOps op;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
op = (GimpChannelOps) action;
|
|
|
|
|
2003-10-06 20:17:11 +08:00
|
|
|
gimp_channel_select_vectors (gimp_image_get_mask (gimage),
|
|
|
|
_("Path to Selection"),
|
|
|
|
active_vectors,
|
|
|
|
op, TRUE, FALSE, 0, 0);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_selection_to_vectors_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-05-16 17:52:49 +08:00
|
|
|
vectors_selection_to_vectors (gimage, FALSE);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_stroke_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-09-02 01:56:44 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-11-08 23:29:47 +08:00
|
|
|
vectors_stroke_vectors (GIMP_ITEM (active_vectors), widget);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_copy_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#ifdef __GNUC__
|
2003-11-02 04:06:01 +08:00
|
|
|
#warning FIXME: need vectors clipboard
|
2002-12-11 00:38:16 +08:00
|
|
|
#endif
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_paste_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#ifdef __GNUC__
|
2003-11-02 04:06:01 +08:00
|
|
|
#warning FIXME: need vectors clipboard
|
2002-12-11 00:38:16 +08:00
|
|
|
#endif
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_import_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2003-09-11 06:11:02 +08:00
|
|
|
GimpImage *gimage;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-11-10 06:05:37 +08:00
|
|
|
vectors_import_query (gimage, widget);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_export_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-11-10 06:05:37 +08:00
|
|
|
vectors_export_query (gimage, active_vectors, widget);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_vectors_tool_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2002-02-27 00:30:14 +08:00
|
|
|
vectors_vectors_tool (active_vectors);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-08-21 23:54:47 +08:00
|
|
|
vectors_edit_attributes_cmd_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *active_vectors;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_vectors (gimage, active_vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-11-08 23:29:47 +08:00
|
|
|
vectors_edit_vectors_query (active_vectors, widget);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
2003-09-27 21:46:30 +08:00
|
|
|
void
|
2003-11-08 23:29:47 +08:00
|
|
|
vectors_stroke_vectors (GimpItem *item,
|
|
|
|
GtkWidget *parent)
|
2003-09-27 21:46:30 +08:00
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpDrawable *active_drawable;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (item);
|
|
|
|
|
|
|
|
active_drawable = gimp_image_active_drawable (gimage);
|
|
|
|
|
|
|
|
if (! active_drawable)
|
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("There is no active layer or channel to stroke to."));
|
2003-09-27 21:46:30 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-09-27 22:41:10 +08:00
|
|
|
dialog = stroke_dialog_new (item, GIMP_STOCK_PATH_STROKE,
|
2003-11-08 23:29:47 +08:00
|
|
|
GIMP_HELP_PATH_STROKE,
|
|
|
|
parent);
|
2003-09-27 21:46:30 +08:00
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|
2003-05-15 22:31:22 +08:00
|
|
|
void
|
|
|
|
vectors_selection_to_vectors (GimpImage *gimage,
|
|
|
|
gboolean advanced)
|
|
|
|
{
|
|
|
|
ProcRecord *proc_rec;
|
|
|
|
Argument *args;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpDisplay *gdisp;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
|
|
|
|
|
|
drawable = gimp_image_active_drawable (gimage);
|
|
|
|
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
|
|
|
|
|
|
|
|
if (advanced)
|
|
|
|
proc_rec = procedural_db_lookup (gimage->gimp,
|
|
|
|
"plug_in_sel2path_advanced");
|
|
|
|
else
|
|
|
|
proc_rec = procedural_db_lookup (gimage->gimp,
|
|
|
|
"plug_in_sel2path");
|
|
|
|
|
|
|
|
if (! proc_rec)
|
|
|
|
{
|
2003-05-27 20:02:34 +08:00
|
|
|
g_message ("Selection to path procedure lookup failed.");
|
2003-05-15 22:31:22 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* plug-in arguments as if called by <Image>/Filters/... */
|
|
|
|
args = g_new (Argument, 3);
|
|
|
|
|
|
|
|
args[0].arg_type = GIMP_PDB_INT32;
|
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
|
|
|
args[1].arg_type = GIMP_PDB_IMAGE;
|
|
|
|
args[1].value.pdb_int = (gint32) gimp_image_get_ID (gimage);
|
|
|
|
args[2].arg_type = GIMP_PDB_DRAWABLE;
|
|
|
|
args[2].value.pdb_int = (gint32) gimp_item_get_ID (GIMP_ITEM (drawable));
|
|
|
|
|
|
|
|
plug_in_run (gimage->gimp,
|
|
|
|
proc_rec, args, 3, FALSE, TRUE,
|
|
|
|
gdisp ? gdisp->ID : 0);
|
|
|
|
|
|
|
|
g_free (args);
|
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
void
|
2002-02-26 22:40:30 +08:00
|
|
|
vectors_vectors_tool (GimpVectors *vectors)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2002-02-26 22:40:30 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpTool *active_tool;
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (vectors));
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
if (! GIMP_IS_VECTOR_TOOL (active_tool))
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-09-18 21:51:10 +08:00
|
|
|
GimpContainer *tool_info_list;
|
|
|
|
GimpToolInfo *tool_info;
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
tool_info_list = gimage->gimp->tool_info_list;
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (tool_info_list,
|
|
|
|
"gimp-vector-tool");
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
if (GIMP_IS_TOOL_INFO (tool_info))
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (gimp_get_current_context (gimage->gimp),
|
|
|
|
tool_info);
|
|
|
|
|
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2003-09-18 21:51:10 +08:00
|
|
|
if (GIMP_IS_VECTOR_TOOL (active_tool))
|
|
|
|
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
|
|
|
|
/**********************************/
|
|
|
|
/* The new vectors query dialog */
|
|
|
|
/**********************************/
|
|
|
|
|
|
|
|
typedef struct _NewVectorsOptions NewVectorsOptions;
|
|
|
|
|
|
|
|
struct _NewVectorsOptions
|
|
|
|
{
|
|
|
|
GtkWidget *query_box;
|
|
|
|
GtkWidget *name_entry;
|
|
|
|
|
|
|
|
GimpImage *gimage;
|
|
|
|
};
|
|
|
|
|
|
|
|
static gchar *vectors_name = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
new_vectors_query_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
NewVectorsOptions *options)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
GimpVectors *new_vectors;
|
|
|
|
GimpImage *gimage;
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (vectors_name)
|
|
|
|
g_free (vectors_name);
|
|
|
|
vectors_name =
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if ((gimage = options->gimage))
|
|
|
|
{
|
|
|
|
new_vectors = gimp_vectors_new (gimage, vectors_name);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_image_add_vectors (gimage, new_vectors, -1);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_new_vectors_query (GimpImage *gimage,
|
2002-09-02 22:39:08 +08:00
|
|
|
GimpVectors *template,
|
2003-11-08 23:29:47 +08:00
|
|
|
gboolean interactive,
|
|
|
|
GtkWidget *parent)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
|
|
|
NewVectorsOptions *options;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
|
|
|
g_return_if_fail (! template || GIMP_IS_VECTORS (template));
|
|
|
|
|
2002-09-02 22:39:08 +08:00
|
|
|
if (template || ! interactive)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
|
|
|
GimpVectors *new_vectors;
|
|
|
|
|
2003-02-01 02:08:32 +08:00
|
|
|
new_vectors = gimp_vectors_new (gimage, _("Empty Vectors Copy"));
|
2002-02-26 01:58:50 +08:00
|
|
|
|
|
|
|
gimp_image_add_vectors (gimage, new_vectors, -1);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the new options structure */
|
|
|
|
options = g_new (NewVectorsOptions, 1);
|
2002-05-09 01:48:24 +08:00
|
|
|
options->gimage = gimage;
|
2003-09-11 00:52:45 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
/* The dialog */
|
|
|
|
options->query_box =
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
|
2003-11-08 01:29:02 +08:00
|
|
|
_("New Path"), "gimp-vectors-new",
|
2003-03-27 22:25:18 +08:00
|
|
|
GIMP_STOCK_TOOL_PATH,
|
2002-08-31 05:00:42 +08:00
|
|
|
_("New Path Options"),
|
2003-11-08 23:29:47 +08:00
|
|
|
parent,
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_PATH_NEW,
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
NULL);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (options->query_box, "response",
|
|
|
|
G_CALLBACK (new_vectors_query_response),
|
|
|
|
options);
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
|
|
|
|
|
|
|
/* The main hbox */
|
2003-11-06 23:27:05 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
hbox);
|
|
|
|
|
|
|
|
/* The vbox */
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
/* The table */
|
|
|
|
table = gtk_table_new (2, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* The name entry hbox, label and entry */
|
2002-02-26 08:04:55 +08:00
|
|
|
label = gtk_label_new (_("Path name:"));
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
|
|
|
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
options->name_entry = gtk_entry_new ();
|
|
|
|
gtk_widget_set_size_request (options->name_entry, 150, -1);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry,
|
|
|
|
1, 2, 0, 1);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
2002-02-26 08:04:55 +08:00
|
|
|
(vectors_name ? vectors_name : _("New Path")));
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_widget_show (options->name_entry);
|
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
gtk_widget_show (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************/
|
|
|
|
/* The edit vectors attributes dialog */
|
|
|
|
/****************************************/
|
|
|
|
|
|
|
|
typedef struct _EditVectorsOptions EditVectorsOptions;
|
|
|
|
|
|
|
|
struct _EditVectorsOptions
|
|
|
|
{
|
|
|
|
GtkWidget *query_box;
|
|
|
|
GtkWidget *name_entry;
|
|
|
|
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpImage *gimage;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
edit_vectors_query_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
EditVectorsOptions *options)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
GimpVectors *vectors = options->vectors;
|
2002-02-26 08:04:55 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
if (options->gimage)
|
2002-02-26 08:04:55 +08:00
|
|
|
{
|
2003-11-06 23:27:05 +08:00
|
|
|
const gchar *new_name;
|
|
|
|
|
|
|
|
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
|
|
|
|
|
|
|
|
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
|
|
|
|
{
|
|
|
|
gimp_item_rename (GIMP_ITEM (vectors), new_name);
|
|
|
|
gimp_image_flush (options->gimage);
|
|
|
|
}
|
2002-02-26 08:04:55 +08:00
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2003-11-08 23:29:47 +08:00
|
|
|
vectors_edit_vectors_query (GimpVectors *vectors,
|
|
|
|
GtkWidget *parent)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
|
|
|
EditVectorsOptions *options;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
2002-02-26 10:00:02 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
options = g_new0 (EditVectorsOptions, 1);
|
|
|
|
|
|
|
|
options->vectors = vectors;
|
|
|
|
options->gimage = gimp_item_get_image (GIMP_ITEM (vectors));
|
|
|
|
|
|
|
|
/* The dialog */
|
|
|
|
options->query_box =
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (vectors),
|
2003-11-08 01:29:02 +08:00
|
|
|
_("Path Attributes"), "gimp-vectors-edit",
|
2002-08-31 05:00:42 +08:00
|
|
|
GIMP_STOCK_EDIT,
|
|
|
|
_("Edit Path Attributes"),
|
2003-11-08 23:29:47 +08:00
|
|
|
parent,
|
2002-08-31 05:00:42 +08:00
|
|
|
gimp_standard_help_func,
|
2003-08-21 23:54:47 +08:00
|
|
|
GIMP_HELP_PATH_EDIT,
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-08-31 05:00:42 +08:00
|
|
|
NULL);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
g_signal_connect (options->query_box, "response",
|
|
|
|
G_CALLBACK (edit_vectors_query_response),
|
|
|
|
options);
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
|
|
|
|
|
|
|
/* The main hbox */
|
2003-11-06 23:27:05 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
hbox);
|
|
|
|
|
|
|
|
/* The vbox */
|
|
|
|
vbox = gtk_vbox_new (FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
/* The table */
|
|
|
|
table = gtk_table_new (2, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* The name entry */
|
2002-02-26 08:04:55 +08:00
|
|
|
label = gtk_label_new (_("Path name:"));
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
options->name_entry = gtk_entry_new ();
|
|
|
|
gtk_widget_set_size_request (options->name_entry, 150, -1);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), options->name_entry,
|
|
|
|
1, 2, 0, 1);
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (vectors)));
|
|
|
|
gtk_widget_show (options->name_entry);
|
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
gtk_widget_show (hbox);
|
|
|
|
gtk_widget_show (options->query_box);
|
|
|
|
}
|
2003-09-13 10:33:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*******************************/
|
|
|
|
/* The vectors import dialog */
|
|
|
|
/*******************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
vectors_import_ok_callback (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = g_object_get_data (G_OBJECT (widget), "gimp-image");
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
{
|
|
|
|
const gchar *filename;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget));
|
|
|
|
|
2003-09-25 08:39:46 +08:00
|
|
|
if (gimp_vectors_import (gimage, filename, FALSE, FALSE, &error))
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_weak_unref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-10 06:05:37 +08:00
|
|
|
vectors_import_query (GimpImage *gimage,
|
|
|
|
GtkWidget *parent)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
|
|
|
GtkFileSelection *filesel;
|
|
|
|
|
|
|
|
filesel =
|
|
|
|
GTK_FILE_SELECTION (gtk_file_selection_new (_("Import Paths from SVG")));
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (filesel), "gimp-image", gimage);
|
|
|
|
g_object_weak_ref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, filesel);
|
|
|
|
|
2003-11-10 06:05:37 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (filesel),
|
|
|
|
gtk_widget_get_screen (parent));
|
|
|
|
|
2003-11-08 01:29:02 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (filesel), "gimp-vectors-import");
|
2003-09-13 10:33:30 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (filesel->ok_button, "clicked",
|
|
|
|
G_CALLBACK (vectors_import_ok_callback),
|
|
|
|
filesel);
|
|
|
|
g_signal_connect_swapped (filesel->cancel_button, "clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
filesel);
|
|
|
|
|
2003-09-25 08:39:46 +08:00
|
|
|
/* FIXME: add a proper file selector
|
|
|
|
and controls for merge and scale options */
|
|
|
|
|
2003-09-13 10:33:30 +08:00
|
|
|
gtk_widget_show (GTK_WIDGET (filesel));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*******************************/
|
|
|
|
/* The vectors export dialog */
|
|
|
|
/*******************************/
|
|
|
|
|
|
|
|
static void
|
|
|
|
vectors_export_ok_callback (GtkWidget *widget)
|
|
|
|
{
|
|
|
|
GimpImage *gimage = g_object_get_data (G_OBJECT (widget), "gimp-image");
|
|
|
|
|
|
|
|
if (gimage)
|
|
|
|
{
|
|
|
|
const gchar *filename;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget));
|
|
|
|
|
2003-09-14 17:34:22 +08:00
|
|
|
if (! gimp_vectors_export (gimage, NULL, filename, &error))
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_weak_unref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (widget);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vectors_export_query (GimpImage *gimage,
|
2003-11-10 06:05:37 +08:00
|
|
|
GimpVectors *vectors,
|
|
|
|
GtkWidget *parent)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
|
|
|
GtkFileSelection *filesel;
|
|
|
|
|
|
|
|
filesel =
|
|
|
|
GTK_FILE_SELECTION (gtk_file_selection_new (_("Export Path to SVG")));
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (filesel), "gimp-image", gimage);
|
|
|
|
g_object_weak_ref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, filesel);
|
|
|
|
|
2003-11-10 06:05:37 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (filesel),
|
|
|
|
gtk_widget_get_screen (parent));
|
|
|
|
|
2003-11-08 01:29:02 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (filesel), "gimp-vectors-export");
|
2003-09-13 10:33:30 +08:00
|
|
|
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
|
|
|
|
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
|
|
|
|
|
|
|
|
g_signal_connect_swapped (filesel->ok_button, "clicked",
|
|
|
|
G_CALLBACK (vectors_export_ok_callback),
|
|
|
|
filesel);
|
|
|
|
g_signal_connect_swapped (filesel->cancel_button, "clicked",
|
|
|
|
G_CALLBACK (gtk_widget_destroy),
|
|
|
|
filesel);
|
|
|
|
|
|
|
|
gtk_widget_show (GTK_WIDGET (filesel));
|
|
|
|
}
|