mirror of https://github.com/GNOME/gimp.git
app: add signal GimpImage::update_vectors() and have the image manage updates
...just as we do for drawables. Connect to adding, removing, modifying and toggling visibility of all vectors and emit "update-vectors" accordingly. Add an update-vectors signal handler to GimpDisplayShell and remove all other vectors handlers.
This commit is contained in:
parent
372e7316b7
commit
6bce0641d4
|
@ -78,6 +78,10 @@ struct _GimpImagePrivate
|
|||
GQuark channel_name_changed_handler;
|
||||
GQuark channel_color_changed_handler;
|
||||
|
||||
GimpTreeHandler *vectors_freeze_handler;
|
||||
GimpTreeHandler *vectors_thaw_handler;
|
||||
GimpTreeHandler *vectors_visible_handler;
|
||||
|
||||
GimpLayer *floating_sel; /* the FS layer */
|
||||
GimpChannel *selection_mask; /* the selection mask channel */
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "gimpsamplepoint.h"
|
||||
#include "gimpselection.h"
|
||||
#include "gimptemplate.h"
|
||||
#include "gimptreehandler.h"
|
||||
#include "gimpundostack.h"
|
||||
|
||||
#include "file/file-utils.h"
|
||||
|
@ -101,6 +102,7 @@ enum
|
|||
EXPORTED,
|
||||
UPDATE_GUIDE,
|
||||
UPDATE_SAMPLE_POINT,
|
||||
UPDATE_VECTORS,
|
||||
SAMPLE_POINT_ADDED,
|
||||
SAMPLE_POINT_REMOVED,
|
||||
PARASITE_ATTACHED,
|
||||
|
@ -189,6 +191,18 @@ static void gimp_image_channel_name_changed (GimpChannel *channel,
|
|||
GimpImage *image);
|
||||
static void gimp_image_channel_color_changed (GimpChannel *channel,
|
||||
GimpImage *image);
|
||||
static void gimp_image_vectors_freeze (GimpVectors *vectors,
|
||||
GimpImage *image);
|
||||
static void gimp_image_vectors_thaw (GimpVectors *vectors,
|
||||
GimpImage *image);
|
||||
static void gimp_image_vectors_visible (GimpVectors *vectors,
|
||||
GimpImage *image);
|
||||
static void gimp_image_vectors_add (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpImage *image);
|
||||
static void gimp_image_vectors_remove (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpImage *image);
|
||||
static void gimp_image_active_layer_notify (GimpItemTree *tree,
|
||||
const GParamSpec *pspec,
|
||||
GimpImage *image);
|
||||
|
@ -428,6 +442,16 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
G_TYPE_NONE, 1,
|
||||
G_TYPE_POINTER);
|
||||
|
||||
gimp_image_signals[UPDATE_VECTORS] =
|
||||
g_signal_new ("update-vectors",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, update_vectors),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__OBJECT,
|
||||
G_TYPE_NONE, 1,
|
||||
GIMP_TYPE_VECTORS);
|
||||
|
||||
gimp_image_signals[SAMPLE_POINT_ADDED] =
|
||||
g_signal_new ("sample-point-added",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -529,6 +553,7 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
klass->exported = NULL;
|
||||
klass->update_guide = NULL;
|
||||
klass->update_sample_point = NULL;
|
||||
klass->update_vectors = NULL;
|
||||
klass->sample_point_added = NULL;
|
||||
klass->sample_point_removed = NULL;
|
||||
klass->parasite_attached = NULL;
|
||||
|
@ -678,6 +703,26 @@ gimp_image_init (GimpImage *image)
|
|||
G_CALLBACK (gimp_image_channel_remove),
|
||||
image);
|
||||
|
||||
private->vectors_freeze_handler =
|
||||
gimp_tree_handler_connect (private->vectors->container, "freeze",
|
||||
G_CALLBACK (gimp_image_vectors_freeze),
|
||||
image);
|
||||
private->vectors_thaw_handler =
|
||||
gimp_tree_handler_connect (private->vectors->container, "thaw",
|
||||
G_CALLBACK (gimp_image_vectors_thaw),
|
||||
image);
|
||||
private->vectors_visible_handler =
|
||||
gimp_tree_handler_connect (private->vectors->container, "visibility-changed",
|
||||
G_CALLBACK (gimp_image_vectors_visible),
|
||||
image);
|
||||
|
||||
g_signal_connect (private->vectors->container, "add",
|
||||
G_CALLBACK (gimp_image_vectors_add),
|
||||
image);
|
||||
g_signal_connect (private->vectors->container, "remove",
|
||||
G_CALLBACK (gimp_image_vectors_remove),
|
||||
image);
|
||||
|
||||
private->floating_sel = NULL;
|
||||
private->selection_mask = NULL;
|
||||
|
||||
|
@ -879,6 +924,22 @@ gimp_image_dispose (GObject *object)
|
|||
gimp_image_channel_remove,
|
||||
image);
|
||||
|
||||
gimp_tree_handler_disconnect (private->vectors_freeze_handler);
|
||||
private->vectors_freeze_handler = NULL;
|
||||
|
||||
gimp_tree_handler_disconnect (private->vectors_thaw_handler);
|
||||
private->vectors_thaw_handler = NULL;
|
||||
|
||||
gimp_tree_handler_disconnect (private->vectors_visible_handler);
|
||||
private->vectors_visible_handler = NULL;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (private->vectors->container,
|
||||
gimp_image_vectors_add,
|
||||
image);
|
||||
g_signal_handlers_disconnect_by_func (private->vectors->container,
|
||||
gimp_image_vectors_remove,
|
||||
image);
|
||||
|
||||
gimp_container_foreach (private->layers->container,
|
||||
(GFunc) gimp_item_removed, NULL);
|
||||
gimp_container_foreach (private->channels->container,
|
||||
|
@ -1379,6 +1440,46 @@ gimp_image_channel_color_changed (GimpChannel *channel,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_vectors_freeze (GimpVectors *vectors,
|
||||
GimpImage *image)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_vectors_thaw (GimpVectors *vectors,
|
||||
GimpImage *image)
|
||||
{
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_image_update_vectors (image, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_vectors_visible (GimpVectors *vectors,
|
||||
GimpImage *image)
|
||||
{
|
||||
gimp_image_update_vectors (image, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_vectors_add (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpImage *image)
|
||||
{
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_image_update_vectors (image, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_vectors_remove (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpImage *image)
|
||||
{
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_image_update_vectors (image, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_active_layer_notify (GimpItemTree *tree,
|
||||
const GParamSpec *pspec,
|
||||
|
@ -2008,6 +2109,17 @@ gimp_image_update_sample_point (GimpImage *image,
|
|||
sample_point);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_update_vectors (GimpImage *image,
|
||||
GimpVectors *vectors)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (GIMP_IS_VECTORS (vectors));
|
||||
|
||||
g_signal_emit (image, gimp_image_signals[UPDATE_VECTORS], 0,
|
||||
vectors);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_sample_point_added (GimpImage *image,
|
||||
GimpSamplePoint *sample_point)
|
||||
|
|
|
@ -135,6 +135,8 @@ struct _GimpImageClass
|
|||
GimpGuide *guide);
|
||||
void (* update_sample_point) (GimpImage *image,
|
||||
GimpSamplePoint *sample_point);
|
||||
void (* update_vectors) (GimpImage *image,
|
||||
GimpVectors *vectors);
|
||||
void (* sample_point_added) (GimpImage *image,
|
||||
GimpSamplePoint *sample_point);
|
||||
void (* sample_point_removed) (GimpImage *image,
|
||||
|
@ -251,6 +253,9 @@ void gimp_image_update_guide (GimpImage *image,
|
|||
GimpGuide *guide);
|
||||
void gimp_image_update_sample_point (GimpImage *image,
|
||||
GimpSamplePoint *sample_point);
|
||||
void gimp_image_update_vectors (GimpImage *image,
|
||||
GimpVectors *vectors);
|
||||
|
||||
void gimp_image_sample_point_added (GimpImage *image,
|
||||
GimpSamplePoint *sample_point);
|
||||
void gimp_image_sample_point_removed (GimpImage *image,
|
||||
|
|
|
@ -93,6 +93,9 @@ static void gimp_display_shell_update_guide_handler (GimpImage *i
|
|||
static void gimp_display_shell_update_sample_point_handler(GimpImage *image,
|
||||
GimpSamplePoint *sample_point,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_update_vectors_handler (GimpImage *image,
|
||||
GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_invalidate_preview_handler (GimpImage *image,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_profile_changed_handler (GimpColorManaged *image,
|
||||
|
@ -107,19 +110,6 @@ static void gimp_display_shell_exported_handler (GimpImage *i
|
|||
static void gimp_display_shell_active_vectors_handler (GimpImage *image,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
static void gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_vectors_thaw_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_vectors_visible_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_vectors_add_handler (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_display_shell_vectors_remove_handler (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpDisplayShell *shell);
|
||||
|
||||
static void gimp_display_shell_check_notify_handler (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
GimpDisplayShell *shell);
|
||||
|
@ -148,14 +138,12 @@ static void gimp_display_shell_quality_notify_handler (GObject *c
|
|||
void
|
||||
gimp_display_shell_connect (GimpDisplayShell *shell)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpContainer *vectors;
|
||||
GimpImage *image;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
|
||||
|
||||
image = gimp_display_get_image (shell->display);
|
||||
vectors = gimp_image_get_vectors (image);
|
||||
image = gimp_display_get_image (shell->display);
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
|
@ -192,6 +180,9 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
|||
g_signal_connect (image, "update-sample-point",
|
||||
G_CALLBACK (gimp_display_shell_update_sample_point_handler),
|
||||
shell);
|
||||
g_signal_connect (image, "update-vectors",
|
||||
G_CALLBACK (gimp_display_shell_update_vectors_handler),
|
||||
shell);
|
||||
g_signal_connect (image, "invalidate-preview",
|
||||
G_CALLBACK (gimp_display_shell_invalidate_preview_handler),
|
||||
shell);
|
||||
|
@ -209,26 +200,6 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
|||
G_CALLBACK (gimp_display_shell_active_vectors_handler),
|
||||
shell);
|
||||
|
||||
shell->vectors_freeze_handler =
|
||||
gimp_tree_handler_connect (vectors, "freeze",
|
||||
G_CALLBACK (gimp_display_shell_vectors_freeze_handler),
|
||||
shell);
|
||||
shell->vectors_thaw_handler =
|
||||
gimp_tree_handler_connect (vectors, "thaw",
|
||||
G_CALLBACK (gimp_display_shell_vectors_thaw_handler),
|
||||
shell);
|
||||
shell->vectors_visible_handler =
|
||||
gimp_tree_handler_connect (vectors, "visibility-changed",
|
||||
G_CALLBACK (gimp_display_shell_vectors_visible_handler),
|
||||
shell);
|
||||
|
||||
g_signal_connect (vectors, "add",
|
||||
G_CALLBACK (gimp_display_shell_vectors_add_handler),
|
||||
shell);
|
||||
g_signal_connect (vectors, "remove",
|
||||
G_CALLBACK (gimp_display_shell_vectors_remove_handler),
|
||||
shell);
|
||||
|
||||
g_signal_connect (shell->display->config,
|
||||
"notify::transparency-size",
|
||||
G_CALLBACK (gimp_display_shell_check_notify_handler),
|
||||
|
@ -297,8 +268,7 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
|
|||
void
|
||||
gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
||||
{
|
||||
GimpImage *image;
|
||||
GimpContainer *vectors;
|
||||
GimpImage *image;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
|
||||
|
@ -307,8 +277,6 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
|||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
vectors = gimp_image_get_vectors (image);
|
||||
|
||||
gimp_display_shell_icon_update_stop (shell);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (shell->display->config,
|
||||
|
@ -336,22 +304,6 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
|||
gimp_display_shell_check_notify_handler,
|
||||
shell);
|
||||
|
||||
g_signal_handlers_disconnect_by_func (vectors,
|
||||
gimp_display_shell_vectors_remove_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (vectors,
|
||||
gimp_display_shell_vectors_add_handler,
|
||||
shell);
|
||||
|
||||
gimp_tree_handler_disconnect (shell->vectors_visible_handler);
|
||||
shell->vectors_visible_handler = NULL;
|
||||
|
||||
gimp_tree_handler_disconnect (shell->vectors_thaw_handler);
|
||||
shell->vectors_thaw_handler = NULL;
|
||||
|
||||
gimp_tree_handler_disconnect (shell->vectors_freeze_handler);
|
||||
shell->vectors_freeze_handler = NULL;
|
||||
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_active_vectors_handler,
|
||||
shell);
|
||||
|
@ -374,6 +326,9 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
|
|||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_update_sample_point_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_update_vectors_handler,
|
||||
shell);
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_display_shell_quick_mask_changed_handler,
|
||||
shell);
|
||||
|
@ -519,6 +474,14 @@ gimp_display_shell_update_sample_point_handler (GimpImage *image,
|
|||
gimp_display_shell_expose_sample_point (shell, sample_point);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_update_vectors_handler (GimpImage *image,
|
||||
GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_expose_vectors (shell, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_size_changed_detailed_handler (GimpImage *image,
|
||||
gint previous_origin_x,
|
||||
|
@ -621,46 +584,6 @@ gimp_display_shell_active_vectors_handler (GimpImage *image,
|
|||
gimp_display_shell_expose_full (shell);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_vectors_freeze_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_vectors_thaw_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_display_shell_expose_vectors (shell, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_vectors_visible_handler (GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
gimp_display_shell_expose_vectors (shell, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_vectors_add_handler (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_display_shell_expose_vectors (shell, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_vectors_remove_handler (GimpContainer *container,
|
||||
GimpVectors *vectors,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
if (gimp_item_get_visible (GIMP_ITEM (vectors)))
|
||||
gimp_display_shell_expose_vectors (shell, vectors);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_display_shell_check_notify_handler (GObject *config,
|
||||
GParamSpec *param_spec,
|
||||
|
|
|
@ -166,10 +166,6 @@ struct _GimpDisplayShell
|
|||
|
||||
gint paused_count;
|
||||
|
||||
GimpTreeHandler *vectors_freeze_handler;
|
||||
GimpTreeHandler *vectors_thaw_handler;
|
||||
GimpTreeHandler *vectors_visible_handler;
|
||||
|
||||
gboolean zoom_on_resize;
|
||||
gboolean show_transform_preview;
|
||||
|
||||
|
|
Loading…
Reference in New Issue