2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-02-26 01:58:50 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-02-26 01:58:50 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-02-26 01:58:50 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2002-02-26 01:58:50 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-28 08:10:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2002-02-26 01:58:50 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2016-08-25 01:49:59 +08:00
|
|
|
#include "config/gimpdialogconfig.h"
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "core/gimp.h"
|
2006-04-11 08:00:36 +08:00
|
|
|
#include "core/gimp-utils.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "core/gimpchannel.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"
|
2006-03-30 07:56:07 +08:00
|
|
|
#include "core/gimpparamspecs.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2008-10-24 15:37:46 +08:00
|
|
|
#include "core/gimpstrokeoptions.h"
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2006-04-26 17:13:47 +08:00
|
|
|
#include "pdb/gimppdb.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
#include "pdb/gimpprocedure.h"
|
2003-05-15 22:31:22 +08:00
|
|
|
|
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"
|
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
#include "dialogs/dialogs.h"
|
2016-03-16 03:52:22 +08:00
|
|
|
#include "dialogs/fill-dialog.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
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
static void vectors_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gpointer user_data);
|
|
|
|
static void vectors_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gpointer user_data);
|
|
|
|
static void vectors_import_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsImportDialog *dialog);
|
|
|
|
static void vectors_export_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsExportDialog *dialog);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
2004-10-24 06:54:41 +08:00
|
|
|
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))
|
|
|
|
{
|
2006-09-08 21:42:00 +08:00
|
|
|
GimpToolInfo *tool_info = gimp_get_tool_info (image->gimp,
|
|
|
|
"gimp-vector-tool");
|
2004-10-16 23:48:23 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2016-09-25 02:32:44 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
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);
|
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
#define EDIT_DIALOG_KEY "gimp-vectors-edit-attributes-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (vectors), EDIT_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
dialog = vectors_options_dialog_new (image, vectors,
|
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("Path Attributes"),
|
|
|
|
"gimp-vectors-edit",
|
|
|
|
"gtk-edit",
|
|
|
|
_("Edit Path Attributes"),
|
|
|
|
GIMP_HELP_PATH_EDIT,
|
|
|
|
gimp_object_get_name (vectors),
|
|
|
|
vectors_edit_attributes_callback,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (vectors), EDIT_DIALOG_KEY, dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (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
|
|
|
{
|
2016-09-25 02:32:44 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
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
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
#define NEW_DIALOG_KEY "gimp-vectors-new-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), NEW_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
|
|
|
dialog = vectors_options_dialog_new (image, NULL,
|
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("New Path"),
|
|
|
|
"gimp-vectors-new",
|
|
|
|
GIMP_STOCK_PATH,
|
|
|
|
_("New Path Options"),
|
|
|
|
GIMP_HELP_PATH_NEW,
|
|
|
|
config->vectors_new_name,
|
|
|
|
vectors_new_callback,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), NEW_DIALOG_KEY, dialog);
|
|
|
|
}
|
2016-08-25 01:49:59 +08:00
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (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
|
|
|
{
|
2016-08-25 01:49:59 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDialogConfig *config;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2016-08-25 01:49:59 +08:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2004-10-16 23:48:23 +08:00
|
|
|
|
2016-08-25 01:49:59 +08:00
|
|
|
vectors = gimp_vectors_new (image, config->vectors_new_name);
|
|
|
|
|
|
|
|
gimp_image_add_vectors (image, vectors,
|
2009-08-04 04:30:36 +08:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
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
|
|
|
|
2010-07-09 00:08:13 +08:00
|
|
|
gimp_image_raise_item (image, GIMP_ITEM (vectors), NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
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
|
|
|
|
2010-07-09 00:08:13 +08:00
|
|
|
gimp_image_raise_item_to_top (image, GIMP_ITEM (vectors));
|
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_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
|
|
|
|
2010-07-09 00:08:13 +08:00
|
|
|
gimp_image_lower_item (image, GIMP_ITEM (vectors), NULL);
|
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-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
|
|
|
|
2010-07-09 00:08:13 +08:00
|
|
|
gimp_image_lower_item_to_bottom (image, GIMP_ITEM (vectors));
|
2006-03-29 01:08:36 +08:00
|
|
|
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
|
|
|
|
2008-01-08 19:46:15 +08:00
|
|
|
new_vectors = GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
|
|
|
|
G_TYPE_FROM_INSTANCE (vectors)));
|
2009-08-04 04:30:36 +08:00
|
|
|
|
2009-08-04 05:19:25 +08:00
|
|
|
/* use the actual parent here, not GIMP_IMAGE_ACTIVE_PARENT because
|
|
|
|
* the latter would add a duplicated group inside itself instead of
|
|
|
|
* above it
|
|
|
|
*/
|
2010-02-07 20:46:46 +08:00
|
|
|
gimp_image_add_vectors (image, new_vectors,
|
|
|
|
gimp_vectors_get_parent (vectors), -1,
|
|
|
|
TRUE);
|
2009-08-04 04:30:36 +08:00
|
|
|
|
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_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
|
|
|
|
2008-10-10 03:40:41 +08:00
|
|
|
gimp_image_remove_vectors (image, vectors, TRUE, NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
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;
|
2007-12-07 03:51:02 +08:00
|
|
|
GtkWidget *widget;
|
|
|
|
GError *error = NULL;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2007-12-07 03:51:02 +08:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
if (! gimp_image_merge_visible_vectors (image, &error))
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
2007-12-07 03:51:02 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
return;
|
|
|
|
}
|
2003-11-07 21:20:52 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
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
|
|
|
{
|
2010-07-21 05:09:19 +08:00
|
|
|
GimpImage *image;
|
|
|
|
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
|
|
|
|
2010-07-21 05:09:19 +08:00
|
|
|
gimp_item_to_selection (GIMP_ITEM (vectors),
|
|
|
|
(GimpChannelOps) value,
|
|
|
|
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
|
|
|
{
|
2012-05-04 06:50:23 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpProcedure *procedure;
|
|
|
|
GimpValueArray *args;
|
|
|
|
GimpDisplay *display;
|
|
|
|
GError *error = NULL;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_image (image, data);
|
2006-10-10 02:49:15 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (value)
|
2006-04-26 17:13:47 +08:00
|
|
|
procedure = gimp_pdb_lookup_procedure (image->gimp->pdb,
|
|
|
|
"plug-in-sel2path-advanced");
|
2004-05-23 18:04:41 +08:00
|
|
|
else
|
2006-04-26 17:13:47 +08:00
|
|
|
procedure = gimp_pdb_lookup_procedure (image->gimp->pdb,
|
|
|
|
"plug-in-sel2path");
|
2004-05-23 18:04:41 +08:00
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
if (! procedure)
|
2004-05-23 18:04:41 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_ERROR,
|
|
|
|
"Selection to path procedure lookup failed.");
|
2004-05-23 18:04:41 +08:00
|
|
|
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
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
2006-04-26 20:26:32 +08:00
|
|
|
gimp_value_array_truncate (args, 2);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
g_value_set_int (gimp_value_array_index (args, 0),
|
|
|
|
GIMP_RUN_INTERACTIVE);
|
|
|
|
gimp_value_set_image (gimp_value_array_index (args, 1),
|
|
|
|
image);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
2006-04-08 02:23:20 +08:00
|
|
|
gimp_procedure_execute_async (procedure, image->gimp,
|
|
|
|
action_data_get_context (data),
|
|
|
|
GIMP_PROGRESS (display), args,
|
2007-12-03 02:05:54 +08:00
|
|
|
GIMP_OBJECT (display), &error);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
2012-05-04 06:50:23 +08:00
|
|
|
gimp_value_array_unref (args);
|
2007-12-03 02:05:54 +08:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_ERROR,
|
|
|
|
error->message);
|
2007-12-03 02:05:54 +08:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2016-03-16 03:52:22 +08:00
|
|
|
void
|
|
|
|
vectors_fill_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
drawable = gimp_image_get_active_drawable (image);
|
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
|
|
|
gimp_message_literal (image->gimp,
|
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
_("There is no active layer or channel to fill."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
|
|
|
|
#define FILL_DIALOG_KEY "gimp-vectors-fill-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (drawable), FILL_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
dialog = fill_dialog_new (GIMP_ITEM (vectors),
|
|
|
|
action_data_get_context (data),
|
|
|
|
_("Fill Path"),
|
|
|
|
GIMP_STOCK_TOOL_BUCKET_FILL,
|
|
|
|
GIMP_HELP_PATH_FILL,
|
|
|
|
widget);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (drawable), FILL_DIALOG_KEY, dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2016-03-16 03:52:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_fill_last_vals_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2016-09-14 07:27:42 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpDialogConfig *config;
|
|
|
|
GError *error = NULL;
|
2016-03-16 03:52:22 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
|
|
|
drawable = gimp_image_get_active_drawable (image);
|
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
|
|
|
gimp_message_literal (image->gimp,
|
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
_("There is no active layer or channel to fill."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-14 07:27:42 +08:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2016-03-16 03:52:22 +08:00
|
|
|
|
|
|
|
if (! gimp_item_fill (GIMP_ITEM (vectors),
|
2016-09-14 07:27:42 +08:00
|
|
|
drawable, config->fill_options, TRUE, NULL, &error))
|
2016-03-16 03:52:22 +08:00
|
|
|
{
|
|
|
|
gimp_message_literal (image->gimp, G_OBJECT (widget),
|
|
|
|
GIMP_MESSAGE_WARNING, error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2007-07-19 22:59:51 +08:00
|
|
|
drawable = gimp_image_get_active_drawable (image);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
_("There is no active layer or channel to stroke to."));
|
2004-05-23 18:04:41 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-12 06:03:22 +08:00
|
|
|
#define STROKE_DIALOG_KEY "gimp-vectors-stroke-dialog"
|
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (drawable), STROKE_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
dialog = stroke_dialog_new (GIMP_ITEM (vectors),
|
|
|
|
action_data_get_context (data),
|
|
|
|
_("Stroke Path"),
|
|
|
|
GIMP_STOCK_PATH_STROKE,
|
|
|
|
GIMP_HELP_PATH_STROKE,
|
|
|
|
widget);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (drawable), STROKE_DIALOG_KEY, dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (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)
|
|
|
|
{
|
2016-09-14 07:27:42 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GimpContext *context;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpDialogConfig *config;
|
|
|
|
GError *error = NULL;
|
2004-10-21 07:14:24 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2006-10-01 19:13:00 +08:00
|
|
|
return_if_no_context (context, data);
|
2006-10-10 02:49:15 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2004-10-21 07:14:24 +08:00
|
|
|
|
2007-07-19 22:59:51 +08:00
|
|
|
drawable = gimp_image_get_active_drawable (image);
|
2004-10-21 07:14:24 +08:00
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 00:59:20 +08:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
_("There is no active layer or channel to stroke to."));
|
2004-10-21 07:14:24 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-09-14 07:27:42 +08:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2004-10-21 07:14:24 +08:00
|
|
|
|
2014-02-07 06:20:39 +08:00
|
|
|
if (! gimp_item_stroke (GIMP_ITEM (vectors),
|
2016-09-14 07:27:42 +08:00
|
|
|
drawable, context, config->stroke_options, NULL,
|
2008-10-25 19:59:03 +08:00
|
|
|
TRUE, NULL, &error))
|
2007-12-07 02:40:12 +08:00
|
|
|
{
|
2008-11-04 20:33:09 +08:00
|
|
|
gimp_message_literal (image->gimp, G_OBJECT (widget),
|
2013-09-15 00:59:20 +08:00
|
|
|
GIMP_MESSAGE_WARNING, error->message);
|
2007-12-07 02:40:12 +08:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
2004-10-21 07:14:24 +08:00
|
|
|
}
|
|
|
|
|
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;
|
2006-10-10 02:49:15 +08:00
|
|
|
GtkWidget *widget;
|
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);
|
2006-10-10 02:49:15 +08:00
|
|
|
return_if_no_widget (widget, 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,
|
2010-11-28 05:28:34 +08:00
|
|
|
TRUE, FALSE,
|
2009-08-04 04:30:36 +08:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, &error))
|
2005-09-20 05:33:03 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
2005-09-20 05:33:03 +08:00
|
|
|
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;
|
2008-11-11 16:24:21 +08:00
|
|
|
const gchar *folder;
|
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
|
|
|
|
2008-11-11 16:24:21 +08:00
|
|
|
folder = g_object_get_data (G_OBJECT (image->gimp),
|
|
|
|
"gimp-vectors-export-folder");
|
|
|
|
if (folder)
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
|
|
|
|
folder);
|
|
|
|
|
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;
|
2008-11-11 16:24:21 +08:00
|
|
|
const gchar *folder;
|
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
|
|
|
|
2008-11-11 16:24:21 +08:00
|
|
|
folder = g_object_get_data (G_OBJECT (image->gimp),
|
|
|
|
"gimp-vectors-import-folder");
|
|
|
|
if (folder)
|
|
|
|
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
|
|
|
|
folder);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-21 03:19:43 +08:00
|
|
|
void
|
|
|
|
vectors_lock_content_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
gboolean locked;
|
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
|
|
|
locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
if (locked != gimp_item_get_lock_content (GIMP_ITEM (vectors)))
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
GimpUndo *undo;
|
|
|
|
#endif
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
|
|
|
GIMP_UNDO_ITEM_LINKED);
|
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (vectors))
|
|
|
|
push_undo = FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
gimp_item_set_lock_content (GIMP_ITEM (vectors), locked, push_undo);
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-09 18:17:25 +08:00
|
|
|
void
|
|
|
|
vectors_lock_position_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
gboolean locked;
|
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
|
|
|
locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
|
|
|
|
|
|
|
|
if (locked != gimp_item_get_lock_position (GIMP_ITEM (vectors)))
|
|
|
|
{
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
|
|
|
|
undo = gimp_image_undo_can_compress (image, GIMP_TYPE_ITEM_UNDO,
|
|
|
|
GIMP_UNDO_ITEM_LOCK_POSITION);
|
|
|
|
|
|
|
|
if (undo && GIMP_ITEM_UNDO (undo)->item == GIMP_ITEM (vectors))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
|
|
|
|
|
|
|
gimp_item_set_lock_position (GIMP_ITEM (vectors), locked, push_undo);
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
}
|
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
|
2016-09-25 02:32:44 +08:00
|
|
|
vectors_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gpointer user_data)
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
2016-09-25 02:32:44 +08:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
g_object_set (config,
|
|
|
|
"path-new-name", vectors_name,
|
|
|
|
NULL);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
vectors = gimp_vectors_new (image, config->vectors_new_name);
|
|
|
|
gimp_image_add_vectors (image, vectors,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
|
|
|
gimp_image_flush (image);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
2003-09-13 10:33:30 +08:00
|
|
|
|
|
|
|
static void
|
2016-09-25 02:32:44 +08:00
|
|
|
vectors_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gpointer user_data)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2016-09-25 02:32:44 +08:00
|
|
|
if (strcmp (vectors_name, gimp_object_get_name (vectors)))
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2016-09-25 02:32:44 +08:00
|
|
|
gimp_item_rename (GIMP_ITEM (vectors), vectors_name, NULL);
|
|
|
|
gimp_image_flush (image);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
gtk_widget_destroy (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
|
|
|
{
|
2008-11-11 16:24:21 +08:00
|
|
|
GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
|
2014-07-02 20:54:56 +08:00
|
|
|
GFile *file;
|
2008-11-11 16:24:21 +08:00
|
|
|
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
|
|
|
|
2014-07-02 20:54:56 +08:00
|
|
|
file = gtk_file_chooser_get_file (chooser);
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2014-07-02 20:54:56 +08:00
|
|
|
if (gimp_vectors_import_file (dialog->image, file,
|
2004-10-24 06:54:41 +08:00
|
|
|
vectors_import_merge, vectors_import_scale,
|
2009-08-04 04:30:36 +08:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, &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
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (dialog->image->gimp, G_OBJECT (widget),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
2003-09-13 10:33:30 +08:00
|
|
|
g_error_free (error);
|
2006-10-10 02:49:15 +08:00
|
|
|
return;
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
2004-10-24 21:13:21 +08:00
|
|
|
|
2014-07-02 20:54:56 +08:00
|
|
|
g_object_unref (file);
|
2008-11-11 16:24:21 +08:00
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (dialog->image->gimp),
|
|
|
|
"gimp-vectors-import-folder",
|
|
|
|
gtk_file_chooser_get_current_folder (chooser),
|
|
|
|
(GDestroyNotify) g_free);
|
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)
|
|
|
|
{
|
2008-11-11 16:24:21 +08:00
|
|
|
GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
|
|
|
|
GimpVectors *vectors = NULL;
|
2014-07-02 20:47:11 +08:00
|
|
|
GFile *file;
|
2008-11-11 16:24:21 +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
|
|
|
|
2014-07-02 20:47:11 +08:00
|
|
|
file = gtk_file_chooser_get_file (chooser);
|
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
|
|
|
|
2014-07-02 20:47:11 +08:00
|
|
|
if (! gimp_vectors_export_file (dialog->image, vectors, file, &error))
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (dialog->image->gimp, G_OBJECT (widget),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
2004-09-20 06:26:41 +08:00
|
|
|
g_error_free (error);
|
2006-10-10 02:49:15 +08:00
|
|
|
return;
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
2004-10-24 21:13:21 +08:00
|
|
|
|
2014-07-02 20:47:11 +08:00
|
|
|
g_object_unref (file);
|
2008-11-11 16:24:21 +08:00
|
|
|
|
|
|
|
g_object_set_data_full (G_OBJECT (dialog->image->gimp),
|
|
|
|
"gimp-vectors-export-folder",
|
|
|
|
gtk_file_chooser_get_current_folder (chooser),
|
|
|
|
(GDestroyNotify) g_free);
|
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
|
|
|
}
|