Commit c1f29141 authored by Manish Singh's avatar Manish Singh Committed by Manish Singh
Browse files

minor tweak to history behavior.

2004-09-29  Manish Singh  <yosh@gimp.org>

        * plug-ins/pygimp/plug-ins/gtkcons.py: minor tweak to history
        behavior.

        * plug-ins/pygimp/plug-ins/clothify.py
        * plug-ins/pygimp/plug-ins/foggify.py
        * plug-ins/pygimp/plug-ins/gimpcons.py
        * plug-ins/pygimp/plug-ins/gtkcons.py
        * plug-ins/pygimp/plug-ins/pdbbrowse.py
        * plug-ins/pygimp/plug-ins/shadow_bevel.py
        * plug-ins/pygimp/plug-ins/sphere.py
        * plug-ins/pygimp/plug-ins/whirlpinch.py: Untabbify
parent b41bb55d
2004-09-29 Manish Singh <yosh@gimp.org>
* plug-ins/pygimp/plug-ins/gtkcons.py: minor tweak to history
behavior.
* plug-ins/pygimp/plug-ins/clothify.py
* plug-ins/pygimp/plug-ins/foggify.py
* plug-ins/pygimp/plug-ins/gimpcons.py
* plug-ins/pygimp/plug-ins/gtkcons.py
* plug-ins/pygimp/plug-ins/pdbbrowse.py
* plug-ins/pygimp/plug-ins/shadow_bevel.py
* plug-ins/pygimp/plug-ins/sphere.py
* plug-ins/pygimp/plug-ins/whirlpinch.py: Untabbify
2004-09-29 Sven Neumann <sven@gimp.org>
* app/tools/gimpcropoptions.c (gimp_crop_options_gui): plugged a
......
......@@ -21,13 +21,13 @@ import math
from gimpfu import *
def python_clothify(timg, tdrawable, bx=9, by=9,
azimuth=135, elevation=45, depth=3):
azimuth=135, elevation=45, depth=3):
bx = 9 ; by = 9 ; azimuth = 135 ; elevation = 45 ; depth = 3
width = tdrawable.width
height = tdrawable.height
img = gimp.Image(width, height, RGB)
layer_one = gimp.Layer(img, "X Dots", width, height, RGB_IMAGE,
100, NORMAL_MODE)
100, NORMAL_MODE)
img.disable_undo()
pdb.gimp_edit_fill(layer_one, BACKGROUND_FILL)
img.add_layer(layer_one, 0)
......@@ -43,26 +43,26 @@ def python_clothify(timg, tdrawable, bx=9, by=9,
pdb.plug_in_c_astretch(img, bump_layer)
pdb.plug_in_noisify(img, bump_layer, 0, 0.2, 0.2, 0.2, 0.2)
pdb.plug_in_bump_map(img, tdrawable, bump_layer, azimuth,
elevation, depth, 0, 0, 0, 0, TRUE, FALSE, 0)
elevation, depth, 0, 0, 0, 0, TRUE, FALSE, 0)
gimp.delete(img)
register(
"python_fu_clothify",
"Make the specified layer look like it is printed on cloth",
"Make the specified layer look like it is printed on cloth",
"James Henstridge",
"James Henstridge",
"1997-1999",
"<Image>/Python-Fu/Alchemy/_Clothify",
"RGB*, GRAY*",
[
(PF_INT, "x_blur", "X blur", 9),
(PF_INT, "y_blur", "Y blur", 9),
(PF_INT, "azimuth", "Azimuth", 135),
(PF_INT, "elevation", "Elevation", 45),
(PF_INT, "depth", "Depth", 3)
],
[],
python_clothify)
"python_fu_clothify",
"Make the specified layer look like it is printed on cloth",
"Make the specified layer look like it is printed on cloth",
"James Henstridge",
"James Henstridge",
"1997-1999",
"<Image>/Python-Fu/Alchemy/_Clothify",
"RGB*, GRAY*",
[
(PF_INT, "x_blur", "X blur", 9),
(PF_INT, "y_blur", "Y blur", 9),
(PF_INT, "azimuth", "Azimuth", 135),
(PF_INT, "elevation", "Elevation", 45),
(PF_INT, "depth", "Depth", 3)
],
[],
python_clothify)
main()
......@@ -7,7 +7,7 @@ def python_foggify(img, layer, name, colour, turbulence, opacity):
img.undo_group_start()
fog = gimp.Layer(img, name, layer.width, layer.height, RGBA_IMAGE,
opacity, NORMAL_MODE)
opacity, NORMAL_MODE)
oldbg = gimp.get_background()
gimp.set_background(colour)
pdb.gimp_edit_fill(fog, BACKGROUND_FILL)
......@@ -18,10 +18,10 @@ def python_foggify(img, layer, name, colour, turbulence, opacity):
# create a layer mask for the new layer
mask = fog.create_mask(0)
fog.add_mask(mask)
# add some clouds to the layer
pdb.plug_in_plasma(img, mask, int(time.time()), turbulence)
# apply the clouds to the layer
fog.remove_mask(MASK_APPLY)
......@@ -38,9 +38,9 @@ register(
"RGB*, GRAY*",
[
(PF_STRING, "name", "The new layer name", "Clouds"),
(PF_COLOUR, "colour", "The colour of the fog", (240,180,70)),
(PF_SLIDER, "turbulence", "The turbulence", 1.0, (0, 10, 0.1)),
(PF_SLIDER, "opacity", "The opacity", 100, (0, 100, 1)),
(PF_COLOUR, "colour", "The colour of the fog", (240,180,70)),
(PF_SLIDER, "turbulence", "The turbulence", 1.0, (0, 10, 0.1)),
(PF_SLIDER, "opacity", "The opacity", 100, (0, 100, 1)),
],
[],
python_foggify)
......
......@@ -28,16 +28,16 @@ def plug_in_python_fu_console():
gtk.rc_parse(gimp.gtkrc())
namespace = {'__builtins__': __builtins__,
'__name__': '__main__', '__doc__': None,
'gimp': gimp, 'pdb': gimp.pdb,
'shelf': gimpshelf.shelf}
'__name__': '__main__', '__doc__': None,
'gimp': gimp, 'pdb': gimp.pdb,
'shelf': gimpshelf.shelf}
for s in gimpenums.__dict__.keys():
if s[0] != '_':
namespace[s] = getattr(gimpenums, s)
def bye(*args):
gtk.main_quit()
gtk.main_quit()
win = gtk.Window()
win.connect("destroy", bye)
......
......@@ -43,17 +43,17 @@ def remQuotStr(s):
quote = ''
prev = None
for ch in s:
if in_quote and (ch != quote or prev == '\\'):
if ch == '\\' and prev == '\\':
prev = None
else:
prev = ch
continue
prev = ch
if ch in '\'"':
if in_quote:
in_quote = 0
else:
if in_quote and (ch != quote or prev == '\\'):
if ch == '\\' and prev == '\\':
prev = None
else:
prev = ch
continue
prev = ch
if ch in '\'"':
if in_quote:
in_quote = 0
else:
in_quote = 1
quote = ch
ret = ret + ch
......@@ -64,13 +64,13 @@ def bracketsBalanced(s):
stack = []
brackets = {'(':')', '[':']', '{':'}'}
for ch in s:
if ch in '([{':
stack.append(ch)
elif ch in '}])':
if len(stack) != 0 and brackets[stack[-1]] == ch:
del stack[-1]
else:
return 0
if ch in '([{':
stack.append(ch)
elif ch in '}])':
if len(stack) != 0 and brackets[stack[-1]] == ch:
del stack[-1]
else:
return 0
return len(stack) == 0
class gtkoutfile:
......@@ -79,7 +79,7 @@ class gtkoutfile:
def __init__(self, buffer, fileno, tag):
self.__fileno = fileno
self.__buffer = buffer
self.__tag = tag
self.__tag = tag
def close(self): pass
flush = close
def fileno(self): return self.__fileno
......@@ -88,13 +88,13 @@ class gtkoutfile:
def readline(self): return ''
def readlines(self): return []
def write(self, string):
#stdout.write(str(self.__w.get_point()) + '\n')
iter = self.__buffer.get_end_iter()
self.__buffer.insert_with_tags_by_name(iter, string, self.__tag)
#stdout.write(str(self.__w.get_point()) + '\n')
iter = self.__buffer.get_end_iter()
self.__buffer.insert_with_tags_by_name(iter, string, self.__tag)
def writelines(self, lines):
iter = self.__buffer.get_end_iter()
for line in lines:
self.__buffer.insert_with_tags_by_name(iter, lines, self.__tag)
iter = self.__buffer.get_end_iter()
for line in lines:
self.__buffer.insert_with_tags_by_name(iter, lines, self.__tag)
def seek(self, a): raise IOError, (29, 'Illegal seek')
def tell(self): raise IOError, (29, 'Illegal seek')
truncate = tell
......@@ -106,27 +106,27 @@ class Console(gtk.VBox):
self.quit_cb = quit_cb
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
swin = gtk.ScrolledWindow()
swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self.pack_start(swin)
swin.show()
self.vadj = swin.get_vadjustment()
self.vadj = swin.get_vadjustment()
self.textview = gtk.TextView()
self.textview.set_editable(gtk.FALSE)
self.textview.set_cursor_visible(gtk.FALSE)
self.textview.set_wrap_mode(gtk.WRAP_WORD)
self.buffer = self.textview.get_buffer()
swin.add(self.textview)
self.textview.show()
self.textview = gtk.TextView()
self.textview.set_editable(gtk.FALSE)
self.textview.set_cursor_visible(gtk.FALSE)
self.textview.set_wrap_mode(gtk.WRAP_WORD)
self.buffer = self.textview.get_buffer()
swin.add(self.textview)
self.textview.show()
# tags to use when inserting text ...
tag = self.buffer.create_tag('normal')
tag = self.buffer.create_tag('command')
tag.set_property('weight', pango.WEIGHT_BOLD)
tag = self.buffer.create_tag('error')
tag.set_property('style', pango.STYLE_ITALIC)
# tags to use when inserting text ...
tag = self.buffer.create_tag('normal')
tag = self.buffer.create_tag('command')
tag.set_property('weight', pango.WEIGHT_BOLD)
tag = self.buffer.create_tag('error')
tag.set_property('style', pango.STYLE_ITALIC)
self.inputbox = gtk.HBox(spacing=2)
self.pack_end(self.inputbox, expand=gtk.FALSE)
......@@ -162,9 +162,9 @@ class Console(gtk.VBox):
self.namespace['__history__'] = self.history
def init(self):
message = 'Python %s\n\n' % (sys.version,)
iter = self.buffer.get_end_iter()
self.buffer.insert_with_tags_by_name(iter, message, 'command')
message = 'Python %s\n\n' % (sys.version,)
iter = self.buffer.get_end_iter()
self.buffer.insert_with_tags_by_name(iter, message, 'command')
self.line.grab_focus()
def quit(self, *args):
......@@ -177,7 +177,7 @@ class Console(gtk.VBox):
self.line.emit_stop_by_name("key_press_event")
self.eval()
if event.keyval == gtk.keysyms.Tab:
self.line.emit_stop_by_name("key_press_event")
self.line.emit_stop_by_name("key_press_event")
self.line.append_text('\t')
gtk.idle_add(self.focus_text)
elif event.keyval in (gtk.keysyms.KP_Up, gtk.keysyms.Up):
......@@ -189,7 +189,7 @@ class Console(gtk.VBox):
self.historyDown()
gtk.idle_add(self.focus_text)
elif event.keyval in (gtk.keysyms.D, gtk.keysyms.d) and \
event.state & gtk.gdk.CONTROL_MASK:
event.state & gtk.gdk.CONTROL_MASK:
self.line.emit_stop_by_name("key_press_event")
self.ctrld()
......@@ -198,7 +198,7 @@ class Console(gtk.VBox):
return gtk.FALSE # don't requeue this handler
def scroll_bottom(self):
self.vadj.set_value(self.vadj.upper - self.vadj.page_size)
return gtk.FALSE
return gtk.FALSE
def ctrld(self):
#self.quit()
......@@ -221,6 +221,7 @@ class Console(gtk.VBox):
self.history[self.histpos] = l
self.histpos = self.histpos + 1
self.line.set_text(self.history[self.histpos])
self.line.set_position(-1)
def eval(self):
l = self.line.get_text() + '\n'
......@@ -231,9 +232,9 @@ class Console(gtk.VBox):
else:
self.history[self.histpos] = l
self.line.set_text('')
iter = self.buffer.get_end_iter()
self.buffer.insert_with_tags_by_name(iter, self.prompt.get_text() + l,
'command')
iter = self.buffer.get_end_iter()
self.buffer.insert_with_tags_by_name(iter, self.prompt.get_text() + l,
'command')
if l == '\n':
self.run(self.cmd)
self.cmd = ''
......@@ -272,7 +273,7 @@ class Console(gtk.VBox):
traceback.print_exc()
self.prompt.set_text(sys.ps1)
self.prompt.queue_draw()
gtk.idle_add(self.scroll_bottom)
gtk.idle_add(self.scroll_bottom)
sys.stdout, self.stdout = self.stdout, sys.stdout
sys.stderr, self.stderr = self.stderr, sys.stderr
......@@ -300,4 +301,4 @@ def gtk_console(ns, title='Python', menu=None):
if __name__ == '__main__':
if len(sys.argv) < 2 or sys.argv[1] != '-gimp':
gtk_console({'__builtins__': __builtins__, '__name__': '__main__',
'__doc__': None})
'__doc__': None})
......@@ -38,257 +38,257 @@ def define_browse_win():
global BrowseWin
class BrowseWin(gtk.Window):
def __init__(self, ok_button=None):
gtk.Window.__init__(self)
self.set_title("PDB Browser")
vbox = gtk.VBox(FALSE, 5)
vbox.set_border_width(2)
self.add(vbox)
vbox.show()
paned = gtk.HPaned()
vbox.pack_start(paned)
paned.show()
listsw = gtk.ScrolledWindow()
listsw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
paned.add1(listsw)
listsw.show()
self.list = gtk.CList(1)
self.list.set_column_auto_resize(0, TRUE)
self.list.set_selection_mode(gtk.SELECTION_BROWSE)
listsw.add(self.list)
self.list.show()
self.update_list()
self.list.connect("select_row", self.display)
self.infosw = gtk.ScrolledWindow()
self.infosw.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
paned.add2(self.infosw)
self.infosw.show()
self.info = None
paned.set_position(150)
self.cmd = None
self.display(self.list, 0, -1, None)
hbox = gtk.HBox(FALSE, 5)
vbox.pack_start(hbox, expand=FALSE)
hbox.show()
entry = gtk.Entry()
hbox.pack_start(entry, expand=FALSE)
entry.show()
button = gtk.Button("Search by name")
button.connect("clicked", self.search_name, entry)
hbox.pack_start(button, expand=FALSE)
button.show()
button = gtk.Button("Search by blurb")
button.connect("clicked", self.search_blurb, entry)
hbox.pack_start(button, expand=FALSE)
button.show()
button = gtk.Button("Close")
button.connect("clicked", lambda btn, win: win.destroy(), self)
hbox.pack_end(button, expand=FALSE)
button.show()
if ok_button:
button = gtk.Button("OK")
button.connect("clicked", ok_button, self)
hbox.pack_end(button, expand=FALSE)
button.show()
self.set_default_size(500, 300)
def search_name(self, button, entry):
self.update_list(name=entry.get_text())
def search_blurb(self, button, entry):
self.update_list(blurb=entry.get_text())
def update_list(self, name='.*', blurb='.*'):
self.pdblist = pdb.query(name,blurb,'.*','.*','.*','.*','.*')
self.pdblist.sort()
self.list.clear()
for item in self.pdblist:
self.list.append([item])
gtk.Window.__init__(self)
self.set_title("PDB Browser")
vbox = gtk.VBox(FALSE, 5)
vbox.set_border_width(2)
self.add(vbox)
vbox.show()
paned = gtk.HPaned()
vbox.pack_start(paned)
paned.show()
listsw = gtk.ScrolledWindow()
listsw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
paned.add1(listsw)
listsw.show()
self.list = gtk.CList(1)
self.list.set_column_auto_resize(0, TRUE)
self.list.set_selection_mode(gtk.SELECTION_BROWSE)
listsw.add(self.list)
self.list.show()
self.update_list()
self.list.connect("select_row", self.display)
self.infosw = gtk.ScrolledWindow()
self.infosw.set_policy(gtk.POLICY_AUTOMATIC,
gtk.POLICY_AUTOMATIC)
paned.add2(self.infosw)
self.infosw.show()
self.info = None
paned.set_position(150)
self.cmd = None
self.display(self.list, 0, -1, None)
hbox = gtk.HBox(FALSE, 5)
vbox.pack_start(hbox, expand=FALSE)
hbox.show()
entry = gtk.Entry()
hbox.pack_start(entry, expand=FALSE)
entry.show()
button = gtk.Button("Search by name")
button.connect("clicked", self.search_name, entry)
hbox.pack_start(button, expand=FALSE)
button.show()
button = gtk.Button("Search by blurb")
button.connect("clicked", self.search_blurb, entry)
hbox.pack_start(button, expand=FALSE)
button.show()
button = gtk.Button("Close")
button.connect("clicked", lambda btn, win: win.destroy(), self)
hbox.pack_end(button, expand=FALSE)
button.show()
if ok_button:
button = gtk.Button("OK")
button.connect("clicked", ok_button, self)
hbox.pack_end(button, expand=FALSE)
button.show()
self.set_default_size(500, 300)
def search_name(self, button, entry):
self.update_list(name=entry.get_text())
def search_blurb(self, button, entry):
self.update_list(blurb=entry.get_text())
def update_list(self, name='.*', blurb='.*'):
self.pdblist = pdb.query(name,blurb,'.*','.*','.*','.*','.*')
self.pdblist.sort()
self.list.clear()
for item in self.pdblist:
self.list.append([item])
def display(self, clist, row, column, event):
proc = pdb[clist.get_text(row, 0)]
self.info = gtk.Table(1, 5, FALSE);
row = 0
label = gtk.Label("Name:")
label.set_alignment(1.0, 0.5)
self.info.attach(label, 0,1, row,row+1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
label.show()
label = gtk.Entry()
label.set_text(proc.proc_name)
label.set_editable(FALSE)
self.info.attach(label, 1,4, row,row+1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
label.show()
row = row + 1
label = gtk.Label("Blurb:")
label.set_alignment(1.0, 0.5)
self.info.attach(label, 0,1, row,row+1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
label.show()
label = gtk.Label(proc.proc_blurb)
label.set_alignment(0.0, 0.5)
self.info.attach(label, 1,4, row,row+1,
yoptions=gtk.FILL)
label.show()
row = row + 1
label = gtk.Label("Copyright:")
label.set_alignment(1.0, 0.5)
self.info.attach(label, 0,1, row,row+1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
label.show()
label = gtk.Label(proc.proc_date+", "+proc.proc_copyright)
label.set_alignment(0.0, 0.5)
self.info.attach(label, 1,4, row,row+1,
yoptions=gtk.FILL)
label.show()
row = row + 1
label = gtk.Label("Author:")
label.set_alignment(1.0, 0.5)
self.info.attach(label, 0,1, row,row+1,
xoptions=gtk.FILL, yoptions=gtk.FILL)
label.show()
label = gtk.Label(proc.proc_author)
label.set_alignment(0.0, 0.5)
self.info.attach(label, 1,4, row,row+1,
yoptions=gtk.FILL)
label.show()
row = row + 1
hsep = gtk.HSeparator()
self.info.attach(hsep, 0,4, row,row+1,
yoptions=gtk.FILL)
hsep.show()
row = row + 1
if len(proc.params) > 0:
label = gtk.Label("In:")
label.set_alignment(1.0, 0.5)
self.info.attach(label, 0,1, row,row+len(proc.params),
xoptions=gtk.FILL, yoptions=gtk.FILL)
label.show()
for tp, name, desc in proc.params:
label = gtk.Label(name)
label.set_alignment(0.0, 0.5)
self.info.attach(label, 1,2, row,row+1,
xoptions=gtk.FILL,
yoptions=gtk.FILL)
label.show()
label = gtk.Label(partypes[tp])
label.set_alignment(0.0, 0.5)
self.info.attach(label, 2,3, row,row+1,
xoptions=gtk.FILL,
yoptions=gtk.FILL)
label.show()
label = gtk.Label(desc)
label.set_alignment(0.0, 0.5)
self.info.attach(label, 3,4, row,row+1,
yoptions=gtk.FILL)