=?windows-1252?Q?Re=3A_=5BPATCHES=5D=5BRFC=5D_Bug_458372_=96_explicit_message_i?= =?windows-1252?Q?f_files=2Fdirectories_are_the_same?=
- From: Vincent Legoll <vincent legoll gmail com>
- To: meld-list <meld-list gnome org>
- Subject: Re: [PATCHES][RFC] Bug 458372 – explicit message if files/directories are the same
- Date: Sun, 19 Apr 2009 22:50:25 +0200
On Fri, Apr 17, 2009 at 5:59 PM, Vincent Legoll
<vincent legoll gmail com> wrote:
> Here is a patch serie that fix this bug for filediffs
>
> - pass meldapp pointer to melddoc instances (may become obsolete with
> Kai's singleton app work...)
> - allow to modify meldapp's actions sensitivity
> - change up/down buttons sensitivity depending depending on actual
> quantity of diffs
>
> this seems to be working for at least 2-way filediffs
>
> comments ?
OK another time, with patches...
--
Vincent Legoll
Index: vcview.py
===================================================================
--- vcview.py (revision 1351)
+++ vcview.py (working copy)
@@ -116,8 +116,8 @@
"VcRevert": ("revert_command", ()),
}
- def __init__(self, prefs):
- melddoc.MeldDoc.__init__(self, prefs)
+ def __init__(self, prefs, app):
+ melddoc.MeldDoc.__init__(self, prefs, app)
gnomeglade.Component.__init__(self, paths.share_dir("glade2/vcview.glade"), "vcview")
actions = (
Index: dirdiff.py
===================================================================
--- dirdiff.py (revision 1351)
+++ dirdiff.py (working copy)
@@ -165,8 +165,8 @@
class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
"""Two or three way diff of directories"""
- def __init__(self, prefs, num_panes):
- melddoc.MeldDoc.__init__(self, prefs)
+ def __init__(self, prefs, num_panes, app):
+ melddoc.MeldDoc.__init__(self, prefs, app=app)
gnomeglade.Component.__init__(self, paths.share_dir("glade2/dirdiff.glade"), "dirdiff")
actions = (
Index: melddoc.py
===================================================================
--- melddoc.py (revision 1351)
+++ melddoc.py (working copy)
@@ -35,7 +35,7 @@
'status-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
}
- def __init__(self, prefs):
+ def __init__(self, prefs, app):
gobject.GObject.__init__(self)
self.undosequence = undo.UndoSequence()
self.undosequence_busy = 0
@@ -44,6 +44,7 @@
self.prefs.notify_add(self.on_preference_changed)
self.num_panes = 0
self.label_text = _("untitled")
+ self.app = app
def save(self):
pass
Index: filediff.py
===================================================================
--- filediff.py (revision 1351)
+++ filediff.py (working copy)
@@ -54,10 +54,10 @@
gtk.keysyms.Shift_R : MASK_SHIFT,
gtk.keysyms.Control_R : MASK_CTRL}
- def __init__(self, prefs, num_panes):
+ def __init__(self, prefs, num_panes, app):
"""Start up an filediff with num_panes empty contents.
"""
- melddoc.MeldDoc.__init__(self, prefs)
+ melddoc.MeldDoc.__init__(self, prefs, app=app)
gnomeglade.Component.__init__(self, paths.share_dir("glade2/filediff.glade"), "filediff", srcviewer.override)
self.map_widgets_into_lists( ["textview", "fileentry", "diffmap", "scrolledwindow", "linkmap", "statusimage"] )
self._update_regexes()
Index: meldapp.py
===================================================================
--- meldapp.py (revision 1351)
+++ meldapp.py (working copy)
@@ -830,7 +830,7 @@
def append_dirdiff(self, dirs, auto_compare=False):
assert len(dirs) in (1,2,3)
- doc = dirdiff.DirDiff(self.prefs, len(dirs))
+ doc = dirdiff.DirDiff(self.prefs, len(dirs), app=self)
self._append_page(doc, "tree-folder-normal.png")
doc.set_locations(dirs)
# FIXME: This doesn't work, as dirdiff behaves differently to vcview
@@ -840,7 +840,7 @@
def append_filediff(self, files):
assert len(files) in (1,2,3)
- doc = filediff.FileDiff(self.prefs, len(files))
+ doc = filediff.FileDiff(self.prefs, len(files), app=self)
seq = doc.undosequence
seq.clear()
seq.connect("can-undo", self.on_can_undo)
@@ -864,7 +864,7 @@
def append_vcview(self, locations, auto_compare=False):
assert len(locations) in (1,)
location = locations[0]
- doc = vcview.VcView(self.prefs)
+ doc = vcview.VcView(self.prefs, app=self)
self._append_page(doc, "vc-icon.png")
doc.set_location(location)
if auto_compare:
Index: meldapp.py
===================================================================
--- meldapp.py (revision 1351)
+++ meldapp.py (working copy)
@@ -790,6 +790,9 @@
self.append_filediff( ("ntest/file%ia"%i, "ntest/file%ib"%i) )
#self.append_filediff( ("ntest/file9a", "ntest/file9b") )
+ def update_action_sensitivity(self, action, sensitivity):
+ self.actiongroup.get_action(action).props.sensitive = sensitivity
+
def on_menu_edit_down_activate(self, *args):
self.current_doc().next_diff(gtk.gdk.SCROLL_DOWN)
Index: filediff.py
===================================================================
--- filediff.py (revision 1351)
+++ filediff.py (working copy)
@@ -134,6 +134,7 @@
melddoc.MeldDoc.on_container_switch_in_event(self, ui)
if self.textview_focussed:
self.scheduler.add_task(self.textview_focussed.grab_focus)
+ self._update_up_down_sensitivity()
def _update_regexes(self):
self.regexes = []
@@ -191,6 +192,7 @@
pass
self.queue_draw()
self._update_cursor_status(buffer)
+ self._update_up_down_sensitivity()
def _get_texts(self, raw=0):
class FakeText(object):
@@ -582,7 +584,8 @@
step = self.linediffer.set_sequences_iter(*lines)
while step.next() == None:
yield 1
- self.scheduler.add_task( lambda: self.next_diff(gdk.SCROLL_DOWN, jump_to_first=True), True )
+ if self._update_up_down_sensitivity():
+ self.scheduler.add_task( lambda: self.next_diff(gdk.SCROLL_DOWN, jump_to_first=True), True )
self.queue_draw()
lenseq = [len(d) for d in self.linediffer.diffs]
self.scheduler.add_task( self._update_highlighting( (0,lenseq[0]), (0,lenseq[1]) ).next )
@@ -593,6 +596,15 @@
srcviewer.set_highlighting_enabled_from_file(self.textbuffer[i], files[i], self.prefs.use_syntax_highlighting)
yield 0
+ def _update_up_down_sensitivity(self):
+ tot = 0
+ for x in self.linediffer.diffs:
+ tot += len(x)
+ sensitivity = tot != 0
+ for b in ("Up", "Down"):
+ self.app.update_action_sensitivity(b, sensitivity)
+ return sensitivity
+
def _update_highlighting(self, range0, range1):
for b in self.textbuffer:
taglist = ["delete line", "conflict line", "replace line", "inline line"]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]