From 7247924240c0e01c1d5a62af3812998db4214c32 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Mon, 18 Feb 2008 19:16:26 +0000 Subject: [PATCH] implement "open" menu item --- tools/cleanroom/cleanroom.glade | 4 ++-- tools/cleanroom/tmp_cleanui.py | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/tools/cleanroom/cleanroom.glade b/tools/cleanroom/cleanroom.glade index a37473a1..ffc5bc5b 100644 --- a/tools/cleanroom/cleanroom.glade +++ b/tools/cleanroom/cleanroom.glade @@ -1,6 +1,6 @@ - + True @@ -33,7 +33,7 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK gtk-open diff --git a/tools/cleanroom/tmp_cleanui.py b/tools/cleanroom/tmp_cleanui.py index f67f2afe..130e2018 100644 --- a/tools/cleanroom/tmp_cleanui.py +++ b/tools/cleanroom/tmp_cleanui.py @@ -291,6 +291,7 @@ class HellowWorldGTK: self.wTree.get_widget("quit_menu_item").connect("activate", gtk.main_quit) self.wTree.get_widget("saveas_menu_item").connect("activate", self.saveas_activated) self.wTree.get_widget("save_menu_item").connect("activate", self.save_activated) + self.wTree.get_widget("open_menu_item").connect("activate", self.open_activated) # select the top-most texture lhs.set_cursor( (0,) , None, False) @@ -311,6 +312,30 @@ class HellowWorldGTK: writetome.write("".join(map(str,self.wip_textures.values()))) writetome.close() + def open_activated(self,arg): + filesel = \ + gtk.FileChooserDialog(action=gtk.FILE_CHOOSER_ACTION_OPEN, + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, + gtk.STOCK_OPEN, gtk.RESPONSE_OK)) + if filesel.run() == gtk.RESPONSE_OK: + self.filename = filesel.get_filename() + filesel.destroy() + print self.filename + + texture1 = file(self.filename, "r").read() + self.wip_textures = {} + current = None + for line in texture1.split("\n"): + if len(line) == 0 or line[0] == ";" or line[0] == "#": + continue + elif line[0] == "*" and current: + junk,name,y,x= line.split() + current.patches.append(Patch(name,int(x),int(y))) + else: + line = line.split() + current = Texture(line[0],line[1],line[2]) + self.wip_textures[line[0]] = current + if __name__ == "__main__": hwg = HellowWorldGTK() gtk.main()