Issue #11642: "images-delete" action not disabled when the selected…
… image's displays change in the Images dockable.
This commit is contained in:
parent
cfba63a932
commit
d893aa373d
4 changed files with 84 additions and 4 deletions
|
|
@ -134,6 +134,7 @@ enum
|
|||
COLORMAP_CHANGED,
|
||||
UNDO_EVENT,
|
||||
ITEM_SETS_CHANGED,
|
||||
DISPLAY_COUNT_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
|
|
@ -591,6 +592,15 @@ gimp_image_class_init (GimpImageClass *klass)
|
|||
G_TYPE_NONE, 1,
|
||||
G_TYPE_GTYPE);
|
||||
|
||||
gimp_image_signals[DISPLAY_COUNT_CHANGED] =
|
||||
g_signal_new ("display-count-changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpImageClass, display_count_changed),
|
||||
NULL, NULL, NULL,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
object_class->constructed = gimp_image_constructed;
|
||||
object_class->set_property = gimp_image_set_property;
|
||||
object_class->get_property = gimp_image_get_property;
|
||||
|
|
@ -4251,6 +4261,8 @@ gimp_image_inc_display_count (GimpImage *image)
|
|||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
GIMP_IMAGE_GET_PRIVATE (image)->disp_count++;
|
||||
g_signal_emit (image, gimp_image_signals[DISPLAY_COUNT_CHANGED], 0,
|
||||
GIMP_IMAGE_GET_PRIVATE (image)->disp_count);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -4259,6 +4271,8 @@ gimp_image_dec_display_count (GimpImage *image)
|
|||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
|
||||
GIMP_IMAGE_GET_PRIVATE (image)->disp_count--;
|
||||
g_signal_emit (image, gimp_image_signals[DISPLAY_COUNT_CHANGED], 0,
|
||||
GIMP_IMAGE_GET_PRIVATE (image)->disp_count);
|
||||
}
|
||||
|
||||
gint
|
||||
|
|
|
|||
|
|
@ -103,6 +103,8 @@ struct _GimpImageClass
|
|||
GimpUndo *undo);
|
||||
void (* item_sets_changed) (GimpImage *image,
|
||||
GType item_type);
|
||||
void (* display_count_changed) (GimpImage *image,
|
||||
gint display_count);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -42,10 +42,18 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
static void gimp_image_view_select_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_image_view_activate_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_image_view_finalize (GObject *object);
|
||||
|
||||
static void gimp_image_view_image_changed (GimpContainerView *container_view,
|
||||
GimpImageView *view);
|
||||
static void gimp_image_view_display_count_changed (GimpImage *image,
|
||||
gint display_count,
|
||||
GimpImageView *view);
|
||||
|
||||
static void gimp_image_view_select_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
static void gimp_image_view_activate_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpImageView, gimp_image_view, GIMP_TYPE_CONTAINER_EDITOR)
|
||||
|
|
@ -56,8 +64,11 @@ G_DEFINE_TYPE (GimpImageView, gimp_image_view, GIMP_TYPE_CONTAINER_EDITOR)
|
|||
static void
|
||||
gimp_image_view_class_init (GimpImageViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
|
||||
|
||||
object_class->finalize = gimp_image_view_finalize;
|
||||
|
||||
editor_class->select_item = gimp_image_view_select_item;
|
||||
editor_class->activate_item = gimp_image_view_activate_item;
|
||||
}
|
||||
|
|
@ -70,6 +81,16 @@ gimp_image_view_init (GimpImageView *view)
|
|||
view->delete_button = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_view_finalize (GObject *object)
|
||||
{
|
||||
GimpImageView *view = GIMP_IMAGE_VIEW (object);
|
||||
|
||||
g_clear_weak_pointer (&view->image);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_image_view_new (GimpViewType view_type,
|
||||
GimpContainer *container,
|
||||
|
|
@ -137,12 +158,53 @@ gimp_image_view_new (GimpViewType view_type,
|
|||
GTK_BUTTON (image_view->delete_button),
|
||||
GIMP_TYPE_IMAGE);
|
||||
|
||||
/* The selection for this GimpContainerView is known to be an image.
|
||||
* The GimpContainerView class will automatically connect to the
|
||||
* "image-changed" signal from the context, but it doesn't tell us
|
||||
* anything about whether the display count of the selected image
|
||||
* changes. Yet this is important information as some action in the
|
||||
* "Images" action group may be set sensitive depending on this count.
|
||||
*/
|
||||
g_signal_connect (editor->view,
|
||||
"selection-changed",
|
||||
G_CALLBACK (gimp_image_view_image_changed),
|
||||
image_view);
|
||||
gimp_image_view_image_changed (editor->view, image_view);
|
||||
|
||||
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)),
|
||||
editor);
|
||||
|
||||
return GTK_WIDGET (image_view);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_view_image_changed (GimpContainerView *container_view,
|
||||
GimpImageView *view)
|
||||
{
|
||||
if (view->image)
|
||||
g_signal_handlers_disconnect_by_func (view->image,
|
||||
G_CALLBACK (gimp_image_view_display_count_changed),
|
||||
view);
|
||||
g_set_weak_pointer (&view->image,
|
||||
GIMP_IMAGE (gimp_container_view_get_1_selected (container_view)));
|
||||
if (view->image)
|
||||
g_signal_connect_object (view->image, "display-count-changed",
|
||||
G_CALLBACK (gimp_image_view_display_count_changed),
|
||||
view, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_view_display_count_changed (GimpImage *image,
|
||||
gint display_count,
|
||||
GimpImageView *view)
|
||||
{
|
||||
GimpContainerEditor *editor;
|
||||
|
||||
editor = GIMP_CONTAINER_EDITOR (view);
|
||||
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor->view)),
|
||||
editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_image_view_select_item (GimpContainerEditor *editor,
|
||||
GimpViewable *viewable)
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ struct _GimpImageView
|
|||
GtkWidget *raise_button;
|
||||
GtkWidget *new_button;
|
||||
GtkWidget *delete_button;
|
||||
|
||||
GimpImage *image;
|
||||
};
|
||||
|
||||
struct _GimpImageViewClass
|
||||
|
|
|
|||
Loading…
Reference in a new issue