[meld: 43/63] ui.msgarea: Add helper for actionable messages and use for binary open
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld: 43/63] ui.msgarea: Add helper for actionable messages and use for binary open
- Date: Wed, 16 Dec 2015 21:22:35 +0000 (UTC)
commit fbeceed5a65032c1bec08163ba6a37ea3ec4aa06
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Sep 28 07:25:42 2015 +1000
ui.msgarea: Add helper for actionable messages and use for binary open
meld/filediff.py | 19 +++----------------
meld/ui/msgarea.py | 13 +++++++++++++
2 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 928ec40..658e9b2 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1086,22 +1086,9 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
primary = _("File %s appears to be a binary file.") % filename
secondary = _(
"Do you want to open the file using the default application?")
- msgarea = self.msgarea_mgr[pane].new_from_text_and_icon(
- Gtk.STOCK_DIALOG_WARNING, primary, secondary)
- msgarea.add_button(_("Open"), Gtk.ResponseType.ACCEPT)
- msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
-
- def make_binary_callback(pane, filename):
- def on_binary_file_open(msgarea, response_id, *args):
- self.msgarea_mgr[pane].clear()
- if response_id == Gtk.ResponseType.ACCEPT:
- self._open_files([filename])
- return on_binary_file_open
- return on_binary_file_open
-
- msgarea.connect(
- "response", make_binary_callback(pane, gfile.get_path()))
- msgarea.show_all()
+ self.msgarea_mgr[pane].add_action_msg(
+ Gtk.STOCK_DIALOG_WARNING, primary, secondary, _("Open"),
+ functools.partial(self._open_files, [gfile.get_path()]))
self.update_buffer_writable(buf)
diff --git a/meld/ui/msgarea.py b/meld/ui/msgarea.py
index 0665a38..70185c2 100644
--- a/meld/ui/msgarea.py
+++ b/meld/ui/msgarea.py
@@ -111,3 +111,16 @@ class MsgAreaController(Gtk.HBox):
msgarea.connect("response", lambda *args: self.clear())
msgarea.show_all()
return msgarea
+
+ def add_action_msg(self, icon, primary, secondary, action_label, callback):
+ def on_response(msgarea, response_id, *args):
+ self.clear()
+ if response_id == Gtk.ResponseType.ACCEPT:
+ callback()
+
+ msgarea = self.new_from_text_and_icon(icon, primary, secondary)
+ msgarea.add_button(action_label, Gtk.ResponseType.ACCEPT)
+ msgarea.add_button(_("Hi_de"), Gtk.ResponseType.CLOSE)
+ msgarea.connect("response", on_response)
+ msgarea.show_all()
+ return msgarea
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]