def prompt_save(self, askname=True): if not self.changed: #print "not changed", self.fname return msg = "\nWould you like to save:\n\n \"%s\" \n" % self.fname rp = pedync.yes_no_cancel("pyedit: Save File ?", msg) if rp == gtk.RESPONSE_YES: if askname: self.file_dlg(rp) else: self.writefile() if rp == gtk.RESPONSE_NO: pass if rp == gtk.RESPONSE_CANCEL or \ rp == gtk.RESPONSE_REJECT or \ rp == gtk.RESPONSE_CLOSE or \ rp == gtk.RESPONSE_DELETE_EVENT: return True '''dialog = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, "\nWould you like to save:\n\n \"%s\" \n" % self.fname) dialog.set_title("Save file ?") dialog.set_default_response(gtk.RESPONSE_YES) dialog.connect("response", self.done_dlg, askname) dialog.run()''' ''' def done_dlg(self, win, resp, askname):
def prompt_save(self, askname=True): # Always save params self.saveparms() if not self.changed: #print "not changed", self.fname return msg = "\nWould you like to save:\n\n \"%s\" \n" % self.fname rp = pedync.yes_no_cancel("pyedit: Save File ?", msg) if rp == gtk.RESPONSE_YES: if askname: self.file_dlg(rp) else: self.save() elif rp == gtk.RESPONSE_NO: pass elif rp == gtk.RESPONSE_CANCEL: return True else: print "warning: invalid response from dialog"
def OnExit(arg, prompt=True): #print "onexit" arg.set_title("Exiting ...") # Save UI related data pos = mained.hpaned.get_position() pos = max(pos, 1) gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/hpaned", pos) firstpage = notebook.get_nth_page(0) if firstpage: pos = firstpage.get_position() pos = max(pos, 1) gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/vpaned", pos) # Do not save ful screen coordinates (when used F11) if not mained.full: xx, yy = mained.window.get_position() gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/xx", xx) gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/yy", yy) ww, hh = mained.window.get_size() gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/ww", ww) gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/hh", hh) # Save current doc: vcurr = notebook.get_nth_page(notebook.get_current_page()) if vcurr: gconf.client_get_default().set_string\ (pedconfig.conf.config_reg + "/curr",\ vcurr.area.fname) # Prompt for save files nn = notebook.get_n_pages() cnt = 0 while True: if cnt >= nn: break ppp = notebook.get_nth_page(cnt) #print "page:", ppp.area ppp.area.saveparms() ss = "/sess_%d" % cnt gconf.client_get_default().set_string\ (pedconfig.conf.config_reg + ss,\ ppp.area.fname) if prompt: if ppp.area.changed: msg = "\nWould you like to save:\n\n \"%s\" \n" % ppp.area.fname rp = pedync.yes_no_cancel("pyedit: Save File ?", msg) if rp == gtk.RESPONSE_YES: ppp.area.writefile() if rp == gtk.RESPONSE_NO: #print "gtk.RESPONSE_NO" pass if rp == gtk.RESPONSE_CANCEL or \ rp == gtk.RESPONSE_REJECT or \ rp == gtk.RESPONSE_CLOSE or \ rp == gtk.RESPONSE_DELETE_EVENT: return else: # Rescue to temporary: if ppp.area.changed: hhh = hash_name(ppp.area.fname) + ".txt" xfile = pedconfig.conf.config_dir + "/" + hhh writefile(xfile, ppp.area.text) cnt += 1 gconf.client_get_default().set_int\ (pedconfig.conf.config_reg + "/cnt",\ cnt) # Exit here gtk.main_quit()
def OnExit(arg, prompt=True): arg.set_title("Exiting ...") # Save UI related data pos = mained.hpaned.get_position() pos = max(pos, 1) pedconfig.conf.sql.put("hpaned", pos) vcurr = notebook.get_nth_page(notebook.get_current_page()) if vcurr: pos = vcurr.get_position() pos = max(pos, 1) pedconfig.conf.sql.put("vpaned", pos) # Do not save full screen coordinates (when used F11) #print mained.full if not mained.full: xx, yy = mained.window.get_position() pedconfig.conf.sql.put("xx", xx) pedconfig.conf.sql.put("yy", yy) ww, hh = mained.window.get_size() pedconfig.conf.sql.put("ww", ww) pedconfig.conf.sql.put("hh", hh) # Save current doc: vcurr = notebook.get_nth_page(notebook.get_current_page()) if vcurr: pedconfig.conf.sql.put("curr", vcurr.area.fname) # Prompt for save files nn = notebook.get_n_pages() cnt = 0 while True: if cnt >= nn: break ppp = notebook.get_nth_page(cnt) #print "page:", ppp.area ppp.area.saveparms() ss = "/sess_%d" % cnt if cnt < 30: pedconfig.conf.sql.put(ss, ppp.area.fname) if prompt: if ppp.area.changed: msg = "\nWould you like to save:\n\n \"%s\" \n" % ppp.area.fname rp = pedync.yes_no_cancel("pyedit: Save File ?", msg) if rp == gtk.RESPONSE_YES: ppp.area.save() if rp == gtk.RESPONSE_NO: #print "gtk.RESPONSE_NO" pass if rp == gtk.RESPONSE_CANCEL or \ rp == gtk.RESPONSE_REJECT or \ rp == gtk.RESPONSE_CLOSE or \ rp == gtk.RESPONSE_DELETE_EVENT: return else: # Rescue to temporary: if ppp.area.changed: hhh = hash_name(ppp.area.fname) + ".rescue" xfile = pedconfig.conf.config_dir + "/" + hhh if (pedconfig.conf.verbose): print "Rescuing", xfile writefile(xfile, ppp.area.text) # This way all the closing doc function gets called ppp.area.closedoc() cnt += 1 pedconfig.conf.sql.put("cnt", cnt) if (pedconfig.conf.verbose): print "Exiting" # Add to accounting: utils.timesheet("Ended pyedit", mained.start_time, time.time()) # Exit here gtk.main_quit()