Skip to content

Commit

Permalink
store recently-opened documents
Browse files Browse the repository at this point in the history
  • Loading branch information
enkiv2 committed Nov 28, 2017
1 parent a7f36e5 commit 2496a78
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions mtv/mtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@

import cStringIO

global clipboard, url2hash, odl
global clipboard, url2hash, odl, recentDocs
clipboard=None
url2hash={}
windows=[]
odl=[]
recentDocs=[]

def genHLColor(obj):
gen=Random(obj)
Expand Down Expand Up @@ -96,12 +97,16 @@ def concatext2str(concatext):
return "".join(concatext)

def spawnTranslitEditor(edl):
global url2hash
global url2hash, recentDocs
for item in windows:
if(edl in [item.ed.currentEDLHash, item.ed.path]):
item.master.master.deiconify()
item.lift()
return item
if edl in recentDocs:
recentDocs.remove(edl)
recentDocs.push(edl)

top=TranslitEditorFrame(Toplevel())
top.pack()
windows.append(top)
Expand All @@ -112,6 +117,7 @@ def spawnTranslitEditor(edl):
top.title()
top.ed.addLinks(odl)
json.dump(url2hash, open("url2hash.json", "w"))
json.dump(recentDocs, open("recent.json", "w"))
return top

def addLinksToODL(links):
Expand Down Expand Up @@ -426,12 +432,14 @@ def title(self, *args):
self.master.wm_title(str(self.ed.path)+" ("+str(self.ed.currentEDLHash)+") - mtv")

def main():
global url2hash
global url2hash, recentDocs
try:
url2hash=json.load(open("url2hash.json", "r"))
recentDocs=json.load(open("recent.json", "r"))
except Exception as e:
print(e)
json.dump(url2hash, open("url2hash.json", "w"))
json.dump(recentDocs, open("recent.json", "w"))
tk=Tk()
top=TranslitEditorFrame(tk)
top.pack()
Expand Down

0 comments on commit 2496a78

Please sign in to comment.