2002-02-26 01:58:50 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-28 08:10:56 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2004-04-20 21:25:55 +08:00
|
|
|
#include "actions-types.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
|
|
|
#include "core/gimp.h"
|
|
|
|
#include "core/gimpchannel.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpchannel-select.h"
|
2003-09-18 21:51:10 +08:00
|
|
|
#include "core/gimpcontainer.h"
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "core/gimpcontext.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-11-08 01:29:02 +08:00
|
|
|
#include "core/gimpimage-merge.h"
|
2004-09-15 21:24:45 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
|
|
|
#include "core/gimpitemundo.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2003-05-15 22:31:22 +08:00
|
|
|
#include "pdb/procedural_db.h"
|
|
|
|
|
|
|
|
#include "plug-in/plug-in-run.h"
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
2003-09-11 07:00:44 +08:00
|
|
|
#include "vectors/gimpvectors-export.h"
|
2003-09-11 00:52:45 +08:00
|
|
|
#include "vectors/gimpvectors-import.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
#include "widgets/gimpaction.h"
|
2003-08-21 23:54:47 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-08-31 05:00:42 +08:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2002-02-26 10:00:02 +08:00
|
|
|
#include "tools/gimpvectortool.h"
|
|
|
|
#include "tools/tool_manager.h"
|
|
|
|
|
2004-09-13 23:15:23 +08:00
|
|
|
#include "dialogs/stroke-dialog.h"
|
2004-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-09-20 06:26:41 +08:00
|
|
|
typedef struct _VectorsOptions VectorsOptions;
|
|
|
|
|
|
|
|
struct _VectorsOptions
|
|
|
|
{
|
|
|
|
GtkWidget *query_box;
|
|
|
|
GtkWidget *name_entry;
|
|
|
|
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-05-03 22:46:29 +08:00
|
|
|
/* local function prototypes */
|
2004-04-29 20:52:29 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
static VectorsOptions * vectors_options_new (GimpImage *gimage,
|
2004-09-20 06:26:41 +08:00
|
|
|
GimpVectors *vectors,
|
|
|
|
GtkWidget *parent);
|
|
|
|
static void vectors_new_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptions *options);
|
|
|
|
static void vectors_edit_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptions *options);
|
2004-10-18 19:29:58 +08:00
|
|
|
static void vectors_import_dialog (GimpImage *gimage,
|
2004-09-20 06:26:41 +08:00
|
|
|
GtkWidget *parent);
|
|
|
|
static void vectors_import_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpImage *gimage);
|
2004-10-18 19:29:58 +08:00
|
|
|
static void vectors_export_dialog (GimpImage *gimage,
|
2004-09-20 06:26:41 +08:00
|
|
|
GimpVectors *vectors,
|
|
|
|
GtkWidget *parent);
|
|
|
|
static void vectors_export_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpImage *gimage);
|
|
|
|
|
|
|
|
|
|
|
|
/* private variables */
|
|
|
|
|
|
|
|
static gchar *vectors_name = NULL;
|
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)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *vectors;
|
2004-10-16 23:48:23 +08:00
|
|
|
GimpTool *active_tool;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
|
|
|
|
2004-10-16 23:48:23 +08:00
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
|
|
|
|
|
|
|
if (! GIMP_IS_VECTOR_TOOL (active_tool))
|
|
|
|
{
|
|
|
|
GimpToolInfo *tool_info;
|
|
|
|
|
|
|
|
tool_info = (GimpToolInfo *)
|
|
|
|
gimp_container_get_child_by_name (gimage->gimp->tool_info_list,
|
|
|
|
"gimp-vector-tool");
|
|
|
|
|
|
|
|
if (GIMP_IS_TOOL_INFO (tool_info))
|
|
|
|
{
|
|
|
|
gimp_context_set_tool (action_data_get_context (data), tool_info);
|
|
|
|
active_tool = tool_manager_get_active (gimage->gimp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GIMP_IS_VECTOR_TOOL (active_tool))
|
|
|
|
gimp_vector_tool_set_vectors (GIMP_VECTOR_TOOL (active_tool), vectors);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_edit_attributes_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
VectorsOptions *options;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GtkWidget *widget;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
|
|
|
return_if_no_widget (widget, data);
|
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
options = vectors_options_new (gimp_item_get_image (GIMP_ITEM (vectors)),
|
|
|
|
vectors, widget);
|
|
|
|
|
|
|
|
g_signal_connect (options->query_box, "response",
|
|
|
|
G_CALLBACK (vectors_edit_vectors_response),
|
|
|
|
options);
|
|
|
|
|
|
|
|
gtk_widget_show (options->query_box);
|
2004-05-25 22:37:02 +08:00
|
|
|
}
|
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_new_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2004-10-18 19:29:58 +08:00
|
|
|
VectorsOptions *options;
|
|
|
|
GimpImage *gimage;
|
|
|
|
GtkWidget *widget;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
options = vectors_options_new (gimage, NULL, widget);
|
|
|
|
|
|
|
|
g_signal_connect (options->query_box, "response",
|
|
|
|
G_CALLBACK (vectors_new_vectors_response),
|
|
|
|
options);
|
|
|
|
|
|
|
|
gtk_widget_show (options->query_box);
|
2004-10-16 23:48:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_new_default_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *new_vectors;
|
|
|
|
return_if_no_image (gimage, data);
|
|
|
|
|
|
|
|
new_vectors = gimp_vectors_new (gimage, _("Empty Path"));
|
|
|
|
|
|
|
|
gimp_image_add_vectors (gimage, new_vectors, -1);
|
|
|
|
|
|
|
|
gimp_image_flush (gimage);
|
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
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_image_raise_vectors (gimage, vectors);
|
2004-04-19 22:54:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_image_raise_vectors_to_top (gimage, vectors);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
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
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_lower_vectors (gimage, vectors);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
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)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2004-04-19 22:54:24 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_lower_vectors_to_bottom (gimage, vectors);
|
2004-04-19 22:54:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2002-02-26 01:58:50 +08:00
|
|
|
GimpVectors *new_vectors;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-09-15 21:24:45 +08:00
|
|
|
new_vectors =
|
|
|
|
GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
|
|
|
|
G_TYPE_FROM_INSTANCE (vectors),
|
|
|
|
TRUE));
|
2002-02-27 00:30:14 +08:00
|
|
|
gimp_image_add_vectors (gimage, new_vectors, -1);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
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
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gimp_image_remove_vectors (gimage, vectors);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
2003-11-07 21:20:52 +08:00
|
|
|
void
|
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)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2003-11-07 21:20:52 +08:00
|
|
|
|
|
|
|
gimp_image_merge_visible_vectors (gimage);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
|
2003-08-27 08:52:00 +08:00
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_to_selection_cmd_callback (GtkAction *action,
|
|
|
|
gint value,
|
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2003-08-27 08:52:00 +08:00
|
|
|
GimpChannelOps op;
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2002-02-27 00:30:14 +08:00
|
|
|
|
2004-04-29 20:52:29 +08:00
|
|
|
op = (GimpChannelOps) value;
|
2003-08-27 08:52:00 +08:00
|
|
|
|
2003-10-06 20:17:11 +08:00
|
|
|
gimp_channel_select_vectors (gimp_image_get_mask (gimage),
|
|
|
|
_("Path to Selection"),
|
2004-05-25 22:37:02 +08:00
|
|
|
vectors,
|
2003-10-06 20:17:11 +08:00
|
|
|
op, TRUE, FALSE, 0, 0);
|
2002-05-09 01:48:24 +08:00
|
|
|
gimp_image_flush (gimage);
|
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
|
|
|
{
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
ProcRecord *proc_rec;
|
|
|
|
Argument *args;
|
|
|
|
GimpDisplay *gdisp;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
if (value)
|
|
|
|
proc_rec = procedural_db_lookup (gimage->gimp,
|
|
|
|
"plug_in_sel2path_advanced");
|
|
|
|
else
|
|
|
|
proc_rec = procedural_db_lookup (gimage->gimp,
|
|
|
|
"plug_in_sel2path");
|
|
|
|
|
|
|
|
if (! proc_rec)
|
|
|
|
{
|
|
|
|
g_message ("Selection to path procedure lookup failed.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
gdisp = gimp_context_get_display (action_data_get_context (data));
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
/* plug-in arguments as if called by <Image>/Filters/... */
|
|
|
|
args = g_new (Argument, 3);
|
|
|
|
|
|
|
|
args[0].arg_type = GIMP_PDB_INT32;
|
|
|
|
args[0].value.pdb_int = GIMP_RUN_INTERACTIVE;
|
|
|
|
args[1].arg_type = GIMP_PDB_IMAGE;
|
|
|
|
args[1].value.pdb_int = (gint32) gimp_image_get_ID (gimage);
|
|
|
|
args[2].arg_type = GIMP_PDB_DRAWABLE;
|
|
|
|
args[2].value.pdb_int = -1; /* unused */
|
|
|
|
|
2004-05-25 22:37:02 +08:00
|
|
|
plug_in_run (gimage->gimp, action_data_get_context (data),
|
2004-08-11 02:47:21 +08:00
|
|
|
gdisp ? GIMP_PROGRESS (gdisp) : NULL,
|
2004-05-23 18:04:41 +08:00
|
|
|
proc_rec, args, 3, FALSE, TRUE,
|
2004-10-16 23:48:23 +08:00
|
|
|
gdisp ? gimp_display_get_ID (gdisp) : 0);
|
2004-05-23 18:04:41 +08:00
|
|
|
|
|
|
|
g_free (args);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +08:00
|
|
|
vectors_stroke_cmd_callback (GtkAction *action,
|
2003-08-21 23:54:47 +08:00
|
|
|
gpointer data)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2004-05-23 18:04:41 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *dialog;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2004-05-23 18:04:41 +08:00
|
|
|
drawable = gimp_image_active_drawable (gimage);
|
|
|
|
|
|
|
|
if (! drawable)
|
|
|
|
{
|
|
|
|
g_message (_("There is no active layer or channel to stroke to."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
dialog = stroke_dialog_new (GIMP_ITEM (vectors),
|
|
|
|
GIMP_STOCK_PATH_STROKE,
|
|
|
|
GIMP_HELP_PATH_STROKE,
|
|
|
|
widget);
|
|
|
|
gtk_widget_show (dialog);
|
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
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#ifdef __GNUC__
|
2003-11-02 04:06:01 +08:00
|
|
|
#warning FIXME: need vectors clipboard
|
2002-12-11 00:38:16 +08:00
|
|
|
#endif
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
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
|
|
|
{
|
2002-02-27 00:30:14 +08:00
|
|
|
GimpImage *gimage;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2002-12-11 00:38:16 +08:00
|
|
|
#ifdef __GNUC__
|
2003-11-02 04:06:01 +08:00
|
|
|
#warning FIXME: need vectors clipboard
|
2002-12-11 00:38:16 +08:00
|
|
|
#endif
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +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
|
|
|
{
|
2003-09-11 06:11:02 +08:00
|
|
|
GimpImage *gimage;
|
2004-04-29 20:52:29 +08:00
|
|
|
GtkWidget *widget;
|
2002-12-11 00:38:16 +08:00
|
|
|
return_if_no_image (gimage, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
vectors_import_dialog (gimage, widget);
|
2002-02-26 22:40:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-29 20:52:29 +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
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
2004-05-25 22:37:02 +08:00
|
|
|
GimpVectors *vectors;
|
2004-04-29 20:52:29 +08:00
|
|
|
GtkWidget *widget;
|
2004-05-25 22:37:02 +08:00
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
2004-04-29 20:52:29 +08:00
|
|
|
return_if_no_widget (widget, data);
|
2002-02-26 22:40:30 +08:00
|
|
|
|
2004-10-18 19:29:58 +08:00
|
|
|
vectors_export_dialog (gimage, vectors, widget);
|
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)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
gboolean visible;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
|
|
|
|
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);
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vectors_linked_cmd_callback (GtkAction *action,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpImage *gimage;
|
|
|
|
GimpVectors *vectors;
|
|
|
|
gboolean linked;
|
|
|
|
return_if_no_vectors (gimage, vectors, data);
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
undo = gimp_image_undo_can_compress (gimage, GIMP_TYPE_ITEM_UNDO,
|
|
|
|
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);
|
2004-09-15 21:24:45 +08:00
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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 VectorsOptions *
|
2004-10-18 19:29:58 +08:00
|
|
|
vectors_options_new (GimpImage *gimage,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GtkWidget *parent)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2004-09-20 06:26:41 +08:00
|
|
|
VectorsOptions *options;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
options = g_new0 (VectorsOptions, 1);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
options->gimage = gimage;
|
|
|
|
options->vectors = vectors;
|
|
|
|
|
|
|
|
if (vectors)
|
2002-02-26 01:58:50 +08:00
|
|
|
{
|
2004-09-20 06:26:41 +08:00
|
|
|
options->query_box =
|
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (vectors),
|
|
|
|
_("Path Attributes"), "gimp-vectors-edit",
|
|
|
|
GIMP_STOCK_EDIT,
|
|
|
|
_("Edit Path Attributes"),
|
|
|
|
parent,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_PATH_EDIT,
|
2002-02-26 08:04:55 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
NULL);
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
2004-09-20 06:26:41 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
options->query_box =
|
|
|
|
gimp_viewable_dialog_new (GIMP_VIEWABLE (gimage),
|
|
|
|
_("New Path"), "gimp-vectors-new",
|
|
|
|
GIMP_STOCK_PATH,
|
|
|
|
_("New Path Options"),
|
|
|
|
parent,
|
|
|
|
gimp_standard_help_func,
|
|
|
|
GIMP_HELP_PATH_NEW,
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
NULL);
|
|
|
|
}
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (options->query_box),
|
|
|
|
(GWeakNotify) g_free,
|
|
|
|
options);
|
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 12);
|
2004-05-04 22:21:13 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (options->query_box)->vbox),
|
|
|
|
hbox);
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_show (hbox);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 6);
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_show (vbox);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
table = gtk_table_new (1, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
2002-02-26 01:58:50 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
2004-05-25 22:37:02 +08:00
|
|
|
gtk_widget_show (table);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
|
|
|
options->name_entry = gtk_entry_new ();
|
|
|
|
gtk_widget_set_size_request (options->name_entry, 150, -1);
|
2004-09-15 23:06:08 +08:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (options->name_entry), TRUE);
|
2004-09-20 06:26:41 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
|
|
|
_("Path Name:"), 0.0, 0.5,
|
|
|
|
options->name_entry, 1, FALSE);
|
2002-02-26 01:58:50 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
if (vectors)
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (vectors)));
|
|
|
|
else
|
|
|
|
gtk_entry_set_text (GTK_ENTRY (options->name_entry),
|
|
|
|
vectors_name ? vectors_name : _("New Path"));
|
|
|
|
|
|
|
|
return options;
|
2002-02-26 01:58:50 +08:00
|
|
|
}
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
static void
|
|
|
|
vectors_new_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptions *options)
|
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
GimpVectors *new_vectors;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
if (vectors_name)
|
|
|
|
g_free (vectors_name);
|
2004-09-28 06:44:28 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
vectors_name =
|
|
|
|
g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
|
|
|
|
|
|
|
|
new_vectors = gimp_vectors_new (options->gimage, vectors_name);
|
|
|
|
|
|
|
|
gimp_image_add_vectors (options->gimage, new_vectors, -1);
|
|
|
|
|
|
|
|
gimp_image_flush (options->gimage);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy (options->query_box);
|
|
|
|
}
|
2003-09-13 10:33:30 +08:00
|
|
|
|
|
|
|
static void
|
2004-09-20 06:26:41 +08:00
|
|
|
vectors_edit_vectors_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
|
|
|
VectorsOptions *options)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2003-11-18 02:29:59 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-09-20 06:26:41 +08:00
|
|
|
GimpVectors *vectors = options->vectors;
|
|
|
|
const gchar *new_name;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
new_name = gtk_entry_get_text (GTK_ENTRY (options->name_entry));
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
if (strcmp (new_name, gimp_object_get_name (GIMP_OBJECT (vectors))))
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-09-20 06:26:41 +08:00
|
|
|
gimp_item_rename (GIMP_ITEM (vectors), new_name);
|
|
|
|
gimp_image_flush (options->gimage);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
gtk_widget_destroy (options->query_box);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-18 19:29:58 +08:00
|
|
|
vectors_import_dialog (GimpImage *gimage,
|
|
|
|
GtkWidget *parent)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-09-28 06:44:28 +08:00
|
|
|
GtkWidget *dialog;
|
|
|
|
GtkFileFilter *filter;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
dialog = gtk_file_chooser_dialog_new (_("Import Paths from SVG"), NULL,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_OPEN,
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OPEN, GTK_RESPONSE_OK,
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
NULL);
|
2004-04-16 00:28:26 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, dialog);
|
2003-11-10 06:05:37 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (parent));
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (dialog), "gimp-vectors-import");
|
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
2003-11-18 02:29:59 +08:00
|
|
|
G_CALLBACK (vectors_import_response),
|
|
|
|
gimage);
|
2004-09-28 06:44:28 +08:00
|
|
|
g_signal_connect (dialog, "delete_event",
|
2003-11-18 02:29:59 +08:00
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
gtk_file_filter_set_name (filter, _("All Files (*.*)"));
|
|
|
|
gtk_file_filter_add_pattern (filter, "*");
|
|
|
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
|
|
|
|
|
|
|
filter = gtk_file_filter_new ();
|
|
|
|
gtk_file_filter_set_name (filter, _("Scalable SVG image (*.svg)"));
|
2004-10-18 19:29:58 +08:00
|
|
|
gtk_file_filter_add_pattern (filter, "*.[Ss][Vv][Gg]");
|
2004-09-28 06:44:28 +08:00
|
|
|
gtk_file_filter_add_mime_type (filter, "image/svg+xml");
|
|
|
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
|
|
|
|
|
|
|
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
|
|
|
|
|
|
|
|
/* FIXME: add controls for merge and scale options */
|
2003-09-25 08:39:46 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
gtk_widget_show (dialog);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-09-20 06:26:41 +08:00
|
|
|
vectors_import_response (GtkWidget *dialog,
|
2003-11-18 02:29:59 +08:00
|
|
|
gint response_id,
|
|
|
|
GimpImage *gimage)
|
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
|
|
|
{
|
|
|
|
const gchar *filename;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2004-04-16 00:28:26 +08:00
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-20 06:26:41 +08:00
|
|
|
if (gimp_vectors_import_file (gimage, filename, FALSE, FALSE, -1, &error))
|
|
|
|
{
|
|
|
|
gimp_image_flush (gimage);
|
|
|
|
}
|
|
|
|
else
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-18 02:29:59 +08:00
|
|
|
g_object_weak_unref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, dialog);
|
|
|
|
gtk_widget_destroy (dialog);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-10-18 19:29:58 +08:00
|
|
|
vectors_export_dialog (GimpImage *gimage,
|
|
|
|
GimpVectors *vectors,
|
|
|
|
GtkWidget *parent)
|
2003-09-13 10:33:30 +08:00
|
|
|
{
|
2004-09-28 06:44:28 +08:00
|
|
|
GtkWidget *dialog;
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
dialog = gtk_file_chooser_dialog_new (_("Export Path to SVG"), NULL,
|
|
|
|
GTK_FILE_CHOOSER_ACTION_SAVE,
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_SAVE, GTK_RESPONSE_OK,
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
NULL);
|
2004-04-16 00:28:26 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
g_object_weak_ref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, dialog);
|
2003-11-10 06:05:37 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (parent));
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
gtk_window_set_role (GTK_WINDOW (dialog), "gimp-vectors-export");
|
|
|
|
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
g_signal_connect (dialog, "response",
|
2003-11-18 02:29:59 +08:00
|
|
|
G_CALLBACK (vectors_export_response),
|
|
|
|
gimage);
|
2004-09-28 06:44:28 +08:00
|
|
|
g_signal_connect (dialog, "delete_event",
|
2003-11-18 02:29:59 +08:00
|
|
|
G_CALLBACK (gtk_true),
|
|
|
|
NULL);
|
2003-09-13 10:33:30 +08:00
|
|
|
|
2004-09-28 06:44:28 +08:00
|
|
|
/* FIXME: add control for saving all or just the active vectors */
|
|
|
|
|
|
|
|
gtk_widget_show (dialog);
|
2003-09-13 10:33:30 +08:00
|
|
|
}
|
2004-09-20 06:26:41 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
vectors_export_response (GtkWidget *dialog,
|
|
|
|
gint response_id,
|
|
|
|
GimpImage *gimage)
|
|
|
|
{
|
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
{
|
|
|
|
const gchar *filename;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
|
|
|
|
|
|
|
|
if (! gimp_vectors_export_file (gimage, NULL, filename, &error))
|
|
|
|
{
|
|
|
|
g_message (error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_weak_unref (G_OBJECT (gimage),
|
|
|
|
(GWeakNotify) gtk_widget_destroy, dialog);
|
|
|
|
gtk_widget_destroy (dialog);
|
|
|
|
}
|