def fill_dialog(self, default_style=False): doc = self.app.current_doc doc.canvas.set_mode() objs = [] if default_style: fill_style = doc.model.styles['Default Style'][0] default_style = True title = _('Default document fill') else: fill_style = None title = _('Fill') if doc.selection.objs: style = self._get_style(doc.selection.objs) if style is not None: fill_style = style[0] elif doc.canvas.mode in modes.EDIT_MODES and \ doc.canvas.controller.target: objs.append(doc.canvas.controller.target) style = self._get_style(objs) if style is not None: fill_style = style[0] if fill_style is None: txt = _( 'Do you wish to change default fill style for this document?') txt += '\n' txt += _('This style will be applied to newly created objects.') title = self.app.appdata.app_name if dialogs.yesno_dialog(self.mw, title, txt): fill_style = doc.model.styles['Default Style'][0] default_style = True title = _('Default document fill') else: return new_fill_style = dialogs.fill_dlg(self.mw, doc, fill_style, title) if new_fill_style is not None: if default_style: new_style = doc.model.get_def_style() new_style[0] = new_fill_style doc.api.set_default_style(new_style) else: doc.api.set_fill_style(new_fill_style, objs)
def fill_dialog(self, default_style=False): doc = self.app.current_doc objs = [] if default_style: fill_style = doc.model.styles['Default Style'][0] default_style = True title = _('Default document fill') else: fill_style = None title = _('Fill') if doc.selection.objs: style = self._get_style(doc.selection.objs) if not style is None: fill_style = style[0] elif doc.canvas.mode in modes.EDIT_MODES and \ doc.canvas.controller.target: objs.append(doc.canvas.controller.target) style = self._get_style(objs) if not style is None: fill_style = style[0] if fill_style is None: txt = _('Do you wish to change default fill style for this document?') txt += '\n' txt += _('This style will be applied to newly created objects.') title = self.app.appdata.app_name if dialogs.yesno_dialog(self.mw, title, txt): fill_style = doc.model.styles['Default Style'][0] default_style = True title = _('Default document fill') else: return new_fill_style = dialogs.fill_dlg(self.mw, doc, fill_style, title) if not new_fill_style is None: if default_style: new_style = doc.model.get_def_style() new_style[0] = new_fill_style doc.api.set_default_style(new_style) else: doc.api.set_fill_style(new_fill_style, objs)