Commit b502235e authored by Kai Willadsen's avatar Kai Willadsen

misc: Move user_critical decorator from filediff

parent db57bf5b
......@@ -36,7 +36,7 @@ from meld.matchers.merge import Merger
from meld.meldbuffer import (
BufferDeletionAction, BufferInsertionAction, BufferLines)
from meld.melddoc import ComparisonState, MeldDoc
from meld.misc import with_focused_pane
from meld.misc import user_critical, with_focused_pane
from meld.patchdialog import PatchDialog
from meld.recent import RecentType
from meld.settings import bind_settings, meldsettings
......@@ -47,27 +47,6 @@ from meld.ui.gnomeglade import Component, ui_file
from meld.undo import UndoSequence
def user_critical(primary, message):
def wrap(function):
@functools.wraps(function)
def wrap_function(locked, *args, **kwargs):
try:
return function(locked, *args, **kwargs)
except Exception:
misc.error_dialog(
primary=primary,
secondary=_(
"{}\n\n"
"Meld encountered a critical error while running:\n"
"<tt>{}</tt>".format(
message, GLib.markup_escape_text(str(function)))
),
)
raise
return wrap_function
return wrap
def with_scroll_lock(lock_attr):
"""Decorator for locking a callback based on an instance attribute
......
......@@ -112,6 +112,27 @@ def modal_dialog(
return response
def user_critical(primary, message):
def wrap(function):
@functools.wraps(function)
def wrap_function(locked, *args, **kwargs):
try:
return function(locked, *args, **kwargs)
except Exception:
error_dialog(
primary=primary,
secondary=_(
"{}\n\n"
"Meld encountered a critical error while running:\n"
"<tt>{}</tt>".format(
message, GLib.markup_escape_text(str(function)))
),
)
raise
return wrap_function
return wrap
# Taken from epiphany
def position_menu_under_widget(menu, x, y, widget):
container = widget.get_ancestor(Gtk.Container)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment