~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimpimage-item-list.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* GIMP - The GNU Image Manipulation Program
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
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 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <glib-object.h>
 
22
 
 
23
#include "core-types.h"
 
24
 
 
25
#include "gimpcontext.h"
 
26
#include "gimpimage.h"
 
27
#include "gimpimage-item-list.h"
 
28
#include "gimpimage-undo.h"
 
29
#include "gimpitem.h"
 
30
#include "gimplist.h"
 
31
#include "gimpprogress.h"
 
32
 
 
33
#include "gimp-intl.h"
 
34
 
 
35
 
 
36
/*  public functions  */
 
37
 
 
38
void
 
39
gimp_image_item_list_translate (GimpImage *image,
 
40
                                GList     *list,
 
41
                                gint       offset_x,
 
42
                                gint       offset_y,
 
43
                                gboolean   push_undo)
 
44
{
 
45
  g_return_if_fail (GIMP_IS_IMAGE (image));
 
46
 
 
47
  if (list)
 
48
    {
 
49
      GList *l;
 
50
 
 
51
      if (push_undo)
 
52
        gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_DISPLACE,
 
53
                                     _("Translate Items"));
 
54
 
 
55
      for (l = list; l; l = g_list_next (l))
 
56
        gimp_item_translate (GIMP_ITEM (l->data),
 
57
                             offset_x, offset_y, push_undo);
 
58
 
 
59
      if (push_undo)
 
60
        gimp_image_undo_group_end (image);
 
61
    }
 
62
}
 
63
 
 
64
void
 
65
gimp_image_item_list_flip (GimpImage           *image,
 
66
                           GList               *list,
 
67
                           GimpContext         *context,
 
68
                           GimpOrientationType  flip_type,
 
69
                           gdouble              axis,
 
70
                           gboolean             clip_result)
 
71
{
 
72
  g_return_if_fail (GIMP_IS_IMAGE (image));
 
73
  g_return_if_fail (GIMP_IS_CONTEXT (context));
 
74
 
 
75
  if (list)
 
76
    {
 
77
      GList *l;
 
78
 
 
79
      gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
 
80
                                   _("Flip Items"));
 
81
 
 
82
      for (l = list; l; l = g_list_next (l))
 
83
        gimp_item_flip (GIMP_ITEM (l->data), context,
 
84
                        flip_type, axis, clip_result);
 
85
 
 
86
      gimp_image_undo_group_end (image);
 
87
    }
 
88
}
 
89
 
 
90
void
 
91
gimp_image_item_list_rotate (GimpImage        *image,
 
92
                             GList            *list,
 
93
                             GimpContext      *context,
 
94
                             GimpRotationType  rotate_type,
 
95
                             gdouble           center_x,
 
96
                             gdouble           center_y,
 
97
                             gboolean          clip_result)
 
98
{
 
99
  g_return_if_fail (GIMP_IS_IMAGE (image));
 
100
  g_return_if_fail (GIMP_IS_CONTEXT (context));
 
101
 
 
102
  if (list)
 
103
    {
 
104
      GList *l;
 
105
 
 
106
      gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
 
107
                                   _("Rotate Items"));
 
108
 
 
109
      for (l = list; l; l = g_list_next (l))
 
110
        gimp_item_rotate (GIMP_ITEM (l->data), context,
 
111
                          rotate_type, center_x, center_y, clip_result);
 
112
 
 
113
      gimp_image_undo_group_end (image);
 
114
    }
 
115
}
 
116
 
 
117
void
 
118
gimp_image_item_list_transform (GimpImage              *image,
 
119
                                GList                  *list,
 
120
                                GimpContext            *context,
 
121
                                const GimpMatrix3      *matrix,
 
122
                                GimpTransformDirection  direction,
 
123
                                GimpInterpolationType   interpolation_type,
 
124
                                gboolean                supersample,
 
125
                                gint                    recursion_level,
 
126
                                GimpTransformResize     clip_result,
 
127
                                GimpProgress           *progress)
 
128
{
 
129
  g_return_if_fail (GIMP_IS_IMAGE (image));
 
130
  g_return_if_fail (GIMP_IS_CONTEXT (context));
 
131
  g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
 
132
 
 
133
  if (list)
 
134
    {
 
135
      GList *l;
 
136
 
 
137
      gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
 
138
                                   _("Transform Items"));
 
139
 
 
140
      for (l = list; l; l = g_list_next (l))
 
141
        gimp_item_transform (GIMP_ITEM (l->data), context,
 
142
                             matrix, direction,
 
143
                             interpolation_type,
 
144
                             supersample, recursion_level,
 
145
                             clip_result, progress);
 
146
 
 
147
      gimp_image_undo_group_end (image);
 
148
    }
 
149
}
 
150
 
 
151
/**
 
152
 * gimp_image_item_list_get_list:
 
153
 * @item:  A linked @item.
 
154
 * @which: Which items to return.
 
155
 *
 
156
 * This function returns a #GList og #GimpItem's for which the
 
157
 * "linked" property is #TRUE. Note that the passed in @item
 
158
 * must be linked too.
 
159
 *
 
160
 * Return value: The list of linked items, excluding the passed @item.
 
161
 **/
 
162
GList *
 
163
gimp_image_item_list_get_list (GimpImage        *image,
 
164
                               GimpItem         *exclude,
 
165
                               GimpItemTypeMask  type,
 
166
                               GimpItemSet       set)
 
167
{
 
168
  GList *list;
 
169
  GList *return_list = NULL;
 
170
 
 
171
  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
 
172
  g_return_val_if_fail (exclude == NULL || GIMP_IS_ITEM (exclude), NULL);
 
173
 
 
174
  if (type & GIMP_ITEM_TYPE_LAYERS)
 
175
    {
 
176
      for (list = GIMP_LIST (image->layers)->list;
 
177
           list;
 
178
           list = g_list_next (list))
 
179
        {
 
180
          GimpItem *item = list->data;
 
181
 
 
182
          if (item != exclude && gimp_item_is_in_set (item, set))
 
183
            return_list = g_list_prepend (return_list, item);
 
184
        }
 
185
    }
 
186
 
 
187
  if (type & GIMP_ITEM_TYPE_CHANNELS)
 
188
    {
 
189
      for (list = GIMP_LIST (image->channels)->list;
 
190
           list;
 
191
           list = g_list_next (list))
 
192
        {
 
193
          GimpItem *item = list->data;
 
194
 
 
195
          if (item != exclude && gimp_item_is_in_set (item, set))
 
196
            return_list = g_list_prepend (return_list, item);
 
197
        }
 
198
    }
 
199
 
 
200
  if (type & GIMP_ITEM_TYPE_VECTORS)
 
201
    {
 
202
      for (list = GIMP_LIST (image->vectors)->list;
 
203
           list;
 
204
           list = g_list_next (list))
 
205
        {
 
206
          GimpItem *item = list->data;
 
207
 
 
208
          if (item != exclude && gimp_item_is_in_set (item, set))
 
209
            return_list = g_list_prepend (return_list, item);
 
210
        }
 
211
    }
 
212
 
 
213
  return g_list_reverse (return_list);
 
214
}