bug 8128; Fix 'print...' dialogs for missing transient parent (#372)

Requires adding uistate to the docgen basedoc and all files that
override the init
This commit is contained in:
Paul Culley 2017-04-14 20:22:54 -05:00 committed by Sam Manzi
parent cb932b9221
commit fd4795e957
8 changed files with 20 additions and 15 deletions

View File

@ -60,7 +60,7 @@ class BaseDoc(metaclass=ABCMeta):
such as OpenOffice, AbiWord, and LaTeX are derived from this base such as OpenOffice, AbiWord, and LaTeX are derived from this base
class, providing a common interface to all document generators. class, providing a common interface to all document generators.
""" """
def __init__(self, styles, paper_style, track=[]): def __init__(self, styles, paper_style, track=[], uistate=None):
""" """
Create a BaseDoc instance, which provides a document generation Create a BaseDoc instance, which provides a document generation
interface. This class should never be instantiated directly, but interface. This class should never be instantiated directly, but
@ -77,6 +77,7 @@ class BaseDoc(metaclass=ABCMeta):
self.track = track self.track = track
self._creator = "" self._creator = ""
self.init_called = False self.init_called = False
self.uistate = uistate
def init(self): def init(self):
self.init_called = True self.init_called = True

View File

@ -385,8 +385,8 @@ class GVDocBase(BaseDoc, GVDoc):
inherit from this class will only need to implement the close function. inherit from this class will only need to implement the close function.
The close function will generate the actual file of the appropriate type. The close function will generate the actual file of the appropriate type.
""" """
def __init__(self, options, paper_style): def __init__(self, options, paper_style, uistate=None):
BaseDoc.__init__(self, None, paper_style) BaseDoc.__init__(self, None, paper_style, uistate=uistate)
self._filename = None self._filename = None
self._dot = BytesIO() self._dot = BytesIO()

View File

@ -108,9 +108,11 @@ class DocReportDialog(ReportDialog):
if self.doc_options: if self.doc_options:
self.doc = self.format(self.selected_style, pstyle, self.doc = self.format(self.selected_style, pstyle,
self.doc_options) self.doc_options,
uistate=self.uistate)
else: else:
self.doc = self.format(self.selected_style, pstyle) self.doc = self.format(self.selected_style, pstyle,
uistate=self.uistate)
if not self.format_menu.get_active_plugin().get_paper_used(): if not self.format_menu.get_active_plugin().get_paper_used():
#set css filename #set css filename
self.doc.set_css_filename(self.css_filename) self.doc.set_css_filename(self.css_filename)

View File

@ -134,8 +134,8 @@ class AsciiDoc(BaseDoc, TextDoc):
""" """
ASCII document generator. ASCII document generator.
""" """
def __init__(self, styles, paper_style, options=None): def __init__(self, styles, paper_style, options=None, uistate=None):
BaseDoc.__init__(self, styles, paper_style) BaseDoc.__init__(self, styles, paper_style, uistate=uistate)
self.__note_format = False self.__note_format = False
self._cpl = 72 # characters per line, in case the options are ignored self._cpl = 72 # characters per line, in case the options are ignored

View File

@ -184,6 +184,7 @@ class PrintPreview:
self._operation = operation self._operation = operation
self._preview = preview self._preview = preview
self._context = context self._context = context
self._parent = parent
self.__build_window() self.__build_window()
self._current_page = None self._current_page = None
@ -196,7 +197,7 @@ class PrintPreview:
from gramps.gui.glade import Glade from gramps.gui.glade import Glade
glade_xml = Glade() glade_xml = Glade()
self._window = glade_xml.toplevel self._window = glade_xml.toplevel
#self._window.set_transient_for(parent) self._window.set_transient_for(self._parent)
# remember active widgets for future use # remember active widgets for future use
self._swin = glade_xml.get_object('swin') self._swin = glade_xml.get_object('swin')
@ -521,7 +522,8 @@ class GtkPrint(libcairodoc.CairoDoc):
# run print dialog # run print dialog
while True: while True:
self.preview = None self.preview = None
res = operation.run(Gtk.PrintOperationAction.PRINT_DIALOG, None) res = operation.run(Gtk.PrintOperationAction.PRINT_DIALOG,
self.uistate.window)
if self.preview is None: # cancel or print if self.preview is None: # cancel or print
break break
# set up printing again; can't reuse PrintOperation? # set up printing again; can't reuse PrintOperation?

View File

@ -93,8 +93,8 @@ class HtmlDoc(BaseDoc, TextDoc):
Fontface is removed. Size, italic, bold, margins, borders are retained Fontface is removed. Size, italic, bold, margins, borders are retained
""" """
def __init__(self, styles, paper_style): def __init__(self, styles, paper_style, uistate=None):
BaseDoc.__init__(self, styles, None) BaseDoc.__init__(self, styles, None, uistate=uistate)
self.style_declaration = '' self.style_declaration = ''
self.htmllist = [] self.htmllist = []
self._backend = None self._backend = None

View File

@ -403,11 +403,11 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
The ODF document class The ODF document class
""" """
def __init__(self, styles, ftype): def __init__(self, styles, ftype, uistate=None):
""" """
Class init Class init
""" """
BaseDoc.__init__(self, styles, ftype) BaseDoc.__init__(self, styles, ftype, uistate=uistate)
self.media_list = [] self.media_list = []
self.init_called = False self.init_called = False
self.index_title = None self.index_title = None

View File

@ -52,8 +52,8 @@ _ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class SvgDrawDoc(BaseDoc, DrawDoc): class SvgDrawDoc(BaseDoc, DrawDoc):
def __init__(self, styles, type, options=None): def __init__(self, styles, type, options=None, uistate=None):
BaseDoc.__init__(self, styles, type) BaseDoc.__init__(self, styles, type, uistate=uistate)
self.file = None self.file = None
self.filename = None self.filename = None
self.level = 0 self.level = 0