1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2025-12-17 11:30:19 +01:00

* Change of behavoiur of standard filechooser dialogs. Now it would for

default open last location, where katalog file was written. If user
   changes location for some other file, then it stick to that
   directory.
This commit is contained in:
2008-05-08 16:57:28 +00:00
parent 3b95c6a16f
commit 29f1266f8d
2 changed files with 26 additions and 7 deletions

View File

@@ -616,7 +616,11 @@ class MainController(Controller):
def on_save_as_activate(self, widget): def on_save_as_activate(self, widget):
"""Save database to file under different filename.""" """Save database to file under different filename."""
path = Dialogs.ChooseDBFilename().run() initial_path = None
if self.model.config.recent[0]:
initial_path = os.path.dirname(self.model.config.recent[0])
path = Dialogs.ChooseDBFilename(initial_path).run()
if path: if path:
ret, err = self.model.save(path) ret, err = self.model.save(path)
if ret: if ret:
@@ -651,8 +655,12 @@ class MainController(Controller):
if not obj.run(): if not obj.run():
return return
initial_path = None
if self.model.config.recent[0]:
initial_path = os.path.dirname(self.model.config.recent[0])
if not path: if not path:
path = Dialogs.LoadDBFile().run() path = Dialogs.LoadDBFile(initial_path).run()
# cleanup files and details # cleanup files and details
try: try:

View File

@@ -260,9 +260,10 @@ class SelectDirectory(object):
class ChooseDBFilename(object): class ChooseDBFilename(object):
"""Sepcific dialog for quering user for selecting filename for database""" """Sepcific dialog for quering user for selecting filename for database"""
URI="file://"+os.path.abspath(os.path.curdir) URI=None
def __init__(self): def __init__(self, path=None):
self.path = path
self.dialog = gtk.FileChooserDialog( self.dialog = gtk.FileChooserDialog(
title="Save catalog as...", title="Save catalog as...",
action=gtk.FILE_CHOOSER_ACTION_SAVE, action=gtk.FILE_CHOOSER_ACTION_SAVE,
@@ -289,6 +290,10 @@ class ChooseDBFilename(object):
def run(self): def run(self):
if self.URI: if self.URI:
self.dialog.set_current_folder_uri(self.URI) self.dialog.set_current_folder_uri(self.URI)
elif self.path and os.path.exists(self.path):
self.path = "file://"+os.path.abspath(self.path)
self.dialog.set_current_folder_uri(self.path)
response = self.dialog.run() response = self.dialog.run()
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
filename = self.dialog.get_filename() filename = self.dialog.get_filename()
@@ -311,9 +316,11 @@ class LoadDBFile(object):
"""Specific class for displaying openFile dialog. It has veryfication """Specific class for displaying openFile dialog. It has veryfication
for file existence.""" for file existence."""
URI="file://"+os.path.abspath(os.path.curdir) URI=None
def __init__(self): def __init__(self, path=None):
self.path = path
self.dialog = gtk.FileChooserDialog( self.dialog = gtk.FileChooserDialog(
title="Open catalog", title="Open catalog",
action=gtk.FILE_CHOOSER_ACTION_OPEN, action=gtk.FILE_CHOOSER_ACTION_OPEN,
@@ -324,7 +331,7 @@ class LoadDBFile(object):
gtk.RESPONSE_OK)) gtk.RESPONSE_OK))
self.dialog.set_default_response(gtk.RESPONSE_OK) self.dialog.set_default_response(gtk.RESPONSE_OK)
f = gtk.FileFilter() f = gtk.FileFilter()
f.set_name("Catalog files") f.set_name("Catalog files")
f.add_pattern("*.pgt") f.add_pattern("*.pgt")
@@ -350,6 +357,10 @@ class LoadDBFile(object):
def run(self): def run(self):
if self.URI: if self.URI:
self.dialog.set_current_folder_uri(self.URI) self.dialog.set_current_folder_uri(self.URI)
elif self.path and os.path.exists(self.path):
self.path = "file://"+os.path.abspath(self.path)
self.dialog.set_current_folder_uri(self.path)
res,filename = self.show_dialog() res,filename = self.show_dialog()
ch = True ch = True
while ch: while ch: