* src/DbPrompter.py: 2.4 filechooser

* src/gramps_main.py:  2.4 filechooser
* src/ReadXML.py:  2.4 filechooser
* src/Pluginsd.py: tooltip deprecation fix


svn: r3118
This commit is contained in:
Don Allingham 2004-05-03 03:47:29 +00:00
parent 3cb7c304ed
commit 04e3e505fb
6 changed files with 127 additions and 132 deletions

View File

@ -1,3 +1,9 @@
2004-05-02 Don Allingham <donaldallingham@users.sourceforge.net>
* src/DbPrompter.py: 2.4 filechooser
* src/gramps_main.py: 2.4 filechooser
* src/ReadXML.py: 2.4 filechooser
* src/Pluginsd.py: tooltip deprecation fix
2004-05-01 Don Allingham <dona@localhost.localdomain> 2004-05-01 Don Allingham <dona@localhost.localdomain>
* src/gramps.glade: rearranged filter apply * src/gramps.glade: rearranged filter apply
* src/gramps.py: update to gtk.main() * src/gramps.py: update to gtk.main()

View File

@ -1,7 +1,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2003 Donald N. Allingham # Copyright (C) 2000-2004 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -27,7 +27,6 @@
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gtk import gtk
import gtk.glade import gtk.glade
import gnome
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -65,8 +64,8 @@ class DbPrompter:
opendb.signal_autoconnect({ opendb.signal_autoconnect({
"on_open_ok_clicked" : self.open_ok_clicked, "on_open_ok_clicked" : self.open_ok_clicked,
"on_open_help_clicked" : self.open_help_clicked, "on_open_help_clicked" : self.open_help_clicked,
"on_open_cancel_clicked" : self.open_cancel_clicked, "on_open_cancel_clicked" : gtk.main_quit,
"on_opendb_delete_event": self.open_delete_event, "on_opendb_delete_event": gtk.main_quit,
}) })
self.new = opendb.get_widget("new") self.new = opendb.get_widget("new")
@ -83,101 +82,57 @@ class DbPrompter:
def open_help_clicked(self,obj): def open_help_clicked(self,obj):
"""Display the GRAMPS manual""" """Display the GRAMPS manual"""
import gnome
gnome.help_display('gramps-manual','choose-db-start') gnome.help_display('gramps-manual','choose-db-start')
def save_as_activate(self): def save_as_activate(self):
if gtk.pygtk_version[1] >= 3: choose = gtk.FileChooserDialog('Create GRAMPS database',
choose = gtk.FileChooserDialog('Create GRAMPS database', None,
None, gtk.FILE_CHOOSER_ACTION_SAVE,
gtk.FILE_CHOOSER_ACTION_SAVE, (gtk.STOCK_CANCEL,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
gtk.RESPONSE_OK)) filter = gtk.FileFilter()
filter = gtk.FileFilter() filter.set_name(_('GRAMPS databases'))
filter.set_name(_('GRAMPS databases')) filter.add_pattern('*.grdb')
filter.add_pattern('*.grdb') choose.add_filter(filter)
choose.add_filter(filter)
filter = gtk.FileFilter()
filter = gtk.FileFilter() filter.set_name(_('All files'))
filter.set_name(_('All files')) filter.add_pattern('*')
filter.add_pattern('*') choose.add_filter(filter)
choose.add_filter(filter)
response = choose.run()
response = choose.run() if response == gtk.RESPONSE_OK:
if response == gtk.RESPONSE_OK: filename = choose.get_filename()
filename = choose.get_filename() self.db.read_file(filename)
self.db.read_file(filename) choose.destroy()
choose.destroy()
else:
wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
wFs.signal_autoconnect({
"on_ok_button1_clicked": self.save_ok_button_clicked,
"destroy_passed_object": self.cancel_button_clicked,
})
filesel = wFs.get_widget('fileselection')
filesel.set_title('%s - GRAMPS' % _('Create database'))
def save_ok_button_clicked(self,obj):
filename = obj.get_filename().encode('iso8859-1')
if filename:
if self.db.read_file(filename) == 1:
Utils.destroy_passed_object(obj)
def open_activate(self): def open_activate(self):
if gtk.pygtk_version[1] >= 3: choose = gtk.FileChooserDialog('Open GRAMPS database',
choose = gtk.FileChooserDialog('Open GRAMPS database', None,
None, gtk.FILE_CHOOSER_ACTION_OPEN,
gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL,
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN,
gtk.STOCK_OPEN, gtk.RESPONSE_OK))
gtk.RESPONSE_OK)) filter = gtk.FileFilter()
filter = gtk.FileFilter() filter.set_name(_('GRAMPS databases'))
filter.set_name(_('GRAMPS databases')) filter.add_pattern('*.grdb')
filter.add_pattern('*.grdb') choose.add_filter(filter)
choose.add_filter(filter)
filter = gtk.FileFilter()
filter.set_name(_('All files'))
filter.add_pattern('*')
choose.add_filter(filter)
if GrampsCfg.lastfile:
choose.set_filename(GrampsCfg.lastfile)
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = choose.get_filename()
self.db.read_file(filename)
choose.destroy()
else:
wFs = gtk.glade.XML (const.gladeFile, "fileselection","gramps")
wFs.signal_autoconnect({
"on_ok_button1_clicked": self.ok_button_clicked,
"destroy_passed_object": self.cancel_button_clicked,
})
self.filesel = wFs.get_widget('fileselection')
self.filesel.set_title('%s - GRAMPS' % _('Open database'))
if GrampsCfg.lastfile:
self.filesel.set_filename(GrampsCfg.lastfile)
return
def cancel_button_clicked(self,obj):
Utils.destroy_passed_object(obj)
self.show()
def ok_button_clicked(self,obj): filter = gtk.FileFilter()
filename = self.filesel.get_filename() filter.set_name(_('All files'))
filter.add_pattern('*')
if not filename: choose.add_filter(filter)
return
if self.db.read_file(filename) == 1: if GrampsCfg.lastfile:
Utils.destroy_passed_object(obj) choose.set_filename(GrampsCfg.lastfile)
def open_delete_event(self,obj,event): response = choose.run()
gtk.main_quit() if response == gtk.RESPONSE_OK:
filename = choose.get_filename()
def open_cancel_clicked(self,obj): self.db.read_file(filename)
gtk.main_quit() choose.destroy()

