Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Sigil > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 12-04-2014, 08:19 AM   #76
turbulent
Member
turbulent began at the beginning.
 
Posts: 14
Karma: 10
Join Date: May 2014
Device: kindle paperwhite
Quote:
Originally Posted by Doitsu View Post
If you have a Windows machine, you could use the win32gui library to find the Sigil title bar text. Here's a quick & dirty solution:

Code:
import win32gui
from win32gui import GetWindowText
class_name = 'Qt5QWindowIcon'
window_name = None
hwnd = win32gui.FindWindow(class_name, window_name)

if hwnd:
    print GetWindowText(hwnd)
    # returns 'untitled.epub - Sigil'
Note that this simple code will return the title bar text of the Qt app that was opened last. I.e. if you open multiple Sigil windows, you'll only get the title bar text of the last window and if you open Calibre (or any other Qt5 app) after Sigil, you'll get the Calibre title bar text.

For a more robust solution, you'll need to enumerate all windows using win32gui.EnumWindows.
When I run the code in your post, I got 'Plugin Runner' instead. It's really a dirty solution. And I doubt whether the method of enumerating all windows could get the right title I need.

Thanks anyway.
turbulent is offline   Reply With Quote
Old 12-04-2014, 08:45 AM   #77
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by turbulent View Post
And I doubt whether the method of enumerating all windows could get the right title I need.
O ye of little faith?

If only one instance of Sigil is running, enumerating all windows will definitely get you the right title. For example, this code that I stole from stack overflow works just fine:

Code:
#!/usr/bin/env python
import ctypes

def run(bk):
 
    EnumWindows = ctypes.windll.user32.EnumWindows
    EnumWindowsProc = ctypes.WINFUNCTYPE(ctypes.c_bool, ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_int))
    GetWindowText = ctypes.windll.user32.GetWindowTextW
    GetWindowTextLength = ctypes.windll.user32.GetWindowTextLengthW
    IsWindowVisible = ctypes.windll.user32.IsWindowVisible
     
    titles = []
    def foreach_window(hwnd, lParam):
        if IsWindowVisible(hwnd):
            length = GetWindowTextLength(hwnd)
            buff = ctypes.create_unicode_buffer(length + 1)
            GetWindowText(hwnd, buff, length + 1)
            if buff.value.find('Sigil') > 0:
                titles.append(buff.value)
        return True
    EnumWindows(EnumWindowsProc(foreach_window), 0)
     
    print(titles)    

    return 0

def main():
    print('I reached main when I should not have\n')
    return -1

if __name__ == "__main__":
    sys.exit(main())
Doitsu is offline   Reply With Quote
Advert
Old 12-04-2014, 03:46 PM   #78
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
Quote:
Originally Posted by KevinH View Post
Hi eschwartz,

I guess I could use it, but they only would work for unix/linux and not Windows. I'll think about it for the next time.

Thanks,

Kevin
Well, I figured 2 out of three is better than 1 out of 3.

And I found something for Windows too, but it's ugly.

https://stackoverflow.com/questions/...age-on-windows
eschwartz is offline   Reply With Quote
Old 12-05-2014, 11:41 AM   #79
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi All,

DiapDealer has figured out a way to make the launcher_updater_20141204.zip actually run by running python directly on the zip file!!!!

So there is now a completely new version of the launcher_updater_20141204.zip up there. The payload is exactly the same as all previous versions See the second post.

Special thanks to DiapDealer for his great work on this!

Thanks,

KevinH


ps. After some discussion we have decided not to force use of sudo, so that Linux and Mac OS X users that install Sigil locally (inside their own home directory) do not have to needlessly run sudo which reduces any possibility of potential misuse.

If it has permissions, it will properly write the files, if not, you will see a clear message of what it tried to install and where, and you can then decide if you want to run sudo or not to let it do its own thing. Ditto for Administrator command line prompts on Windows.

Last edited by KevinH; 12-05-2014 at 11:45 AM.
KevinH is offline   Reply With Quote
Old 12-05-2014, 12:21 PM   #80
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
I have tested the new updater with the official 64bit Windows build and DiapDealer's 64bit Linux build and it worked as designed when executed as root/admin.

