[meld/meld-3-14] filediff: Offer to open binary files externally (bgo#665154)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/meld-3-14] filediff: Offer to open binary files externally (bgo#665154)
- Date: Fri, 25 Sep 2015 21:38:54 +0000 (UTC)
commit 6c852af67c7bc9c3c9bb25c6b27a9ac106f11b4a
Author: Pratik Dayama <pratik dayama63 gmail com>
Date: Sat Sep 26 07:32:28 2015 +1000
filediff: Offer to open binary files externally (bgo#665154)
If we think we've got a binary file, currently Meld just refuses to
display it. It's somewhat more useful to to offer to open this file in
whatever program we think will be able to view it. This is primarily
for file comparisons started from folder comparisons, though VC
comparisons will also benefit somewhat.
meld/filediff.py | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index c132959..66ef2e4 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1152,9 +1152,24 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if nextbit.find("\x00") != -1:
t.buf.delete(*t.buf.get_bounds())
filename = GObject.markup_escape_text(t.filename)
- add_dismissable_msg(t.pane, Gtk.STOCK_DIALOG_ERROR,
- _("Could not read file"),
- _("%s appears to be a binary file.") % filename)
+
+ 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[t.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(t.pane, t.filename))
+ msgarea.show_all()
tasks.remove(t)
continue
except ValueError as err:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]