2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2002-02-25 17:58:50 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2002-02-25 17:58:50 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-02-25 17:58:50 +00: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-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2002-02-25 17:58:50 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-28 00:10:56 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2002-02-25 17:58:50 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2016-09-26 00:16:47 +02:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 13:25:55 +00:00
|
|
|
#include "actions-types.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2016-08-24 19:49:59 +02:00
|
|
|
#include "config/gimpdialogconfig.h"
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
#include "core/gimp.h"
|
2006-04-11 00:00:36 +00:00
|
|
|
#include "core/gimp-utils.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
#include "core/gimpchannel.h"
|
2002-02-26 02:00:02 +00:00
|
|
|
#include "core/gimpcontext.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
#include "core/gimpimage.h"
|
2003-11-07 17:29:02 +00:00
|
|
|
#include "core/gimpimage-merge.h"
|
2004-09-15 13:24:45 +00:00
|
|
|
#include "core/gimpimage-undo.h"
|
2006-03-29 23:56:07 +00:00
|
|
|
#include "core/gimpparamspecs.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "core/gimpprogress.h"
|
2002-02-26 02:00:02 +00:00
|
|
|
#include "core/gimptoolinfo.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2006-04-26 09:13:47 +00:00
|
|
|
#include "pdb/gimppdb.h"
|
2006-03-31 09:15:08 +00:00
|
|
|
#include "pdb/gimpprocedure.h"
|
2003-05-15 14:31:22 +00:00
|
|
|
|
2024-07-12 06:16:25 +00:00
|
|
|
#include "vectors/gimppath.h"
|
2024-07-13 05:07:57 +00:00
|
|
|
#include "vectors/gimppath-export.h"
|
|
|
|
#include "vectors/gimppath-import.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2004-10-16 15:48:23 +00:00
|
|
|
#include "widgets/gimpaction.h"
|
2005-09-19 21:33:03 +00:00
|
|
|
#include "widgets/gimpclipboard.h"
|
2003-08-21 15:54:47 +00:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2002-12-10 16:38:16 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2002-02-26 02:00:02 +00:00
|
|
|
#include "tools/gimpvectortool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2016-09-12 00:03:22 +02:00
|
|
|
#include "dialogs/dialogs.h"
|
2024-07-13 05:07:57 +00:00
|
|
|
#include "dialogs/path-export-dialog.h"
|
|
|
|
#include "dialogs/path-import-dialog.h"
|
|
|
|
#include "dialogs/path-options-dialog.h"
|
2004-04-20 13:25:55 +00:00
|
|
|
|
2004-05-03 14:03:51 +00:00
|
|
|
#include "actions.h"
|
2016-10-29 16:50:13 +02:00
|
|
|
#include "items-commands.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
#include "vectors-commands.h"
|
|
|
|
|
2003-03-25 16:38:19 +00:00
|
|
|
#include "gimp-intl.h"
|
2002-02-25 17:58:50 +00:00
|
|
|
|
|
|
|
|
2004-05-03 14:46:29 +00:00
|
|
|
/* local function prototypes */
|
2004-04-29 12:52:29 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
static void paths_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpPath *path,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *path_name,
|
|
|
|
gboolean path_visible,
|
|
|
|
GimpColorTag path_color_tag,
|
|
|
|
gboolean path_lock_content,
|
|
|
|
gboolean path_lock_position,
|
|
|
|
gboolean path_lock_visibility,
|
|
|
|
gpointer user_data);
|
|
|
|
static void paths_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpPath *path,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *path_name,
|
|
|
|
gboolean path_visible,
|
|
|
|
GimpColorTag path_color_tag,
|
|
|
|
gboolean path_lock_content,
|
|
|
|
gboolean path_lock_position,
|
|
|
|
gboolean path_lock_visibility,
|
|
|
|
gpointer user_data);
|
|
|
|
static void paths_import_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *import_folder,
|
|
|
|
gboolean merge_paths,
|
|
|
|
gboolean scale_paths,
|
|
|
|
gpointer user_data);
|
|
|
|
static void paths_export_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *export_folder,
|
|
|
|
gboolean active_only,
|
|
|
|
gpointer user_data);
|
2004-09-19 22:26:41 +00:00
|
|
|
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
/* public functions */
|
|
|
|
|
2004-05-25 14:37:02 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_edit_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-05-25 14:37:02 +00:00
|
|
|
{
|
2023-01-11 00:30:32 +01:00
|
|
|
GimpImage *image;
|
2024-07-13 05:07:57 +00:00
|
|
|
GList *paths;
|
2023-01-11 00:30:32 +01:00
|
|
|
GimpTool *active_tool;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, paths, data);
|
2023-01-11 00:30:32 +01:00
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
if (g_list_length (paths) != 1)
|
2023-01-11 00:30:32 +01:00
|
|
|
return;
|
2004-05-25 14:37:02 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
active_tool = tool_manager_get_active (image->gimp);
|
2004-10-16 15:48:23 +00:00
|
|
|
|
|
|
|
if (! GIMP_IS_VECTOR_TOOL (active_tool))
|
|
|
|
{
|
2006-09-08 13:42:00 +00:00
|
|
|
GimpToolInfo *tool_info = gimp_get_tool_info (image->gimp,
|
|
|
|
"gimp-vector-tool");
|
2004-10-16 15:48:23 +00:00
|
|
|
|
|
|
|
if (GIMP_IS_TOOL_INFO (tool_info))
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (action_data_get_context (data), tool_info);
|
2006-03-28 17:08:36 +00:00
|
|
|
active_tool = tool_manager_get_active (image->gimp);
|
2004-10-16 15:48:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_VECTOR_TOOL (active_tool))
|
2024-07-13 05:07:57 +00:00
|
|
|
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), paths->data);
|
2004-05-25 14:37:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_edit_attributes_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-05-25 14:37:02 +00:00
|
|
|
{
|
2016-09-24 20:32:44 +02:00
|
|
|
GimpImage *image;
|
2023-01-11 00:30:32 +01:00
|
|
|
GList *paths;
|
2024-08-04 20:11:53 +02:00
|
|
|
GimpPath *path;
|
2016-09-24 20:32:44 +02:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, paths, data);
|
2004-05-25 14:37:02 +00:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2023-01-11 00:30:32 +01:00
|
|
|
if (g_list_length (paths) != 1)
|
|
|
|
return;
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
path = paths->data;
|
2023-01-11 00:30:32 +01:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
#define EDIT_DIALOG_KEY "gimp-path-edit-attributes-dialog"
|
2016-09-24 20:32:44 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (path), EDIT_DIALOG_KEY);
|
2016-09-24 20:32:44 +02:00
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
2024-08-04 20:11:53 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (path);
|
2016-10-26 16:51:56 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
dialog = path_options_dialog_new (image, path,
|
2024-07-13 05:07:57 +00:00
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("Path Attributes"),
|
2024-08-04 20:11:53 +02:00
|
|
|
"gimp-path-edit",
|
2024-07-13 05:07:57 +00:00
|
|
|
GIMP_ICON_EDIT,
|
|
|
|
_("Edit Path Attributes"),
|
|
|
|
GIMP_HELP_PATH_EDIT,
|
2024-08-04 20:11:53 +02:00
|
|
|
gimp_object_get_name (path),
|
2024-07-13 05:07:57 +00:00
|
|
|
gimp_item_get_visible (item),
|
|
|
|
gimp_item_get_color_tag (item),
|
|
|
|
gimp_item_get_lock_content (item),
|
|
|
|
gimp_item_get_lock_position (item),
|
|
|
|
gimp_item_get_lock_visibility (item),
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_edit_attributes_callback,
|
2024-07-13 05:07:57 +00:00
|
|
|
NULL);
|
2016-09-24 20:32:44 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
dialogs_attach_dialog (G_OBJECT (path), EDIT_DIALOG_KEY, dialog);
|
2016-09-24 20:32:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-05-25 14:37:02 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_new_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2016-09-24 20:32:44 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2004-04-29 12:52:29 +00:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
#define NEW_DIALOG_KEY "gimp-path-new-dialog"
|
2016-09-24 20:32:44 +02:00
|
|
|
|
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), NEW_DIALOG_KEY);
|
|
|
|
|
|
|
|
if (! dialog)
|
|
|
|
{
|
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
dialog = path_options_dialog_new (image, NULL,
|
|
|
|
action_data_get_context (data),
|
|
|
|
widget,
|
|
|
|
_("New Path"),
|
2024-08-04 20:11:53 +02:00
|
|
|
"gimp-path-new",
|
2024-07-13 05:07:57 +00:00
|
|
|
GIMP_ICON_PATH,
|
|
|
|
_("Create a New Path"),
|
|
|
|
GIMP_HELP_PATH_NEW,
|
2024-08-04 20:11:53 +02:00
|
|
|
config->path_new_name,
|
2024-07-13 05:07:57 +00:00
|
|
|
FALSE,
|
|
|
|
GIMP_COLOR_TAG_NONE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
|
|
|
FALSE,
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_new_callback,
|
2024-07-13 05:07:57 +00:00
|
|
|
NULL);
|
2016-09-24 20:32:44 +02:00
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), NEW_DIALOG_KEY, dialog);
|
|
|
|
}
|
2016-08-24 19:49:59 +02:00
|
|
|
|
2016-09-24 20:32:44 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2004-10-16 15:48:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_new_last_vals_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-10-16 15:48:23 +00:00
|
|
|
{
|
2016-08-24 19:49:59 +02:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GimpPath *path;
|
2016-08-24 19:49:59 +02:00
|
|
|
GimpDialogConfig *config;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2004-10-16 15:48:23 +00:00
|
|
|
|
2016-08-24 19:49:59 +02:00
|
|
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2004-10-16 15:48:23 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
path = gimp_path_new (image, config->path_new_name);
|
|
|
|
gimp_image_add_path (image, path,
|
2024-07-11 00:07:44 +00:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 14:54:24 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_raise_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-04-19 14:54:24 +00:00
|
|
|
{
|
2022-10-12 21:45:13 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GList *list;
|
|
|
|
GList *iter;
|
|
|
|
GList *moved_list = NULL;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, list, data);
|
2004-04-19 14:54:24 +00:00
|
|
|
|
2022-10-12 21:45:13 +02:00
|
|
|
for (iter = list; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
gint index;
|
|
|
|
|
|
|
|
index = gimp_item_get_index (iter->data);
|
|
|
|
if (index > 0)
|
2024-07-16 15:21:44 +00:00
|
|
|
{
|
|
|
|
moved_list = g_list_prepend (moved_list, iter->data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
g_list_free (moved_list);
|
|
|
|
return;
|
|
|
|
}
|
2022-10-12 21:45:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (moved_list)
|
|
|
|
{
|
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
|
|
|
ngettext ("Raise Path",
|
|
|
|
"Raise Paths",
|
|
|
|
g_list_length (moved_list)));
|
2024-07-16 15:21:44 +00:00
|
|
|
|
|
|
|
moved_list = g_list_reverse (moved_list);
|
2022-10-12 21:45:13 +02:00
|
|
|
for (iter = moved_list; iter; iter = iter->next)
|
|
|
|
gimp_image_raise_item (image, GIMP_ITEM (iter->data), NULL);
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
g_list_free (moved_list);
|
|
|
|
}
|
2004-04-19 14:54:24 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_raise_to_top_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2022-10-12 21:45:13 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GList *list;
|
|
|
|
GList *iter;
|
|
|
|
GList *moved_list = NULL;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, list, data);
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2022-10-12 21:45:13 +02:00
|
|
|
for (iter = list; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
gint index;
|
|
|
|
|
|
|
|
index = gimp_item_get_index (iter->data);
|
|
|
|
if (index > 0)
|
|
|
|
moved_list = g_list_prepend (moved_list, iter->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moved_list)
|
|
|
|
{
|
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
|
|
|
ngettext ("Raise Path to Top",
|
|
|
|
"Raise Paths to Top",
|
|
|
|
g_list_length (moved_list)));
|
|
|
|
|
|
|
|
for (iter = moved_list; iter; iter = iter->next)
|
|
|
|
gimp_image_raise_item_to_top (image, GIMP_ITEM (iter->data));
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
g_list_free (moved_list);
|
|
|
|
}
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_lower_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2022-10-12 21:45:13 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GList *list;
|
|
|
|
GList *iter;
|
|
|
|
GList *moved_list = NULL;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, list, data);
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2022-10-12 21:45:13 +02:00
|
|
|
for (iter = list; iter; iter = iter->next)
|
|
|
|
{
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths_list;
|
2022-10-12 21:45:13 +02:00
|
|
|
gint index;
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_list = gimp_item_get_container_iter (GIMP_ITEM (iter->data));
|
2022-10-12 21:45:13 +02:00
|
|
|
index = gimp_item_get_index (iter->data);
|
2024-08-04 20:11:53 +02:00
|
|
|
if (index < g_list_length (paths_list) - 1)
|
2024-07-16 15:21:44 +00:00
|
|
|
{
|
|
|
|
moved_list = g_list_prepend (moved_list, iter->data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_flush (image);
|
|
|
|
g_list_free (moved_list);
|
|
|
|
return;
|
|
|
|
}
|
2022-10-12 21:45:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (moved_list)
|
|
|
|
{
|
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
|
|
|
ngettext ("Lower Path",
|
|
|
|
"Lower Paths",
|
|
|
|
g_list_length (moved_list)));
|
|
|
|
|
|
|
|
for (iter = moved_list; iter; iter = iter->next)
|
|
|
|
gimp_image_lower_item (image, GIMP_ITEM (iter->data), NULL);
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
g_list_free (moved_list);
|
|
|
|
}
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
2004-04-19 14:54:24 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_lower_to_bottom_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-04-19 14:54:24 +00:00
|
|
|
{
|
2022-10-12 21:45:13 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GList *list;
|
|
|
|
GList *iter;
|
|
|
|
GList *moved_list = NULL;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, list, data);
|
2004-04-19 14:54:24 +00:00
|
|
|
|
2022-10-12 21:45:13 +02:00
|
|
|
for (iter = list; iter; iter = iter->next)
|
|
|
|
{
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths_list;
|
2022-10-12 21:45:13 +02:00
|
|
|
gint index;
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_list = gimp_item_get_container_iter (GIMP_ITEM (iter->data));
|
2022-10-12 21:45:13 +02:00
|
|
|
index = gimp_item_get_index (iter->data);
|
2024-08-04 20:11:53 +02:00
|
|
|
if (index < g_list_length (paths_list) - 1)
|
2022-10-12 21:45:13 +02:00
|
|
|
moved_list = g_list_prepend (moved_list, iter->data);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (moved_list)
|
|
|
|
{
|
|
|
|
moved_list = g_list_reverse (moved_list);
|
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
|
|
|
ngettext ("Lower Path to Bottom",
|
|
|
|
"Lower Paths to Bottom",
|
|
|
|
g_list_length (moved_list)));
|
|
|
|
|
|
|
|
for (iter = moved_list; iter; iter = iter->next)
|
|
|
|
gimp_image_lower_item_to_bottom (image, GIMP_ITEM (iter->data));
|
|
|
|
|
|
|
|
gimp_image_flush (image);
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
g_list_free (moved_list);
|
|
|
|
}
|
2004-04-19 14:54:24 +00:00
|
|
|
}
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_duplicate_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2023-01-11 00:30:32 +01:00
|
|
|
GimpImage *image;
|
|
|
|
GList *paths;
|
|
|
|
GList *new_paths = NULL;
|
|
|
|
GList *iter;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, paths, data);
|
2023-01-11 00:30:32 +01:00
|
|
|
|
|
|
|
paths = g_list_copy (paths);
|
|
|
|
paths = g_list_reverse (paths);
|
|
|
|
|
|
|
|
/* TODO: proper undo group. */
|
|
|
|
gimp_image_undo_group_start (image,
|
2024-07-13 05:07:57 +00:00
|
|
|
GIMP_UNDO_GROUP_PATHS_IMPORT,
|
2023-01-11 00:30:32 +01:00
|
|
|
_("Duplicate Paths"));
|
|
|
|
for (iter = paths; iter; iter = iter->next)
|
|
|
|
{
|
2024-07-12 06:16:25 +00:00
|
|
|
GimpPath *new_path;
|
2023-01-11 00:30:32 +01:00
|
|
|
|
2024-07-12 06:16:25 +00:00
|
|
|
new_path = GIMP_PATH (gimp_item_duplicate (iter->data,
|
|
|
|
G_TYPE_FROM_INSTANCE (iter->data)));
|
2023-01-11 00:30:32 +01: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
|
|
|
|
*/
|
2024-07-11 00:07:44 +00:00
|
|
|
gimp_image_add_path (image, new_path,
|
2024-07-13 05:07:57 +00:00
|
|
|
gimp_path_get_parent (iter->data), -1,
|
2024-07-11 00:07:44 +00:00
|
|
|
TRUE);
|
|
|
|
new_paths = g_list_prepend (new_paths, new_path);
|
2023-01-11 00:30:32 +01:00
|
|
|
}
|
|
|
|
if (new_paths)
|
|
|
|
{
|
2024-07-11 00:07:44 +00:00
|
|
|
gimp_image_set_selected_paths (image, new_paths);
|
2023-01-11 00:30:32 +01:00
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
g_list_free (paths);
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_delete_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2023-01-11 00:30:32 +01:00
|
|
|
GimpImage *image;
|
|
|
|
GList *paths;
|
2024-07-17 23:25:48 +00:00
|
|
|
return_if_no_paths (image, paths, data);
|
2023-01-11 00:30:32 +01:00
|
|
|
|
|
|
|
paths = g_list_copy (paths);
|
|
|
|
/* TODO: proper undo group. */
|
|
|
|
gimp_image_undo_group_start (image,
|
2024-07-13 05:07:57 +00:00
|
|
|
GIMP_UNDO_GROUP_PATHS_IMPORT,
|
2023-01-11 00:30:32 +01:00
|
|
|
_("Remove Paths"));
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2023-01-11 00:30:32 +01:00
|
|
|
for (GList *iter = paths; iter; iter = iter->next)
|
2024-07-11 00:07:44 +00:00
|
|
|
gimp_image_remove_path (image, iter->data, TRUE, NULL);
|
2023-01-11 00:30:32 +01:00
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2023-01-11 00:30:32 +01:00
|
|
|
g_list_free (paths);
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
2003-11-07 13:20:52 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_merge_visible_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2003-11-07 13:20:52 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
2007-12-06 19:51:02 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
GError *error = NULL;
|
2024-08-04 20:11:53 +02:00
|
|
|
return_if_no_paths (image, paths, data);
|
2007-12-06 19:51:02 +00:00
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2024-07-11 00:07:44 +00:00
|
|
|
if (! gimp_image_merge_visible_paths (image, &error))
|
2007-12-06 19:51:02 +00:00
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 04:59:20 +12:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
|
|
|
|
error->message);
|
2007-12-06 19:51:02 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
return;
|
|
|
|
}
|
2003-11-07 13:20:52 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2003-11-07 13:20:52 +00:00
|
|
|
}
|
|
|
|
|
2003-08-27 00:52:00 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_to_selection_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2019-07-04 01:11:48 +02:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
2023-01-10 20:05:15 +01:00
|
|
|
GList *iter;
|
2019-07-04 01:11:48 +02:00
|
|
|
GimpChannelOps operation;
|
2024-08-04 20:11:53 +02:00
|
|
|
return_if_no_paths (image, paths, data);
|
2023-01-10 20:05:15 +01:00
|
|
|
|
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_DRAWABLE_MOD,
|
|
|
|
_("Paths to selection"));
|
2002-02-26 16:30:14 +00:00
|
|
|
|
2019-07-04 01:11:48 +02:00
|
|
|
operation = (GimpChannelOps) g_variant_get_int32 (value);
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
for (iter = paths; iter; iter = iter->next)
|
2023-01-10 20:05:15 +01:00
|
|
|
{
|
|
|
|
gimp_item_to_selection (iter->data, operation, TRUE, FALSE, 0, 0);
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (operation == GIMP_CHANNEL_OP_REPLACE && iter == paths)
|
2023-01-10 20:05:15 +01:00
|
|
|
operation = GIMP_CHANNEL_OP_ADD;
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_image_undo_group_end (image);
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_selection_to_paths_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2012-05-04 00:50:23 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GimpProcedure *procedure;
|
|
|
|
GimpValueArray *args;
|
|
|
|
GimpDisplay *display;
|
2019-07-04 01:11:48 +02:00
|
|
|
gboolean advanced;
|
2012-05-04 00:50:23 +02:00
|
|
|
GError *error = NULL;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2006-10-09 18:49:15 +00:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2019-07-04 01:11:48 +02:00
|
|
|
advanced = (gboolean) g_variant_get_int32 (value);
|
|
|
|
|
2019-08-28 03:13:09 +02:00
|
|
|
procedure = gimp_pdb_lookup_procedure (image->gimp->pdb,
|
|
|
|
"plug-in-sel2path");
|
2004-05-23 10:04:41 +00:00
|
|
|
|
2006-03-31 09:15:08 +00:00
|
|
|
if (! procedure)
|
2004-05-23 10:04:41 +00:00
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 04:59:20 +12:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_ERROR,
|
|
|
|
"Selection to path procedure lookup failed.");
|
2004-05-23 10:04:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-28 17:55:52 +00:00
|
|
|
display = gimp_context_get_display (action_data_get_context (data));
|
2004-05-23 10:04:41 +00:00
|
|
|
|
2006-03-31 09:15:08 +00:00
|
|
|
args = gimp_procedure_get_arguments (procedure);
|
2004-05-23 10:04:41 +00:00
|
|
|
|
2019-08-29 11:25:35 +02: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 10:04:41 +00:00
|
|
|
|
2006-04-07 18:23:20 +00:00
|
|
|
gimp_procedure_execute_async (procedure, image->gimp,
|
|
|
|
action_data_get_context (data),
|
|
|
|
GIMP_PROGRESS (display), args,
|
2019-09-04 14:27:18 +02:00
|
|
|
display, &error);
|
2004-05-23 10:04:41 +00:00
|
|
|
|
2012-05-04 00:50:23 +02:00
|
|
|
gimp_value_array_unref (args);
|
2007-12-02 18:05:54 +00:00
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
2008-11-04 12:33:09 +00:00
|
|
|
gimp_message_literal (image->gimp,
|
2013-09-15 04:59:20 +12:00
|
|
|
G_OBJECT (widget), GIMP_MESSAGE_ERROR,
|
|
|
|
error->message);
|
2007-12-02 18:05:54 +00:00
|
|
|
g_error_free (error);
|
|
|
|
}
|
2002-02-25 17:58:50 +00:00
|
|
|
}
|
|
|
|
|
2016-03-15 20:52:22 +01:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_fill_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2016-03-15 20:52:22 +01:00
|
|
|
{
|
2023-01-11 01:31:10 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2016-03-15 20:52:22 +01:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_fill_cmd_callback (action, image, paths,
|
2016-10-30 17:02:59 +01:00
|
|
|
_("Fill Path"),
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_TOOL_BUCKET_FILL,
|
2016-10-30 17:02:59 +01:00
|
|
|
GIMP_HELP_PATH_FILL,
|
|
|
|
data);
|
2016-03-15 20:52:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_fill_last_vals_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2016-03-15 20:52:22 +01:00
|
|
|
{
|
2023-01-11 01:39:29 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2016-03-15 20:52:22 +01:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_fill_last_vals_cmd_callback (action, image, paths, data);
|
2016-03-15 20:52:22 +01:00
|
|
|
}
|
|
|
|
|
2002-02-25 17:58:50 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_stroke_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-25 17:58:50 +00:00
|
|
|
{
|
2023-01-11 01:56:29 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2016-09-12 00:03:22 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_stroke_cmd_callback (action, image, paths,
|
2016-10-30 17:02:59 +01:00
|
|
|
_("Stroke Path"),
|
2017-03-05 16:01:59 +01:00
|
|
|
GIMP_ICON_PATH_STROKE,
|
2016-10-30 17:02:59 +01:00
|
|
|
GIMP_HELP_PATH_STROKE,
|
|
|
|
data);
|
2002-02-26 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
2004-10-20 23:14:24 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_stroke_last_vals_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-10-20 23:14:24 +00:00
|
|
|
{
|
2023-01-11 01:56:29 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2004-10-20 23:14:24 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_stroke_last_vals_cmd_callback (action, image, paths, data);
|
2004-10-20 23:14:24 +00:00
|
|
|
}
|
|
|
|
|
2002-02-26 14:40:30 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_copy_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-26 14:40:30 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
2005-09-19 21:33:03 +00:00
|
|
|
gchar *svg;
|
2024-08-04 20:11:53 +02:00
|
|
|
return_if_no_paths (image, paths, data);
|
2002-02-26 14:40:30 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
svg = gimp_path_export_string (image, paths);
|
2005-09-19 21:33:03 +00:00
|
|
|
|
|
|
|
if (svg)
|
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_clipboard_set_svg (image->gimp, svg);
|
2005-09-19 21:33:03 +00:00
|
|
|
g_free (svg);
|
|
|
|
}
|
2002-02-26 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_paste_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-26 14:40:30 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2006-10-09 18:49:15 +00:00
|
|
|
GtkWidget *widget;
|
2005-09-19 21:33:03 +00:00
|
|
|
gchar *svg;
|
|
|
|
gsize svg_size;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2006-10-09 18:49:15 +00:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 14:40:30 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
svg = gimp_clipboard_get_svg (image->gimp, &svg_size);
|
2005-09-19 21:33:03 +00:00
|
|
|
|
|
|
|
if (svg)
|
|
|
|
{
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
if (! gimp_path_import_buffer (image, svg, svg_size,
|
|
|
|
TRUE, FALSE,
|
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, &error))
|
2005-09-19 21:33:03 +00:00
|
|
|
{
|
2006-10-09 18:49:15 +00:00
|
|
|
gimp_message (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
2005-09-19 21:33:03 +00:00
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
gimp_image_flush (image);
|
2005-09-19 21:33:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (svg);
|
|
|
|
}
|
2002-02-26 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_export_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-26 14:40:30 +00:00
|
|
|
{
|
2016-10-27 21:26:07 +02:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
2016-10-27 21:26:07 +02:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2024-08-04 20:11:53 +02:00
|
|
|
return_if_no_paths (image, paths, data);
|
2004-04-29 12:52:29 +00:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 14:40:30 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
#define EXPORT_DIALOG_KEY "gimp-paths-export-dialog"
|
2016-09-26 00:16:47 +02:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY);
|
2016-09-26 00:16:47 +02:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
if (! dialog)
|
2016-09-26 00:16:47 +02:00
|
|
|
{
|
2016-10-27 21:26:07 +02:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
GFile *folder = NULL;
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (config->path_export_path)
|
|
|
|
folder = gimp_file_new_for_config_path (config->path_export_path,
|
2016-10-27 21:26:07 +02:00
|
|
|
NULL);
|
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
dialog = path_export_dialog_new (image, widget,
|
|
|
|
folder,
|
2024-08-04 20:11:53 +02:00
|
|
|
config->path_export_active_only,
|
|
|
|
paths_export_callback,
|
2024-07-13 05:07:57 +00:00
|
|
|
NULL);
|
2004-10-19 14:08:44 +00:00
|
|
|
|
2016-09-26 00:16:47 +02:00
|
|
|
if (folder)
|
2016-10-27 21:26:07 +02:00
|
|
|
g_object_unref (folder);
|
2008-11-11 08:24:21 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
dialogs_attach_dialog (G_OBJECT (image), EXPORT_DIALOG_KEY, dialog);
|
|
|
|
}
|
2004-10-19 14:08:44 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2002-02-26 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_import_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2002-02-26 14:40:30 +00:00
|
|
|
{
|
2016-10-27 21:26:07 +02:00
|
|
|
GimpImage *image;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
2006-03-28 17:08:36 +00:00
|
|
|
return_if_no_image (image, data);
|
2004-04-29 12:52:29 +00:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 14:40:30 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
#define IMPORT_DIALOG_KEY "gimp-paths-import-dialog"
|
2016-09-26 00:16:47 +02:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
dialog = dialogs_get_dialog (G_OBJECT (image), IMPORT_DIALOG_KEY);
|
2004-10-19 14:08:44 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
if (! dialog)
|
2016-09-26 00:16:47 +02:00
|
|
|
{
|
2016-10-27 21:26:07 +02:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
GFile *folder = NULL;
|
2016-09-26 00:16:47 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (config->path_import_path)
|
|
|
|
folder = gimp_file_new_for_config_path (config->path_import_path,
|
2016-10-27 21:26:07 +02:00
|
|
|
NULL);
|
2008-11-11 08:24:21 +00:00
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
dialog = path_import_dialog_new (image, widget,
|
|
|
|
folder,
|
2024-08-04 20:11:53 +02:00
|
|
|
config->path_import_merge,
|
|
|
|
config->path_import_scale,
|
|
|
|
paths_import_callback,
|
2024-07-13 05:07:57 +00:00
|
|
|
NULL);
|
2016-10-27 21:26:07 +02:00
|
|
|
|
|
|
|
dialogs_attach_dialog (G_OBJECT (image), IMPORT_DIALOG_KEY, dialog);
|
|
|
|
}
|
2004-10-19 14:08:44 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
gtk_window_present (GTK_WINDOW (dialog));
|
2002-02-26 14:40:30 +00:00
|
|
|
}
|
|
|
|
|
2004-09-15 13:24:45 +00:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_visible_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2004-09-15 13:24:45 +00:00
|
|
|
{
|
2023-01-10 18:41:31 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2004-09-15 13:24:45 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_visible_cmd_callback (action, value, image, paths);
|
2004-09-15 13:24:45 +00:00
|
|
|
}
|
|
|
|
|
2009-08-20 21:19:43 +02:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_lock_content_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2009-08-20 21:19:43 +02:00
|
|
|
{
|
2023-01-10 19:06:42 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2009-08-20 21:19:43 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_lock_content_cmd_callback (action, value, image, paths);
|
2009-08-20 21:19:43 +02:00
|
|
|
}
|
|
|
|
|
2012-11-09 11:17:25 +01:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_lock_position_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2012-11-09 11:17:25 +01:00
|
|
|
{
|
2023-01-10 19:12:36 +01:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
|
|
|
return_if_no_paths (image, paths, data);
|
2012-11-09 11:17:25 +01:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_lock_position_cmd_callback (action, value, image, paths);
|
2016-10-29 16:50:13 +02:00
|
|
|
}
|
2012-11-09 11:17:25 +01:00
|
|
|
|
2016-10-29 16:50:13 +02:00
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_color_tag_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2016-10-29 16:50:13 +02:00
|
|
|
{
|
2019-07-04 01:11:48 +02:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths;
|
2019-07-04 01:11:48 +02:00
|
|
|
GimpColorTag color_tag;
|
2024-08-04 20:11:53 +02:00
|
|
|
return_if_no_paths (image, paths, data);
|
2012-11-09 11:17:25 +01:00
|
|
|
|
2019-07-04 01:11:48 +02:00
|
|
|
color_tag = (GimpColorTag) g_variant_get_int32 (value);
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
items_color_tag_cmd_callback (action, image, paths, color_tag);
|
2012-11-09 11:17:25 +01:00
|
|
|
}
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2016-09-25 22:18:37 +02:00
|
|
|
|
2004-09-19 22:26:41 +00:00
|
|
|
/* private functions */
|
2002-02-25 17:58:50 +00:00
|
|
|
|
2004-09-19 22:26:41 +00:00
|
|
|
static void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_new_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpPath *path,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *paths_name,
|
|
|
|
gboolean paths_visible,
|
|
|
|
GimpColorTag paths_color_tag,
|
|
|
|
gboolean paths_lock_content,
|
|
|
|
gboolean paths_lock_position,
|
|
|
|
gboolean paths_lock_visibility,
|
|
|
|
gpointer user_data)
|
2004-09-19 22:26:41 +00:00
|
|
|
{
|
2016-09-24 20:32:44 +02:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2004-09-19 22:26:41 +00:00
|
|
|
|
2016-09-24 20:32:44 +02:00
|
|
|
g_object_set (config,
|
2024-08-04 20:11:53 +02:00
|
|
|
"path-new-name", paths_name,
|
2016-09-24 20:32:44 +02:00
|
|
|
NULL);
|
2004-09-19 22:26:41 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
path = gimp_path_new (image, config->path_new_name);
|
|
|
|
gimp_item_set_visible (GIMP_ITEM (path), paths_visible, FALSE);
|
|
|
|
gimp_item_set_color_tag (GIMP_ITEM (path), paths_color_tag, FALSE);
|
|
|
|
gimp_item_set_lock_content (GIMP_ITEM (path), paths_lock_content, FALSE);
|
|
|
|
gimp_item_set_lock_position (GIMP_ITEM (path), paths_lock_position, FALSE);
|
|
|
|
gimp_item_set_lock_visibility (GIMP_ITEM (path), paths_lock_visibility, FALSE);
|
2016-10-26 16:51:56 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
gimp_image_add_path (image, path,
|
2024-07-11 00:07:44 +00:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
|
2016-09-24 20:32:44 +02:00
|
|
|
gimp_image_flush (image);
|
2004-09-19 22:26:41 +00:00
|
|
|
|
2016-09-24 20:32:44 +02:00
|
|
|
gtk_widget_destroy (dialog);
|
2004-09-19 22:26:41 +00:00
|
|
|
}
|
2003-09-13 02:33:30 +00:00
|
|
|
|
|
|
|
static void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_edit_attributes_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GimpPath *path,
|
|
|
|
GimpContext *context,
|
|
|
|
const gchar *paths_name,
|
|
|
|
gboolean paths_visible,
|
|
|
|
GimpColorTag paths_color_tag,
|
|
|
|
gboolean paths_lock_content,
|
|
|
|
gboolean paths_lock_position,
|
|
|
|
gboolean paths_lock_visibility,
|
|
|
|
gpointer user_data)
|
2003-09-13 02:33:30 +00:00
|
|
|
{
|
2024-08-04 20:11:53 +02:00
|
|
|
GimpItem *item = GIMP_ITEM (path);
|
|
|
|
|
|
|
|
if (strcmp (paths_name, gimp_object_get_name (path)) ||
|
|
|
|
paths_visible != gimp_item_get_visible (item) ||
|
|
|
|
paths_color_tag != gimp_item_get_color_tag (item) ||
|
|
|
|
paths_lock_content != gimp_item_get_lock_content (item) ||
|
|
|
|
paths_lock_position != gimp_item_get_lock_position (item) ||
|
|
|
|
paths_lock_visibility != gimp_item_get_lock_visibility (item))
|
2003-09-13 02:33:30 +00:00
|
|
|
{
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_image_undo_group_start (image,
|
|
|
|
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
|
|
|
|
_("Path Attributes"));
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (strcmp (paths_name, gimp_object_get_name (path)))
|
|
|
|
gimp_item_rename (GIMP_ITEM (path), paths_name, NULL);
|
2016-10-26 16:51:56 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (paths_visible != gimp_item_get_visible (item))
|
|
|
|
gimp_item_set_visible (item, paths_visible, TRUE);
|
2016-10-26 16:51:56 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (paths_color_tag != gimp_item_get_color_tag (item))
|
|
|
|
gimp_item_set_color_tag (item, paths_color_tag, TRUE);
|
2016-10-29 16:50:13 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (paths_lock_content != gimp_item_get_lock_content (item))
|
|
|
|
gimp_item_set_lock_content (item, paths_lock_content, TRUE);
|
2016-10-26 16:51:56 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (paths_lock_position != gimp_item_get_lock_position (item))
|
|
|
|
gimp_item_set_lock_position (item, paths_lock_position, TRUE);
|
2016-10-26 16:51:56 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (paths_lock_visibility != gimp_item_get_lock_visibility (item))
|
|
|
|
gimp_item_set_lock_visibility (item, paths_lock_visibility, TRUE);
|
2023-05-26 02:46:53 +02:00
|
|
|
|
2016-10-26 16:51:56 +02:00
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
2016-09-24 20:32:44 +02:00
|
|
|
gimp_image_flush (image);
|
2003-09-13 02:33:30 +00:00
|
|
|
}
|
|
|
|
|
2016-09-24 20:32:44 +02:00
|
|
|
gtk_widget_destroy (dialog);
|
2003-09-13 02:33:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_import_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *import_folder,
|
|
|
|
gboolean merge_vectors,
|
|
|
|
gboolean scale_vectors,
|
|
|
|
gpointer user_data)
|
2003-09-13 02:33:30 +00:00
|
|
|
{
|
2016-10-27 21:26:07 +02:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
|
|
|
gchar *path = NULL;
|
|
|
|
GError *error = NULL;
|
2003-09-13 02:33:30 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
if (import_folder)
|
|
|
|
path = gimp_file_get_config_path (import_folder, NULL);
|
2004-10-23 21:49:46 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
g_object_set (config,
|
|
|
|
"path-import-path", path,
|
|
|
|
"path-import-merge", merge_vectors,
|
|
|
|
"path-import-scale", scale_vectors,
|
|
|
|
NULL);
|
2004-10-23 21:49:46 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
if (path)
|
|
|
|
g_free (path);
|
2004-10-24 13:13:21 +00:00
|
|
|
|
2024-07-13 05:07:57 +00:00
|
|
|
if (gimp_path_import_file (image, file,
|
2024-08-04 20:11:53 +02:00
|
|
|
config->path_import_merge,
|
|
|
|
config->path_import_scale,
|
2024-07-13 05:07:57 +00:00
|
|
|
GIMP_IMAGE_ACTIVE_PARENT, -1,
|
|
|
|
NULL, &error))
|
2016-10-27 21:26:07 +02:00
|
|
|
{
|
|
|
|
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 02:33:30 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
gtk_widget_destroy (dialog);
|
2003-09-13 02:33:30 +00:00
|
|
|
}
|
|
|
|
|
2004-09-19 22:26:41 +00:00
|
|
|
static void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_export_callback (GtkWidget *dialog,
|
|
|
|
GimpImage *image,
|
|
|
|
GFile *file,
|
|
|
|
GFile *export_folder,
|
|
|
|
gboolean active_only,
|
|
|
|
gpointer user_data)
|
2004-09-19 22:26:41 +00:00
|
|
|
{
|
2016-10-27 21:26:07 +02:00
|
|
|
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *paths = NULL;
|
2016-10-27 21:26:07 +02:00
|
|
|
gchar *path = NULL;
|
|
|
|
GError *error = NULL;
|
2016-09-26 00:16:47 +02:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
if (export_folder)
|
|
|
|
path = gimp_file_get_config_path (export_folder, NULL);
|
2004-09-19 22:26:41 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
g_object_set (config,
|
|
|
|
"path-export-path", path,
|
|
|
|
"path-export-active-only", active_only,
|
|
|
|
NULL);
|
2004-10-23 21:49:46 +00:00
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
if (path)
|
|
|
|
g_free (path);
|
2004-10-23 21:49:46 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (config->path_export_active_only)
|
|
|
|
paths = gimp_image_get_selected_paths (image);
|
2004-10-24 13:13:21 +00:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (! gimp_path_export_file (image, paths, file, &error))
|
2016-10-27 21:26:07 +02:00
|
|
|
{
|
|
|
|
gimp_message (image->gimp, G_OBJECT (dialog),
|
|
|
|
GIMP_MESSAGE_ERROR,
|
|
|
|
"%s", error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
return;
|
2004-09-19 22:26:41 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 21:26:07 +02:00
|
|
|
gtk_widget_destroy (dialog);
|
2004-09-19 22:26:41 +00:00
|
|
|
}
|
2017-06-25 22:10:11 +02:00
|
|
|
|
|
|
|
void
|
2024-08-04 20:11:53 +02:00
|
|
|
paths_select_cmd_callback (GimpAction *action,
|
|
|
|
GVariant *value,
|
|
|
|
gpointer data)
|
2017-06-25 22:10:11 +02:00
|
|
|
{
|
2020-04-29 13:30:35 +02:00
|
|
|
GimpImage *image;
|
2024-08-04 20:11:53 +02:00
|
|
|
GList *new_paths = NULL;
|
|
|
|
GList *paths;
|
2022-10-12 21:21:22 +02:00
|
|
|
GList *iter;
|
2020-04-29 13:30:35 +02:00
|
|
|
GimpActionSelectType select_type;
|
2022-10-12 21:21:22 +02:00
|
|
|
gboolean run_once;
|
2017-06-25 22:10:11 +02:00
|
|
|
return_if_no_image (image, data);
|
|
|
|
|
2020-04-29 13:30:35 +02:00
|
|
|
select_type = (GimpActionSelectType) g_variant_get_int32 (value);
|
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
paths = gimp_image_get_selected_paths (image);
|
|
|
|
run_once = (g_list_length (paths) == 0);
|
2017-06-25 22:10:11 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
for (iter = paths; iter || run_once; iter = iter ? iter->next : NULL)
|
2022-10-12 21:21:22 +02:00
|
|
|
{
|
2024-07-12 06:16:25 +00:00
|
|
|
GimpPath *new_vec;
|
2022-10-12 21:21:22 +02:00
|
|
|
GimpContainer *container;
|
2017-06-25 22:10:11 +02:00
|
|
|
|
2022-10-12 21:21:22 +02:00
|
|
|
if (iter)
|
|
|
|
{
|
|
|
|
container = gimp_item_get_container (GIMP_ITEM (iter->data));
|
|
|
|
}
|
|
|
|
else /* run_once */
|
|
|
|
{
|
2024-07-11 00:07:44 +00:00
|
|
|
container = gimp_image_get_paths (image);
|
2022-10-12 21:21:22 +02:00
|
|
|
run_once = FALSE;
|
|
|
|
}
|
2024-07-12 06:16:25 +00:00
|
|
|
new_vec = (GimpPath *) action_select_object (select_type,
|
|
|
|
container,
|
|
|
|
iter ? iter->data : NULL);
|
2022-10-12 21:21:22 +02:00
|
|
|
if (new_vec)
|
2024-08-04 20:11:53 +02:00
|
|
|
new_paths = g_list_prepend (new_paths, new_vec);
|
2022-10-12 21:21:22 +02:00
|
|
|
}
|
2017-06-25 22:10:11 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
if (new_paths)
|
2017-06-25 22:10:11 +02:00
|
|
|
{
|
2024-08-04 20:11:53 +02:00
|
|
|
gimp_image_set_selected_paths (image, new_paths);
|
2017-06-25 22:10:11 +02:00
|
|
|
gimp_image_flush (image);
|
|
|
|
}
|
2022-10-12 21:21:22 +02:00
|
|
|
|
2024-08-04 20:11:53 +02:00
|
|
|
g_list_free (new_paths);
|
2017-07-18 13:23:23 +02:00
|
|
|
}
|