For testing purposes, I also repeated the test without root/admin rights. It initially failed but then displayed a folder selection dialog box only to fail again afterwards even if the correct folder was selected.
Maybe it should completely fail at this point and ask the user whether they are root or have admin rights, because the chances of users using non-standard install folders is relatively slim and those users are presumably knowledgeable enough to manually update the launcher files.
Doitsu is offline   Reply With Quote
Advert
Old 12-05-2014, 12:35 PM   #81
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi Doitsu,

I guess it depends on what types of systems you are used to working on. Here at my university many students who do research share accounts on a school cluster but have no permissions to install anything outside of their home and so they often install packages and software and in their own home directory. They can not be root/admin as they are not provided with that.

The launcher_updater_20141204.zip was designed to search "standard locations" that typically would require admin/root privs but not always. If that fails, it opens a gui for the user to navigate to his own copy where-ever it may be in his own home or area, or on an external volume or usb key or a dev folder or net drive or wherever?. Once selected, the installer should run just fine for them without need for sudo/root/admin privs.

I could of course skip that part for Windows users as this case probably never arises for them, but it is often found at universities, shared web services/companies, on company servers, on locked down boot systems who run linux / unix shared systems under a separate administrator. Many student developers at our university are faced with exactly this situation when at school.

I hope this explains the reasoning for why the gui comes up. It is to allow the user one more chance to find the proper location if the user's set-up is at all unique in any way. It is not meant just to retry what just failed. If you so desire you can simply hit "Cancel" when it comes up and the installer will stop.

Take care,

KevinH

Quote:
Originally Posted by Doitsu View Post
I have tested the new updater with the official 64bit Windows build and DiapDealer's 64bit Linux build and it worked as designed when executed as root/admin.

For testing purposes, I also repeated the test without root/admin rights. It initially failed but then displayed a folder selection dialog box only to fail again afterwards even if the correct folder was selected.
Maybe it should completely fail at this point and ask the user whether they are root or have admin rights, because the chances of users using non-standard install folders is relatively slim and those users are presumably knowledgeable enough to manually update the launcher files.
KevinH is offline   Reply With Quote
Old 12-05-2014, 01:30 PM   #82
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Hey, cool! Glad it's working.
DiapDealer is offline   Reply With Quote
Old 12-05-2014, 03:35 PM   #83
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,038
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
For Windows users who may be unaware of how to start an administrator (elevated privileges) command prompt ... one of the easiest ways is from the Start menu. Go to Programs->Accessories; then right click on "Command Prompt" and select "Run as Administrator."

You'll have to cd to the directory where you saved "launcher_updater_20141204.zip", of course, before running the python command to launch the updater.

If you need to do this kind of thing a lot (like me), that whole "cd"-ing around can get to be a pain in the butt. I've found a fairly simple script that will add a context menu item to Windows Explorer. It allows you to right-click on any folder in Windows Explorer and select "CMD here as Admin." You get the UAC prompt and, BOOM ... an command prompt in the correct folder with elevated privileges.

It's a registry text file (*.inf) that you right click on and choose "Install". It also provides an uninstall option in the standard add/remove programs should you want to get rid of it.

It's only for Vista and Win7, since Win8 already has the feature and XP doesn't need it. I'll post it if there's an interest.

Last edited by DiapDealer; 12-05-2014 at 03:43 PM.
DiapDealer is offline   Reply With Quote
Old 12-06-2014, 08:05 AM   #84
crutledge
eBook FANatic
crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.crutledge ought to be getting tired of karma fortunes by now.
 
crutledge's Avatar
 
Posts: 18,301
Karma: 16071131
Join Date: Apr 2008
Location: Alabama, USA
Device: HP ipac RX5915 Wife's Kindle
Question about epubcheck

If I have a file name e.g.
Code:
Openings in the Old Trail
epubcheck recomends removal of the spaces.

If I replace the file name with
Code:
Openings_in_the_Old_Trail
I get the same recomendation to remove spaces.
Attached Files
File Type: epub Openings in the Old Trail.epub (1.23 MB, 769 views)
crutledge is offline   Reply With Quote
Old 12-06-2014, 08:44 AM   #85
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by crutledge View Post
If I have a file name e.g.
Code:
Openings in the Old Trail
epubcheck recomends removal of the spaces.
If you get this message, click the .opf file and search for %20.
In your case you'll find that you missed a space between Old and _Trail:

Code:
<item href="Text/Openings_in_the_Old%20_Trail_0001.htm" id="Openings_in_the_Old__Trail_0001.htm" media-type="application/xhtml+xml" />

