Removal of GnomeQuestionDialogs

svn: r943
This commit is contained in:
Don Allingham 2002-04-25 04:36:16 +00:00
parent 279b84e68a
commit 0713907c68
11 changed files with 124 additions and 93 deletions

View File

@ -32,7 +32,7 @@ import pickle
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import gtk import gtk
from gnome.ui import GnomeErrorDialog, GnomeWarningDialog, GnomeQuestionDialog from gnome.ui import GnomeErrorDialog, GnomeWarningDialog
import libglade import libglade
import GdkImlib import GdkImlib
from GDK import ACTION_COPY, BUTTON1_MASK, _2BUTTON_PRESS from GDK import ACTION_COPY, BUTTON1_MASK, _2BUTTON_PRESS
@ -51,6 +51,7 @@ import ImageSelect
import sort import sort
import AutoComp import AutoComp
from DateEdit import DateEdit from DateEdit import DateEdit
from QuestionDialog import QuestionDialog
from intl import gettext from intl import gettext
_ = gettext _ = gettext
@ -735,8 +736,11 @@ class EditPerson:
"""If the data has changed, give the user a chance to cancel """If the data has changed, give the user a chance to cancel
the close window""" the close window"""
if self.did_data_change(): if self.did_data_change():
q = _("Are you sure you want to abandon your changes?") QuestionDialog(_('Abandon Changes'),
GnomeQuestionDialog(q,self.cancel_callback) _("Are you sure you want to abandon your changes?"),
_("Abandon Changes"),
self.cancel_callback,
_("Continue Editing"))
else: else:
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
@ -744,17 +748,19 @@ class EditPerson:
"""If the data has changed, give the user a chance to cancel """If the data has changed, give the user a chance to cancel
the close window""" the close window"""
if self.did_data_change(): if self.did_data_change():
q = _("Are you sure you want to abandon your changes?") QuestionDialog(_('Abandon Changes'),
GnomeQuestionDialog(q,self.cancel_callback) _("Are you sure you want to abandon your changes?"),
_("Abandon Changes"),
self.cancel_callback,
_("Continue Editing"))
return 1 return 1
else: else:
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
return 0 return 0
def cancel_callback(self,a): def cancel_callback(self):
"""If the user answered yes to abandoning changes, close the window""" """If the user answered yes to abandoning changes, close the window"""
if a==0: Utils.destroy_passed_object(self.window)
Utils.destroy_passed_object(self.window)
def did_data_change(self): def did_data_change(self):
"""Check to see if any of the data has changed from the """Check to see if any of the data has changed from the
@ -1561,3 +1567,4 @@ def reorder_child_list(person, list):
list.remove(person) list.remove(person)
list.insert(target,person) list.insert(target,person)
return list return list

View File

@ -399,9 +399,7 @@ class DeletePlaceQuery:
self.place = place self.place = place
self.update = update self.update = update
def query_response(self,ans): def query_response(self):
if ans == 1:
return
del self.db.getPlaceMap()[self.place.getId()] del self.db.getPlaceMap()[self.place.getId()]
Utils.modified() Utils.modified()

View File

@ -231,7 +231,7 @@ class DelSrcQuery:
if m: if m:
object.setSourceRefList(l) object.setSourceRefList(l)
def query_response(self,ans): def query_response(self):
if ans == 1: if ans == 1:
return return
del self.db.getSourceMap()[self.source.getId()] del self.db.getSourceMap()[self.source.getId()]

View File

@ -774,9 +774,7 @@ class DeleteMediaQuery:
self.media = media self.media = media
self.update = update self.update = update
def query_response(self,ans): def query_response(self):
if ans == 1:
return
del self.db.getObjectMap()[self.media.getId()] del self.db.getObjectMap()[self.media.getId()]
Utils.modified() Utils.modified()

View File

