Example #1
0
    def add_to_grid(self, grid, row):
        for c in self._confmap.values():
            c.setup_preference(self.get_prefpath())

        outgrid = grid
        outrow = row
        if self.label is not None:
            self._expander = Gtk.Expander(label=self.label)
            self._expander.set_expanded(self.expanded)
            outgrid = Gtk.Grid()
            self._expander.add(outgrid)
            grid.attach(self._expander, 1, row, 1, 1)
            outrow = 0
            row += 1

        if self.removable:
            self._remove_btn = Gtk.Button(label="Remove")
            self._remove_btn.connect("clicked", self.remove)
            outgrid.attach(self._remove_btn, 0, outrow, 2, 1)
            outrow += 1

        for c in self._confmap.values():
            outrow = c.add_to_grid(outgrid, outrow)

        for sc in self._subconfigs:
            outrow = sc.add_to_grid(outgrid, outrow)

        if self.label is not None:
            return row
        return outrow
Example #2
0
 def init_specialized_widgets(self, row=0):
     curve = LineModeCurveWidget()
     curve.set_size_request(175, 125)
     self._curve = curve
     exp = Gtk.Expander()
     exp.set_label(_(u"Pressure variation…"))
     exp.set_use_markup(False)
     exp.add(curve)
     self.attach(exp, 0, row, 2, 1)
     row += 1
     return row
Example #3
0
def _info(exctyp, value, tb):
    global exception_dialog_active
    if exctyp is KeyboardInterrupt:
        return original_excepthook(exctyp, value, tb)
    sys.stderr.write(analyse_simple(exctyp, value, tb).getvalue())
    if exception_dialog_active:
        return

    Gdk.pointer_ungrab(Gdk.CURRENT_TIME)
    Gdk.keyboard_ungrab(Gdk.CURRENT_TIME)

    exception_dialog_active = True
    # Create the dialog
    dialog = Gtk.MessageDialog(message_type=Gtk.MessageType.WARNING)
    dialog.set_title(_("Bug Detected"))

    primary = _(
        "<big><b>A programming error has been detected.</b></big>"
    )
    secondary = _(
        "You may be able to ignore this error and carry on working, "
        "but you should probably save your work soon.\n\n"
        "Please tell the developers about this using the issue tracker "
        "if no-one else has reported it yet."
    )
    dialog.set_markup(primary)
    dialog.format_secondary_text(secondary)

    dialog.add_button(_(u"Search Tracker…"), RESPONSE_SEARCH)
    if "-" in lib.meta.MYPAINT_VERSION:  # only development and prereleases
        dialog.add_button(_("Report…"), RESPONSE_REPORT)
        dialog.set_response_sensitive(RESPONSE_REPORT, False)
    dialog.add_button(_("Ignore Error"), Gtk.ResponseType.CLOSE)
    dialog.add_button(_("Quit MyPaint"), RESPONSE_QUIT)

    # Add an expander with details of the problem to the dialog
    def expander_cb(expander, *ignore):
        # Ensures that on deactivating the expander, the dialog is resized down
        if expander.get_expanded():
            dialog.set_resizable(True)
        else:
            dialog.set_resizable(False)
    details_expander = Gtk.Expander()
    details_expander.set_label(_(u"Details…"))
    details_expander.connect("notify::expanded", expander_cb)

    textview = Gtk.TextView()
    textview.show()
    textview.set_editable(False)
    textview.modify_font(Pango.FontDescription("Monospace normal"))

    sw = Gtk.ScrolledWindow()
    sw.show()
    sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
    sw.add(textview)

    # Set window sizing so that it's always at least 600 pixels wide, and
    # increases by 300 pixels in height once the details panel is open
    sw.set_size_request(0, 300)
    dialog.set_size_request(600, 0)

    details_expander.add(sw)
    details_expander.show_all()
    dialog.get_content_area().pack_start(details_expander, True, True, 0)

    # Get the traceback and set contents of the details
    try:
        trace = analyse(exctyp, value, tb).getvalue()
    except:
        try:
            trace = _("Exception while analyzing the exception.") + "\n"
            trace += analyse_simple(exctyp, value, tb).getvalue()
        except:
            trace = _("Exception while analyzing the exception.")
    buf = textview.get_buffer()
    trace = "\n".join(["```python", trace, "```"])
    buf.set_text(trace)
    ## Would be nice to scroll to the bottom automatically, but @#&%*@
    #first, last = buf.get_bounds()
    #buf.place_cursor(last)
    #mark = buf.get_insert()
    ##buf.scroll_mark_onscreen()
    ##textview.scroll_mark_onscreen(buf.get_insert(), 0)
    #textview.scroll_to_mark(mark, 0.0)

    # Connect callback and present the dialog
    dialog.connect('response', _dialog_response_cb, trace, exctyp, value)
    #dialog.set_modal(True) # this might actually be contra-productive...
    dialog.show()