8128: GtkDialog mapped without a transient parent

This commit is contained in:
Paul Franklin 2016-08-09 13:48:57 -07:00
parent a8b0037fab
commit 3edab6e2e6
8 changed files with 32 additions and 20 deletions

View File

@ -25,8 +25,6 @@
# Standard Python modules # Standard Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
import re import re
import time import time
@ -35,7 +33,10 @@ import time
# Gramps modules # Gramps modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from ...const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
from . import Rule from . import Rule
from gramps.gen.errors import FilterError
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -77,8 +78,8 @@ class ChangedSinceBase(Rule):
time_tup = time.strptime(iso_date_time, "%Y-%m-%d %H:%M:%S") time_tup = time.strptime(iso_date_time, "%Y-%m-%d %H:%M:%S")
time_sec = time.mktime(time_tup) time_sec = time.mktime(time_tup)
except ValueError: except ValueError:
from gramps.gui.dialog import WarningDialog raise FilterError(
WarningDialog(_("Wrong format of date-time"), # no-parent _("Wrong format of date-time"),
_("Only date-times in the iso format of yyyy-mm-dd " _("Only date-times in the iso format of yyyy-mm-dd "
"hh:mm:ss, where the time part is optional, are " "hh:mm:ss, where the time part is optional, are "
"accepted. %s does not satisfy.") % iso_date_time) "accepted. %s does not satisfy.") % iso_date_time)

View File

@ -114,7 +114,8 @@ class LastNameDialog(ManagedWindow):
# build up the list of surnames, keeping track of the count for each # build up the list of surnames, keeping track of the count for each
# name (this can be a lengthy process, so by passing in the # name (this can be a lengthy process, so by passing in the
# dictionary we can be certain we only do this once) # dictionary we can be certain we only do this once)
progress = ProgressMeter(_('Finding Surnames')) # no-parent progress = ProgressMeter( # parent-OK
_('Finding Surnames'), parent=uistate.window)
progress.set_pass(_('Finding surnames'), progress.set_pass(_('Finding surnames'),
database.get_number_of_people()) database.get_number_of_people())
for person in database.iter_people(): for person in database.iter_people():

View File

@ -305,7 +305,8 @@ class PluginStatus(ManagedWindow):
except: except:
print("Error: cannot open %s" % URL) print("Error: cannot open %s" % URL)
return return
pm = ProgressMeter(_("Refreshing Addon List")) # no-parent pm = ProgressMeter(_("Refreshing Addon List"), # parent-OK
parent=self.uistate.window)
pm.set_pass(header=_("Reading gramps-project.org...")) pm.set_pass(header=_("Reading gramps-project.org..."))
state = "read" state = "read"
rows = [] rows = []
@ -383,8 +384,9 @@ class PluginStatus(ManagedWindow):
Get all addons from the wiki and install them. Get all addons from the wiki and install them.
""" """
from ..utils import ProgressMeter from ..utils import ProgressMeter
pm = ProgressMeter( # no-parent pm = ProgressMeter( # parent-OK
_("Install all Addons"), _("Installing..."), message_area=True) _("Install all Addons"), _("Installing..."), message_area=True,
parent=self.uistate.window)
pm.set_pass(total=len(self.addon_model)) pm.set_pass(total=len(self.addon_model))
errors = [] errors = []
for row in self.addon_model: for row in self.addon_model:
@ -402,8 +404,9 @@ class PluginStatus(ManagedWindow):
Toplevel method to get an addon. Toplevel method to get an addon.
""" """
from ..utils import ProgressMeter from ..utils import ProgressMeter
pm = ProgressMeter( # no-parent pm = ProgressMeter( # parent-OK
_("Installing Addon"), message_area=True) _("Installing Addon"), message_area=True,
parent=self.uistate.window)
pm.set_pass(total=2, header=_("Reading gramps-project.org...")) pm.set_pass(total=2, header=_("Reading gramps-project.org..."))
pm.step() pm.step()
self.__get_addon(obj, callback=pm.append_message) self.__get_addon(obj, callback=pm.append_message)
@ -879,7 +882,8 @@ class ToolManagedWindowBase(ManagedWindow):
def pre_run(self): def pre_run(self):
from ..utils import ProgressMeter from ..utils import ProgressMeter
self.progress = ProgressMeter(self.get_title()) # no-parent self.progress = ProgressMeter(self.get_title(), # parent-OK
parent=self.uistate.window)
def run(self): def run(self):
raise NotImplementedError("tool needs to define a run() method") raise NotImplementedError("tool needs to define a run() method")

