images-commands.c 3.26 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
4
 * This program is free software: you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7 8 9 10 11 12 13 14
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19
 */

#include "config.h"

20
#include <gegl.h>
21 22
#include <gtk/gtk.h>

23 24
#include "libgimpwidgets/gimpwidgets.h"

Michael Natterer's avatar
Michael Natterer committed
25
#include "actions-types.h"
26

27
#include "core/gimp.h"
28
#include "core/gimpcontainer.h"
Michael Natterer's avatar
Michael Natterer committed
29
#include "core/gimpcontext.h"
30 31
#include "core/gimpimage.h"

Michael Natterer's avatar
Michael Natterer committed
32
#include "widgets/gimpcontainerview.h"
33 34
#include "widgets/gimpimageview.h"

35
#include "display/gimpdisplay.h"
36
#include "display/gimpdisplayshell.h"
37

38 39 40
#include "images-commands.h"


41
/*  public functions */
42 43

void
44
images_raise_views_cmd_callback (GtkAction *action,
45
                                 gpointer   data)
46
{
47 48 49 50
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpImage           *image;
51

52 53 54 55 56 57 58
  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  image = gimp_context_get_image (context);

  if (image && gimp_container_have (container, GIMP_OBJECT (image)))
    {
59 60
      GList *list;

61
      for (list = gimp_get_display_iter (image->gimp);
62 63 64 65 66
           list;
           list = g_list_next (list))
        {
          GimpDisplay *display = list->data;

67
          if (gimp_display_get_image (display) == image)
68
            gimp_display_shell_present (gimp_display_get_shell (display));
69
        }
70
    }
71 72 73
}

void
74
images_new_view_cmd_callback (GtkAction *action,
75
                              gpointer   data)
76
{
77 78 79 80 81 82 83 84 85
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpImage           *image;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);

  image = gimp_context_get_image (context);
86

87 88
  if (image && gimp_container_have (container, GIMP_OBJECT (image)))
    {
89
      gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
90
                           G_OBJECT (gimp_widget_get_monitor (GTK_WIDGET (editor))));
91
    }
92 93 94
}

void
95
images_delete_image_cmd_callback (GtkAction *action,
96 97
                                  gpointer   data)
{
98 99 100 101 102 103 104
  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data);
  GimpContainer       *container;
  GimpContext         *context;
  GimpImage           *image;

  container = gimp_container_view_get_container (editor->view);
  context   = gimp_container_view_get_context (editor->view);
105

106 107 108 109
  image = gimp_context_get_image (context);

  if (image && gimp_container_have (container, GIMP_OBJECT (image)))
    {
110
      if (gimp_image_get_display_count (image) == 0)
111 112
        g_object_unref (image);
    }
113
}