Commit b5e31047 authored by Kai Willadsen's avatar Kai Willadsen

ui.msgarea: Move dismissable message helper to msgarea

parent 92be30fd
......@@ -902,17 +902,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
else:
continue
secondary = "\n".join(messages)
self.add_dismissable_msg(pane, Gtk.STOCK_DIALOG_ERROR, header,
secondary)
def add_dismissable_msg(self, pane, icon, primary, secondary):
msgarea = self.msgarea_mgr[pane].new_from_text_and_icon(
icon, primary, secondary)
msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
msgarea.connect("response",
lambda *args: self.msgarea_mgr[pane].clear())
msgarea.show_all()
return msgarea
self.msgarea_mgr[pane].add_dismissable_msg(
Gtk.STOCK_DIALOG_ERROR, header, secondary)
def copy_selected(self, direction):
assert direction in (-1, 1)
......
......@@ -1075,15 +1075,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
def file_loaded(self, loader, result, user_data):
def add_dismissable_msg(pane, icon, primary, secondary):
msgarea = self.msgarea_mgr[pane].new_from_text_and_icon(
icon, primary, secondary)
msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
msgarea.connect("response",
lambda *args: self.msgarea_mgr[pane].clear())
msgarea.show_all()
return msgarea
gfile = loader.get_location()
pane = user_data[0]
......@@ -1102,8 +1093,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
gfile.get_parse_name()).decode('utf-8')
primary = _(
u"There was a problem opening the file “%s”." % filename)
add_dismissable_msg(
pane, Gtk.STOCK_DIALOG_ERROR, primary, err.message)
self.msgarea_mgr[pane].add_dismissable_msg(
Gtk.STOCK_DIALOG_ERROR, primary, err.message)
buf = loader.get_buffer()
......
......@@ -21,6 +21,7 @@
from gi.repository import Gtk
from meld.conf import _
from meld.ui.wraplabel import WrapLabel
......@@ -103,3 +104,10 @@ class MsgAreaController(Gtk.HBox):
self.pack_start(msgarea, True, True, 0)
return msgarea
def add_dismissable_msg(self, icon, primary, secondary):
msgarea = self.new_from_text_and_icon(icon, primary, secondary)
msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
msgarea.connect("response", lambda *args: self.clear())
msgarea.show_all()
return msgarea
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