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"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
|
|
|
#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"
|
2004-09-15 21:24:45 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
|
|
|
#include "core/gimpitemundo.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2004-10-22 20:32:31 +08:00
|
|
|
#include "core/gimpstrokedesc.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
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
#include "widgets/gimpaction.h"
|
2005-09-20 05:33:03 +08:00
|
|
|
#include "widgets/gimpclipboard.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "tools/gimpvectortool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs/stroke-dialog.h"
|
2004-10-24 06:54:41 +08:00
|
|
|
#include "dialogs/vectors-export-dialog.h"
|
|
|
|
#include "dialogs/vectors-import-dialog.h"
|
2004-10-19 22:08:44 +08:00
|
|
|
#include "dialogs/vectors-options-dialog.h"
|
2004-04-20 21:25:55 +08:00
|
|
|
|
2004-05-03 22:03:51 +08:00
|
|
|
#include "actions.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
|
|
|
|
|
|
|
|
2004-05-03 22:46:29 +08:00
|
|
|
/* local function prototypes */
|
2004-04-29 20:52:29 +08:00
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
static void vectors_new_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptionsDialog *options);
|
|
|
|
static void vectors_edit_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptionsDialog *options);
|
2004-10-24 06:54:41 +08:00
|
|
|
static void vectors_import_response (GtkWidget *widget,
|
2004-10-19 22:08:44 +08:00
|
|
|
gint response_id,
|
2004-10-24 06:54:41 +08:00
|
|
|
VectorsImportDialog *dialog);
|
|
|
|
static void vectors_export_response (GtkWidget *widget,
|
2004-10-19 22:08:44 +08:00
|
|
|
gint response_id,
|
2004-10-24 06:54:41 +08:00
|
|
|
VectorsExportDialog *dialog);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
static gchar *vectors_name = NULL;
|
|
|
|
static gboolean vectors_import_merge = FALSE;
|
|
|
|
static gboolean vectors_import_scale = FALSE;
|
|
|
|
static gboolean vectors_export_active_only = TRUE;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
void
|
|
|
|
vectors_vectors_tool_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpTool *active_tool;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-05-25 22:37:02 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
active_tool = tool_manager_get_active (image->gimp);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
|
|
|
if (! GIMP_IS_VECTOR_TOOL (active_tool))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_container_get_child_by_name (image->gimp->tool_info_list,
|
2004-10-16 23:48:23 +08:00
|
|
|
"gimp-vector-tool");
|
|
|
|
|
|
|
|
if (GIMP_IS_TOOL_INFO (tool_info))
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (action_data_get_context (data), tool_info);
|
2006-03-29 01:08:36 +08:00
|
|
|
active_tool = tool_manager_get_active (image->gimp);
|
2004-10-16 23:48:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_VECTOR_TOOL (active_tool))
|
|
|
|
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_edit_attributes_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-19 22:08:44 +08:00
|
|
|
VectorsOptionsDialog *options;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-10-19 22:08:44 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
GtkWidget *widget;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
options = vectors_options_dialog_new (image,
|
2004-10-19 22:08:44 +08:00
|
|
|
vectors,
|
|
|
|
widget,
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (vectors)),
|
|
|
|
_("Path Attributes"),
|
|
|
|
"gimp-vectors-edit",
|
2005-09-19 21:07:24 +08:00
|
|
|
GTK_STOCK_EDIT,
|
2004-10-19 22:08:44 +08:00
|
|
|
_("Edit Path Attributes"),
|
|
|
|
GIMP_HELP_PATH_EDIT);
|
|
|
|
|
|
|
|
g_signal_connect (options->dialog, "response",
|
2004-10-18 19:29:58 +08:00
|
|
|
G_CALLBACK (vectors_edit_vectors_response),
|
|
|
|
options);
|
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_show (options->dialog);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_new_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2004-10-19 22:08:44 +08:00
|
|
|
VectorsOptionsDialog *options;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-10-19 22:08:44 +08:00
|
|
|
GtkWidget *widget;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
options = vectors_options_dialog_new (image,
|
2004-10-19 22:08:44 +08:00
|
|
|
NULL,
|
|
|
|
widget,
|
|
|
|
vectors_name ? vectors_name :
|
|
|
|
_("New Path"),
|
|
|
|
_("New Path"),
|
|
|
|
"gimp-vectors-new",
|
|
|
|
GIMP_STOCK_PATH,
|
|
|
|
_("New Path Options"),
|
|
|
|
GIMP_HELP_PATH_NEW);
|
|
|
|
|
|
|
|
g_signal_connect (options->dialog, "response",
|
2004-10-18 19:29:58 +08:00
|
|
|
G_CALLBACK (vectors_new_vectors_response),
|
|
|
|
options);
|
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_show (options->dialog);
|
2004-10-16 23:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-10-23 08:53:48 +08:00
|
|
|
vectors_new_last_vals_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2004-10-16 23:48:23 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpVectors *new_vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
new_vectors = gimp_vectors_new (image,
|
2004-10-23 08:53:48 +08:00
|
|
|
vectors_name ? vectors_name : _("New Path"));
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_add_vectors (image, new_vectors, -1);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
void
|
2004-09-15 21:24:45 +08:00
|
|
|
vectors_raise_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2004-04-19 22:54:24 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_raise_vectors (image, vectors);
|
|
|
|
gimp_image_flush (image);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
void
|
2004-09-15 21:24:45 +08:00
|
|
|
vectors_raise_to_top_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_raise_vectors_to_top (image, vectors);
|
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_lower_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_lower_vectors (image, vectors);
|
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2004-04-19 22:54:24 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_lower_to_bottom_cmd_callback (GtkAction *action,
|
2004-04-19 22:54:24 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_lower_vectors_to_bottom (image, vectors);
|
|
|
|
gimp_image_flush (image);
|
2004-04-19 22:54:24 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_duplicate_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpVectors *new_vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
new_vectors =
|
|
|
|
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
|
|
|
|
G_TYPE_FROM_INSTANCE (vectors),
|
|
|
|
TRUE));
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_add_vectors (image, new_vectors, -1);
|
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_delete_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_remove_vectors (image, vectors);
|
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2003-11-07 21:20:52 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_merge_visible_cmd_callback (GtkAction *action,
|
2003-11-07 21:20:52 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2003-11-07 21:20:52 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_merge_visible_vectors (image);
|
|
|
|
gimp_image_flush (image);
|
2003-11-07 21:20:52 +08:00
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-08-27 08:52:00 +08:00
|
|
|
GimpChannelOps op;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
op = (GimpChannelOps) value;
|
2003-08-27 08:52:00 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_channel_select_vectors (gimp_image_get_mask (image),
|
2003-10-06 20:17:11 +08:00
|
|
|
_("Path to Selection"),
|
2004-05-25 22:37:02 +08:00
|
|
|
vectors,
|
2003-10-06 20:17:11 +08:00
|
|
|
op, TRUE, FALSE, 0, 0);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_selection_to_vectors_cmd_callback (GtkAction *action,
|
2004-05-13 02:36:33 +08:00
|
|
|
gint value,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-23 18:04:41 +08:00
|
|
|
ProcRecord *proc_rec;
|
|
|
|
Argument *args;
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (value)
|
2006-03-29 01:08:36 +08:00
|
|
|
proc_rec = procedural_db_lookup (image->gimp,
|
2005-08-03 07:02:56 +08:00
|
|
|
"plug-in-sel2path-advanced");
|
2004-05-23 18:04:41 +08:00
|
|
|
else
|
2006-03-29 01:08:36 +08:00
|
|
|
proc_rec = procedural_db_lookup (image->gimp,
|
2005-08-03 07:02:56 +08:00
|
|
|
"plug-in-sel2path");
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
if (! proc_rec)
|
|
|
|
{
|
|
|
|
g_message ("Selection to path procedure lookup failed.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
display = gimp_context_get_display (action_data_get_context (data));
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
/* plug-in arguments as if called by <Image>/Filters/... */
|
2006-03-28 05:09:32 +08:00
|
|
|
args = procedural_db_arguments (proc_rec);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
2006-03-29 01:08:36 +08:00
|
|
|
args[1].value.pdb_int = (gint32) gimp_image_get_ID (image);
|
2004-05-23 18:04:41 +08:00
|
|
|
args[2].value.pdb_int = -1; /* unused */
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
plug_in_run (image->gimp, action_data_get_context (data),
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_PROGRESS (display),
|
2006-03-28 05:09:32 +08:00
|
|
|
proc_rec, args, 3 /* not proc_rec->num_args */,
|
2006-03-29 01:55:52 +08:00
|
|
|
FALSE, TRUE, display ? gimp_display_get_ID (display) : 0);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
g_free (args);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_stroke_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
drawable = gimp_image_active_drawable (image);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
|
|
|
g_message (_("There is no active layer or channel to stroke to."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog = stroke_dialog_new (GIMP_ITEM (vectors),
|
2004-10-23 18:28:56 +08:00
|
|
|
_("Stroke Path"),
|
2004-05-23 18:04:41 +08:00
|
|
|
GIMP_STOCK_PATH_STROKE,
|
|
|
|
GIMP_HELP_PATH_STROKE,
|
|
|
|
widget);
|
|
|
|
gtk_widget_show (dialog);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
2004-10-21 07:14:24 +08:00
|
|
|
void
|
|
|
|
vectors_stroke_last_vals_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-22 20:32:31 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpContext *context;
|
|
|
|
GimpStrokeDesc *desc;
|
2004-10-21 07:14:24 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
|
|
|
drawable = gimp_image_active_drawable (image);
|
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
|
|
|
g_message (_("There is no active layer or channel to stroke to."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
context = gimp_get_user_context (image->gimp);
|
|
|
|
|
2004-10-22 20:32:31 +08:00
|
|
|
desc = g_object_get_data (G_OBJECT (context), "saved-stroke-desc");
|
2004-10-21 07:14:24 +08:00
|
|
|
|
2004-10-22 20:32:31 +08:00
|
|
|
if (desc)
|
|
|
|
g_object_ref (desc);
|
2004-10-21 07:14:24 +08:00
|
|
|
else
|
2004-10-22 20:32:31 +08:00
|
|
|
desc = gimp_stroke_desc_new (image->gimp, context);
|
2004-10-21 07:14:24 +08:00
|
|
|
|
2004-10-22 20:32:31 +08:00
|
|
|
gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, desc, FALSE);
|
2004-10-21 07:14:24 +08:00
|
|
|
|
2004-10-22 20:32:31 +08:00
|
|
|
g_object_unref (desc);
|
2004-10-21 07:14:24 +08:00
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_copy_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2005-09-20 05:33:03 +08:00
|
|
|
gchar *svg;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
svg = gimp_vectors_export_string (image, vectors);
|
2005-09-20 05:33:03 +08:00
|
|
|
|
|
|
|
if (svg)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_clipboard_set_svg (image->gimp, svg);
|
2005-09-20 05:33:03 +08:00
|
|
|
g_free (svg);
|
|
|
|
}
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_paste_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2005-09-20 05:33:03 +08:00
|
|
|
gchar *svg;
|
|
|
|
gsize svg_size;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
svg = gimp_clipboard_get_svg (image->gimp, &svg_size);
|
2005-09-20 05:33:03 +08:00
|
|
|
|
|
|
|
if (svg)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! gimp_vectors_import_buffer (image, svg, svg_size,
|
2005-09-20 05:33:03 +08:00
|
|
|
TRUE, TRUE, -1, &error))
|
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2005-09-20 05:33:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (svg);
|
|
|
|
}
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-20 05:33:03 +08:00
|
|
|
vectors_export_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2005-09-20 05:33:03 +08:00
|
|
|
VectorsExportDialog *dialog;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2005-09-20 05:33:03 +08:00
|
|
|
GimpVectors *vectors;
|
2004-10-24 06:54:41 +08:00
|
|
|
GtkWidget *widget;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
dialog = vectors_export_dialog_new (image, widget,
|
2005-09-20 05:33:03 +08:00
|
|
|
vectors_export_active_only);
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
g_signal_connect (dialog->dialog, "response",
|
2005-09-20 05:33:03 +08:00
|
|
|
G_CALLBACK (vectors_export_response),
|
2004-10-24 06:54:41 +08:00
|
|
|
dialog);
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
gtk_widget_show (dialog->dialog);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-20 05:33:03 +08:00
|
|
|
vectors_import_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2005-09-20 05:33:03 +08:00
|
|
|
VectorsImportDialog *dialog;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-10-24 06:54:41 +08:00
|
|
|
GtkWidget *widget;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
dialog = vectors_import_dialog_new (image, widget,
|
2005-09-20 05:33:03 +08:00
|
|
|
vectors_import_merge,
|
|
|
|
vectors_import_scale);
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
g_signal_connect (dialog->dialog, "response",
|
2005-09-20 05:33:03 +08:00
|
|
|
G_CALLBACK (vectors_import_response),
|
2004-10-24 06:54:41 +08:00
|
|
|
dialog);
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
gtk_widget_show (dialog->dialog);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
void
|
|
|
|
vectors_visible_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-09-15 21:24:45 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
gboolean visible;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
|
|
|
visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
if (visible != gimp_item_get_visible (GIMP_ITEM (vectors)))
|
|
|
|
{
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
2004-09-15 21:24:45 +08:00
|
|
|
GIMP_UNDO_ITEM_VISIBILITY);
|
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (vectors))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
|
|
|
gimp_item_set_visible (GIMP_ITEM (vectors), visible, push_undo);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2004-09-15 21:24:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_linked_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-09-15 21:24:45 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
gboolean linked;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
|
|
|
linked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
if (linked != gimp_item_get_linked (GIMP_ITEM (vectors)))
|
|
|
|
{
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
2004-09-15 21:24:45 +08:00
|
|
|
GIMP_UNDO_ITEM_LINKED);
|
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (vectors))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2004-10-16 23:51:55 +08:00
|
|
|
gimp_item_set_linked (GIMP_ITEM (vectors), linked, push_undo);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2004-09-15 21:24:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
/* private functions */
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
static void
|
2004-10-19 22:08:44 +08:00
|
|
|
vectors_new_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptionsDialog *options)
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
GimpVectors *new_vectors;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
if (vectors_name)
|
|
|
|
g_free (vectors_name);
|
2004-09-28 06:44:28 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
vectors_name =
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
new_vectors = gimp_vectors_new (options->image, vectors_name);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_add_vectors (options->image, new_vectors, -1);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (options->image);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_destroy (options->dialog);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
2003-09-13 10:33:30 +08:00
|
|
|
|
|
|
|
static void
|
2004-10-19 22:08:44 +08:00
|
|
|
vectors_edit_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptionsDialog *options)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2003-11-18 02:29:59 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-09-20 06:26:41 +08:00
|
|
|
GimpVectors *vectors = options->vectors;
|
|
|
|
const gchar *new_name;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-09-20 06:26:41 +08:00
|
|
|
gimp_item_rename (GIMP_ITEM (vectors), new_name);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (options->image);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-19 22:08:44 +08:00
|
|
|
gtk_widget_destroy (options->dialog);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-24 06:54:41 +08:00
|
|
|
vectors_import_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsImportDialog *dialog)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2003-11-18 02:29:59 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-10-24 21:13:21 +08:00
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
vectors_import_merge = dialog->merge_vectors;
|
|
|
|
vectors_import_scale = dialog->scale_vectors;
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
if (gimp_vectors_import_file (dialog->image, filename,
|
|
|
|
vectors_import_merge, vectors_import_scale,
|
|
|
|
-1, &error))
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
2004-10-24 06:54:41 +08:00
|
|
|
gimp_image_flush (dialog->image);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
|
|
|
else
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
2004-10-24 21:13:21 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
gtk_widget_destroy (widget);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
static void
|
2004-10-24 06:54:41 +08:00
|
|
|
vectors_export_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsExportDialog *dialog)
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
2004-10-24 05:49:46 +08:00
|
|
|
GimpVectors *vectors = NULL;
|
2004-10-24 21:13:21 +08:00
|
|
|
gchar *filename;
|
2004-10-24 05:49:46 +08:00
|
|
|
GError *error = NULL;
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
vectors_export_active_only = dialog->active_only;
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
if (vectors_export_active_only)
|
|
|
|
vectors = gimp_image_get_active_vectors (dialog->image);
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
if (! gimp_vectors_export_file (dialog->image, vectors, filename, &error))
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
2004-10-24 21:13:21 +08:00
|
|
|
|
|
|
|
g_free (filename);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
gtk_widget_destroy (widget);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|