Commit 984eef25 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

added new function vectors_selection_to_vectors() which invokes the

2003-05-15  Michael Natterer  <mitch@gimp.org>

	* app/gui/vectors-commands.[ch]: added new function
	vectors_selection_to_vectors() which invokes the sel2path Plug-In.

	* app/gui/dialogs-constructors.c: make the new function known to
	GimpVectorTreeView.

	* app/widgets/gimpvectorstreeview.[ch]: Added a "Selection to Path"
	button anc call the new function.
parent 9c48f76b
2003-05-15 Michael Natterer <mitch@gimp.org>
* app/gui/vectors-commands.[ch]: added new function
vectors_selection_to_vectors() which invokes the sel2path Plug-In.
* app/gui/dialogs-constructors.c: make the new function known to
GimpVectorTreeView.
* app/widgets/gimpvectorstreeview.[ch]: Added a "Selection to Path"
button anc call the new function.
2003-05-15 Michael Natterer <mitch@gimp.org>
* plug-ins/sel2path/sel2path.c: don't clear the selection after
......@@ -40,6 +40,10 @@
#include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintoptions.h"
#include "pdb/procedural_db.h"
#include "plug-in/plug-in-run.h"
#include "vectors/gimpvectors.h"
#include "widgets/gimpitemtreeview.h"
......@@ -328,6 +332,50 @@ vectors_stroke_vectors (GimpVectors *vectors)
}
}
void
vectors_selection_to_vectors (GimpImage *gimage,
gboolean advanced)
{
ProcRecord *proc_rec;
Argument *args;
GimpDrawable *drawable;
GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
drawable = gimp_image_active_drawable (gimage);
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
if (advanced)
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;
}
/* 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 = (gint32) gimp_item_get_ID (GIMP_ITEM (drawable));
plug_in_run (gimage->gimp,
proc_rec, args, 3, FALSE, TRUE,
gdisp ? gdisp->ID : 0);
g_free (args);
}
void
vectors_vectors_tool (GimpVectors *vectors)
{
......
......@@ -56,6 +56,8 @@ void vectors_edit_vectors_attributes_cmd_callback (GtkWidget *widget,
gpointer data);
void vectors_stroke_vectors (GimpVectors *vectors);
void vectors_selection_to_vectors (GimpImage *gimage,
gboolean advanced);
void vectors_vectors_tool (GimpVectors *vectors);
void vectors_new_vectors_query (GimpImage *gimage,
GimpVectors *template,
......
......@@ -727,7 +727,8 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
vectors_view = GIMP_VECTORS_TREE_VIEW (view);
vectors_view->stroke_item_func = vectors_stroke_vectors;
vectors_view->stroke_item_func = vectors_stroke_vectors;
vectors_view->selection_to_vectors_func = vectors_selection_to_vectors;
dockable = dialogs_dockable_new (view,
_("Paths List"), _("Paths"), NULL,
......
......@@ -727,7 +727,8 @@ dialogs_vectors_list_view_new (GimpDialogFactory *factory,
vectors_view = GIMP_VECTORS_TREE_VIEW (view);
vectors_view->stroke_item_func = vectors_stroke_vectors;
vectors_view->stroke_item_func = vectors_stroke_vectors;
vectors_view->selection_to_vectors_func = vectors_selection_to_vectors;
dockable = dialogs_dockable_new (view,
_("Paths List"), _("Paths"), NULL,
......
......@@ -40,6 +40,10 @@
#include "paint/gimppaintcore-stroke.h"
#include "paint/gimppaintoptions.h"
#include "pdb/procedural_db.h"
#include "plug-in/plug-in-run.h"
#include "vectors/gimpvectors.h"
#include "widgets/gimpitemtreeview.h"
......@@ -328,6 +332,50 @@ vectors_stroke_vectors (GimpVectors *vectors)
}
}
void
vectors_selection_to_vectors (GimpImage *gimage,
gboolean advanced)
{
ProcRecord *proc_rec;
Argument *args;
GimpDrawable *drawable;
GimpDisplay *gdisp;
g_return_if_fail (GIMP_IS_IMAGE (gimage));
drawable = gimp_image_active_drawable (gimage);
gdisp = gimp_context_get_display (gimp_get_user_context (gimage->gimp));
if (advanced)
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;
}
/* 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 = (gint32) gimp_item_get_ID (GIMP_ITEM (drawable));
plug_in_run (gimage->gimp,
proc_rec, args, 3, FALSE, TRUE,
gdisp ? gdisp->ID : 0);
g_free (args);
}
void
vectors_vectors_tool (GimpVectors *vectors)
{
......
......@@ -56,6 +56,8 @@ void vectors_edit_vectors_attributes_cmd_callback (GtkWidget *widget,
gpointer data);
void vectors_stroke_vectors (GimpVectors *vectors);
void vectors_selection_to_vectors (GimpImage *gimage,
gboolean advanced);
void vectors_vectors_tool (GimpVectors *vectors);
void vectors_new_vectors_query (GimpImage *gimage,
GimpVectors *template,
......
......@@ -56,6 +56,14 @@ static void gimp_vectors_tree_view_toselection_extended_clicked
guint state,
GimpVectorsTreeView *view);
static void gimp_vectors_tree_view_tovectors_clicked
(GtkWidget *widget,
GimpVectorsTreeView *view);
static void gimp_vectors_tree_view_tovectors_extended_clicked
(GtkWidget *widget,
guint state,
GimpVectorsTreeView *view);
static void gimp_vectors_tree_view_stroke_clicked (GtkWidget *widget,
GimpVectorsTreeView *view);
......@@ -149,6 +157,19 @@ gimp_vectors_tree_view_init (GimpVectorsTreeView *view)
g_free (str);
str = g_strdup_printf (_("Selection to Path\n"
"%s Advanced Options"),
gimp_get_mod_name_shift ());
view->tovectors_button =
gimp_editor_add_button (editor,
GIMP_STOCK_SELECTION_TO_PATH, str, NULL,
G_CALLBACK (gimp_vectors_tree_view_tovectors_clicked),
G_CALLBACK (gimp_vectors_tree_view_tovectors_extended_clicked),
view);
g_free (str);
view->stroke_button =
gimp_editor_add_button (editor,
GIMP_STOCK_PATH_STROKE, _("Stroke Path"), NULL,
......@@ -159,7 +180,9 @@ gimp_vectors_tree_view_init (GimpVectorsTreeView *view)
gtk_box_reorder_child (GTK_BOX (editor->button_box),
view->toselection_button, 5);
gtk_box_reorder_child (GTK_BOX (editor->button_box),
view->stroke_button, 6);
view->tovectors_button, 6);
gtk_box_reorder_child (GTK_BOX (editor->button_box),
view->stroke_button, 7);
gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (editor),
GTK_BUTTON (view->toselection_button),
......@@ -234,6 +257,23 @@ gimp_vectors_tree_view_toselection_extended_clicked (GtkWidget *widget
}
}
static void
gimp_vectors_tree_view_tovectors_clicked (GtkWidget *widget,
GimpVectorsTreeView *view)
{
gimp_vectors_tree_view_tovectors_extended_clicked (widget, 0, view);
}
static void
gimp_vectors_tree_view_tovectors_extended_clicked (GtkWidget *widget,
guint state,
GimpVectorsTreeView *view)
{
if (view->selection_to_vectors_func)
view->selection_to_vectors_func (GIMP_ITEM_TREE_VIEW (view)->gimage,
(state & GDK_SHIFT_MASK) != 0);
}
static void
gimp_vectors_tree_view_stroke_clicked (GtkWidget *widget,
GimpVectorsTreeView *view)
......@@ -246,7 +286,5 @@ gimp_vectors_tree_view_stroke_clicked (GtkWidget *widget,
item = GIMP_ITEM_TREE_VIEW_GET_CLASS (view)->get_active_item (gimage);
if (item && view->stroke_item_func)
{
view->stroke_item_func (GIMP_VECTORS (item));
}
view->stroke_item_func (GIMP_VECTORS (item));
}
......@@ -26,7 +26,9 @@
#include "gimpitemtreeview.h"
typedef void (* GimpStrokeItemFunc) (GimpVectors *vectors);
typedef void (* GimpStrokeItemFunc) (GimpVectors *vectors);
typedef void (* GimpSelectionToVectorsFunc) (GimpImage *gimage,
gboolean advanced);
#define GIMP_TYPE_VECTORS_TREE_VIEW (gimp_vectors_tree_view_get_type ())
......@@ -41,12 +43,14 @@ typedef struct _GimpVectorsTreeViewClass GimpVectorsTreeViewClass;
struct _GimpVectorsTreeView
{
GimpItemTreeView parent_instance;
GimpItemTreeView parent_instance;
GimpStrokeItemFunc stroke_item_func;
GimpStrokeItemFunc stroke_item_func;
GimpSelectionToVectorsFunc selection_to_vectors_func;
GtkWidget *toselection_button;
GtkWidget *stroke_button;
GtkWidget *toselection_button;
GtkWidget *tovectors_button;
GtkWidget *stroke_button;
};
struct _GimpVectorsTreeViewClass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment