* save state between invocations * update ChangeLog
This commit is contained in:
parent
1e5b131e7d
commit
6e3931983a
2 changed files with 24 additions and 6 deletions
|
@ -1,7 +1,8 @@
|
||||||
2008-01-05 Jan Dittberner <jan@dittberner.info>
|
2008-01-05 Jan Dittberner <jan@dittberner.info>
|
||||||
|
|
||||||
* btn4ws.py: switch to non gimpfu gimpplugin, GtkAssistant GUI,
|
* 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>
|
2007-12-04 Jan Dittberner <jan@dittberner.info>
|
||||||
|
|
||||||
|
|
25
btn4ws.py
25
btn4ws.py
|
@ -29,7 +29,7 @@ port of the older gimp-perl version to python.
|
||||||
|
|
||||||
(c) 2007, 2008 Jan Dittberner <jan@dittberner.info>
|
(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 gimp, gimpplugin, gimpui, gimpcolor
|
||||||
import pygtk
|
import pygtk
|
||||||
pygtk.require('2.0')
|
pygtk.require('2.0')
|
||||||
|
@ -780,6 +780,7 @@ class btn4wsplugin(gimpplugin.plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.data = {}
|
self.data = {}
|
||||||
self.inputdata = {}
|
self.inputdata = {}
|
||||||
|
self.datafile = os.path.join(gimp.directory, "btn4wsrc")
|
||||||
|
|
||||||
def checkdata(self, data):
|
def checkdata(self, data):
|
||||||
logging.debug("checkdata " + str(data))
|
logging.debug("checkdata " + str(data))
|
||||||
|
@ -1033,11 +1034,27 @@ class btn4wsplugin(gimpplugin.plugin):
|
||||||
logging.debug("destroy")
|
logging.debug("destroy")
|
||||||
gtk.main_quit()
|
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):
|
def _cb_apply(self, widget):
|
||||||
self.data = widget.data
|
self.data = widget.data
|
||||||
logging.debug(str(self.data))
|
logging.debug(str(self.data))
|
||||||
if self.checkdata(self.data):
|
if self.checkdata(self.data):
|
||||||
self.makebuttons(**self.data)
|
self.makebuttons(**self.data)
|
||||||
|
shelf["btn4ws"] = self.data
|
||||||
|
self._storedata(self.data)
|
||||||
else:
|
else:
|
||||||
logging.error("checking data failed")
|
logging.error("checking data failed")
|
||||||
|
|
||||||
|
@ -1066,11 +1083,11 @@ class btn4wsplugin(gimpplugin.plugin):
|
||||||
"makeinactive" : makeinactive, "makeactive" : makeactive,
|
"makeinactive" : makeinactive, "makeactive" : makeactive,
|
||||||
"makepressed" : makepressed, "makejscript" : makejscript
|
"makepressed" : makepressed, "makejscript" : makejscript
|
||||||
}
|
}
|
||||||
if runmode == RUN_WITH_LAST_VALS:
|
if runmode in (RUN_INTERACTIVE, RUN_WITH_LAST_VALS):
|
||||||
logging.debug("runmode with last vals")
|
|
||||||
if shelf.has_key("btn4ws"):
|
if shelf.has_key("btn4ws"):
|
||||||
self.inputdata = shelf["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 = Btn4wsDialog(self.inputdata)
|
||||||
dialog.connect("close", self._cb_destroy)
|
dialog.connect("close", self._cb_destroy)
|
||||||
dialog.connect("cancel", self._cb_destroy)
|
dialog.connect("cancel", self._cb_destroy)
|
||||||
|
|
Loading…
Reference in a new issue