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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://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"
|
2016-09-26 06:16:47 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.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"
|
2006-03-30 07:56:07 +08:00
|
|
|
#include "core/gimpparamspecs.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.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"
|
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"
|
2016-10-29 22:50:13 +08:00
|
|
|
#include "items-commands.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-10-31 00:02:59 +08:00
|
|
|
static void vectors_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gboolean vectors_visible,
|
|
|
|
gboolean vectors_linked,
|
|
|
|
GimpColorTag vectors_color_tag,
|
|
|
|
gboolean vectors_lock_content,
|
|
|
|
gboolean vectors_lock_position,
|
|
|
|
gpointer user_data);
|
|
|
|
static void vectors_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gboolean vectors_visible,
|
|
|
|
gboolean vectors_linked,
|
|
|
|
GimpColorTag vectors_color_tag,
|
|
|
|
gboolean vectors_lock_content,
|
|
|
|
gboolean vectors_lock_position,
|
|
|
|
gpointer user_data);
|
|
|
|
static void vectors_import_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *import_folder,
|
|
|
|
gboolean merge_vectors,
|
|
|
|
gboolean scale_vectors,
|
|
|
|
gpointer user_data);
|
|
|
|
static void vectors_export_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *export_folder,
|
|
|
|
gboolean active_only,
|
|
|
|
gpointer user_data);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_edit_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-05-25 22:37:02 +08:00
|
|
|
{
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_edit_attributes_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-05-25 22:37:02 +08:00
|
|
|
{
|
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)
|
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
GimpItem *item = GIMP_ITEM (vectors);
|
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
dialog = vectors_options_dialog_new (image, vectors,
|
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("Path Attributes"),
|
|
|
|
"gimp-vectors-edit",
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_EDIT,
|
2016-09-25 02:32:44 +08:00
|
|
|
_("Edit Path Attributes"),
|
|
|
|
GIMP_HELP_PATH_EDIT,
|
|
|
|
gimp_object_get_name (vectors),
|
2016-10-26 22:51:56 +08:00
|
|
|
gimp_item_get_visible (item),
|
|
|
|
gimp_item_get_linked (item),
|
2016-10-29 22:50:13 +08:00
|
|
|
gimp_item_get_color_tag (item),
|
2016-10-26 22:51:56 +08:00
|
|
|
gimp_item_get_lock_content (item),
|
|
|
|
gimp_item_get_lock_position (item),
|
2016-09-25 02:32:44 +08:00
|
|
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_new_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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",
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_PATH,
|
2016-10-24 05:01:47 +08:00
|
|
|
_("Create a New Path"),
|
2016-09-25 02:32:44 +08:00
|
|
|
GIMP_HELP_PATH_NEW,
|
|
|
|
config->vectors_new_name,
|
2016-10-26 22:51:56 +08:00
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2016-10-29 22:50:13 +08:00
|
|
|
GIMP_COLOR_TAG_NONE,
|
2016-10-26 22:51:56 +08:00
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2016-09-25 02:32:44 +08:00
|
|
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_new_last_vals_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
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);
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_raise_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_raise_to_top_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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_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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_lower_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_lower_to_bottom_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
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_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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_duplicate_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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 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);
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_delete_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_merge_visible_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2003-11-07 21:20:52 +08:00
|
|
|
{
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_to_selection_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2019-07-04 07:11:48 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpChannelOps operation;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
operation = (GimpChannelOps) g_variant_get_int32 (value);
|
|
|
|
|
|
|
|
gimp_item_to_selection (GIMP_ITEM (vectors), operation,
|
2010-07-21 05:09:19 +08:00
|
|
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_selection_to_vectors_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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;
|
2019-07-04 07:11:48 +08:00
|
|
|
gboolean advanced;
|
2012-05-04 06:50:23 +08:00
|
|
|
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
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
advanced = (gboolean) g_variant_get_int32 (value);
|
|
|
|
|
2019-08-28 09:13:09 +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);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
2019-08-29 17:25:35 +08:00
|
|
|
g_value_set_enum (gimp_value_array_index (args, 0),
|
|
|
|
advanced ?
|
|
|
|
GIMP_RUN_INTERACTIVE : GIMP_RUN_NONINTERACTIVE);
|
|
|
|
g_value_set_object (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,
|
2019-09-04 20:27:18 +08:00
|
|
|
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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_fill_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2016-03-16 03:52:22 +08:00
|
|
|
{
|
2016-10-31 00:02:59 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
2016-03-16 03:52:22 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
2016-10-31 00:02:59 +08:00
|
|
|
items_fill_cmd_callback (action,
|
|
|
|
image, GIMP_ITEM (vectors),
|
|
|
|
"gimp-vectors-fill-dialog",
|
|
|
|
_("Fill Path"),
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_BUCKET_FILL,
|
2016-10-31 00:02:59 +08:00
|
|
|
GIMP_HELP_PATH_FILL,
|
|
|
|
data);
|
2016-03-16 03:52:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_fill_last_vals_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2016-03-16 03:52:22 +08:00
|
|
|
{
|
2016-10-31 00:02:59 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
2016-03-16 03:52:22 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
2016-10-31 00:02:59 +08:00
|
|
|
items_fill_last_vals_cmd_callback (action,
|
|
|
|
image, GIMP_ITEM (vectors),
|
|
|
|
data);
|
2016-03-16 03:52:22 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_stroke_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2016-10-31 00:02:59 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2016-09-12 06:03:22 +08:00
|
|
|
|
2016-10-31 00:02:59 +08:00
|
|
|
items_stroke_cmd_callback (action,
|
|
|
|
image, GIMP_ITEM (vectors),
|
|
|
|
"gimp-vectors-stroke-dialog",
|
|
|
|
_("Stroke Path"),
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_PATH_STROKE,
|
2016-10-31 00:02:59 +08:00
|
|
|
GIMP_HELP_PATH_STROKE,
|
|
|
|
data);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
2004-10-21 07:14:24 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_stroke_last_vals_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-10-21 07:14:24 +08:00
|
|
|
{
|
2016-10-31 00:02:59 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
2004-10-21 07:14:24 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
2016-10-31 00:02:59 +08:00
|
|
|
items_stroke_last_vals_cmd_callback (action,
|
|
|
|
image, GIMP_ITEM (vectors),
|
|
|
|
data);
|
2004-10-21 07:14:24 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 22:40:30 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_copy_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_paste_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +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
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_export_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2016-10-28 03:26:07 +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-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
#define EXPORT_DIALOG_KEY "gimp-vectors-export-dialog"
|
2016-09-26 06:16:47 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY);
|
2016-09-26 06:16:47 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (! dialog)
|
2016-09-26 06:16:47 +08:00
|
|
|
{
|
2016-10-28 03:26:07 +08:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
GFile *folder = NULL;
|
|
|
|
|
|
|
|
if (config->vectors_export_path)
|
|
|
|
folder = gimp_file_new_for_config_path (config->vectors_export_path,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dialog = vectors_export_dialog_new (image, widget,
|
|
|
|
folder,
|
|
|
|
config->vectors_export_active_only,
|
|
|
|
vectors_export_callback,
|
|
|
|
NULL);
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2016-09-26 06:16:47 +08:00
|
|
|
if (folder)
|
2016-10-28 03:26:07 +08:00
|
|
|
g_object_unref (folder);
|
2008-11-11 16:24:21 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY, dialog);
|
|
|
|
}
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_import_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2002-02-26 22:40:30 +08:00
|
|
|
{
|
2016-10-28 03:26:07 +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 22:40:30 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
#define IMPORT_DIALOG_KEY "gimp-vectors-import-dialog"
|
2016-09-26 06:16:47 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), IMPORT_DIALOG_KEY);
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (! dialog)
|
2016-09-26 06:16:47 +08:00
|
|
|
{
|
2016-10-28 03:26:07 +08:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
GFile *folder = NULL;
|
2016-09-26 06:16:47 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (config->vectors_import_path)
|
|
|
|
folder = gimp_file_new_for_config_path (config->vectors_import_path,
|
|
|
|
NULL);
|
2008-11-11 16:24:21 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
dialog = vectors_import_dialog_new (image, widget,
|
|
|
|
folder,
|
|
|
|
config->vectors_import_merge,
|
|
|
|
config->vectors_import_scale,
|
|
|
|
vectors_import_callback,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), IMPORT_DIALOG_KEY, dialog);
|
|
|
|
}
|
2004-10-19 22:08:44 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_visible_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-09-15 21:24:45 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-09-15 21:24:45 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
items_visible_cmd_callback (action, value, image, GIMP_ITEM (vectors));
|
2004-09-15 21:24:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_linked_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2004-09-15 21:24:45 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2004-09-15 21:24:45 +08:00
|
|
|
GimpVectors *vectors;
|
2006-03-29 01:08:36 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2004-09-15 21:24:45 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
items_linked_cmd_callback (action, value, image, GIMP_ITEM (vectors));
|
2004-09-15 21:24:45 +08:00
|
|
|
}
|
|
|
|
|
2009-08-21 03:19:43 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_lock_content_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2009-08-21 03:19:43 +08:00
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
items_lock_content_cmd_callback (action, value, image, GIMP_ITEM (vectors));
|
2009-08-21 03:19:43 +08:00
|
|
|
}
|
|
|
|
|
2012-11-09 18:17:25 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_lock_position_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2012-11-09 18:17:25 +08:00
|
|
|
{
|
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (image, vectors, data);
|
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
items_lock_position_cmd_callback (action, value, image, GIMP_ITEM (vectors));
|
2016-10-29 22:50:13 +08:00
|
|
|
}
|
2012-11-09 18:17:25 +08:00
|
|
|
|
2016-10-29 22:50:13 +08:00
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_color_tag_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2016-10-29 22:50:13 +08:00
|
|
|
{
|
2019-07-04 07:11:48 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpColorTag color_tag;
|
2016-10-29 22:50:13 +08:00
|
|
|
return_if_no_vectors (image, vectors, data);
|
2012-11-09 18:17:25 +08:00
|
|
|
|
2019-07-04 07:11:48 +08:00
|
|
|
color_tag = (GimpColorTag) g_variant_get_int32 (value);
|
|
|
|
|
2016-10-29 22:50:13 +08:00
|
|
|
items_color_tag_cmd_callback (action, image, GIMP_ITEM (vectors),
|
2019-07-04 07:11:48 +08:00
|
|
|
color_tag);
|
2012-11-09 18:17:25 +08:00
|
|
|
}
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2016-09-26 04:18:37 +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-10-29 22:50:13 +08:00
|
|
|
vectors_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gboolean vectors_visible,
|
|
|
|
gboolean vectors_linked,
|
|
|
|
GimpColorTag vectors_color_tag,
|
|
|
|
gboolean vectors_lock_content,
|
|
|
|
gboolean vectors_lock_position,
|
|
|
|
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);
|
2016-10-26 22:51:56 +08:00
|
|
|
gimp_item_set_visible (GIMP_ITEM (vectors), vectors_visible, FALSE);
|
|
|
|
gimp_item_set_linked (GIMP_ITEM (vectors), vectors_linked, FALSE);
|
2016-10-29 22:50:13 +08:00
|
|
|
gimp_item_set_color_tag (GIMP_ITEM (vectors), vectors_color_tag, FALSE);
|
2016-10-26 22:51:56 +08:00
|
|
|
gimp_item_set_lock_content (GIMP_ITEM (vectors), vectors_lock_content, FALSE);
|
|
|
|
gimp_item_set_lock_position (GIMP_ITEM (vectors), vectors_lock_position, FALSE);
|
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
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-10-29 22:50:13 +08:00
|
|
|
vectors_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *vectors_name,
|
|
|
|
gboolean vectors_visible,
|
|
|
|
gboolean vectors_linked,
|
|
|
|
GimpColorTag vectors_color_tag,
|
|
|
|
gboolean vectors_lock_content,
|
|
|
|
gboolean vectors_lock_position,
|
|
|
|
gpointer user_data)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
GimpItem *item = GIMP_ITEM (vectors);
|
|
|
|
|
|
|
|
if (strcmp (vectors_name, gimp_object_get_name (vectors)) ||
|
|
|
|
vectors_visible != gimp_item_get_visible (item) ||
|
|
|
|
vectors_linked != gimp_item_get_linked (item) ||
|
2016-10-29 22:50:13 +08:00
|
|
|
vectors_color_tag != gimp_item_get_color_tag (item) ||
|
2016-10-26 22:51:56 +08:00
|
|
|
vectors_lock_content != gimp_item_get_lock_content (item) ||
|
|
|
|
vectors_lock_position != gimp_item_get_lock_position (item))
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2016-10-26 22:51:56 +08:00
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
|
|
|
|
_("Path Attributes"));
|
|
|
|
|
|
|
|
if (strcmp (vectors_name, gimp_object_get_name (vectors)))
|
|
|
|
gimp_item_rename (GIMP_ITEM (vectors), vectors_name, NULL);
|
|
|
|
|
|
|
|
if (vectors_visible != gimp_item_get_visible (item))
|
|
|
|
gimp_item_set_visible (item, vectors_visible, TRUE);
|
|
|
|
|
|
|
|
if (vectors_linked != gimp_item_get_linked (item))
|
|
|
|
gimp_item_set_linked (item, vectors_linked, TRUE);
|
|
|
|
|
2016-10-29 22:50:13 +08:00
|
|
|
if (vectors_color_tag != gimp_item_get_color_tag (item))
|
|
|
|
gimp_item_set_color_tag (item, vectors_color_tag, TRUE);
|
|
|
|
|
2016-10-26 22:51:56 +08:00
|
|
|
if (vectors_lock_content != gimp_item_get_lock_content (item))
|
|
|
|
gimp_item_set_lock_content (item, vectors_lock_content, TRUE);
|
|
|
|
|
|
|
|
if (vectors_lock_position != gimp_item_get_lock_position (item))
|
|
|
|
gimp_item_set_lock_position (item, vectors_lock_position, TRUE);
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
2016-09-25 02:32:44 +08:00
|
|
|
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
|
2016-10-28 03:26:07 +08:00
|
|
|
vectors_import_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *import_folder,
|
|
|
|
gboolean merge_vectors,
|
|
|
|
gboolean scale_vectors,
|
|
|
|
gpointer user_data)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2016-10-28 03:26:07 +08:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
gchar *path = NULL;
|
|
|
|
GError *error = NULL;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (import_folder)
|
|
|
|
path = gimp_file_get_config_path (import_folder, NULL);
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
g_object_set (config,
|
|
|
|
"path-import-path", path,
|
|
|
|
"path-import-merge", merge_vectors,
|
|
|
|
"path-import-scale", scale_vectors,
|
|
|
|
NULL);
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (path)
|
|
|
|
g_free (path);
|
2004-10-24 21:13:21 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (gimp_vectors_import_file (image, file,
|
|
|
|
config->vectors_import_merge,
|
|
|
|
config->vectors_import_scale,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, &error))
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
return;
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
static void
|
2016-10-28 03:26:07 +08:00
|
|
|
vectors_export_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *export_folder,
|
|
|
|
gboolean active_only,
|
|
|
|
gpointer user_data)
|
2004-09-20 06:26:41 +08:00
|
|
|
{
|
2016-10-28 03:26:07 +08:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
GimpVectors *vectors = NULL;
|
|
|
|
gchar *path = NULL;
|
|
|
|
GError *error = NULL;
|
2016-09-26 06:16:47 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (export_folder)
|
|
|
|
path = gimp_file_get_config_path (export_folder, NULL);
|
2004-09-20 06:26:41 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
g_object_set (config,
|
|
|
|
"path-export-path", path,
|
|
|
|
"path-export-active-only", active_only,
|
|
|
|
NULL);
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (path)
|
|
|
|
g_free (path);
|
2004-10-24 05:49:46 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (config->vectors_export_active_only)
|
|
|
|
vectors = gimp_image_get_active_vectors (image);
|
2004-10-24 21:13:21 +08:00
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
if (! gimp_vectors_export_file (image, vectors, file, &error))
|
|
|
|
{
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
return;
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
|
|
|
|
2016-10-28 03:26:07 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
2004-09-20 06:26:41 +08:00
|
|
|
}
|
2017-06-26 04:10:11 +08:00
|
|
|
|
|
|
|
void
|
2019-07-02 22:12:18 +08:00
|
|
|
vectors_select_cmd_callback (GimpAction *action,
|
2019-07-04 07:11:48 +08:00
|
|
|
GVariant *value,
|
2019-07-02 22:12:18 +08:00
|
|
|
gpointer data)
|
2017-06-26 04:10:11 +08:00
|
|
|
{
|
2020-04-29 19:30:35 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpContainer *container;
|
|
|
|
GimpVectors *new_vectors;
|
|
|
|
GimpActionSelectType select_type;
|
2017-06-26 04:10:11 +08:00
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
2020-04-29 19:30:35 +08:00
|
|
|
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
|
|
|
|
2017-06-26 04:10:11 +08:00
|
|
|
vectors = gimp_image_get_active_vectors (image);
|
|
|
|
|
|
|
|
if (vectors)
|
|
|
|
container = gimp_item_get_container (GIMP_ITEM (vectors));
|
|
|
|
else
|
|
|
|
container = gimp_image_get_vectors (image);
|
|
|
|
|
2020-04-29 19:30:35 +08:00
|
|
|
new_vectors = (GimpVectors *) action_select_object (select_type,
|
|
|
|
container,
|
2017-06-26 04:10:11 +08:00
|
|
|
(GimpObject *) vectors);
|
|
|
|
|
|
|
|
if (new_vectors && new_vectors != vectors)
|
|
|
|
{
|
|
|
|
gimp_image_set_active_vectors (image, new_vectors);
|
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
2017-07-18 19:23:23 +08:00
|
|
|
}
|