Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Add support for Evince with SyncTex #225

Merged
merged 7 commits into from
Sep 22, 2016
Merged

Add support for Evince with SyncTex #225

merged 7 commits into from
Sep 22, 2016

Conversation

yitzchak
Copy link
Collaborator

@yitzchak yitzchak commented Sep 18, 2016

This PR addresses #162. It is currently a bit of callback hell, but SyncTeX forward and backward are working.

Remaining issues

  • Determine if dbus.sessionBus() needs to be disposed of. It does not, although if we allow the user to change the opener we may need to call removeListener
  • It should be possible to listen to all Evince instances and respond to SyncSource even if a build has not been done yet by listening to add_signal_receiver, but I have not been able figure out how do this using dbus-native. The current functionality matches that of okular, etc. It's done with addMatch but it seems useless, since Evince does not start sending SyncSource until it receives SyncView.
  • Improve the opener logic. Evince is only called if Okular is not present. Maybe the user should be able to choose? I'll do it in another PR
  • Test on old versions of Evince. dbus does not appear to be versioned like COM. The GNOME team added timestamp parameter to SyncView in version 2.91.0. If we do not pass this parameter (zero works) then current versions break. Passing this parameter may cause old versions to break, so we may need to inspect the method signature. Evince 2.91.0 was released in 2011, so I think we are okay assuming the s(ii)u signature.
  • Investigate support for opening in foreground vs. background. Done, although SyncView seems a little fickle about window activation so it may not be perfect.

@yitzchak yitzchak changed the title Add suport for Evince with SyncTex Add support for Evince with SyncTex Sep 18, 2016
import dbus from 'dbus-native'
import url from 'url'

function SyncSource (uri, point) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I'm missing something, this should be syncSource

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not. I'll fix it.

if (callback) callback(error)
})
}
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really need to hide all the callback stuff behind promises. Let's move to the async future ⚡

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in latest commit.


getDaemon (callback) {
if (this.daemon) return callback(null, this.daemon)
this.bus.getInterface('org.gnome.evince.Daemon', '/org/gnome/evince/Daemon', 'org.gnome.evince.Daemon',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what these strings mean. Can we extract them as constants with meaningful names?

Copy link
Collaborator Author

@yitzchak yitzchak Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are the object and interface names. I'll attach constants to them.

windowInterface.on('Closed', () => delete this.windows[texPath])
// Hack: a small wait seems to help when the document is opened for the
// first time.
setTimeout(() => callback(null, windowInterface), 200)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't like this. Is there some way we can avoid this? Using some kind of polling maybe? This is almost guaranteed to cause problems under heavy workloads, on a slow computer, or what not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I am going to remove it and see what happens.

Copy link
Owner

@thomasjo thomasjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@yitzchak yitzchak merged commit e861f94 into master Sep 22, 2016
@yitzchak yitzchak deleted the evince branch September 22, 2016 10:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants