app: Make image flush related functions idle

Made `gimp_image_editor_image_flush` and
`gimp_image_editor_image_flush_idle` functions idle. For expanding
layers dynamically, we need to use gimp_image_flush funtion from the
paint therad. The gimp_image_flush eventually calls these functions.
This commit is contained in:
Shubham 2023-07-13 01:13:26 +05:30 committed by Jehan
parent 3ccec0b128
commit 95f795008f
2 changed files with 40 additions and 0 deletions

View File

@ -42,6 +42,11 @@ static void gimp_display_bounds_changed_handler (GimpImage *image,
gint old_x,
gint old_y,
GimpDisplay *display);
static void gimp_display_flush_handler (GimpImage *image,
gboolean invalidate_preview,
GimpDisplay *display);
static gboolean
gimp_display_flush_handler_idle (gpointer user_data);
/* public functions */
@ -118,3 +123,23 @@ gimp_display_bounds_changed_handler (GimpImage *image,
{
gimp_display_update_bounding_box (display);
}
static void
gimp_display_flush_handler (GimpImage *image,
gboolean invalidate_preview,
GimpDisplay *display)
{
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_display_flush_handler_idle,
g_object_ref (display), g_object_unref);
}
static gboolean
gimp_display_flush_handler_idle (gpointer user_data)
{
GimpDisplay *display = user_data;
gimp_display_flush (display);
return G_SOURCE_REMOVE;
}

View File

@ -42,6 +42,9 @@ static void gimp_image_editor_real_set_image (GimpImageEditor *editor,
static void gimp_image_editor_image_flush (GimpImage *image,
gboolean invalidate_preview,
GimpImageEditor *editor);
static gboolean
gimp_image_editor_image_flush_idle
(gpointer user_data);
G_DEFINE_TYPE_WITH_CODE (GimpImageEditor, gimp_image_editor, GIMP_TYPE_EDITOR,
@ -173,7 +176,19 @@ gimp_image_editor_image_flush (GimpImage *image,
gboolean invalidate_preview,
GimpImageEditor *editor)
{
g_idle_add_full (G_PRIORITY_LOW,
(GSourceFunc) gimp_image_editor_image_flush_idle,
g_object_ref (editor), g_object_unref);
}
static gboolean
gimp_image_editor_image_flush_idle (gpointer user_data)
{
GimpImageEditor *editor = user_data;
if (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)))
gimp_ui_manager_update (gimp_editor_get_ui_manager (GIMP_EDITOR (editor)),
gimp_editor_get_popup_data (GIMP_EDITOR (editor)));
return G_SOURCE_REMOVE;
}