#!/usr/bin/env python # next-mode.py: set the current layer to the next layer mode. # Copyright (C) 2008 Akkana Peck. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (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 # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. from gimpfu import * import gtk mode_list = [ NORMAL_MODE, DISSOLVE_MODE, MULTIPLY_MODE, DIVIDE_MODE, SCREEN_MODE, OVERLAY_MODE, DODGE_MODE, BURN_MODE, HARDLIGHT_MODE, SOFTLIGHT_MODE, GRAIN_EXTRACT_MODE, GRAIN_MERGE_MODE, DIFFERENCE_MODE, ADDITION_MODE, SUBTRACT_MODE, DARKEN_ONLY_MODE, LIGHTEN_ONLY_MODE, HUE_MODE, SATURATION_MODE, COLOR_MODE, VALUE_MODE ] mode_names = [ "Normal", "Dissolve", "Multiply", "Divide", "Screen", "Overlay", "Dodge", "Burn", "Hard light", "Soft light", "Grain extract", "Grain merge", "Difference", "Addition", "Subtract", "Darken only", "Lighten only", "Hue", "Saturation", "Color", "Value" ] class ModeDialog(gtk.Window): def __init__ (self, image, *args): self.image = image self.w, self.h = 0, 0 ret = gtk.Window.__init__(self, *args) vbox = gtk.VBox(False, 0) self.add(vbox) for i in range(0, len(mode_list)) : btn = gtk.Button(mode_names[i], mode_names[i]) vbox.pack_start(btn, False, False, 0) btn.connect("clicked", self.changemode, mode_list[i]) btn.show() btn = gtk.Button("close", gtk.STOCK_CLOSE) btn.connect("clicked", self.disappear) vbox.pack_start(btn, False, False, 0) btn.show() vbox.show() self.show() return ret def changemode(self, widget, mode) : #self.drawable.mode = mode self.image.active_layer.mode = mode pdb.gimp_displays_flush() def disappear(self, widget) : gtk.main_quit() return False def show_mode_dlg(img, drawable): r = ModeDialog(img) gtk.main() def next_mode(img, drawable) : i = mode_list.index(drawable.mode) drawable.mode = mode_list[(i+1) % len(mode_list)] register( "python-fu-next-mode", N_("Change the current layer to the next layer mode"), "Change the current layer to the next layer mode", "Akkana Peck", "Akkana Peck", "2008", N_("/Layer/Next mode"), "*", [ ], [], next_mode ) register( "python-fu-mode_dialog", N_("Show a dialog with all modes"), "Show a dialog with all modes", "Akkana Peck", "Akkana Peck", "2008", N_("/Layer/Mode dialog..."), "*", [ ], [], show_mode_dlg ) main()