@ -40,6 +40,7 @@ import const
import GrampsCfg import GrampsCfg
import Utils import Utils
import AutoComp import AutoComp
from QuestionDialog import QuestionDialog
from RelLib import * from RelLib import *
import ImageSelect import ImageSelect
from intl import gettext from intl import gettext
@ -339,13 +340,19 @@ class Marriage:
return changed return changed
def cancel_callback(self):
Utils.destroy_passed_object(self.quit)
def on_cancel_edit(self,obj): def on_cancel_edit(self,obj):
if self.did_data_change(): if self.did_data_change():
global quit global quit
q = _("Data was modified. Are you sure you want to abandon your changes?") self.quit = obj
quit = obj QuestionDialog(_('Abandon Changes'),
GnomeQuestionDialog(q,cancel_callback) _("Data was modified. Are you sure you "
"want to abandon your changes?"),
_('Abandon Changes'),self.cancel_callback,
_('Continue Editing'))
else: else:
Utils.destroy_passed_object(obj) Utils.destroy_passed_object(obj)
@ -521,14 +528,5 @@ def disp_event(event):
return [const.display_fevent(event.getName()), event.getQuoteDate(), return [const.display_fevent(event.getName()), event.getQuoteDate(),
event.getPlaceName(), Utils.get_detail_flags(event)] event.getPlaceName(), Utils.get_detail_flags(event)]
#-------------------------------------------------------------------------
#
#
#
#-------------------------------------------------------------------------
def cancel_callback(a):
if a==0:
Utils.destroy_passed_object(quit)
def src_changed(parent): def src_changed(parent):
parent.lists_changed = 1 parent.lists_changed = 1

View File

@ -26,6 +26,7 @@ import string
import ImageSelect import ImageSelect
from RelLib import * from RelLib import *
from QuestionDialog import QuestionDialog
import Utils import Utils
import os import os
import GrampsCfg import GrampsCfg
@ -267,8 +268,11 @@ class MediaView:
mobj = self.media_list.get_row_data(index) mobj = self.media_list.get_row_data(index)
if self.is_media_object_used(mobj): if self.is_media_object_used(mobj):
ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.update) ans = ImageSelect.DeleteMediaQuery(mobj,self.db,self.update)
msg = _("This media object is currently being used. Delete anyway?") QuestionDialog(_('Delete Object'),
gnome.ui.GnomeQuestionDialog(msg,ans.query_response) _("This media object is currently being used. "
"Delete anyway?"),
_('Delete Object'),ans.query_response,
_('Keep Object'))
else: else:
map = self.db.getObjectMap() map = self.db.getObjectMap()
del map[mobj.getId()] del map[mobj.getId()]

View File

@ -44,6 +44,8 @@ import string
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import * from RelLib import *
from QuestionDialog import QuestionDialog
import EditPlace import EditPlace
import Utils import Utils
import GrampsCfg import GrampsCfg
@ -252,8 +254,10 @@ class PlaceView:
if used == 1: if used == 1:
ans = EditPlace.DeletePlaceQuery(place,self.db,self.update_display) ans = EditPlace.DeletePlaceQuery(place,self.db,self.update_display)
msg = _("This place is currently being used. Delete anyway?") QuestionDialog(_('Delete Place'),
gnome.ui.GnomeQuestionDialog(msg,ans.query_response) _("This place is currently being used. Delete anyway?"),
_('Delete Place'),ans.query_response,
_('Keep Place'))
else: else:
obj.remove(index) obj.remove(index)
map = self.db.getPlaceMap() map = self.db.getPlaceMap()

View File

@ -34,6 +34,7 @@ class QuestionDialog:
self.task1 = task1 self.task1 = task1
self.top.button_connect(0,self.my_task1) self.top.button_connect(0,self.my_task1)
self.top.button_connect(1,self.my_task2) self.top.button_connect(1,self.my_task2)
self.top.set_modal(1)
self.top.show() self.top.show()
def my_task1(self,obj): def my_task1(self,obj):

View File

@ -40,6 +40,8 @@ import gnome.ui
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from RelLib import * from RelLib import *
from QuestionDialog import QuestionDialog
import EditSource import EditSource
import Utils import Utils
import GrampsCfg import GrampsCfg
@ -173,9 +175,12 @@ class SourceView:
source = obj.get_row_data(index) source = obj.get_row_data(index)
if self.is_source_used(source): if self.is_source_used(source):
msg = _("This source is currently being used. Delete anyway?")
ans = EditSource.DelSrcQuery(source,self.db,self.update) ans = EditSource.DelSrcQuery(source,self.db,self.update)
gnome.ui.GnomeQuestionDialog(msg,ans.query_response)
QuestionDialog(_('Delete Source'),
_("This source is currently being used. Delete anyway?"),
_('Delete Source'),ans.query_response,
_('Keep Source'))
else: else:
map = self.db.getSourceMap() map = self.db.getSourceMap()
del map[source.getId()] del map[source.getId()]

View File

@ -75,7 +75,6 @@ OBJECT = "o"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def modified(): def modified():
global _modifiedFlag, _autosave_tim global _modifiedFlag, _autosave_tim
if _autosave_fun and not _autosave_tim: if _autosave_fun and not _autosave_tim:
_autosave_tim = gtk.timeout_add(60000*_autotime_val,_autosave_fun) _autosave_tim = gtk.timeout_add(60000*_autotime_val,_autosave_fun)
_modifiedFlag = 1 _modifiedFlag = 1

