Commit 5f842847 authored by Kai Willadsen's avatar Kai Willadsen

Merge branch 'master' into Gio

parents 3a8dae9b 5f2e3f45
2015-10-05 meld 3.15.0
======================
Features:
* New API for version control plugins with more consistent interfaces and
data structures across different plugins, enabling many minor
improvements (Kai Willadsen)
* Support the conflict resolution prompt in file comparisons for all VCs
* Improve caching behaviour for some version control plugins
* Better sensitivity handling for version control actions
* Cache and show more metadata (e.g., file renames)
* Several version control plugins have not been ported to the new API; the
current list of support plugins is: Git, Mercurial, Subversion 1.7+,
Bazaar
* Faster rendering in file comparison view, enabled by new GtkTextView API
(Kai Willadsen)
* Move to using GtkSourceView style schemes with Meld-specific colour tags
for highlight colours; this lets themes include colours that match the
sourceview theme (Kai Willadsen)
* Offer to open binary files externally (Pratik Dayama)
* Show the common ancestor in conflicting regions (and the merged file
everywhere else) when viewing conflicts through Meld's version control
view; currently this is only supported under Git (Kai Willadsen)
* Support showing staged/partially staged status of files under Git (Kai
Willadsen)
* Update preferences dialog to new style with headerbar (Kai Willadsen)
Fixes:
* Documentation updates (Andrew Beyer)
* Fix crash with some GTK+ versions when using --output (Kai Willadsen)
* Fix merge-all action not working at all (Kai Willadsen)
* Fix creating patches with unicode path names (Kai Willadsen)
* Fix copy-to-clipboard option in patch dialog (Kai Willadsen)
* Fix diffmap alignment for new GTK+ allocation behaviour (Kai Willadsen)
* Improve float accuracy in folder comparison timestamp resolution (Kai
Willadsen)
* Fix default SVN keyword filter to escape $ characters (Kai Willadsen)
* Fix display of unicode --help from command line (Kai Willadsen)
* Fix keyboard shortcut docs (Kai Willadsen)
* Don't incorrectly show identical notification for changed folder
comparisons (Kai Willadsen)
Internal changes:
* Requirements are now GTK+ 3.14, GtkSourceView 3.14 and GLib 2.36
* Rewritten version control plugin API
* Unified colour handling between linkmap, diffmap and file comparison
* Move all textview drawing to a new GtkSourceView subclass, using the new
GTK+ draw-layer API
Translations:
* Daniel Mustieles (es)
* Gábor Kelemen (hu)
* Jiri Grönroos (fi)
* Josef Andersson (sv)
* Marek Černocký (cs)
* Piotr Drąg (pl)
2015-07-23 meld 3.14.0
======================
......
......@@ -158,8 +158,8 @@ def check_requirements():
try:
# FIXME: Extra clause for gi
import gi
from gi.repository import Gtk
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
version = (Gtk.get_major_version(), Gtk.get_minor_version())
assert version >= gtk_requirement
except (ImportError, AssertionError) as e:
......@@ -172,6 +172,7 @@ def check_requirements():
missing_reqs("GLib", glib_requirement, e)
try:
gi.require_version('GtkSource', '3.0')
from gi.repository import GtkSource
# TODO: There is no way to get at GtkSourceView's actual version
assert hasattr(GtkSource, 'SearchSettings')
......
......@@ -13,4 +13,5 @@
<style name="meld:unknown-text" foreground="#888888"/>
<style name="meld:syncpoint-outline" foreground="#555555"/>
<style name="meld:current-chunk-highlight" background="rgba(255, 255, 255, 0.5)"/>
<style name="meld:dimmed" foreground="#999999"/>
</style-scheme>
......@@ -14,4 +14,5 @@
<style name="meld:unknown-text" background="#aaaaaa"/>
<style name="meld:syncpoint-outline" foreground="#bbbbbb"/>
<style name="meld:current-chunk-highlight" background="rgba(255, 255, 255, 0.1)"/>
<style name="meld:dimmed" foreground="#999999"/>
</style-scheme>
......@@ -181,7 +181,6 @@
</object>
<object class="GtkMessageDialog" id="check_save_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="message_type">warning</property>
......@@ -197,7 +196,7 @@
<object class="GtkButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="close_button">
<property name="label" translatable="yes">Close _without Saving</property>
......@@ -208,7 +207,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
......@@ -222,7 +221,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
......@@ -236,7 +235,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
......@@ -804,7 +803,6 @@
</object>
<object class="GtkMessageDialog" id="revert_dialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="message_type">question</property>
......@@ -821,7 +819,7 @@
<object class="GtkButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="cancel_button1">
<property name="label">gtk-cancel</property>
......@@ -833,7 +831,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
......@@ -848,7 +846,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
......
......@@ -86,64 +86,23 @@
</data>
</object>
<object class="GtkDialog" id="preferencesdialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="border_width">0</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="title" translatable="yes">Meld Preferences</property>
<property name="type_hint">dialog</property>
<property name="use-header-bar">1</property>
<signal name="response" handler="on_response" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child internal-child="action_area">
<object class="GtkButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="helpbutton1">
<property name="label">gtk-help</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="closebutton1">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_stock">True</property>
<accelerator key="Escape" signal="clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<property name="border-width">0</property>
<child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="show_border">False</property>
<child>
<object class="GtkVBox" id="editor_tab">
......@@ -1586,10 +1545,6 @@
</child>
</object>
</child>
<action-widgets>
<action-widget response="-11">helpbutton1</action-widget>
<action-widget response="-7">closebutton1</action-widget>
</action-widgets>
</object>
<object class="GtkSizeGroup" id="sizegroup_editor">
<widgets>
......
......@@ -633,7 +633,6 @@
</object>
<object class="GtkMessageDialog" id="pushdialog">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="type_hint">dialog</property>
<property name="skip_taskbar_hint">True</property>
<property name="message_type">question</property>
......@@ -649,7 +648,7 @@
<object class="GtkButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<property name="layout_style">expand</property>
<child>
<object class="GtkButton" id="cancelbutton">
<property name="label">gtk-cancel</property>
......@@ -660,7 +659,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
......@@ -674,7 +673,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
......
......@@ -6,8 +6,8 @@
msgid ""
msgstr ""
"Project-Id-Version: meld master\n"
"POT-Creation-Date: 2015-07-20 19:42+0000\n"
"PO-Revision-Date: 2015-07-21 11:57+0200\n"
"POT-Creation-Date: 2015-10-11 11:40+0000\n"
"PO-Revision-Date: 2015-10-11 18:42+0200\n"
"Last-Translator: Marek Černocký <marek@manet.cz>\n"
"Language-Team: Czech <gnome-cs-list@gnome.org>\n"
"Language: cs\n"
......@@ -33,8 +33,7 @@ msgstr "3"
#: C/resolving-conflicts.page:10 C/preferences.page:10 C/file-changes.page:10
#: C/file-mode.page:11 C/flattened-view.page:10 C/index.page:8
#: C/vc-mode.page:10 C/keyboard-shortcuts.page:10 C/introduction.page:10
#: C/folder-mode.page:10 C/missing-functionality.page:10
#: C/command-line.page:10
#: C/folder-mode.page:10 C/missing-functionality.page:10 C/command-line.page:10
msgid "Kai Willadsen"
msgstr "Kai Willadsen"
......@@ -709,10 +708,10 @@ msgid ""
msgstr ""
"Název příkazu, který provede otevření textových souborů v externím editoru. "
"Stačí samotný příkaz (např. <cmd>gedit</cmd>), a otevíraný soubor je pak "
"předán jako poslední argument. Nebo případně můžete do příkazu přidat <code>"
"{file}</code> a <code>{line}</code>, které pak <app>Meld</app> nahradí "
"názvem souboru včetně cesty, respektive číslem aktuálního řádku. (např. "
"<cmd>gedit {file}:{line}</cmd>)."
"předán jako poslední argument. Nebo případně můžete do příkazu přidat "
"<code>{file}</code> a <code>{line}</code>, které pak <app>Meld</app> "
"nahradí názvem souboru včetně cesty, respektive číslem aktuálního řádku. "
"(např. <cmd>gedit {file}:{line}</cmd>)."
#. (itstool) path: terms/title
#: C/preferences.page:31
......@@ -1441,9 +1440,9 @@ msgid "Find the next instance of the string."
msgstr "Najít následující výskyt řetězce"
#. (itstool) path: td/p
#: C/keyboard-shortcuts.page:90 C/keyboard-shortcuts.page:96
msgid "<keyseq><key>Alt</key><key>Up</key></keyseq>"
msgstr "<keyseq><key>Alt</key><key>Up</key></keyseq>"
#: C/keyboard-shortcuts.page:90
msgid "<keyseq><key>Alt</key><key>Down</key></keyseq>"
msgstr "<keyseq><key>Alt</key><key></key></keyseq>"
#. (itstool) path: td/p
#: C/keyboard-shortcuts.page:91
......@@ -1454,6 +1453,11 @@ msgstr ""
"Přejít na následující rozdíl (také <keyseq><key>Ctrl</key><key>D</key></"
"keyseq>)"
#. (itstool) path: td/p
#: C/keyboard-shortcuts.page:96
msgid "<keyseq><key>Alt</key><key>Up</key></keyseq>"
msgstr "<keyseq><key>Alt</key><key>↑</key></keyseq>"
#. (itstool) path: td/p
#: C/keyboard-shortcuts.page:97
msgid ""
......
......@@ -139,10 +139,12 @@ class build_help(distutils.cmd.Command):
msgfmt = ['msgfmt', po_file, '-o', mo_file]
self.spawn(msgfmt)
for page in self.C_PAGES:
itstool = ['itstool', '-m', mo_file, '-o', build_path, page]
itstool = [
'itstool', '-m', mo_file, '-o', build_path, page]
self.spawn(itstool)
for extra in self.C_EXTRA:
extra_path = os.path.join(build_path, os.path.basename(extra))
extra_path = os.path.join(
build_path, os.path.basename(extra))
if os.path.exists(extra_path):
os.unlink(extra_path)
os.symlink(os.path.relpath(extra, source_path), extra_path)
......@@ -154,7 +156,8 @@ class build_help(distutils.cmd.Command):
path_help = os.path.join('share', 'help', lang, name)
path_figures = os.path.join(path_help, 'figures')
data_files.append((path_help, xml_files + mallard_files))
data_files.append((path_figures, glob.glob('%s/figures/*.png' % build_path)))
data_files.append(
(path_figures, glob.glob('%s/figures/*.png' % build_path)))
return data_files
......@@ -201,7 +204,8 @@ class build_icons(distutils.cmd.Command):
for category in glob.glob(os.path.join(size, "*")):
icons = (glob.glob(os.path.join(category, "*.png")) +
glob.glob(os.path.join(category, "*.svg")))
icons = [icon for icon in icons if not os.path.islink(icon)]
icons = [
icon for icon in icons if not os.path.islink(icon)]
if not icons:
continue
data_files.append(("%s/%s/%s/%s" %
......@@ -262,7 +266,7 @@ class build_i18n(distutils.cmd.Command):
max_po_mtime = 0
for po_file in glob.glob("%s/*.po" % self.po_dir):
lang = os.path.basename(po_file[:-3])
if selected_languages and not lang in selected_languages:
if selected_languages and lang not in selected_languages:
continue
mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
mo_file = os.path.join(mo_dir, "%s.mo" % self.domain)
......
......@@ -3,7 +3,7 @@ import os
import sys
__package__ = "meld"
__version__ = "3.15.0"
__version__ = "3.15.1"
# START; these paths are clobbered on install by meld.build_helpers
DATADIR = os.path.join(sys.prefix, "share", "meld")
......
......@@ -78,22 +78,19 @@ class DiffMap(Gtk.DrawingArea):
self.fill_colors, self.line_colors = get_common_theme()
def on_scrollbar_style_updated(self, scrollbar):
value = GObject.Value(int)
scrollbar.style_get_property("stepper-size", value)
stepper_size = value.get_int()
scrollbar.style_get_property("stepper-spacing", value)
stepper_spacing = value.get_int()
bool_value = GObject.Value(bool)
scrollbar.style_get_property("has-backward-stepper", bool_value)
has_backward = bool_value.get_boolean()
scrollbar.style_get_property("has-secondary-forward-stepper", bool_value)
has_secondary_forward = bool_value.get_boolean()
scrollbar.style_get_property("has-secondary-backward-stepper", bool_value)
has_secondary_backward = bool_value.get_boolean()
scrollbar.style_get_property("has-forward-stepper", bool_value)
has_foreward = bool_value.get_boolean()
steppers = [has_backward, has_secondary_forward, has_secondary_backward, has_foreward]
stepper_size = scrollbar.style_get_property("stepper-size")
stepper_spacing = scrollbar.style_get_property("stepper-spacing")
has_backward = scrollbar.style_get_property("has-backward-stepper")
has_secondary_backward = scrollbar.style_get_property(
"has-secondary-backward-stepper")
has_secondary_forward = scrollbar.style_get_property(
"has-secondary-forward-stepper")
has_forward = scrollbar.style_get_property("has-forward-stepper")
steppers = [
has_backward, has_secondary_backward,
has_secondary_forward, has_forward,
]
offset = stepper_size * steppers[0:2].count(True)
shorter = stepper_size * steppers.count(True)
......@@ -107,7 +104,8 @@ class DiffMap(Gtk.DrawingArea):
self.queue_draw()
def on_scrollbar_size_allocate(self, scrollbar, allocation):
self._scroll_y = allocation.y
translation = scrollbar.translate_coordinates(self, 0, 0)
self._scroll_y = translation[1] if translation else 0
self._scroll_height = allocation.height
self._width = max(allocation.width, 10)
self._cached_map = None
......@@ -117,7 +115,7 @@ class DiffMap(Gtk.DrawingArea):
if not self._setup:
return
height = self._scroll_height - self._h_offset - 1
y_start = self._scroll_y - self.get_allocation().y - self._y_offset + 1
y_start = self._scroll_y + self._y_offset + 1
width = self.get_allocated_width()
xpad = 2.5
x0 = xpad
......
......@@ -63,7 +63,7 @@ class Differ(GObject.GObject):
__gsignals__ = {
'diffs-changed': (GObject.SignalFlags.RUN_FIRST, None,
(object,)),
(object,)),
}
_matcher = MyersSequenceMatcher
......@@ -296,14 +296,14 @@ class Differ(GObject.GObject):
def offset(c, o1, o2):
return DiffChunk._make((c[0], c[1] + o1, c[2] + o1,
c[3] + o2, c[4] + o2))
c[3] + o2, c[4] + o2))
newdiffs = self._matcher(None, lines1, linesx).get_difference_opcodes()
newdiffs = [offset(c, range1[0], rangex[0]) for c in newdiffs]
if hiidx < len(self.diffs[which]):
offset_diffs = [offset(c, lines_added[1], lines_added[x]) for c
in self.diffs[which][hiidx:]]
offset_diffs = [offset(c, lines_added[1], lines_added[x])
for c in self.diffs[which][hiidx:]]
self.diffs[which][hiidx:] = offset_diffs
self.diffs[which][loidx:hiidx] = newdiffs
......
......@@ -753,17 +753,37 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
None, True)
self.queue_draw()
def _filter_text(self, txt):
def _filter_text(self, txt, buf, start_iter, end_iter):
dimmed_tag = buf.get_tag_table().lookup("dimmed")
buf.remove_tag(dimmed_tag, start_iter, end_iter)
start = start_iter.copy()
end = start_iter.copy()
def killit(m):
assert m.group().count("\n") == 0
if len(m.groups()):
s = m.group()
for g in m.groups():
for i in reversed(range(1, len(m.groups())+1)):
g = m.group(i)
if g:
s = s.replace(g,"")
start.forward_chars(m.start(i))
end.forward_chars(m.end(i))
buf.apply_tag(dimmed_tag, start, end)
start.forward_chars(-m.start(i))
end.forward_chars(-m.end(i))
s = s[:m.start(i)-m.start()]+s[m.end(i)-m.start():]
return s
else:
start.forward_chars(m.start())
end.forward_chars(m.end())
buf.apply_tag(dimmed_tag, start, end)
start.forward_chars(-m.start())
end.forward_chars(-m.end())
return ""
try:
for filt in self.text_filters:
if filt.active:
......@@ -841,7 +861,8 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
messagetype=Gtk.MessageType.QUESTION)
if resolve_response == Gtk.ResponseType.OK:
conflict_file = self.textbuffer[1].data.filename
bufdata = self.textbuffer[1].data
conflict_file = bufdata.savefile or bufdata.filename
parent.command('resolve', [conflict_file])
elif response == Gtk.ResponseType.CANCEL:
self.state = melddoc.STATE_NORMAL
......
......@@ -39,7 +39,7 @@ class MeldGutterRenderer(object):
def on_setting_changed(self, meldsettings, key):
if key == 'style-scheme':
#meldsettings.style_scheme
# meldsettings.style_scheme
self.fill_colors, self.line_colors = get_common_theme()
def draw_chunks(
......
......@@ -56,7 +56,8 @@ class LinkMap(Gtk.DrawingArea):
allocation = self.get_allocation()
pix_start = [t.get_visible_rect().y for t in self.views]
y_offset = [t.translate_coordinates(self, 0, 0)[1] + 1 for t in self.views]
y_offset = [
t.translate_coordinates(self, 0, 0)[1] + 1 for t in self.views]
clip_y = min(y_offset) - 1
clip_height = max(t.get_visible_rect().height for t in self.views) + 2
......
......@@ -428,7 +428,7 @@ class SyncPointMyersSequenceMatcher(MyersSequenceMatcher):
tag = 'insert'
if tag:
opcodes.append((tag, i, ai, j, bj))
i, j = ai+size, bj+size
i, j = ai + size, bj + size
# the list of matching blocks is terminated by a
# sentinel with size 0
if size:
......
......@@ -98,7 +98,7 @@ class MeldApp(Gtk.Application):
def do_window_removed(self, widget):
widget.meldwindow = None
Gtk.Application.do_window_removed(self, widget)
if not self.get_windows():
if not len(self.get_windows()):
self.quit()
# We can't override do_local_command_line because it has no introspection
......
......@@ -123,7 +123,7 @@ class MeldBufferData(GObject.GObject):
@property
def label(self):
#TRANSLATORS: This is the label of a new, currently-unnamed file.
# TRANSLATORS: This is the label of a new, currently-unnamed file.
return self._label or _(u"<unnamed>")
@label.setter
......@@ -238,7 +238,7 @@ class BufferLines(object):
end = self.buf.get_iter_at_line_or_eof(hi)
txt = text_type(self.buf.get_text(start, end, False), 'utf8')
filter_txt = self.textfilter(txt)
filter_txt = self.textfilter(txt, self.buf, start, end)
lines = filter_txt.splitlines()
ends = filter_txt.splitlines(True)
......@@ -284,7 +284,8 @@ class BufferLines(object):
if not line_end.ends_line():
line_end.forward_to_line_end()
txt = self.buf.get_text(line_start, line_end, False)
return text_type(self.textfilter(txt), 'utf8')
txt_filtered = self.textfilter(txt, self.buf, line_start, line_end)
return text_type(txt_filtered, 'utf8')
def __len__(self):
return self.buf.get_line_count()
......
......@@ -138,8 +138,9 @@ class MeldWindow(gnomeglade.Component):
self.actiongroup.add_actions(actions)
self.actiongroup.add_toggle_actions(toggleactions)
recent_action = Gtk.RecentAction(name="Recent", label=_("Open Recent"),
tooltip=_("Open recent files"), stock_id=None)
recent_action = Gtk.RecentAction(
name="Recent", label=_("Open Recent"),
tooltip=_("Open recent files"), stock_id=None)
recent_action.set_show_private(True)
recent_action.set_filter(recent_comparisons.recent_filter)
recent_action.set_sort_type(Gtk.RecentSortType.MRU)
......@@ -254,6 +255,14 @@ class MeldWindow(gnomeglade.Component):
self.widget.connect('focus_in_event', self.on_focus_change)
self.widget.connect('focus_out_event', self.on_focus_change)
# Set tooltip on map because the recentmenu is lazily created
rmenu = self.ui.get_widget('/Menubar/FileMenu/Recent').get_submenu()
rmenu.connect("map", self._on_recentmenu_map)
def _on_recentmenu_map(self, recentmenu):
for imagemenuitem in recentmenu.get_children():
imagemenuitem.set_tooltip_text(imagemenuitem.get_label())
def on_focus_change(self, widget, event, callback_data=None):
for idx in range(self.notebook.get_n_pages()):
w = self.notebook.get_nth_page(idx)
......@@ -558,7 +567,9 @@ class MeldWindow(gnomeglade.Component):
label = label.replace("_", "__")
name = "SwitchTab%d" % i
tooltip = _("Switch to this tab")
action = Gtk.RadioAction(name=name, label=label, tooltip=tooltip, stock_id=None, value=i)
action = Gtk.RadioAction(
name=name, label=label, tooltip=tooltip,
stock_id=None, value=i)
action.join_group(group)
group = action
action.set_active(current_page == i)
......@@ -651,7 +662,7 @@ class MeldWindow(gnomeglade.Component):
doc.on_button_diff_clicked(None)
return doc
def append_filediff(self, files, merge_output=None, meta=None):
def append_filediff(self, files, merge_output=None, meta=None):
assert len(files) in (1, 2, 3)
doc = filediff.FileDiff(len(files))
self._append_page(doc, "text-x-generic")
......
......@@ -20,7 +20,7 @@ from . import matchers
class AutoMergeDiffer(diffutil.Differ):
_matcher = matchers.MyersSequenceMatcher
# _matcher = PatienceSequenceMatcher
# _matcher = PatienceSequenceMatcher
def __init__(self):
diffutil.Differ.__init__(self)
......
......@@ -413,7 +413,7 @@ def shell_to_regex(pat):
res += r'\['
else:
stuff = pat[i:j]
i = j+1
i = j + 1
if stuff[0] == '!':
stuff = '^%s' % stuff[1:]
elif stuff[0] == '^':
......@@ -426,7 +426,7 @@ def shell_to_regex(pat):
res += '\\{'
else:
stuff = pat[i:j]
i = j+1
i = j + 1
res += '(%s)' % "|".join(
[shell_to_regex(p)[:-1] for p in stuff.split(",")]
)
......
......@@ -17,6 +17,7 @@
import difflib
import os
from gi.repository import Gdk
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import Gtk
......@@ -90,11 +91,16 @@ class PatchDialog(gnomeglade.Component):
names = [self.filediff.textbuffer[i].data.label for i in range(3)]
prefix = os.path.commonprefix(names)
names = [n[prefix.rfind("/") + 1:] for n in names]
# difflib doesn't handle getting unicode file labels
names = [n.encode('utf8') for n in names]
buf = self.textview.get_buffer()
text0, text1 = texts[indices[0]], texts[indices[1]]
name0, name1 = names[indices[0]], names[indices[1]]
diff_text = "".join(difflib.unified_diff(text0, text1, name0, name1))
diff = difflib.unified_diff(text0, text1, name0, name1)
unicodeify = lambda x: x.decode('utf8') if isinstance(x, str) else x
diff_text = "".join(unicodeify(d) for d in diff)
buf.set_text(diff_text)
def save_patch(self, filename):
......@@ -133,8 +139,8 @@ class PatchDialog(gnomeglade.Component):
if result == 1:
buf = self.textview.get_buffer()
start, end = buf.get_bounds()
clip = Gtk.Clipboard.get()
clip.set_text(buf.get_text(start, end, False))
clip = Gtk.Clipboard.get_default(Gdk.Display.get_default())
clip.set_text(buf.get_text(start, end, False), -1)
clip.store()
# Save patch as a file
else:
......
......@@ -98,7 +98,8 @@ class RecentFiles(object):
comparison_key = (comp_type, tuple(paths))
paths = [unicodeify(p) for p in paths]
if comparison_key in self._stored_comparisons:
gio_file = Gio.File.new_for_uri(self._stored_comparisons[comparison_key])
gio_file = Gio.File.new_for_uri(