Subversion Repositories Scribus

Compare Revisions

Ignore whitespace Rev 2616 → Rev 2617

/branches/Version13x/Scribus/scribus/scribusapp.h
47,5 → 47,8
bool showSplash;
bool showFontInfo;
QString file;
 
signals:
void appStarted();
};
#endif
/branches/Version13x/Scribus/scribus/plugins/scriptplugin/samples/startup_hook.py
0,0 → 1,38
#!/usr/bin/env python
# -*- coding: utf8 -*-
 
"""
This script is a simple example to show how you can trigger things based on
event hooks provided by Scribus. This sample runs the `gotSignal' method
when the app has finished setting up and it emits the appStarted() signal.
This is useful if, for example, you need access to the main window to
do your setup when running as a startup script.
 
This script isn't very interesting unless you run it as a startup script,
with Scribus running in an xterm, and watch the output on stdout/stderr.
 
You will need PyQt for this script to work.
"""
 
try:
import qt
except:
print "Seems you don't have PyQt. Doing nothing."
return
 
from qt import SIGNAL, PYSIGNAL, SLOT
 
# Note that to connect to signals etc you MUST inherit from QObject or a subclass
# of QObject.
class Recipient(qt.QObject):
 
def __init__(self):
# Connect ourselves to the "appStarted()" signal emitted by Scribus.
# Ask PyQt to run the self.gotSignal method when the signal is emitted.
self.connect(qt.qApp, SIGNAL("appStarted()"), self.gotSignal)
 
def gotSignal(self):
print "PONG!"
 
if __name__ == '__main__':
recip = Recipient();
Property changes:
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Index: branches/Version13x/Scribus/scribus/scribusapp.cpp
===================================================================
--- branches/Version13x/Scribus/scribus/scribusapp.cpp (revision 2616)
+++ branches/Version13x/Scribus/scribus/scribusapp.cpp (revision 2617)
@@ -169,11 +169,17 @@
setMainWidget(scribus);
connect(this, SIGNAL(lastWindowClosed()), this, SLOT(quit()));
-
+
scribus->show();
scribus->ShowSubs();
+
if (file != "")
scribus->loadDoc(file);
+
+ // A hook for plug-ins and scripts to trigger on. Some plugins and scripts
+ // require the app to be fully set up (in particular, the main window to be
+ // built and shown) before running their setup.
+ emit appStarted();
}
return EXIT_SUCCESS;
}