app/core/core-enums.[ch] add vectors in an undo-group.

2003-09-13  Sven Neumann  <sven@gimp.org>

	* app/core/core-enums.[ch]
	* app/vectors/gimpvectors-import.c: add vectors in an undo-group.

	* app/gui/vectors-commands.c: added simple file selection dialogs
	for vectors import and export.
This commit is contained in:
Sven Neumann 2003-09-13 02:33:30 +00:00 committed by Sven Neumann
parent e898287e48
commit 26ae4062a7
6 changed files with 280 additions and 30 deletions

View File

@ -1,3 +1,11 @@
2003-09-13 Sven Neumann <sven@gimp.org>
* app/core/core-enums.[ch]
* app/vectors/gimpvectors-import.c: add vectors in an undo-group.
* app/gui/vectors-commands.c: added simple file selection dialogs
for vectors import and export.
2003-09-13 Sven Neumann <sven@gimp.org> 2003-09-13 Sven Neumann <sven@gimp.org>
* app/vectors/gimpvectors-import.c: simplified the parser and * app/vectors/gimpvectors-import.c: simplified the parser and

View File

@ -77,6 +77,11 @@
return return
static void vectors_import_query (GimpImage *gimage);
static void vectors_export_query (GimpImage *gimage,
GimpVectors *vectors);
/* public functions */ /* public functions */
void void
@ -227,16 +232,9 @@ vectors_import_cmd_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpImage *gimage; GimpImage *gimage;
GError *error = NULL;
return_if_no_image (gimage, data); return_if_no_image (gimage, data);
if (! gimp_vectors_import (gimage, "path.svg", FALSE, &error)) vectors_import_query (gimage);
{
g_message (error->message);
g_error_free (error);
}
gimp_image_flush (gimage);
} }
void void
@ -245,15 +243,9 @@ vectors_export_cmd_callback (GtkWidget *widget,
{ {
GimpImage *gimage; GimpImage *gimage;
GimpVectors *active_vectors; GimpVectors *active_vectors;
GError *error = NULL;
return_if_no_vectors (gimage, active_vectors, data); return_if_no_vectors (gimage, active_vectors, data);
if (! gimp_vectors_export (gimage, active_vectors, vectors_export_query (gimage, active_vectors);
"path-export.svg", &error))
{
g_message (error->message);
g_error_free (error);
}
} }
void void
@ -595,3 +587,128 @@ vectors_edit_vectors_query (GimpVectors *vectors)
gtk_widget_show (hbox); gtk_widget_show (hbox);
gtk_widget_show (options->query_box); gtk_widget_show (options->query_box);
} }
/*******************************/
/* The vectors import dialog */
/*******************************/
static void
vectors_import_ok_callback (GtkWidget *widget)
{
GimpImage *gimage = g_object_get_data (G_OBJECT (widget), "gimp-image");
if (gimage)
{
const gchar *filename;
GError *error = NULL;
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget));
if (gimp_vectors_import (gimage, filename, FALSE, &error))
{
gimp_image_flush (gimage);
}
else
{
g_message (error->message);
g_error_free (error);
}
g_object_weak_unref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, widget);
}
gtk_widget_destroy (widget);
}
static void
vectors_import_query (GimpImage *gimage)
{
GtkFileSelection *filesel;
filesel =
GTK_FILE_SELECTION (gtk_file_selection_new (_("Import Paths from SVG")));
g_object_set_data (G_OBJECT (filesel), "gimp-image", gimage);
g_object_weak_ref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, filesel);
gtk_window_set_wmclass (GTK_WINDOW (filesel), "gimp-vectors-import", "Gimp");
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
g_signal_connect_swapped (filesel->ok_button, "clicked",
G_CALLBACK (vectors_import_ok_callback),
filesel);
g_signal_connect_swapped (filesel->cancel_button, "clicked",
G_CALLBACK (gtk_widget_destroy),
filesel);
gtk_widget_show (GTK_WIDGET (filesel));
}
/*******************************/
/* The vectors export dialog */
/*******************************/
static void
vectors_export_ok_callback (GtkWidget *widget)
{
GimpImage *gimage = g_object_get_data (G_OBJECT (widget), "gimp-image");
if (gimage)
{
const gchar *filename;
GError *error = NULL;
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget));
if (gimp_vectors_export (gimage, NULL, filename, &error))
{
gimp_image_flush (gimage);
}
else
{
g_message (error->message);
g_error_free (error);
}
g_object_weak_unref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, widget);
}
gtk_widget_destroy (widget);
}
static void
vectors_export_query (GimpImage *gimage,
GimpVectors *vectors)
{
GtkFileSelection *filesel;
filesel =
GTK_FILE_SELECTION (gtk_file_selection_new (_("Export Path to SVG")));
g_object_set_data (G_OBJECT (filesel), "gimp-image", gimage);
g_object_weak_ref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, filesel);
gtk_window_set_wmclass (GTK_WINDOW (filesel), "gimp-vectors-export", "Gimp");
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
g_signal_connect_swapped (filesel->ok_button, "clicked",
G_CALLBACK (vectors_export_ok_callback),
filesel);
g_signal_connect_swapped (filesel->cancel_button, "clicked",
G_CALLBACK (gtk_widget_destroy),
filesel);
gtk_widget_show (GTK_WIDGET (filesel));
}