If you have more plugin-specific questions, please post them in the thread where you downloaded the plugin from.

This thread is primarily intended for plugin developers not end-users.
Doitsu is offline   Reply With Quote
Old 02-20-2015, 03:20 PM   #86
bmix
Member
bmix began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Mar 2014
Location: Budapest/Hungary
Device: Kindle4,reMarkable2,MoonReader Pro
Quote:
Originally Posted by Doitsu View Post
@KevinH & user_none:

IMHO, Javascript would be the perfect embedded scripting language for Sigil, because it has been designed for website manipulation and the Qt Quick library already has JavaScript support.
What I find much more interesting would be to use the language, that has been created with a single cause in mind: the processing of XML DOM trees. I am talking about XSLT. Now, this surely would not suite to be an embedded language, it is quite exotic, and most people will be fine with Python. On the other hand, I often find myself sighing: "Oh, if I only could apply a quick XSL-stylesheet (not to be confused with CSS) or a single template on this xhtml!"

I am trying to write a wrapper around 'xsltproc', but I just started checking out the new version of Sigil today, and currently I am pretty tired, so that has to wait. In it I would like to offer the possibility to apply a style upon the currently opened editor document (would need a way, to find out, which file is being frontmost) or selected or all xhtml files. Also, with xsltproc the problem is, that it only supports XSLT v1, which is a little weak. But may be well enough suited for the task at hand.

Andreas
bmix is offline   Reply With Quote
Old 02-20-2015, 04:04 PM   #87
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by bmix View Post
In it I would like to offer the possibility to apply a style upon the currently opened editor document (would need a way, to find out, which file is being frontmost) or selected or all xhtml files.
Unfortunately, it's not possible to programmatically determine the the .html file currently opened in the Code View window; you'll either have to enumerate all .html files or use a Tkinter file selection dialog. (For an example, see DiapDealer's Smarten Punctuation plugin.)

BTW, for simple html manipulation BeautifulSoup might do the trick.
Doitsu is offline   Reply With Quote
Old 02-27-2015, 05:42 AM   #88
bmix
Member
bmix began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Mar 2014
Location: Budapest/Hungary
Device: Kindle4,reMarkable2,MoonReader Pro
Quote:
Originally Posted by Doitsu View Post
Unfortunately, it's not possible to programmatically determine the the .html file currently opened in the Code View window
May I assume, that this is a limitation by the plugin API and not the underlying framework? It should be possible to query the tab-title (which holds the filename) in Qt5, no? I am not versed in Qt development (or C++), but, on the run, I found this at http://doc.qt.io/qt-5/qtabwidget.html:

QString QTabWidget::tabText(int index) const
Returns the label text for the tab on the page at position index.
See also setTabText().

and

currentIndex : int
This property holds the index position of the current tab page.

That would allow to query the currently opened tab's filename and compose a full filespec from it.
bmix is offline   Reply With Quote
Old 02-27-2015, 05:47 AM   #89
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,640
Karma: 23191067
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by bmix View Post
May I assume, that this is a limitation by the plugin API and not the underlying framework?
You're correct. This is a limitation of the Python plugin API.
Doitsu is offline   Reply With Quote
Old 02-27-2015, 02:38 PM   #90
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,156
Karma: 5450818
Join Date: Nov 2009
Device: many
Hi,

Yes it is a limitation of the current plugin api but if something like this is important we could add support for it in a future version of the plugin launcher. It could be as simple as always writing a list of selected files "in order" in xml to the temp directory before invoking the plugin. The plugin itself can then decide whether to use that xml list, or work on the entire set of book files, or throw up a gui to select which files you would like to have processed.

Let me think about how that best could be implemented with the fewest number of interface changes that would maintain backwards compatibility.

Kevin

Last edited by KevinH; 02-27-2015 at 03:47 PM.
KevinH is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading Plugin in development Sladd Development 6 06-17-2014 07:57 PM
Question for plugin development gurus DiapDealer Plugins 2 02-05-2012 12:33 AM
DR800 Plugin development for DR800/DR1000 yuri_b iRex Developer's Corner 0 09-18-2010 10:46 AM
Device plugin development reader42 Plugins 10 03-29-2010 01:39 PM
Calibre plugin development - Newbie problems minstrel Plugins 5 04-12-2009 01:44 PM


All times are GMT -4. The time now is 08:36 PM.


MobileRead.com is a privately owned, operated and funded community.