View File

@ -412,7 +412,7 @@ def open_file_with_default_application(path):
norm_path = os.path.normpath(path) norm_path = os.path.normpath(path)
if not os.path.exists(norm_path): if not os.path.exists(norm_path):
display_error_dialog(0, _("File does not exist")) display_error_dialog(0, _("File %s does not exist") % norm_path)
return return
if win(): if win():

View File

@ -57,13 +57,13 @@ from .navigationview import NavigationView
from ..actiongroup import ActionGroup from ..actiongroup import ActionGroup
from ..columnorder import ColumnOrder from ..columnorder import ColumnOrder
from gramps.gen.config import config from gramps.gen.config import config
from gramps.gen.errors import WindowActiveError from gramps.gen.errors import WindowActiveError, FilterError
from ..filters import SearchBar from ..filters import SearchBar
from ..widgets.menuitem import add_menuitem from ..widgets.menuitem import add_menuitem
from gramps.gen.const import CUSTOM_FILTERS from gramps.gen.const import CUSTOM_FILTERS
from gramps.gen.utils.debug import profile from gramps.gen.utils.debug import profile
from gramps.gen.utils.string import data_recover_msg from gramps.gen.utils.string import data_recover_msg
from ..dialog import QuestionDialog, QuestionDialog2 from ..dialog import QuestionDialog, QuestionDialog2, ErrorDialog
from ..editors import FilterEditor from ..editors import FilterEditor
from ..ddtargets import DdTargets from ..ddtargets import DdTargets
from ..plug.quick import create_quickreport_menu, create_web_connect_menu from ..plug.quick import create_quickreport_menu, create_web_connect_menu
@ -328,7 +328,12 @@ class ListView(NavigationView):
#run only the part that determines what to show #run only the part that determines what to show
self.list.set_model(None) self.list.set_model(None)
self.model.set_search(filter_info) self.model.set_search(filter_info)
self.model.rebuild_data() try:
self.model.rebuild_data()
except FilterError as msg:
(msg1, msg2) = msg.messages()
ErrorDialog(msg1, msg2, # parent-OK
parent=self.uistate.window)
cput1 = time.clock() cput1 = time.clock()
self.build_columns() self.build_columns()

View File

@ -167,8 +167,9 @@ class PatchNames(tool.BatchTool, ManagedWindow):
self.cb = callback self.cb = callback
self.handle_to_action = {} self.handle_to_action = {}
self.progress = ProgressMeter( # no-parent self.progress = ProgressMeter( # parent-OK
_('Extracting Information from Names'), '') _('Extracting Information from Names'), '',
parent=self.uistate.window)
self.progress.set_pass(_('Analyzing names'), self.progress.set_pass(_('Analyzing names'),
self.db.get_number_of_people()) self.db.get_number_of_people())

View File

@ -134,8 +134,8 @@ class PopulateSources(tool.Tool, ManagedWindow):
num_citations_text = self.citations_entry.get_text() num_citations_text = self.citations_entry.get_text()
num_citations = int(num_citations_text) num_citations = int(num_citations_text)
self.progress = ProgressMeter( # no-parent self.progress = ProgressMeter( # parent-OK
'Generating data', '') 'Generating data', '', parent=self.uistate.window)
self.progress.set_pass('Generating data', self.progress.set_pass('Generating data',
num_sources*num_citations) num_sources*num_citations)
LOG.debug("sources %04d citations %04d" % (num_sources, LOG.debug("sources %04d citations %04d" % (num_sources,

View File

@ -118,5 +118,5 @@ authors_email = [""],
category = TOOL_DEBUG, category = TOOL_DEBUG,
toolclass = 'PopulateSources', toolclass = 'PopulateSources',
optionclass = 'PopulateSourcesOptions', optionclass = 'PopulateSourcesOptions',
tool_modes = [TOOL_MODE_GUI, TOOL_MODE_CLI] tool_modes = [TOOL_MODE_GUI]
) )