mirror of https://github.com/GNOME/gimp.git
keep the container of dirty images up to date.
2004-10-13 Michael Natterer <mitch@gimp.org> * app/display/gimpdisplay-foreach.c: keep the container of dirty images up to date. * app/dialogs/quit-dialog.c: fixed model/view behavior here, too. (both are still far from perfect)
This commit is contained in:
parent
e5fe5e7221
commit
12280a31a1
|
@ -1,3 +1,12 @@
|
|||
2004-10-13 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplay-foreach.c: keep the container of dirty
|
||||
images up to date.
|
||||
|
||||
* app/dialogs/quit-dialog.c: fixed model/view behavior here, too.
|
||||
|
||||
(both are still far from perfect)
|
||||
|
||||
2004-10-13 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell-close.c
|
||||
|
|
|
@ -89,10 +89,12 @@ quit_dialog_new (Gimp *gimp)
|
|||
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), box);
|
||||
gtk_widget_show (box);
|
||||
|
||||
g_signal_connect_object (images, "add",
|
||||
G_CALLBACK (quit_dialog_container_changed),
|
||||
box, 0);
|
||||
g_signal_connect_object (images, "remove",
|
||||
G_CALLBACK (quit_dialog_container_changed),
|
||||
box, 0);
|
||||
quit_dialog_container_changed (images, NULL, GIMP_MESSAGE_BOX (box));
|
||||
|
||||
preview_size = gimp->config->layer_preview_size;
|
||||
|
||||
|
@ -112,6 +114,10 @@ quit_dialog_new (Gimp *gimp)
|
|||
gtk_box_pack_start (GTK_BOX (box), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
g_object_set_data (G_OBJECT (box), "lost-label", label);
|
||||
|
||||
quit_dialog_container_changed (images, NULL, GIMP_MESSAGE_BOX (box));
|
||||
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
@ -131,7 +137,8 @@ quit_dialog_container_changed (GimpContainer *images,
|
|||
GimpObject *image,
|
||||
GimpMessageBox *box)
|
||||
{
|
||||
gint num_images = gimp_container_num_children (images);
|
||||
gint num_images = gimp_container_num_children (images);
|
||||
GtkWidget *label = g_object_get_data (G_OBJECT (box), "lost-label");
|
||||
|
||||
if (num_images == 1)
|
||||
gimp_message_box_set_primary_text (box,
|
||||
|
@ -140,5 +147,9 @@ quit_dialog_container_changed (GimpContainer *images,
|
|||
gimp_message_box_set_primary_text (box,
|
||||
_("There are %d images with unsaved changes:"),
|
||||
num_images);
|
||||
}
|
||||
|
||||
if (num_images == 0)
|
||||
gtk_widget_hide (label);
|
||||
else
|
||||
gtk_widget_show (label);
|
||||
}
|
||||
|
|
|
@ -53,19 +53,38 @@ gimp_displays_dirty (Gimp *gimp)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_displays_image_dirty_callback (GimpImage *image,
|
||||
GimpDirtyMask dirty_mask,
|
||||
GimpContainer *container)
|
||||
{
|
||||
if (image->dirty && image->disp_count > 0 &&
|
||||
! gimp_container_have (container, GIMP_OBJECT (image)))
|
||||
gimp_container_add (container, GIMP_OBJECT (image));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_displays_dirty_images_disconnect (GimpContainer *dirty_container,
|
||||
GimpContainer *global_container)
|
||||
{
|
||||
GQuark handler;
|
||||
|
||||
handler = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dirty_container),
|
||||
"clean-handler"));
|
||||
gimp_container_remove_handler (global_container, handler);
|
||||
|
||||
handler = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dirty_container),
|
||||
"dirty-handler"));
|
||||
gimp_container_remove_handler (global_container, handler);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_displays_image_clean_callback (GimpImage *image,
|
||||
GimpDirtyMask dirty_mask,
|
||||
GimpContainer *container)
|
||||
{
|
||||
if (! image->dirty)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (image,
|
||||
gimp_displays_image_clean_callback,
|
||||
container);
|
||||
|
||||
gimp_container_remove (container, GIMP_OBJECT (image));
|
||||
}
|
||||
gimp_container_remove (container, GIMP_OBJECT (image));
|
||||
}
|
||||
|
||||
GimpContainer *
|
||||
|
@ -77,6 +96,25 @@ gimp_displays_get_dirty_images (Gimp *gimp)
|
|||
{
|
||||
GimpContainer *container = gimp_list_new_weak (GIMP_TYPE_IMAGE, FALSE);
|
||||
GList *list;
|
||||
GQuark handler;
|
||||
|
||||
handler =
|
||||
gimp_container_add_handler (gimp->images, "clean",
|
||||
G_CALLBACK (gimp_displays_image_dirty_callback),
|
||||
container);
|
||||
g_object_set_data (G_OBJECT (container), "clean-handler",
|
||||
GINT_TO_POINTER (handler));
|
||||
|
||||
handler =
|
||||
gimp_container_add_handler (gimp->images, "dirty",
|
||||
G_CALLBACK (gimp_displays_image_dirty_callback),
|
||||
container);
|
||||
g_object_set_data (G_OBJECT (container), "dirty-handler",
|
||||
GINT_TO_POINTER (handler));
|
||||
|
||||
g_signal_connect_object (container, "disconnect",
|
||||
G_CALLBACK (gimp_displays_dirty_images_disconnect),
|
||||
G_OBJECT (gimp->images), 0);
|
||||
|
||||
gimp_container_add_handler (container, "clean",
|
||||
G_CALLBACK (gimp_displays_image_clean_callback),
|
||||
|
@ -85,18 +123,14 @@ gimp_displays_get_dirty_images (Gimp *gimp)
|
|||
G_CALLBACK (gimp_displays_image_clean_callback),
|
||||
container);
|
||||
|
||||
for (list = GIMP_LIST (gimp->displays)->list;
|
||||
for (list = GIMP_LIST (gimp->images)->list;
|
||||
list;
|
||||
list = g_list_next (list))
|
||||
{
|
||||
GimpDisplay *display = list->data;
|
||||
GimpImage *image = display->gimage;
|
||||
GimpImage *image = list->data;
|
||||
|
||||
if (image->dirty &&
|
||||
! gimp_container_have (container, GIMP_OBJECT (image)))
|
||||
{
|
||||
gimp_container_add (container, GIMP_OBJECT (image));
|
||||
}
|
||||
if (image->dirty && image->disp_count > 0)
|
||||
gimp_container_add (container, GIMP_OBJECT (image));
|
||||
}
|
||||
|
||||
return container;
|
||||
|
|
Loading…
Reference in New Issue