diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /dcoppython/test/dcopserver | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'dcoppython/test/dcopserver')
-rw-r--r-- | dcoppython/test/dcopserver/Makefile.am | 36 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/README | 8 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/gen.py | 46 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/hi16-app-kdedcoptest.png | bin | 0 -> 1033 bytes | |||
-rw-r--r-- | dcoppython/test/dcopserver/hi32-app-kdedcoptest.png | bin | 0 -> 2749 bytes | |||
-rw-r--r-- | dcoppython/test/dcopserver/kdedcoptest.cpp | 27 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/kdedcoptest.desktop | 6 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/kdedcoptest.h | 38 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/kdedcoptestui.rc | 8 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/main.cpp | 54 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/mainclass.cpp | 20 | ||||
-rw-r--r-- | dcoppython/test/dcopserver/mainclass.h | 23 |
12 files changed, 266 insertions, 0 deletions
diff --git a/dcoppython/test/dcopserver/Makefile.am b/dcoppython/test/dcopserver/Makefile.am new file mode 100644 index 00000000..61610ae5 --- /dev/null +++ b/dcoppython/test/dcopserver/Makefile.am @@ -0,0 +1,36 @@ +# set the include path for X, qt and KDE +INCLUDES = $(all_includes) + +# these are the headers for your project +noinst_HEADERS = kdedcoptest.h + +# let automoc handle all of the meta source files (moc) +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kdedcoptest.pot + +KDE_ICON = kdedcoptest + +######################################################################### +# APPLICATION SECTION +######################################################################### +# this is the program that gets installed. it's name is used for all +# of the other Makefile.am variables +bin_PROGRAMS = kdedcoptest + +# the application source, library search path, and link libraries +kdedcoptest_SOURCES = main.cpp kdedcoptest.cpp kdedcoptest_iface.skel mainclass.cpp +kdedcoptest_LDFLAGS = $(KDE_RPATH) $(all_libraries) +kdedcoptest_LDADD = $(LIB_KDEUI) + +# this is where the desktop file will go +shelldesktopdir = $(kde_appsdir)/Utilities +shelldesktop_DATA = kdedcoptest.desktop + +# this is where the shell's XML-GUI resource file goes +shellrcdir = $(kde_datadir)/kdedcoptest +shellrc_DATA = kdedcoptestui.rc + +h_inc.h: gen.py + python gen.py diff --git a/dcoppython/test/dcopserver/README b/dcoppython/test/dcopserver/README new file mode 100644 index 00000000..47e69273 --- /dev/null +++ b/dcoppython/test/dcopserver/README @@ -0,0 +1,8 @@ +What's this doing here? It's here to help if you're developing the Python DCOP bindings themselves. You don't need it if you just want to _use_ the bindings. + +It's a simple DCOP server in C++, that can be used to conveniently test the Python DCOP interface (or any other DCOP binding, for that matter). The script gen.py generates simple get/set DCOP methods for a variety of types. + +Note that gen.py is _not_ automatically invoked from the Makefile, so you should run it yourself before doing make. + +Julian Rockey +kde@jrockey.com diff --git a/dcoppython/test/dcopserver/gen.py b/dcoppython/test/dcopserver/gen.py new file mode 100644 index 00000000..ae2947af --- /dev/null +++ b/dcoppython/test/dcopserver/gen.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python + +type_list = ['KURL', 'QDate', 'QTime', 'QDateTime', 'QRect', 'QString', 'int', 'QFont', 'QSize', 'QPoint', 'QPointArray' ] + +inc_exceptions = {'QDate': None, 'QTime': None, 'KURL' : 'kurl'} + +iface_inc_list = ['dcopobject'] + +iface_inc_list += [ t.lower() for t in type_list if t[0]=='Q' and t not in inc_exceptions ] +iface_inc_list += inc_exceptions.values() + +iface_inc_1 = ['class DCOPDemoIface : virtual public DCOPObject {', + ' K_DCOP', + ' k_dcop:'] +h_inc = [] +cpp_inc = [] + +for t in type_list: + iface_inc_1.append("virtual void set%sVal(const %s &val) = 0; " % (t,t) ) + iface_inc_1.append("virtual %s %sVal() const = 0;" % (t,t) ) + + h_inc.append("virtual void set%sVal(const %s &val); " % (t,t) ) + h_inc.append("virtual %s %sVal() const;" % (t,t) ) + h_inc.append("%s m_%sValue;" % (t,t) ) + + cpp_inc.append("void MainClass::set%sVal(const %s & val) {" % (t,t) ) + cpp_inc.append(" m_%sValue = val; }" % t) + cpp_inc.append("%s MainClass::%sVal() const {" % (t,t) ) + cpp_inc.append(" return m_%sValue; }" % t) + +iface_inc = [] +for inc in iface_inc_list: + if inc: iface_inc.append("#include <%s.h>" % inc) +iface_inc += iface_inc_1 +iface_inc.append("};") + +files = {'kdedcoptest_iface.h': iface_inc, + 'h_inc.h': h_inc, + 'cpp_inc.h': cpp_inc + } + +for (fname,data) in files.items(): + outf = file(fname,'w') + for d in data: + outf.write(d+'\n') + outf.close() diff --git a/dcoppython/test/dcopserver/hi16-app-kdedcoptest.png b/dcoppython/test/dcopserver/hi16-app-kdedcoptest.png Binary files differnew file mode 100644 index 00000000..4ed606c1 --- /dev/null +++ b/dcoppython/test/dcopserver/hi16-app-kdedcoptest.png diff --git a/dcoppython/test/dcopserver/hi32-app-kdedcoptest.png b/dcoppython/test/dcopserver/hi32-app-kdedcoptest.png Binary files differnew file mode 100644 index 00000000..45ae1a11 --- /dev/null +++ b/dcoppython/test/dcopserver/hi32-app-kdedcoptest.png diff --git a/dcoppython/test/dcopserver/kdedcoptest.cpp b/dcoppython/test/dcopserver/kdedcoptest.cpp new file mode 100644 index 00000000..3046eaac --- /dev/null +++ b/dcoppython/test/dcopserver/kdedcoptest.cpp @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2003 Julian Rockey <kde@jrockey.com> + */ + +#include "kdedcoptest.h" + +#include <qlabel.h> + +#include <kmainwindow.h> +#include <klocale.h> + +KDEDcopTest::KDEDcopTest() + : KMainWindow( 0, "KDEDcopTest" ) +{ + // set the shell's ui resource file + //setXMLFile("kdedcoptestui.rc"); + + //new QLabel( "Hello World", this, "hello label" ); + m_mainClass = new MainClass(); +} + +KDEDcopTest::~KDEDcopTest() +{ + if (m_mainClass) delete m_mainClass; +} + +#include "kdedcoptest.moc" diff --git a/dcoppython/test/dcopserver/kdedcoptest.desktop b/dcoppython/test/dcopserver/kdedcoptest.desktop new file mode 100644 index 00000000..beee065d --- /dev/null +++ b/dcoppython/test/dcopserver/kdedcoptest.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=KDEDcopTest +Exec=kdedcoptest +Icon=kdedcoptest +Type=Application +Comment=A simple KDE Application diff --git a/dcoppython/test/dcopserver/kdedcoptest.h b/dcoppython/test/dcopserver/kdedcoptest.h new file mode 100644 index 00000000..42a54da6 --- /dev/null +++ b/dcoppython/test/dcopserver/kdedcoptest.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2003 Julian Rockey <kde@jrockey.com> + */ + +#ifndef _KDEDCOPTEST_H_ +#define _KDEDCOPTEST_H_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <kmainwindow.h> + +#include "mainclass.h" + +/** + * @short Application Main Window + * @author Julian Rockey <kde@jrockey.com> + * @version 0.1 + */ +class KDEDcopTest : public KMainWindow +{ + Q_OBJECT +public: + /** + * Default Constructor + */ + KDEDcopTest(); + + /** + * Default Destructor + */ + virtual ~KDEDcopTest(); +private: + MainClass *m_mainClass; +}; + +#endif // _KDEDCOPTEST_H_ diff --git a/dcoppython/test/dcopserver/kdedcoptestui.rc b/dcoppython/test/dcopserver/kdedcoptestui.rc new file mode 100644 index 00000000..7f6ee828 --- /dev/null +++ b/dcoppython/test/dcopserver/kdedcoptestui.rc @@ -0,0 +1,8 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kdedcoptest" version="1"> +<MenuBar> + <Menu name="custom"><text>C&ustom</text> + <Action name="custom_action" /> + </Menu> +</MenuBar> +</kpartgui> diff --git a/dcoppython/test/dcopserver/main.cpp b/dcoppython/test/dcopserver/main.cpp new file mode 100644 index 00000000..5335ffe9 --- /dev/null +++ b/dcoppython/test/dcopserver/main.cpp @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2003 Julian Rockey <kde@jrockey.com> + */ + +#include "kdedcoptest.h" +#include <kapplication.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <klocale.h> + +static const char *description = + I18N_NOOP("A KDE KPart Application"); + +static const char *version = "0.1"; + +static KCmdLineOptions options[] = +{ +// { "+[URL]", I18N_NOOP( "Document to open" ), 0 }, + { 0, 0, 0 } +}; + +int main(int argc, char **argv) +{ + KAboutData about("kdedcoptest", I18N_NOOP("KDEDcopTest"), version, description, + KAboutData::License_GPL, "(C) 2003 Julian Rockey", 0, 0, "kde@jrockey.com"); + about.addAuthor( "Julian Rockey", 0, "kde@jrockey.com" ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineArgs::addCmdLineOptions( options ); + KApplication app; + KDEDcopTest *mainWin = 0; + + if (app.isRestored()) + { + RESTORE(KDEDcopTest); + } + else + { + // no session.. just start up normally + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + // TODO: do something with the command line args here + + mainWin = new KDEDcopTest(); + app.setMainWidget( mainWin ); + mainWin->show(); + + args->clear(); + } + + int ret = app.exec(); + + delete mainWin; + return ret; +} diff --git a/dcoppython/test/dcopserver/mainclass.cpp b/dcoppython/test/dcopserver/mainclass.cpp new file mode 100644 index 00000000..d74b7f10 --- /dev/null +++ b/dcoppython/test/dcopserver/mainclass.cpp @@ -0,0 +1,20 @@ +/*************************************************************************** + * Copyright (C) 2003 by Julian Rockey * + * kde@jrockey.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "mainclass.h" + + +MainClass::MainClass() + : DCOPDemoIface(), DCOPObject("test") +{} + +MainClass::~MainClass() +{} + +#include "cpp_inc.h" diff --git a/dcoppython/test/dcopserver/mainclass.h b/dcoppython/test/dcopserver/mainclass.h new file mode 100644 index 00000000..7d4f7f4e --- /dev/null +++ b/dcoppython/test/dcopserver/mainclass.h @@ -0,0 +1,23 @@ + +#ifndef MAINCLASS_H +#define MAINCLASS_H + + +#include "kdedcoptest_iface.h" + +/** + * + * Julian Rockey + **/ +class MainClass : virtual public DCOPDemoIface +{ +public: + MainClass(); + + ~MainClass(); + +#include "h_inc.h" + +}; + +#endif |