* src/DbPrompter.py: handle open dialog in a clean manner
* src/gramps.py: handle open dialog in a clean manner * src/gramps_main.py: handle open dialog in a clean manner * src/gramps.glade: handle open dialog in a clean manner svn: r3143
This commit is contained in:
parent
15ccb443a0
commit
2d5e249839
@ -1,3 +1,9 @@
|
|||||||
|
2004-05-07 Don Allingham <donaldallingham@users.sourceforge.net>
|
||||||
|
* src/DbPrompter.py: handle open dialog in a clean manner
|
||||||
|
* src/gramps.py: handle open dialog in a clean manner
|
||||||
|
* src/gramps_main.py: handle open dialog in a clean manner
|
||||||
|
* src/gramps.glade: handle open dialog in a clean manner
|
||||||
|
|
||||||
2004-05-07 Alex Roitman <shura@alex.neuro.umn.edu>
|
2004-05-07 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/plugins/soundgen.py: Convert to db.
|
* src/plugins/soundgen.py: Convert to db.
|
||||||
* src/plugins/GraphViz.py: Typo.
|
* src/plugins/GraphViz.py: Typo.
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gtk
|
import gtk
|
||||||
import gtk.glade
|
import gtk.glade
|
||||||
|
import gobject
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -36,6 +37,8 @@ import gtk.glade
|
|||||||
import Utils
|
import Utils
|
||||||
import const
|
import const
|
||||||
import GrampsCfg
|
import GrampsCfg
|
||||||
|
import gnome
|
||||||
|
import QuestionDialog
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -48,44 +51,36 @@ class DbPrompter:
|
|||||||
|
|
||||||
def __init__(self,db,want_new,parent=None):
|
def __init__(self,db,want_new,parent=None):
|
||||||
self.db = db
|
self.db = db
|
||||||
self.want_new = want_new
|
|
||||||
self.parent = parent
|
|
||||||
self.show()
|
|
||||||
|
|
||||||
def show(self):
|
|
||||||
opendb = gtk.glade.XML(const.gladeFile, "opendb","gramps")
|
opendb = gtk.glade.XML(const.gladeFile, "opendb","gramps")
|
||||||
top = opendb.get_widget('opendb')
|
top = opendb.get_widget('opendb')
|
||||||
if self.parent:
|
if parent:
|
||||||
top.set_transient_for(self.parent)
|
top.set_transient_for(parent)
|
||||||
title = opendb.get_widget('title')
|
title = opendb.get_widget('title')
|
||||||
|
|
||||||
Utils.set_titles(top,title,_('Open a database'))
|
Utils.set_titles(top,title,_('Open a database'))
|
||||||
|
|
||||||
opendb.signal_autoconnect({
|
new = opendb.get_widget("new")
|
||||||
"on_open_ok_clicked" : self.open_ok_clicked,
|
new.set_active(want_new)
|
||||||
"on_open_help_clicked" : self.open_help_clicked,
|
|
||||||
"on_open_cancel_clicked" : gtk.main_quit,
|
|
||||||
"on_opendb_delete_event": gtk.main_quit,
|
|
||||||
})
|
|
||||||
|
|
||||||
self.new = opendb.get_widget("new")
|
while 1:
|
||||||
if self.want_new:
|
response = top.run()
|
||||||
self.new.set_active(1)
|
if response == gtk.RESPONSE_OK:
|
||||||
|
if self.chooser(new.get_active()):
|
||||||
def open_ok_clicked(self,obj):
|
break
|
||||||
if self.new.get_active():
|
elif response == gtk.RESPONSE_CANCEL:
|
||||||
self.db.clear_database()
|
break
|
||||||
self.save_as_activate()
|
elif response == gtk.RESPONSE_HELP:
|
||||||
else:
|
try:
|
||||||
self.open_activate()
|
|
||||||
Utils.destroy_passed_object(obj)
|
|
||||||
|
|
||||||
def open_help_clicked(self,obj):
|
|
||||||
"""Display the GRAMPS manual"""
|
|
||||||
import gnome
|
|
||||||
gnome.help_display('gramps-manual','choose-db-start')
|
gnome.help_display('gramps-manual','choose-db-start')
|
||||||
|
except gobject.GError,msg:
|
||||||
|
QuestionDialog.ErrorDialog(_('Help not available'),msg)
|
||||||
|
|
||||||
def save_as_activate(self):
|
top.destroy()
|
||||||
|
if response == gtk.RESPONSE_CANCEL:
|
||||||
|
gtk.main_quit()
|
||||||
|
|
||||||
|
def chooser(self,save):
|
||||||
|
if save:
|
||||||
choose = gtk.FileChooserDialog('Create GRAMPS database',
|
choose = gtk.FileChooserDialog('Create GRAMPS database',
|
||||||
None,
|
None,
|
||||||
gtk.FILE_CHOOSER_ACTION_SAVE,
|
gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||||
@ -93,23 +88,8 @@ class DbPrompter:
|
|||||||
gtk.RESPONSE_CANCEL,
|
gtk.RESPONSE_CANCEL,
|
||||||
gtk.STOCK_OPEN,
|
gtk.STOCK_OPEN,
|
||||||
gtk.RESPONSE_OK))
|
gtk.RESPONSE_OK))
|
||||||
filter = gtk.FileFilter()
|
self.db.clear_database()
|
||||||
filter.set_name(_('GRAMPS databases'))
|
else:
|
||||||
filter.add_pattern('*.grdb')
|
|
||||||
choose.add_filter(filter)
|
|
||||||
|
|
||||||
filter = gtk.FileFilter()
|
|
||||||
filter.set_name(_('All files'))
|
|
||||||
filter.add_pattern('*')
|
|
||||||
choose.add_filter(filter)
|
|
||||||
|
|
||||||
response = choose.run()
|
|
||||||
if response == gtk.RESPONSE_OK:
|
|
||||||
filename = choose.get_filename()
|
|
||||||
self.db.read_file(filename)
|
|
||||||
choose.destroy()
|
|
||||||
|
|
||||||
def open_activate(self):
|
|
||||||
choose = gtk.FileChooserDialog('Open GRAMPS database',
|
choose = gtk.FileChooserDialog('Open GRAMPS database',
|
||||||
None,
|
None,
|
||||||
gtk.FILE_CHOOSER_ACTION_OPEN,
|
gtk.FILE_CHOOSER_ACTION_OPEN,
|
||||||
@ -117,6 +97,7 @@ class DbPrompter:
|
|||||||
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')
|
||||||
@ -127,7 +108,7 @@ class DbPrompter:
|
|||||||
filter.add_pattern('*')
|
filter.add_pattern('*')
|
||||||
choose.add_filter(filter)
|
choose.add_filter(filter)
|
||||||
|
|
||||||
if GrampsCfg.lastfile:
|
if save and GrampsCfg.lastfile:
|
||||||
choose.set_filename(GrampsCfg.lastfile)
|
choose.set_filename(GrampsCfg.lastfile)
|
||||||
|
|
||||||
response = choose.run()
|
response = choose.run()
|
||||||
@ -135,4 +116,8 @@ class DbPrompter:
|
|||||||
filename = choose.get_filename()
|
filename = choose.get_filename()
|
||||||
self.db.read_file(filename)
|
self.db.read_file(filename)
|
||||||
choose.destroy()
|
choose.destroy()
|
||||||
|
return 1
|
||||||
|
else:
|
||||||
|
choose.destroy()
|
||||||
|
return 0
|
||||||
|
|
||||||
|
@ -6589,7 +6589,7 @@
|
|||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">-6</property>
|
||||||
<signal name="clicked" handler="on_open_cancel_clicked" object="opendb"/>
|
<signal name="clicked" handler="on_open_cancel_clicked" object="opendb"/>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
@ -6604,7 +6604,7 @@
|
|||||||
<property name="use_stock">True</property>
|
<property name="use_stock">True</property>
|
||||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||||
<property name="focus_on_click">True</property>
|
<property name="focus_on_click">True</property>
|
||||||
<property name="response_id">0</property>
|
<property name="response_id">-5</property>
|
||||||
<signal name="clicked" handler="on_open_ok_clicked" object="opendb"/>
|
<signal name="clicked" handler="on_open_ok_clicked" object="opendb"/>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
@ -78,20 +78,23 @@ gettext.install("gramps",loc,unicode=1)
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import gramps_main
|
import gramps_main
|
||||||
|
import gobject
|
||||||
|
|
||||||
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
|
||||||
|
|
||||||
args = sys.argv[1:]
|
args = sys.argv[1:]
|
||||||
|
|
||||||
try:
|
def run():
|
||||||
|
try:
|
||||||
import StartupDialog
|
import StartupDialog
|
||||||
|
|
||||||
if StartupDialog.need_to_run():
|
if StartupDialog.need_to_run():
|
||||||
StartupDialog.StartupDialog(gramps_main.Gramps,args)
|
StartupDialog.StartupDialog(gramps_main.Gramps,args)
|
||||||
else:
|
else:
|
||||||
gramps_main.Gramps(args)
|
gramps_main.Gramps(args)
|
||||||
except:
|
except:
|
||||||
import DisplayTrace
|
import DisplayTrace
|
||||||
DisplayTrace.DisplayTrace()
|
DisplayTrace.DisplayTrace()
|
||||||
|
|
||||||
|
gobject.timeout_add(100, run, priority=100)
|
||||||
gtk.main()
|
gtk.main()
|
||||||
|
@ -59,9 +59,6 @@ import FamilyView
|
|||||||
import SourceView
|
import SourceView
|
||||||
import PeopleView
|
import PeopleView
|
||||||
import GenericFilter
|
import GenericFilter
|
||||||
|
|
||||||
from QuestionDialog import *
|
|
||||||
|
|
||||||
import DisplayTrace
|
import DisplayTrace
|
||||||
import const
|
import const
|
||||||
import Plugins
|
import Plugins
|
||||||
@ -72,6 +69,8 @@ import EditPerson
|
|||||||
import Find
|
import Find
|
||||||
import DbPrompter
|
import DbPrompter
|
||||||
|
|
||||||
|
from QuestionDialog import *
|
||||||
|
|
||||||
try: # First try python2.3 and later: this is the future
|
try: # First try python2.3 and later: this is the future
|
||||||
from bsddb import db
|
from bsddb import db
|
||||||
except ImportError: # try python2.2
|
except ImportError: # try python2.2
|
||||||
@ -894,7 +893,6 @@ class Gramps:
|
|||||||
self.new_database_response,self.topWindow)
|
self.new_database_response,self.topWindow)
|
||||||
|
|
||||||
def new_database_response(self):
|
def new_database_response(self):
|
||||||
import DbPrompter
|
|
||||||
DbPrompter.DbPrompter(self,1,self.topWindow)
|
DbPrompter.DbPrompter(self,1,self.topWindow)
|
||||||
|
|
||||||
def clear_database(self):
|
def clear_database(self):
|
||||||
@ -1175,7 +1173,6 @@ class Gramps:
|
|||||||
|
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
if not os.path.isdir(filename):
|
if not os.path.isdir(filename):
|
||||||
import DbPrompter
|
|
||||||
DbPrompter.DbPrompter(self,0,self.topWindow)
|
DbPrompter.DbPrompter(self,0,self.topWindow)
|
||||||
self.displayError(_("Database could not be opened"),
|
self.displayError(_("Database could not be opened"),
|
||||||
_("%s is not a directory.") % filename + ' ' + \
|
_("%s is not a directory.") % filename + ' ' + \
|
||||||
|
Loading…
Reference in New Issue
Block a user