fixes #7, fixes #12

* save state between invocations
 * update ChangeLog
This commit is contained in:
Jan Dittberner 2008-01-05 22:19:03 +00:00
parent 1e5b131e7d
commit 6e3931983a
2 changed files with 24 additions and 6 deletions

View file

@ -1,7 +1,8 @@
2008-01-05 Jan Dittberner <jan@dittberner.info>
* btn4ws.py: switch to non gimpfu gimpplugin, GtkAssistant GUI,
get interactive functionallity completed
get interactive functionallity completed, store settings in
btn4wsrc
2007-12-04 Jan Dittberner <jan@dittberner.info>

View file

@ -29,7 +29,7 @@ port of the older gimp-perl version to python.
(c) 2007, 2008 Jan Dittberner <jan@dittberner.info>
"""
import os, urllib, logging, sys
import os, urllib, logging, sys, pickle
import gimp, gimpplugin, gimpui, gimpcolor
import pygtk
pygtk.require('2.0')
@ -780,6 +780,7 @@ class btn4wsplugin(gimpplugin.plugin):
def __init__(self):
self.data = {}
self.inputdata = {}
self.datafile = os.path.join(gimp.directory, "btn4wsrc")
def checkdata(self, data):
logging.debug("checkdata " + str(data))
@ -1033,11 +1034,27 @@ class btn4wsplugin(gimpplugin.plugin):
logging.debug("destroy")
gtk.main_quit()
def _loaddata(self, data):
try:
if os.path.exists(self.datafile):
return pickle.load(open(self.datafile))
except OSError, e:
pass
return data
def _storedata(self, data):
try:
pickle.dump(data, open(self.datafile, 'w'))
except OSError, e:
pass
def _cb_apply(self, widget):
self.data = widget.data
logging.debug(str(self.data))
if self.checkdata(self.data):
if self.checkdata(self.data):
self.makebuttons(**self.data)
shelf["btn4ws"] = self.data
self._storedata(self.data)
else:
logging.error("checking data failed")
@ -1066,11 +1083,11 @@ class btn4wsplugin(gimpplugin.plugin):
"makeinactive" : makeinactive, "makeactive" : makeactive,
"makepressed" : makepressed, "makejscript" : makejscript
}
if runmode == RUN_WITH_LAST_VALS:
logging.debug("runmode with last vals")
if runmode in (RUN_INTERACTIVE, RUN_WITH_LAST_VALS):
if shelf.has_key("btn4ws"):
self.inputdata = shelf["btn4ws"]
if runmode in (RUN_INTERACTIVE, RUN_WITH_LAST_VALS):
else:
self.inputdata = self._loaddata(self.inputdata)
dialog = Btn4wsDialog(self.inputdata)
dialog.connect("close", self._cb_destroy)
dialog.connect("cancel", self._cb_destroy)