Commit 32ab99eb authored by Pratik Dayama's avatar Pratik Dayama Committed by Kai Willadsen

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.
parent b4005379
......@@ -1084,9 +1084,24 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
if nextbit.find("\x00") != -1:
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):
if response_id == Gtk.ResponseType.ACCEPT:
return on_binary_file_open
return on_binary_file_open
msgarea.connect("response", make_binary_callback(t.pane, t.filename))
except ValueError as err:
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