Beispiel #1
0
void
gimp_undo_create_preview (GimpUndo    *undo,
                          GimpContext *context,
                          gboolean     create_now)
{
  g_return_if_fail (GIMP_IS_UNDO (undo));
  g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));

  if (undo->preview || undo->preview_idle_id)
    return;

  if (create_now)
    {
      gimp_undo_create_preview_private (undo, context);
    }
  else
    {
      GimpUndoIdle *idle = g_slice_new0 (GimpUndoIdle);

      idle->undo = undo;

      if (context)
        idle->context = g_object_ref (context);

      undo->preview_idle_id =
        g_idle_add_full (GIMP_VIEWABLE_PRIORITY_IDLE,
                         gimp_undo_create_preview_idle, idle,
                         (GDestroyNotify) gimp_undo_idle_free);
    }
}
Beispiel #2
0
void
gimp_undo_free (GimpUndo     *undo,
                GimpUndoMode  undo_mode)
{
  g_return_if_fail (GIMP_IS_UNDO (undo));

  g_signal_emit (undo, undo_signals[FREE], 0, undo_mode);
}
Beispiel #3
0
/**
 * gimp_undo_reset_age:
 * @undo:
 *
 * Changes the creation time of this undo item to the current time.
 */
void
gimp_undo_reset_age (GimpUndo *undo)
{
  g_return_if_fail (GIMP_IS_UNDO (undo));

  undo->time = time (NULL);

  g_object_notify (G_OBJECT (undo), "time");
}
Beispiel #4
0
void
gimp_undo_stack_push_undo (GimpUndoStack *stack,
                           GimpUndo      *undo)
{
  g_return_if_fail (GIMP_IS_UNDO_STACK (stack));
  g_return_if_fail (GIMP_IS_UNDO (undo));

  gimp_container_add (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo));
}
Beispiel #5
0
/**
 * gimp_undo_get_age:
 * @undo:
 *
 * Return value: the time in seconds since this undo item was created
 */
gint
gimp_undo_get_age (GimpUndo *undo)
{
  guint now = time (NULL);

  g_return_val_if_fail (GIMP_IS_UNDO (undo), 0);
  g_return_val_if_fail (now >= undo->time, 0);

  return now - undo->time;
}
Beispiel #6
0
void
gimp_undo_refresh_preview (GimpUndo    *undo,
                           GimpContext *context)
{
  g_return_if_fail (GIMP_IS_UNDO (undo));
  g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));

  if (undo->preview_idle_id)
    return;

  if (undo->preview)
    {
      gimp_temp_buf_unref (undo->preview);
      undo->preview = NULL;
      gimp_undo_create_preview (undo, context, FALSE);
    }
}
Beispiel #7
0
void
gimp_undo_pop (GimpUndo            *undo,
               GimpUndoMode         undo_mode,
               GimpUndoAccumulator *accum)
{
  g_return_if_fail (GIMP_IS_UNDO (undo));
  g_return_if_fail (accum != NULL);

  if (undo->dirty_mask != GIMP_DIRTY_NONE)
    {
      switch (undo_mode)
        {
        case GIMP_UNDO_MODE_UNDO:
          gimp_image_clean (undo->image, undo->dirty_mask);
          break;

        case GIMP_UNDO_MODE_REDO:
          gimp_image_dirty (undo->image, undo->dirty_mask);
          break;
        }
    }

  g_signal_emit (undo, undo_signals[POP], 0, undo_mode, accum);
}