* src/DbPrompter.py (DbPrompter): Use Combo to list multiple rcecent files

* src/gramps.glade: Use Combo to list multiple rcecent files


svn: r5381
This commit is contained in:
Martin Hawlisch 2005-11-09 11:26:22 +00:00
parent 246aa995a6
commit 666cc08475
3 changed files with 66 additions and 22 deletions

View File

@ -1,3 +1,7 @@
2005-11-09 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DbPrompter.py (DbPrompter): Use Combo to list multiple rcecent files
* src/gramps.glade: Use Combo to list multiple rcecent files
2005-11-08 Martin Hawlisch <Martin.Hawlisch@gmx.de> 2005-11-08 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* src/DbPrompter.py (DbPrompter): Give possibility to open * src/DbPrompter.py (DbPrompter): Give possibility to open
the recent file the recent file

View File

@ -96,28 +96,42 @@ class DbPrompter:
recent = opendb.get_widget("recent") recent = opendb.get_widget("recent")
existing = opendb.get_widget("existing") existing = opendb.get_widget("existing")
new = opendb.get_widget("new") new = opendb.get_widget("new")
filelist = opendb.get_widget("filelist")
# write in recent file # write in recent file into UI
gramps_rf = RecentFiles.GrampsRecentFiles() gramps_rf = RecentFiles.GrampsRecentFiles()
gramps_rf.gramps_recent_files.sort() gramps_rf.gramps_recent_files.sort()
gramps_rf.gramps_recent_files.reverse() gramps_rf.gramps_recent_files.reverse()
self.recent_files = []
if gramps_rf.gramps_recent_files: if gramps_rf.gramps_recent_files:
self.recent_file = gramps_rf.gramps_recent_files[0].get_path() # if recent files have been stored
cell = gtk.CellRendererText()
filelist.pack_start(cell,True)
filelist.add_attribute(cell,'text',0)
store = gtk.ListStore(str)
for item in gramps_rf.gramps_recent_files:
try: try:
self.recent_filetype = get_mime_type(self.recent_file) filename = os.path.basename(item.get_path())
filename = os.path.basename(self.recent_file).replace("_", "__") filetype = get_mime_type(item.get_path())
recent.set_label( _("_Recent file: %s") % filename) node = store.append()
store.set(node,0,unicode(filename))
self.recent_files.append( (item.get_path(), filetype))
except RuntimeError: except RuntimeError:
recent.set_sensitive(False) pass # ignore no longer existing files
self.recent_file = None if self.recent_files:
filelist.set_model(store)
filelist.set_active(0)
else: else:
recent.set_sensitive(False) recent.set_sensitive(False)
self.recent_file = None filelist.set_sensitive(False)
else:
recent.set_sensitive(False)
filelist.set_sensitive(False)
if want_new: if want_new:
new.set_active(True) new.set_active(True)
else: else:
if not self.recent_file: if not self.recent_files:
existing.set_active(True) existing.set_active(True)
while 1: while 1:
@ -127,13 +141,13 @@ class DbPrompter:
if response == gtk.RESPONSE_OK: if response == gtk.RESPONSE_OK:
if recent.get_active(): if recent.get_active():
try: try:
if open_native(self.parent,self.recent_file,self.recent_filetype): (filename,filetype) = self.recent_files[filelist.get_active()]
if open_native(self.parent,filename,filetype):
break break
except RuntimeError,msg: except RuntimeError,msg:
QuestionDialog.ErrorDialog( QuestionDialog.ErrorDialog(
_("Could not open file: %s") % self.recent_file, _("Could not open file: %s") % self.recent_file,
str(msg)) str(msg))
recent.set_sensitive(False)
continue continue
elif new.get_active(): elif new.get_active():
prompter = NewNativeDbPrompter(self.parent, prompter = NewNativeDbPrompter(self.parent,

View File

@ -5706,6 +5706,12 @@ Other</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkHBox" id="hbox107">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child> <child>
<widget class="GtkRadioButton" id="recent"> <widget class="GtkRadioButton" id="recent">
<property name="border_width">5</property> <property name="border_width">5</property>
@ -5726,6 +5732,26 @@ Other</property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkComboBox" id="filelist">
<property name="visible">True</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child> <child>
<widget class="GtkRadioButton" id="existing"> <widget class="GtkRadioButton" id="existing">
<property name="border_width">5</property> <property name="border_width">5</property>