Re: Embedding FileDiff in another application - next problem



Hi Szilveszter, (I meant to keep this discussion on meld-list!)

Ah, the deferred execution is catching you out. Each doc has a
scheduler which does some work when the app is otherwise idle. So
set_files doesn't actually do anything until the gtk idle callbacks
happen.

Call doc.scheduler.complete_tasks() to flush the work queue before
calling set_editable. Or you might prefer to add a task to the docs
scheduler so that your app won't block reading the files before the
gui comes up. You can add any callable.
e.g. doc.scheduler.add_task( lambda : [t.set_editable(False) for t in
doc.textview] )

Stephen.

On 5/24/07, Szilveszter Farkas <szilveszter farkas gmail com> wrote:
> I see meld calls set_editable when loading files which is probably
> overriding your setting. Perhaps you can modify
> _{dis,}connect_buffer_handlers to save/restore the editable state?

The problem is that I call the set_editable() methods after setting the files:

---
#!/usr/bin/python

import sys

import pygtk
import gtk

import gettext
gettext.install('meld')

# Adding meld's stuff to the path
sys.path += [ '/usr/lib/meld' ]

import filediff
import meldapp
import prefs

files = [ 'old.txt', 'new.txt' ]

app = meldapp.MeldApp()
app.widget.hide()

window = gtk.Window()
doc = filediff.FileDiff(app.prefs, len(files))

def cleanup():
    app.scheduler.remove_scheduler(doc.scheduler)

app.scheduler.add_task(cleanup)
app.scheduler.add_scheduler(doc.scheduler)

doc.set_files(files)

# Hide file entries (no need for them)
doc.fileentry0.hide()
doc.fileentry1.hide()
# TextViews shouldn't be editable
print "DEBUG: textview0.editable =", doc.textview0.get_editable()
print "DEBUG: textview1.editable =", doc.textview1.get_editable()
doc.textview0.set_editable(False)
doc.textview1.set_editable(False)
print "DEBUG: textview0.editable =", doc.textview0.get_editable()
print "DEBUG: textview1.editable =", doc.textview1.get_editable()

window.add(doc.widget)
window.connect('delete-event', gtk.main_quit)
window.show()

gtk.main()
---

If you run the script above, the editable properties get set to False,
but the TextViews are still editable...

Thanks for your help,
Szilveszter




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]