Feature request: Get current page of file using dbus

Asked by iBart

I am looking to write a plugin for my text editor so that I'd be able take notes for pdfs using that text editor.

I want to get the current page for a certain file in the plugin, so that I can go to the note corresponding to that page.
This is already possible: the current page is stored in the sqlite database.
However, the 'save database interval' is too long: 1 minute, this needs to be 1 second to be usable.
I'm also not quite sure if this is the right way to go, since the filePath in the database is not readable and I'm not quite sure what it represents.

Therefore, I am making a feature request that the current page (of a certain file, filepath given as argument) is made accessible using dbus.

Question information

Language:
English Edit question
Status:
Solved
For:
qpdfview Edit question
Assignee:
No assignee Edit question
Solved by:
Adam Reichold
Solved:
Last query:
Last reply:
Revision history for this message
Adam Reichold (adamreichold) said :
#1

Hello,

The per_file_settings table in the database is not really meant for this purpose: As you already found out, the file path column is actually a hash of the file path so that this table does not act as a kind of accidental history of opened documents as the hash is enough to look up the settings when the file is opened.

I also think that the D-Bus interface is definitely the right place for this to go and will update it as soon as I can to include a "currentPage" method supplying either the current page of the current tab or -1 if not tab is available.

Best regards, Adam.

P.S.: You can also trigger saving the database via the D-Bus interface using the "saveDatabase" method.

Revision history for this message
Best Adam Reichold (adamreichold) said :
#2

Should be available in trunk...

Revision history for this message
iBart (bart-) said :
#3

Dear Adam,

Thanks for your blazingly fast response to this feature request.

Although it's not exactly what I had in mind (I thought about supplying the filePath as argument), this works too if I call jumpToPageOrOpenInNewTab before calling currentPage.

Just a note on the side: as far as I know qpdfview's API is an unique amongst pdf readers, which is one of the things that makes it really great.
I also believe that there are many more interesting features to expand the API with.
Things that come to mind are: query for amount of tabs open, get currently selected tab #, select active tab #, query file(path) open in tab.

I hope you don't mind me suggesting something else (perhaps the form of a code import) in this area in the future. :)

Revision history for this message
iBart (bart-) said :
#4

Thanks Adam Reichold, that solved my question.

Revision history for this message
Adam Reichold (adamreichold) said :
#5

Hello again,

the API was initially designed with qpdfview as its only user it is definitely incomplete and I am rather happy about suggestions on how it can be made more useful to separate applications. A wishlist bug detailing or even specifying the intended changes is probably the better format and can also easily be converted or linked to a merge request if an implementation is available for inclusion into qpdfview's trunk. An API to query and manage the open tabs also seems like a reasonable place to start IMHO...

Best regards, Adam.