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

« back to all changes in this revision

Viewing changes to plug-ins/pygimp/plug-ins/palette-offset.py

  • 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
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
#    This program is free software; you can redistribute it and/or modify
 
4
#   it under the terms of the GNU General Public License as published by
 
5
#   the Free Software Foundation; either version 2 of the License, or
 
6
#   (at your option) any later version.
 
7
#
 
8
#   This program is distributed in the hope that it will be useful,
 
9
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#   GNU General Public License for more details.
 
12
#
 
13
#   You should have received a copy of the GNU General Public License
 
14
#   along with this program; if not, write to the Free Software
 
15
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
16
 
 
17
from gimpfu import *
 
18
 
 
19
gettext.install("gimp20-python", gimp.locale_directory, unicode=True)
 
20
 
 
21
def palette_offset(palette, amount):
 
22
    #If palette is read only, work on a copy:
 
23
    editable = pdb.gimp_palette_is_editable(palette) 
 
24
    if not editable:palette = pdb.gimp_palette_duplicate (palette)     
 
25
 
 
26
    num_colors = pdb.gimp_palette_get_info (palette)
 
27
 
 
28
    tmp_entry_array = []
 
29
    for i in xrange (num_colors):
 
30
        tmp_entry_array.append  ((pdb.gimp_palette_entry_get_name (palette, i),
 
31
                                  pdb.gimp_palette_entry_get_color (palette, i)))
 
32
    for i in xrange (num_colors):
 
33
        target_index = i + amount
 
34
        if target_index >= num_colors:
 
35
            target_index -= num_colors
 
36
        elif target_index < 0:
 
37
            target_index += num_colors
 
38
        pdb.gimp_palette_entry_set_name (palette, target_index, tmp_entry_array[i][0])
 
39
        pdb.gimp_palette_entry_set_color (palette, target_index, tmp_entry_array[i][1])
 
40
    return palette
 
41
 
 
42
 
 
43
register(
 
44
    "python-fu-palette-offset",
 
45
    N_("Offset the colors in a palette"),
 
46
    "palette_offset (palette, amount) -> modified_palette",
 
47
    "Joao S. O. Bueno Calligaris, Carol Spears",
 
48
    "(c) Joao S. O. Bueno Calligaris",
 
49
    "2004, 2006",
 
50
    N_("_Offset Palette..."),
 
51
    "",
 
52
    [
 
53
     (PF_PALETTE, "palette", _("Palette"), ""),
 
54
     (PF_INT,     "amount",  _("Off_set"),  1),
 
55
    ],
 
56
    [(PF_PALETTE, "new-palette", "Result")],
 
57
    palette_offset,
 
58
    menu="<Palettes>",
 
59
    domain=("gimp20-python", gimp.locale_directory)
 
60
    )
 
61
 
 
62
main ()