View File

@ -171,7 +171,7 @@ class PluginDialog:
self.apply_button.set_use_underline(gtk.TRUE) self.apply_button.set_use_underline(gtk.TRUE)
if tool_tip: if tool_tip:
try: try:
tt = gtk.gtk_tooltips_data_get(self.apply_button) tt = gtk.tooltips_data_get(self.apply_button)
if tt: if tt:
tt[0].set_tip(self.apply_button,tool_tip) tt[0].set_tip(self.apply_button,tool_tip)
except AttributeError: except AttributeError:

View File

@ -197,12 +197,29 @@ def importData(database, filename, callback,cl=0):
except: except:
pass pass
fs_top = gtk.FileSelection("%s - GRAMPS" % _("Select file")) choose = gtk.FileChooserDialog('Select file',
fs_top.hide_fileop_buttons() None,
fs_top.ok_button.connect('clicked',fs_ok_clicked) gtk.FILE_CHOOSER_ACTION_OPEN,
fs_top.cancel_button.connect('clicked',fs_close_window) (gtk.STOCK_CANCEL,
fs_top.run() gtk.RESPONSE_CANCEL,
fs_top.destroy() gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
filter = gtk.FileFilter()
filter.set_name(_('All files'))
filter.add_pattern('*')
choose.add_filter(filter)
response = choose.run()
if response == gtk.RESPONSE_OK:
name = fs_top.get_filename()
if os.path.isfile(name):
shutil.copyfile(name,newfile)
try:
shutil.copystat(name,newfile)
except:
pass
choose.destroy()
del parser del parser
return 1 return 1

View File

@ -1,7 +0,0 @@
#undef ENABLE_NLS
#undef HAVE_CATGETS
#undef HAVE_GETTEXT
#undef GETTEXT_PACKAGE
#undef HAVE_LC_MESSAGES
#undef HAVE_STPCPY
#undef HAVE_LIBSM

View File

@ -1114,25 +1114,28 @@ class Gramps:
pass pass
def select_clicked(): def select_clicked():
# File is lost => select a file to replace the lost one choose = gtk.FileChooserDialog('Open GRAMPS database',
def fs_close_window(obj): None,
fs_top.destroy() gtk.FILE_CHOOSER_ACTION_OPEN,
(gtk.STOCK_CANCEL,
def fs_ok_clicked(obj): gtk.RESPONSE_CANCEL,
name = fs_top.get_filename() gtk.STOCK_OPEN,
gtk.RESPONSE_OK))
filter = gtk.FileFilter()
filter.set_name(_('All files'))
filter.add_pattern('*')
choose.add_filter(filter)
response = choose.run()
if response == gtk.RESPONSE_OK:
name = choose.get_filename()
if os.path.isfile(name): if os.path.isfile(name):
RelImage.import_media_object(name,filename,base) RelImage.import_media_object(name,filename,base)
object = self.db.find_object_from_id(ObjectId) object = self.db.find_object_from_id(ObjectId)
object.set_path(newfile) object.set_path(newfile)
Utils.destroy_passed_object(fs_top) choose.destroy()
fs_top = gtk.FileSelection("%s - GRAMPS" % _("Select file"))
fs_top.hide_fileop_buttons()
fs_top.ok_button.connect('clicked',fs_ok_clicked)
fs_top.cancel_button.connect('clicked',fs_close_window)
fs_top.show()
fs_top.run()
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
for ObjectId in self.db.get_object_keys(): for ObjectId in self.db.get_object_keys():
object = self.db.find_object_from_id(ObjectId) object = self.db.find_object_from_id(ObjectId)
@ -1392,15 +1395,36 @@ class Gramps:
def on_open_activate(self,obj): def on_open_activate(self,obj):
top = gtk.glade.XML (const.gladeFile, "fileselection","gramps") choose = gtk.FileChooserDialog('Open GRAMPS database',
top.signal_autoconnect({ None,
"on_ok_button1_clicked": self.on_ok_button1_clicked, gtk.FILE_CHOOSER_ACTION_OPEN,
"destroy_passed_object": self.fs_close_window, (gtk.STOCK_CANCEL,
}) gtk.RESPONSE_CANCEL,
self.filesel = top.get_widget('fileselection') gtk.STOCK_OPEN,
if GrampsCfg.lastfile: gtk.RESPONSE_OK))
self.filesel.set_filename(GrampsCfg.lastfile)
filter = gtk.FileFilter()
filter.set_name(_('GRAMPS databases'))
filter.add_pattern('*.grdb')
choose.add_filter(filter)
filter = gtk.FileFilter()
filter.set_name(_('All files'))
filter.add_pattern('*')
choose.add_filter(filter)
if GrampsCfg.lastfile:
choose.set_filename(GrampsCfg.lastfile)
response = choose.run()
if response == gtk.RESPONSE_OK:
filename = choose.get_filename()
filename = os.path.normpath(os.path.abspath(filename))
self.clear_database()
if self.auto_save_load(filename) == 0:
DbPrompter.DbPrompter(self,0,self.topWindow)
choose.destroy()
def on_revert_activate(self,obj): def on_revert_activate(self,obj):
pass pass