Since GimpVectorTool is no GimpSelectionTool, it does not make sense to

2003-11-15  Simon Budig  <simon@gimp.org>

	* app/tools/gimpvectoroptions.[ch]: Since GimpVectorTool is no
	GimpSelectionTool, it does not make sense to have
	GimpSelectionOptions for it.

	* app/tools/gimpvectoroptions.c
	* app/tools/gimpvectortool.c: Connect the Buttons to the
	Help system and make the to-selection Button modifier
	aware.
This commit is contained in:
Simon Budig
2003-11-14 23:10:24 +00:00
committed by Simon Budig
parent cc718bfa6b
commit 832b51b5a8
4 changed files with 73 additions and 14 deletions

View File

@ -1,3 +1,14 @@
2003-11-15 Simon Budig <simon@gimp.org>
* app/tools/gimpvectoroptions.[ch]: Since GimpVectorTool is no
GimpSelectionTool, it does not make sense to have
GimpSelectionOptions for it.
* app/tools/gimpvectoroptions.c
* app/tools/gimpvectortool.c: Connect the Buttons to the
Help system and make the to-selection Button modifier
aware.
2003-11-14 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpwidgets.[ch]: guard old functions using

View File

@ -31,6 +31,7 @@
#include "core/gimptoolinfo.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimppropwidgets.h"
#include "widgets/gimpwidgets-utils.h"
@ -81,7 +82,7 @@ gimp_vector_options_get_type (void)
(GInstanceInitFunc) gimp_vector_options_init,
};
type = g_type_register_static (GIMP_TYPE_SELECTION_OPTIONS,
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
"GimpVectorOptions",
&info, 0);
}
@ -176,6 +177,7 @@ gimp_vector_options_gui (GimpToolOptions *tool_options)
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *button;
gchar *str;
config = G_OBJECT (tool_options);
@ -192,17 +194,32 @@ gimp_vector_options_gui (GimpToolOptions *tool_options)
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
button = gtk_button_new_with_label (_("Create Selection from Path"));
str = g_strdup_printf (_("Path to Selection\n"
"%s Add\n"
"%s Subtract\n"
"%s%s%s Intersect"),
gimp_get_mod_name_shift (),
gimp_get_mod_name_control (),
gimp_get_mod_name_shift (),
gimp_get_mod_separator (),
gimp_get_mod_name_control ());
button = gimp_button_new ();
gtk_button_set_label (GTK_BUTTON (button), _("Create Selection from Path"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (button, FALSE);
gimp_help_set_help_data (button, str, GIMP_HELP_PATH_SELECTION_REPLACE);
gtk_widget_show (button);
g_free (str);
g_object_set_data (G_OBJECT (tool_options),
"gimp-vectors-to-selection", button);
button = gtk_button_new_with_label (_("Stroke Path"));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_widget_set_sensitive (button, FALSE);
gimp_help_set_help_data (button, NULL, GIMP_HELP_PATH_STROKE);
gtk_widget_show (button);
g_object_set_data (G_OBJECT (tool_options),

View File

@ -20,7 +20,7 @@
#define __GIMP_VECTOR_OPTIONS_H__
#include "gimpselectionoptions.h"
#include "core/gimptooloptions.h"
#define GIMP_TYPE_VECTOR_OPTIONS (gimp_vector_options_get_type ())
@ -36,7 +36,7 @@ typedef struct _GimpToolOptionsClass GimpVectorOptionsClass;
struct _GimpVectorOptions
{
GimpSelectionOptions parent_instance;
GimpToolOptions parent_instance;
GimpVectorMode edit_mode;
gboolean polygonal;

View File

@ -136,6 +136,9 @@ static void gimp_vector_tool_undo_push (GimpVectorTool *vector_tool,
const gchar *desc);
static void gimp_vector_tool_to_selection (GimpVectorTool *vector_tool);
static void gimp_vector_tool_to_selection_extended
(GimpVectorTool *vector_tool,
gint state);
static void gimp_vector_tool_stroke_vectors (GimpVectorTool *vector_tool,
GtkWidget *button);
@ -1503,6 +1506,9 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
g_signal_handlers_disconnect_by_func (sel_button,
gimp_vector_tool_to_selection,
tool);
g_signal_handlers_disconnect_by_func (sel_button,
gimp_vector_tool_to_selection_extended,
tool);
}
if (stroke_button)
@ -1553,6 +1559,9 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
g_signal_connect_swapped (sel_button, "clicked",
G_CALLBACK (gimp_vector_tool_to_selection),
tool);
g_signal_connect_swapped (sel_button, "extended_clicked",
G_CALLBACK (gimp_vector_tool_to_selection_extended),
tool);
gtk_widget_set_sensitive (sel_button, TRUE);
}
@ -1740,19 +1749,41 @@ gimp_vector_tool_undo_push (GimpVectorTool *vector_tool, const gchar *desc)
static void
gimp_vector_tool_to_selection (GimpVectorTool *vector_tool)
{
gimp_vector_tool_to_selection_extended (vector_tool, 0);
}
static void
gimp_vector_tool_to_selection_extended (GimpVectorTool *vector_tool,
gint state)
{
GimpImage *gimage;
GimpChannelOps operation = GIMP_CHANNEL_OP_REPLACE;
if (! vector_tool->vectors)
return;
gimage = gimp_item_get_image (GIMP_ITEM (vector_tool->vectors));
if (state & GDK_SHIFT_MASK)
{
if (state & GDK_CONTROL_MASK)
operation = GIMP_CHANNEL_OP_INTERSECT;
else
operation = GIMP_CHANNEL_OP_ADD;
}
else if (state & GDK_CONTROL_MASK)
{
operation = GIMP_CHANNEL_OP_SUBTRACT;
}
gimp_channel_select_vectors (gimp_image_get_mask (gimage),
_("Path to Selection"),
vector_tool->vectors,
GIMP_CHANNEL_OP_REPLACE,
operation,
TRUE, FALSE, 0, 0);
gimp_image_flush (gimage);
}