View File

@ -518,6 +518,7 @@ static const GEnumValue gimp_undo_type_enum_values[] =
{ GIMP_UNDO_GROUP_PAINT, N_("Paint"), "group-paint" }, { GIMP_UNDO_GROUP_PAINT, N_("Paint"), "group-paint" },
{ GIMP_UNDO_GROUP_PARASITE_ATTACH, N_("Attach Parasite"), "group-parasite-attach" }, { GIMP_UNDO_GROUP_PARASITE_ATTACH, N_("Attach Parasite"), "group-parasite-attach" },
{ GIMP_UNDO_GROUP_PARASITE_REMOVE, N_("Remove Parasite"), "group-parasite-remove" }, { GIMP_UNDO_GROUP_PARASITE_REMOVE, N_("Remove Parasite"), "group-parasite-remove" },
{ GIMP_UNDO_GROUP_VECTORS_IMPORT, N_("Import Paths"), "group-vectors-import" },
{ GIMP_UNDO_GROUP_MISC, N_("Plug-In"), "group-misc" }, { GIMP_UNDO_GROUP_MISC, N_("Plug-In"), "group-misc" },
{ GIMP_UNDO_IMAGE, N_("Image"), "image" }, { GIMP_UNDO_IMAGE, N_("Image"), "image" },
{ GIMP_UNDO_IMAGE_MOD, N_("Image Mod"), "image-mod" }, { GIMP_UNDO_IMAGE_MOD, N_("Image Mod"), "image-mod" },

View File

@ -381,6 +381,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_PAINT, /*< desc="Paint" >*/ GIMP_UNDO_GROUP_PAINT, /*< desc="Paint" >*/
GIMP_UNDO_GROUP_PARASITE_ATTACH, /*< desc="Attach Parasite" >*/ GIMP_UNDO_GROUP_PARASITE_ATTACH, /*< desc="Attach Parasite" >*/
GIMP_UNDO_GROUP_PARASITE_REMOVE, /*< desc="Remove Parasite" >*/ GIMP_UNDO_GROUP_PARASITE_REMOVE, /*< desc="Remove Parasite" >*/
GIMP_UNDO_GROUP_VECTORS_IMPORT, /*< desc="Import Paths" >*/
GIMP_UNDO_GROUP_MISC, /*< desc="Plug-In" >*/ GIMP_UNDO_GROUP_MISC, /*< desc="Plug-In" >*/
GIMP_UNDO_GROUP_LAST = GIMP_UNDO_GROUP_MISC, /*< skip >*/ GIMP_UNDO_GROUP_LAST = GIMP_UNDO_GROUP_MISC, /*< skip >*/

View File

