Ejemplo n.º 1
0
static void
gimp_tagged_container_src_remove (GimpFilteredContainer *filtered_container,
                                  GimpObject            *object)
{
  GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container);
  GList               *list;

  g_signal_handlers_disconnect_by_func (object,
                                        gimp_tagged_container_tag_added,
                                        tagged_container);
  g_signal_handlers_disconnect_by_func (object,
                                        gimp_tagged_container_tag_removed,
                                        tagged_container);

  for (list = gimp_tagged_get_tags (GIMP_TAGGED (object));
       list;
       list = g_list_next (list))
    {
      gimp_tagged_container_unref_tag (tagged_container, list->data);
    }

  if (gimp_tagged_container_object_matches (tagged_container, object))
    {
      gimp_container_remove (GIMP_CONTAINER (tagged_container), object);
    }
}
Ejemplo n.º 2
0
GimpUndo *
gimp_undo_stack_free_bottom (GimpUndoStack *stack,
                             GimpUndoMode   undo_mode)
{
  GimpUndo *undo;
  gint      n_children;

  g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), NULL);

  n_children = gimp_container_num_children (GIMP_CONTAINER (stack->undos));

  undo = (GimpUndo *)
    gimp_container_get_child_by_index (GIMP_CONTAINER (stack->undos),
                                       n_children - 1);

  if (undo)
    {
      gimp_container_remove (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo));
      gimp_undo_free (undo, undo_mode);

      return undo;
    }

  return NULL;
}
Ejemplo n.º 3
0
static GValueArray *
buffer_delete_invoker (GimpProcedure     *procedure,
                       Gimp              *gimp,
                       GimpContext       *context,
                       GimpProgress      *progress,
                       const GValueArray *args)
{
  gboolean success = TRUE;
  const gchar *buffer_name;

  buffer_name = g_value_get_string (&args->values[0]);

  if (success)
    {
      GimpBuffer *buffer = (GimpBuffer *)
        gimp_container_get_child_by_name (gimp->named_buffers, buffer_name);

      if (buffer)
        success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer));
      else
        success = FALSE;
    }

  return gimp_procedure_get_return_values (procedure, success);
}
Ejemplo n.º 4
0
static void
gimp_displays_image_clean_callback (GimpImage     *image,
                                    GimpDirtyMask  dirty_mask,
                                    GimpContainer *container)
{
  if (! image->dirty)
    gimp_container_remove (container, GIMP_OBJECT (image));
}
Ejemplo n.º 5
0
static void
gimp_list_clear (GimpContainer *container)
{
  GimpList *list = GIMP_LIST (container);

  while (list->list)
    gimp_container_remove (container, list->list->data);
}
Ejemplo n.º 6
0
GimpObject *
gimp_edit_cut (GimpImage     *image,
               GimpDrawable  *drawable,
               GimpContext   *context,
               GError       **error)
{
  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
  g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);

  if (GIMP_IS_LAYER (drawable) &&
      gimp_channel_is_empty (gimp_image_get_mask (image)))
    {
      GimpImage *clip_image;

      clip_image = gimp_image_new_from_drawable (image->gimp, drawable);
      gimp_container_remove (image->gimp->images, GIMP_OBJECT (clip_image));
      gimp_set_clipboard_image (image->gimp, clip_image);
      g_object_unref (clip_image);

      gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_EDIT_CUT,
                                   C_("undo-type", "Cut Layer"));

      gimp_image_remove_layer (image, GIMP_LAYER (drawable),
                               TRUE, NULL);

      gimp_image_undo_group_end (image);

      return GIMP_OBJECT (gimp_get_clipboard_image (image->gimp));
    }
  else
    {
      GimpBuffer *buffer;

      buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable),
                                  context, TRUE, error);

      if (buffer)
        {
          gimp_set_clipboard_buffer (image->gimp, buffer);
          g_object_unref (buffer);

          return GIMP_OBJECT (gimp_get_clipboard_buffer (image->gimp));
        }
    }

  return NULL;
}
Ejemplo n.º 7
0
static void
gimp_tagged_container_tag_removed (GimpTagged          *tagged,
                                   GimpTag             *tag,
                                   GimpTaggedContainer *tagged_container)
{
  gimp_tagged_container_unref_tag (tagged_container, tag);

  if (! gimp_tagged_container_object_matches (tagged_container,
                                              GIMP_OBJECT (tagged)) &&
      gimp_container_have (GIMP_CONTAINER (tagged_container),
                           GIMP_OBJECT (tagged)))
    {
      gimp_container_remove (GIMP_CONTAINER (tagged_container),
                             GIMP_OBJECT (tagged));
    }
}
Ejemplo n.º 8
0
static void
documents_remove_dangling_foreach (GimpImagefile *imagefile,
                                   GimpContainer *container)
{
  GimpThumbnail *thumbnail = gimp_imagefile_get_thumbnail (imagefile);

  if (gimp_thumbnail_peek_image (thumbnail) == GIMP_THUMB_STATE_NOT_FOUND)
    {
      const gchar *uri = gimp_object_get_name (imagefile);

      gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri,
                                      NULL);

      gimp_container_remove (container, GIMP_OBJECT (imagefile));
    }
}
Ejemplo n.º 9
0
void
windows_open_recent_cmd_callback (GtkAction *action,
                                  gpointer   data)
{
  GimpSessionInfo *info = g_object_get_data (G_OBJECT (action), "info");

  g_object_ref (info);

  gimp_container_remove (global_recent_docks, GIMP_OBJECT (info));

  gimp_dialog_factory_add_session_info (gimp_dialog_factory_get_singleton (),
                                        info);

  gimp_session_info_restore (info, gimp_dialog_factory_get_singleton ());

  g_object_unref (info);
}
Ejemplo n.º 10
0
GimpUndo *
gimp_undo_stack_free_bottom (GimpUndoStack *stack,
                             GimpUndoMode   undo_mode)
{
  GimpUndo *undo;

  g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), NULL);

  undo = GIMP_UNDO (gimp_container_get_last_child (stack->undos));

  if (undo)
    {
      gimp_container_remove (stack->undos, GIMP_OBJECT (undo));
      gimp_undo_free (undo, undo_mode);

      return undo;
    }

  return NULL;
}
Ejemplo n.º 11
0
void
gimp_display_delete (GimpDisplay *display)
{
  GimpTool *active_tool;

  g_return_if_fail (GIMP_IS_DISPLAY (display));

  /* remove the display from the list */
  gimp_container_remove (display->image->gimp->displays,
                         GIMP_OBJECT (display));

  /*  stop any active tool  */
  tool_manager_control_active (display->image->gimp, GIMP_TOOL_ACTION_HALT,
                               display);

  active_tool = tool_manager_get_active (display->image->gimp);

  if (active_tool && active_tool->focus_display == display)
    tool_manager_focus_display_active (display->image->gimp, NULL);

  /*  free the update area lists  */
  gimp_area_list_free (display->update_areas);
  display->update_areas = NULL;

  if (display->shell)
    {
      GtkWidget *shell = display->shell;

      /*  set display->shell to NULL *before* destroying the shell.
       *  all callbacks in gimpdisplayshell-callbacks.c will check
       *  this pointer and do nothing if the shell is in destruction.
       */
      display->shell = NULL;
      gtk_widget_destroy (shell);
    }

  /*  unrefs the image  */
  gimp_display_disconnect (display);

  g_object_unref (display);
}
Ejemplo n.º 12
0
static void
gimp_undo_stack_free (GimpUndo     *undo,
                      GimpUndoMode  undo_mode)
{
  GimpUndoStack *stack = GIMP_UNDO_STACK (undo);
  GList         *list;

  for (list = GIMP_LIST (stack->undos)->list;
       list;
       list = g_list_next (list))
    {
      GimpUndo *child = list->data;

      gimp_undo_free (child, undo_mode);
      g_object_unref (child);
    }

  while (GIMP_LIST (stack->undos)->list)
    gimp_container_remove (GIMP_CONTAINER (stack->undos),
                           GIMP_LIST (stack->undos)->list->data);
}
Ejemplo n.º 13
0
GimpUndo *
gimp_undo_stack_pop_undo (GimpUndoStack       *stack,
                          GimpUndoMode         undo_mode,
                          GimpUndoAccumulator *accum)
{
  GimpUndo *undo;

  g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), NULL);
  g_return_val_if_fail (accum != NULL, NULL);

  undo = GIMP_UNDO (gimp_container_get_first_child (stack->undos));

  if (undo)
    {
      gimp_container_remove (stack->undos, GIMP_OBJECT (undo));
      gimp_undo_pop (undo, undo_mode, accum);

      return undo;
    }

  return NULL;
}
Ejemplo n.º 14
0
static void
windows_menu_remove_toolbox_entries (GimpContainer *docks)
{
  GList *iter        = NULL;
  GList *for_removal = NULL;

  for (iter = GIMP_LIST (docks)->list; iter; iter = g_list_next (iter))
    {
      GimpSessionInfo        *info  = iter->data;
      GimpDialogFactoryEntry *entry = gimp_session_info_get_factory_entry (info);

      if (entry && strcmp ("gimp-toolbox-window", entry->identifier) == 0)
        for_removal = g_list_prepend (for_removal, info);
    }

  for (iter = for_removal; iter; iter = g_list_next (iter))
    {
      GimpSessionInfo *info = iter->data;

      gimp_container_remove (docks, GIMP_OBJECT (info));
    }

  g_list_free (for_removal);
}
Ejemplo n.º 15
0
static void
gimp_controller_list_remove_clicked (GtkWidget          *button,
                                     GimpControllerList *list)
{
  GtkWidget   *dialog;
  const gchar *name;

#define RESPONSE_DISABLE 1

  dialog = gimp_message_dialog_new (_("Remove Controller?"),
                                    GIMP_STOCK_WARNING,
                                    GTK_WIDGET (list), GTK_DIALOG_MODAL,
                                    NULL, NULL,

                                    _("Disable Controller"), RESPONSE_DISABLE,
                                    GTK_STOCK_CANCEL,        GTK_RESPONSE_CANCEL,
                                    _("Remove Controller"),  GTK_RESPONSE_OK,

                                    NULL);

  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
                                           GTK_RESPONSE_OK,
                                           GTK_RESPONSE_CANCEL,
                                           RESPONSE_DISABLE,
                                           -1);

  name = gimp_object_get_name (list->dest_info);
  gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                     _("Remove Controller '%s'?"), name);

  gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                             "%s",
                             _("Removing this controller from the list of "
                               "active controllers will permanently delete "
                               "all event mappings you have configured.\n\n"
                               "Selecting \"Disable Controller\" will disable "
                               "the controller without removing it."));

  switch (gimp_dialog_run (GIMP_DIALOG (dialog)))
    {
    case RESPONSE_DISABLE:
      gimp_controller_info_set_enabled (list->dest_info, FALSE);
      break;

    case GTK_RESPONSE_OK:
      {
        GtkWidget     *editor_dialog;
        GimpContainer *container;

        editor_dialog = g_object_get_data (G_OBJECT (list->dest_info),
                                           "gimp-controller-editor-dialog");

        if (editor_dialog)
          gtk_dialog_response (GTK_DIALOG (editor_dialog),
                               GTK_RESPONSE_DELETE_EVENT);

        container = gimp_controllers_get_list (list->gimp);
        gimp_container_remove (container, GIMP_OBJECT (list->dest_info));
      }
      break;

    default:
      break;
    }

  gtk_widget_destroy (dialog);
}