* 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
try: cell = gtk.CellRendererText()
self.recent_filetype = get_mime_type(self.recent_file) filelist.pack_start(cell,True)
filename = os.path.basename(self.recent_file).replace("_", "__") filelist.add_attribute(cell,'text',0)
recent.set_label( _("_Recent file: %s") % filename) store = gtk.ListStore(str)
except RuntimeError: for item in gramps_rf.gramps_recent_files:
try:
filename = os.path.basename(item.get_path())
filetype = get_mime_type(item.get_path())
node = store.append()
store.set(node,0,unicode(filename))
self.recent_files.append( (item.get_path(), filetype))
except RuntimeError:
pass # ignore no longer existing files
if self.recent_files:
filelist.set_model(store)
filelist.set_active(0)
else:
recent.set_sensitive(False) recent.set_sensitive(False)
self.recent_file = None filelist.set_sensitive(False)
else: else:
recent.set_sensitive(False) recent.set_sensitive(False)
self.recent_file = None 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

@ -5707,17 +5707,43 @@ Other</property>
</child> </child>
<child> <child>
<widget class="GtkRadioButton" id="recent"> <widget class="GtkHBox" id="hbox107">
<property name="border_width">5</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="homogeneous">False</property>
<property name="label" translatable="yes">Open recent file: </property> <property name="spacing">0</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property> <child>
<property name="focus_on_click">True</property> <widget class="GtkRadioButton" id="recent">
<property name="active">False</property> <property name="border_width">5</property>
<property name="inconsistent">False</property> <property name="visible">True</property>
<property name="draw_indicator">True</property> <property name="can_focus">True</property>
<property name="label" translatable="yes">Open recent file: </property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</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> </widget>
<packing> <packing>
<property name="padding">0</property> <property name="padding">0</property>