@ -77,6 +77,11 @@
return return
static void vectors_import_query (GimpImage *gimage);
static void vectors_export_query (GimpImage *gimage,
GimpVectors *vectors);
/* public functions */ /* public functions */
void void
@ -227,16 +232,9 @@ vectors_import_cmd_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpImage *gimage; GimpImage *gimage;
GError *error = NULL;
return_if_no_image (gimage, data); return_if_no_image (gimage, data);
if (! gimp_vectors_import (gimage, "path.svg", FALSE, &error)) vectors_import_query (gimage);
{
g_message (error->message);
g_error_free (error);
}
gimp_image_flush (gimage);
} }
void void
@ -245,15 +243,9 @@ vectors_export_cmd_callback (GtkWidget *widget,
{ {
GimpImage *gimage; GimpImage *gimage;
GimpVectors *active_vectors; GimpVectors *active_vectors;
GError *error = NULL;
return_if_no_vectors (gimage, active_vectors, data); return_if_no_vectors (gimage, active_vectors, data);
if (! gimp_vectors_export (gimage, active_vectors, vectors_export_query (gimage, active_vectors);
"path-export.svg", &error))
{
g_message (error->message);
g_error_free (error);
}
} }
void void
@ -595,3 +587,128 @@ vectors_edit_vectors_query (GimpVectors *vectors)
gtk_widget_show (hbox); gtk_widget_show (hbox);
gtk_widget_show (options->query_box); gtk_widget_show (options->query_box);
} }
/*******************************/
/* The vectors import dialog */
/*******************************/
static void
vectors_import_ok_callback (GtkWidget *widget)
{
GimpImage *gimage = g_object_get_data (G_OBJECT (widget), "gimp-image");
if (gimage)
{
const gchar *filename;
GError *error = NULL;
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget));
if (gimp_vectors_import (gimage, filename, FALSE, &error))
{
gimp_image_flush (gimage);
}
else
{
g_message (error->message);
g_error_free (error);
}
g_object_weak_unref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, widget);
}
gtk_widget_destroy (widget);
}
static void
vectors_import_query (GimpImage *gimage)
{
GtkFileSelection *filesel;
filesel =
GTK_FILE_SELECTION (gtk_file_selection_new (_("Import Paths from SVG")));
g_object_set_data (G_OBJECT (filesel), "gimp-image", gimage);
g_object_weak_ref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, filesel);
gtk_window_set_wmclass (GTK_WINDOW (filesel), "gimp-vectors-import", "Gimp");
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
g_signal_connect_swapped (filesel->ok_button, "clicked",
G_CALLBACK (vectors_import_ok_callback),
filesel);
g_signal_connect_swapped (filesel->cancel_button, "clicked",
G_CALLBACK (gtk_widget_destroy),
filesel);
gtk_widget_show (GTK_WIDGET (filesel));
}
/*******************************/
/* The vectors export dialog */
/*******************************/
static void
vectors_export_ok_callback (GtkWidget *widget)
{
GimpImage *gimage = g_object_get_data (G_OBJECT (widget), "gimp-image");
if (gimage)
{
const gchar *filename;
GError *error = NULL;
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget));
if (gimp_vectors_export (gimage, NULL, filename, &error))
{
gimp_image_flush (gimage);
}
else
{
g_message (error->message);
g_error_free (error);
}
g_object_weak_unref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, widget);
}
gtk_widget_destroy (widget);
}
static void
vectors_export_query (GimpImage *gimage,
GimpVectors *vectors)
{
GtkFileSelection *filesel;
filesel =
GTK_FILE_SELECTION (gtk_file_selection_new (_("Export Path to SVG")));
g_object_set_data (G_OBJECT (filesel), "gimp-image", gimage);
g_object_weak_ref (G_OBJECT (gimage),
(GWeakNotify) gtk_widget_destroy, filesel);
gtk_window_set_wmclass (GTK_WINDOW (filesel), "gimp-vectors-export", "Gimp");
gtk_window_set_position (GTK_WINDOW (filesel), GTK_WIN_POS_MOUSE);
gtk_container_set_border_width (GTK_CONTAINER (filesel), 2);
gtk_container_set_border_width (GTK_CONTAINER (filesel->button_area), 2);
g_signal_connect_swapped (filesel->ok_button, "clicked",
G_CALLBACK (vectors_export_ok_callback),
filesel);
g_signal_connect_swapped (filesel->cancel_button, "clicked",
G_CALLBACK (gtk_widget_destroy),
filesel);
gtk_widget_show (GTK_WIDGET (filesel));
}

View File

@ -35,6 +35,7 @@
#include "vectors-types.h" #include "vectors-types.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "gimpbezierstroke.h" #include "gimpbezierstroke.h"
#include "gimpstroke.h" #include "gimpstroke.h"
@ -182,6 +183,9 @@ gimp_vectors_import (GimpImage *image,
base.paths = g_list_reverse (base.paths); base.paths = g_list_reverse (base.paths);
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_VECTORS_IMPORT,
_("Import Paths"));
vectors = gimp_vectors_new (image, _("Imported Path")); vectors = gimp_vectors_new (image, _("Imported Path"));
for (paths = base.paths; paths; paths = paths->next) for (paths = base.paths; paths; paths = paths->next)
@ -201,6 +205,8 @@ gimp_vectors_import (GimpImage *image,
} }
gimp_image_add_vectors (image, vectors, -1); gimp_image_add_vectors (image, vectors, -1);
gimp_image_undo_group_end (image);
} }
else else
{ {