View File

@ -58,6 +58,8 @@ from PlaceView import PlaceView
from SourceView import SourceView from SourceView import SourceView
from MediaView import MediaView from MediaView import MediaView
from QuestionDialog import QuestionDialog
import ReadXML import ReadXML
import Filter import Filter
import const import const
@ -108,7 +110,8 @@ class Gramps:
gtk.rc_parse(const.gtkrcFile) gtk.rc_parse(const.gtkrcFile)
if os.getuid() == 0: if os.getuid() == 0:
msg = _("You are running GRAMPS as the 'root' user.\nThis account is not meant for normal application use.") msg = _("You are running GRAMPS as the 'root' user.\n"
"This account is not meant for normal application use.")
gnome.ui.GnomeWarningDialog(msg) gnome.ui.GnomeWarningDialog(msg)
self.database = GrampsDB() self.database = GrampsDB()
@ -133,14 +136,14 @@ class Gramps:
if arg != None: if arg != None:
self.read_file(arg) self.read_file(arg)
elif GrampsCfg.lastfile != None and GrampsCfg.lastfile != "" and GrampsCfg.autoload: elif GrampsCfg.lastfile and GrampsCfg.autoload:
self.auto_save_load(GrampsCfg.lastfile) self.auto_save_load(GrampsCfg.lastfile)
else: else:
import DbPrompter import DbPrompter
DbPrompter.DbPrompter(self,0) DbPrompter.DbPrompter(self,0)
if GrampsCfg.autosave_int != 0: if GrampsCfg.autosave_int != 0:
Utils.enable_autosave(self.autosave_database,GrampsCfg.autosave_int) Utils.enable_autosave(self.autosave_database,GrampsCfg.autosave_int)
self.database.setResearcher(GrampsCfg.get_researcher()) self.database.setResearcher(GrampsCfg.get_researcher())
@ -400,17 +403,23 @@ class Gramps:
def on_exit_activate(self,obj): def on_exit_activate(self,obj):
"""Prompt to save on exit if needed""" """Prompt to save on exit if needed"""
if Utils.wasModified(): if Utils.wasModified():
question = _("Unsaved changes exist in the current database\n") + \ self.delobj = obj
_("Do you wish to save the changes?") QuestionDialog(_('Abandon Changes'),
gnome.ui.GnomeQuestionDialog(question,self.save_query) _("Unsaved changes exist in the current database\n"
"Do you wish to save the changes?"),
_("Save Changes"), self.save_query,
_("Abandon Changes"), self.quit)
else: else:
gtk.mainquit(obj) gtk.mainquit()
def save_query(self,value): def save_query(self):
"""Catch the reponse to the save on exit question""" """Catch the reponse to the save on exit question"""
if value == 0: self.on_save_activate_quit()
self.on_save_activate_quit() gtk.mainquit()
gtk.mainquit(self.gtop)
def quit(self):
"""Catch the reponse to the save on exit question"""
gtk.mainquit()
def on_about_activate(self,obj): def on_about_activate(self,obj):
"""Displays the about box. Called from Help menu""" """Displays the about box. Called from Help menu"""
@ -573,13 +582,14 @@ class Gramps:
def on_new_clicked(self,obj): def on_new_clicked(self,obj):
"""Prompt for permission to close the current database""" """Prompt for permission to close the current database"""
msg = _("Do you want to close the current database and create a new one?")
gnome.ui.GnomeQuestionDialog(msg,self.new_database_response)
def new_database_response(self,val): msg = _("Do you want to close the current database and create a new one?")
QuestionDialog(_('New Database'),msg,
_('Close Current Database'),self.new_database_response,
_('Return to Current Database'))
def new_database_response(self):
import DbPrompter import DbPrompter
if val == 1:
return
self.clear_database() self.clear_database()
DbPrompter.DbPrompter(self,1) DbPrompter.DbPrompter(self,1)
@ -648,7 +658,7 @@ class Gramps:
elif page == 3: elif page == 3:
self.source_view.load_sources() self.source_view.load_sources()
elif page == 4: elif page == 4:
pass self.place_view.load_places()
else: else:
self.media_view.load_media() self.media_view.load_media()
@ -693,15 +703,18 @@ class Gramps:
"be loaded instead of the last saved version?") % dirname "be loaded instead of the last saved version?") % dirname
self.yname = autosave self.yname = autosave
self.nname = filename self.nname = filename
gnome.ui.GnomeQuestionDialog(q,self.autosave_query)
QuestionDialog(_('Autosave File'),q,
_('Load Autosave File'),self.autosave_query,
_('Load Last Saved File'),self.loadsaved_file)
else: else:
self.read_file(filename) self.read_file(filename)
def autosave_query(self,value): def autosave_query(self):
if value == 0: self.read_file(self.yname)
self.read_file(self.yname)
else: def loadsaved_file(self):
self.read_file(self.nname) self.read_file(self.nname)
def read_file(self,filename): def read_file(self,filename):
base = os.path.basename(filename) base = os.path.basename(filename)
@ -841,15 +854,15 @@ class Gramps:
if len(self.person_list.selection) == 1: if len(self.person_list.selection) == 1:
name = GrampsCfg.nameof(self.active_person) name = GrampsCfg.nameof(self.active_person)
msg = _("Do you really wish to delete %s?") % name msg = _("Do you really wish to delete %s?") % name
gnome.ui.GnomeQuestionDialog(msg, self.delete_person_response)
QuestionDialog(_('Delete Person'), msg,
_('Delete Person'),self.delete_person_response,
_('Keep Person'))
elif len(self.person_list.selection) > 1: elif len(self.person_list.selection) > 1:
msg = _("Currently, you can only delete one person at a time") msg = _("Currently, you can only delete one person at a time")
gnome.ui.GnomeErrorDialog(msg) gnome.ui.GnomeErrorDialog(msg)
def delete_person_response(self,val): def delete_person_response(self):
if val == 1:
return
personmap = self.database.getPersonMap() personmap = self.database.getPersonMap()
familymap = self.database.getPersonMap() familymap = self.database.getPersonMap()
@ -1191,33 +1204,35 @@ class Gramps:
if self.database.getSavePath() != "": if self.database.getSavePath() != "":
msg = _("Do you wish to abandon your changes and " msg = _("Do you wish to abandon your changes and "
"revert to the last saved database?") "revert to the last saved database?")
gnome.ui.GnomeQuestionDialog(msg,self.revert_query)
QuestionDialog(_('Abandon Changes'),msg,
_('Revert to Last Database'),self.revert_query,
_('Continue with Current Database'))
else: else:
msg = _("Cannot revert to a previous database, since " msg = _("Cannot revert to a previous database, since "
"one does not exist") "one does not exist")
gnome.ui.GnomeWarningDialog(msg) gnome.ui.GnomeWarningDialog(msg)
def revert_query(self,value): def revert_query(self):
if value == 0: const.personalEvents = const.init_personal_event_list()
const.personalEvents = const.init_personal_event_list() const.personalAttributes = const.init_personal_attribute_list()
const.personalAttributes = const.init_personal_attribute_list() const.marriageEvents = const.init_marriage_event_list()
const.marriageEvents = const.init_marriage_event_list() const.familyAttributes = const.init_family_attribute_list()
const.familyAttributes = const.init_family_attribute_list() const.familyRelations = const.init_family_relation_list()
const.familyRelations = const.init_family_relation_list()
file = self.database.getSavePath() file = self.database.getSavePath()
self.database.new() self.database.new()
self.active_person = None self.active_person = None
self.active_father = None self.active_father = None
self.active_family = None self.active_family = None
self.active_mother = None self.active_mother = None
self.active_child = None self.active_child = None
self.active_spouse = None self.active_spouse = None
self.id2col = {} self.id2col = {}
self.alt2col = {} self.alt2col = {}
self.read_file(file) self.read_file(file)
Utils.clearModified() Utils.clearModified()
Utils.clear_timer() Utils.clear_timer()
def on_save_as_activate(self,obj): def on_save_as_activate(self,obj):
wFs = libglade.GladeXML (const.gladeFile, "fileselection") wFs = libglade.GladeXML (const.gladeFile, "fileselection")
@ -1882,12 +1897,14 @@ class Gramps:
if self.active_person: if self.active_person:
name = self.active_person.getPrimaryName().getRegularName() name = self.active_person.getPrimaryName().getRegularName()
msg = _("Do you wish to set %s as the home person?") % name msg = _("Do you wish to set %s as the home person?") % name
gnome.ui.GnomeQuestionDialog(msg,self.set_person)
def set_person(self,value): QuestionDialog(_('Set Home Person'),msg,
if not value: _('Set as Home Person'),self.set_person,
self.database.setDefaultPerson(self.active_person) _('Do not change Home Person'))
Utils.modified()
def set_person(self):
self.database.setDefaultPerson(self.active_person)
Utils.modified()
def family_up_clicked(self,obj): def family_up_clicked(self,obj):
if self.active_parents == None: if self.active_parents == None: