8128: GtkDialog mapped without a transient parent
This commit is contained in:
parent
5140e97dbd
commit
e7e865f596
@ -67,8 +67,8 @@ _ = glocale.translation.gettext
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def make_launcher(path):
|
||||
return lambda x: open_file_with_default_application(path)
|
||||
def make_launcher(path, uistate):
|
||||
return lambda x: open_file_with_default_application(path, uistate)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -140,12 +140,12 @@ class GalleryTab(ButtonTab, DbGUIElement):
|
||||
img = Gtk.Image()
|
||||
img.set_from_icon_name("gramps-viewmedia", Gtk.IconSize.MENU)
|
||||
item.set_image(img)
|
||||
item.connect('activate', make_launcher(media_path))
|
||||
item.connect('activate', make_launcher(media_path, self.uistate))
|
||||
item.show()
|
||||
self.menu.append(item)
|
||||
mfolder, mfile = os.path.split(media_path)
|
||||
item = Gtk.MenuItem(label=_('Open Containing _Folder'))
|
||||
item.connect('activate', make_launcher(mfolder))
|
||||
item.connect('activate', make_launcher(mfolder, self.uistate))
|
||||
item.show()
|
||||
self.menu.append(item)
|
||||
item = Gtk.SeparatorMenuItem()
|
||||
|
@ -252,7 +252,7 @@ class EditMedia(EditPrimary):
|
||||
if ref_obj:
|
||||
media_path = media_path_full(self.dbstate.db,
|
||||
ref_obj.get_path())
|
||||
open_file_with_default_application(media_path)
|
||||
open_file_with_default_application(media_path, self.uistate)
|
||||
|
||||
def select_file(self, val):
|
||||
self.determine_mime()
|
||||
|
@ -411,7 +411,7 @@ class EditMediaRef(EditReference):
|
||||
def button_press_event(self, obj, event):
|
||||
if event.button==1 and event.type == Gdk.EventType._2BUTTON_PRESS:
|
||||
photo_path = media_path_full(self.db, self.source.get_path())
|
||||
open_file_with_default_application(photo_path)
|
||||
open_file_with_default_application(photo_path, self.uistate)
|
||||
|
||||
def _update_addmedia(self, obj):
|
||||
"""
|
||||
|
@ -663,7 +663,7 @@ class EditPerson(EditPrimary):
|
||||
object_handle = photo.get_reference_handle()
|
||||
ref_obj = self.db.get_media_from_handle(object_handle)
|
||||
photo_path = media_path_full(self.db, ref_obj.get_path())
|
||||
open_file_with_default_application(photo_path)
|
||||
open_file_with_default_application(photo_path, self.uistate)
|
||||
|
||||
def _popup_change_description(self, obj):
|
||||
"""
|
||||
|
@ -661,8 +661,8 @@ class PluginStatus(ManagedWindow):
|
||||
pdata = self.__preg.get_plugin(id)
|
||||
if pdata.fpath and pdata.fname:
|
||||
open_file_with_default_application(
|
||||
os.path.join(pdata.fpath, pdata.fname)
|
||||
)
|
||||
os.path.join(pdata.fpath, pdata.fname),
|
||||
self.uistate)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -1024,7 +1024,7 @@ class BookDialog(DocReportDialog):
|
||||
return
|
||||
|
||||
if self.open_with_app.get_active():
|
||||
open_file_with_default_application(self.target_path)
|
||||
open_file_with_default_application(self.target_path, self.uistate)
|
||||
|
||||
def init_options(self, option_class):
|
||||
try:
|
||||
|
@ -706,7 +706,7 @@ def report(dbstate, uistate, person, report_class, options_class,
|
||||
dialog.open_with_app.get_property('sensitive') == True
|
||||
and dialog.open_with_app.get_active()):
|
||||
out_file = dialog.options.get_output()
|
||||
open_file_with_default_application(out_file)
|
||||
open_file_with_default_application(out_file, self.uistate)
|
||||
|
||||
except FilterError as msg:
|
||||
(msg1, msg2) = msg.messages()
|
||||
|
@ -357,7 +357,7 @@ class SystemFonts:
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def display_error_dialog (index, errorstrings):
|
||||
def display_error_dialog (index, errorstrings, uistate=None):
|
||||
"""
|
||||
Display a message box for errors resulting from xdg-open/open
|
||||
"""
|
||||
@ -372,7 +372,8 @@ def display_error_dialog (index, errorstrings):
|
||||
else:
|
||||
error = errorstrings
|
||||
|
||||
ErrorDialog(_("Error from external program"), error) # TODO no-parent
|
||||
ErrorDialog(_("Error from external program"), # parent-OK
|
||||
error, parent=uistate.window)
|
||||
|
||||
def poll_external (args):
|
||||
"""
|
||||
@ -387,16 +388,16 @@ def poll_external (args):
|
||||
:return: bool returned to timeout_add_seconds: should this function be
|
||||
called again?
|
||||
"""
|
||||
(proc, errorstrings) = args
|
||||
(proc, errorstrings, uistate) = args
|
||||
resp = proc.poll()
|
||||
if resp is None:
|
||||
return True
|
||||
|
||||
if resp != 0:
|
||||
display_error_dialog(resp, errorstrings)
|
||||
display_error_dialog(resp, errorstrings, uistate)
|
||||
return False
|
||||
|
||||
def open_file_with_default_application(path):
|
||||
def open_file_with_default_application(path, uistate):
|
||||
"""
|
||||
Launch a program to open an arbitrary file. The file will be opened using
|
||||
whatever program is configured on the host as the default program for that
|
||||
@ -412,14 +413,16 @@ def open_file_with_default_application(path):
|
||||
|
||||
norm_path = os.path.normpath(path)
|
||||
if not os.path.exists(norm_path):
|
||||
display_error_dialog(0, _("File %s does not exist") % norm_path)
|
||||
display_error_dialog(0, _("File %s does not exist") % norm_path,
|
||||
uistate)
|
||||
return
|
||||
|
||||
if win():
|
||||
try:
|
||||
os.startfile(norm_path)
|
||||
except WindowsError as msg:
|
||||
display_error_dialog(0, str(msg))
|
||||
display_error_dialog(0, str(msg),
|
||||
uistate)
|
||||
|
||||
return
|
||||
|
||||
@ -435,7 +438,7 @@ def open_file_with_default_application(path):
|
||||
proc = subprocess.Popen([utility, norm_path], stderr=subprocess.STDOUT)
|
||||
|
||||
from gi.repository import GLib
|
||||
GLib.timeout_add_seconds(1, poll_external, (proc, errstrings))
|
||||
GLib.timeout_add_seconds(1, poll_external, (proc, errstrings, uistate))
|
||||
return
|
||||
|
||||
def process_pending_events(max_count=10):
|
||||
|
@ -78,7 +78,7 @@ class Photo(Gtk.EventBox):
|
||||
Display the image with the default external viewer.
|
||||
"""
|
||||
if event.type == Gdk.EventType._2BUTTON_PRESS and event.button == 1:
|
||||
open_file_with_default_application(self.full_path)
|
||||
open_file_with_default_application(self.full_path, self.uistate)
|
||||
return True
|
||||
elif is_right_click(event):
|
||||
if self.handle and self.uistate:
|
||||
|
@ -86,3 +86,4 @@ class MediaPreview(Gramplet):
|
||||
self.full_path = media_path_full(self.dbstate.db, media.get_path())
|
||||
mime_type = media.get_mime_type()
|
||||
self.photo.set_image(self.full_path, mime_type)
|
||||
self.photo.set_uistate(self.uistate, None)
|
||||
|
@ -139,6 +139,7 @@ class MediaView(ListView):
|
||||
})
|
||||
|
||||
self.additional_uis.append(self.additional_ui())
|
||||
self.uistate = uistate
|
||||
|
||||
def navigation_type(self):
|
||||
return 'Media'
|
||||
@ -224,7 +225,7 @@ class MediaView(ListView):
|
||||
for handle in self.selected_handles():
|
||||
ref_obj = self.dbstate.db.get_media_from_handle(handle)
|
||||
mpath = media_path_full(self.dbstate.db, ref_obj.get_path())
|
||||
open_file_with_default_application(mpath)
|
||||
open_file_with_default_application(mpath, self.uistate)
|
||||
|
||||
def open_containing_folder(self, obj):
|
||||
"""
|
||||
@ -235,7 +236,7 @@ class MediaView(ListView):
|
||||
mpath = media_path_full(self.dbstate.db, ref_obj.get_path())
|
||||
if mpath:
|
||||
mfolder, mfile = os.path.split(mpath)
|
||||
open_file_with_default_application(mfolder)
|
||||
open_file_with_default_application(mfolder, self.uistate)
|
||||
|
||||
def get_stock(self):
|
||||
"""
|
||||
|
@ -673,7 +673,7 @@ class RelationshipView(NavigationView):
|
||||
Open this picture in the default picture viewer.
|
||||
"""
|
||||
photo_path = media_path_full(self.dbstate.db, photo.get_path())
|
||||
open_file_with_default_application(photo_path)
|
||||
open_file_with_default_application(photo_path, self.uistate)
|
||||
|
||||
def write_person_event(self, ename, event):
|
||||
if event:
|
||||
|
Loading…
Reference in New Issue
Block a user