Hello. I'm trying to get the inverse search to work with gedit/latex plugin/xdvi.
Compiling to DVI seems to work OK. Xdvi comes up and does not complain about missing Source Spesials when I CTRL left-click in the DVI file. However, nothing happens when I do so, gedit does not skip to another line in the latex-file.
When trying the dbus-send command manually in an xterm, with an extra --print-reply option, I get the following error message:
dbus-send --type=method_call --print-reply --dest=org.gedit.LaTeXPlugin /org/gedit/DBusInterface org.gedit.LaTeXPluginIFace.inverse string:SNLS2.tex int32:10
Error org.freedesktop.DBus.Python.exceptions.AttributeError: Traceback (most recent call last):
File "/var/lib/python-support/python2.4/dbus/service.py", line 696, in _message_cb
retval = candidate_method(self, *args, **keywords)
File "/home/tmac/.gnome2/gedit/plugins/LaTeXPlugin/ipc/DBusController.py", line 45, in inverse
self.__instance.set_active_tab_by_filename(filename)
AttributeError: 'WindowHelper' object has no attribute 'set_active_tab_by_filename'
I'm using Debian Unstable, Latex Pluging v0.1.3.1, gedit v2.20.4-1
Best regards
Torquil Sørensen
Logged In: YES
user_id=1016811
Originator: NO
Thanks for reporting, I've filed this as a bug...
Michael
Logged In: YES
user_id=1944614
Originator: NO
I was investigating the same issue and I'd like to add that substituting the dbus-send command with simply 'gedit' makes the inverse search work. Just a temporary hack, I know, but at list it works.
Best,
guido
Logged In: YES
user_id=2051545
Originator: NO
Hi, here are two patches fixing the problem for me (with LaTeXPlugin-0.1.3.1 and gedit-2.20.3) with (at least I suppose from the initial code) two features more:
1) the line corresponding to the point clicked on in the dvi is highlighted in the source, instead of just having the cursor on it;
2) the gedit window is pulled to the front.
I don't know if I achieved this the "correct" way, as I'm really new to PyGTK and to LaTeXPlugin, which is definitely not a ten-lines plugin, but at least it works!
Many thanks to Michael for this really great plugin! It is really useful.
Best regards,
Yannick Voglaire
PS: I dont know how to attach files so here are the patches:
---------------- DBusController.patch ----------------
--- DBusController.py
+++ DBusController.py.modif
@@ -23,6 +23,8 @@
BUS_NAME = 'org.gedit.LaTeXPlugin'
OBJECT_PATH = '/org/gedit/DBusInterface'
+DVI_INVERSE_SEARCH = 2 # 0, 1 are ERROR, WARNING in builder/Messages.py
+
try:
from dbus import SessionBus
from dbus.service import Object, method, BusName
@@ -42,9 +44,16 @@
def inverse(self, filename, line):
debug(self, "Got inverse DVI search: %s %s" % (filename, line))
- self.__instance.set_active_tab_by_filename(filename)
- wrapper = self.__instance.get_active_wrapper()
- wrapper.select_line(line - 1)
+ tab = self.__instance.window.get_tab_from_uri(filename)
+ self.__instance.window.set_active_tab(tab)
+
+ helper = self.__instance.document_helper_manager.find_helper(filename)
+ helper.jump_to_line(line - 1)
+
+ helper.language_helper.reset_dvi_highlight()
+ helper.language_helper.highlight_line(line-1, DVI_INVERSE_SEARCH)
+
+ self.__instance.window.present()
except ImportError:
error(self, None, "Failed to import D-Bus bindings")
---------------- LatexLanguageHelper.patch ----------------
--- LatexLanguageHelper.py
+++ LatexLanguageHelper.py.modif
@@ -28,10 +28,12 @@
from LaTeXPlugin.autocomplete.Controller import Controller
from LaTeXPlugin.common import TEXT, MATH, ConditionalSource, PrefaceSource
from LaTeXPlugin.builder.Message import ERROR, WARNING
+from LaTeXPlugin.ipc.DBusController import DVI_INVERSE_SEARCH
from LaTeXPlugin.bibtex.BibTeXFile import BibTeXFile
ERROR_COLOR = "#ffe6e6"
WARNING_COLOR = "#fff2cc"
+DVI_INVERSE_SEARCH_COLOR = "#edf2ff"
_pattern_indent = compile("[ \t]+")
@@ -51,6 +53,7 @@
try:
self.__buffer.create_tag("error", background=ERROR_COLOR)
self.__buffer.create_tag("warning", background=WARNING_COLOR)
+ self.__buffer.create_tag("dvi_inverse_search", background=DVI_INVERSE_SEARCH_COLOR)
except TypeError, s:
# FIXME: this happens when deactivating and reactivating the plugin
error(self, "__init__", s)
@@ -337,6 +340,8 @@
if severity == WARNING:
self.__buffer.apply_tag_by_name("warning", iter_l, iter_r)
+ elif severity == DVI_INVERSE_SEARCH:
+ self.__buffer.apply_tag_by_name("dvi_inverse_search", iter_l, iter_r)
else:
self.__buffer.apply_tag_by_name("error", iter_l, iter_r)
@@ -349,6 +354,17 @@
self.__buffer.remove_tag_by_name("error", self.__buffer.get_start_iter(),
self.__buffer.get_end_iter())
self.__buffer.remove_tag_by_name("warning", self.__buffer.get_start_iter(),
+ self.__buffer.get_end_iter())
+ self.__buffer.remove_tag_by_name("dvi_inverse_search", self.__buffer.get_start_iter(),
+ self.__buffer.get_end_iter())
+
+ def reset_dvi_highlight(self):
+ """
+ Undo dvi inverse search highlighting
+
+ Called at inverse from DBusInterface
+ """
+ self.__buffer.remove_tag_by_name("dvi_inverse_search", self.__buffer.get_start_iter(),
self.__buffer.get_end_iter())
@property
Logged In: YES
user_id=1016811
Originator: NO
Thanks for your patch, I think I'll use it for the next release...
Michael