• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeutils API Reference
  • KDE Home
  • Contact Us
 

superkaramba

  • sources
  • kde-4.12
  • kdeutils
  • superkaramba
  • src
main.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
3  * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org>
4  * Copyright (c) 2005 Ryan Nickell <p0z3r@earthlink.net>
5  *
6  * This file is part of SuperKaramba.
7  *
8  * SuperKaramba is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * SuperKaramba is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with SuperKaramba; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  ****************************************************************************/
22 
23 #include "karambaapp.h"
24 #include "karambasessionmanaged.h"
25 #include "python/karamba.h"
26 
27 #include "config-superkaramba.h"
28 
29 #include <stdlib.h>
30 
31 #include <KLocale>
32 #include <KConfig>
33 #include <KDebug>
34 #include <KStandardDirs>
35 #include <KCmdLineArgs>
36 #include <KAboutData>
37 #include <KWindowSystem>
38 
39 #include <X11/extensions/Xrender.h>
40 
41 static const char description[] =
42  I18N_NOOP("A KDE Eye-candy Application");
43 
44 static const char version[] = "0.59";
45 
46 int main(int argc, char **argv)
47 {
48  Display *dpy = XOpenDisplay(0); // open default display
49  if (!dpy) {
50  kWarning() << "Cannot connect to the X server";
51  exit(1);
52  }
53 
54  Colormap colormap = 0;
55  Visual *visual = 0;
56 
57  if (KWindowSystem::compositingActive()) {
58  int screen = DefaultScreen(dpy);
59  int eventBase, errorBase;
60 
61  if (XRenderQueryExtension(dpy, &eventBase, &errorBase)) {
62  int nvi;
63  XVisualInfo templ;
64  templ.screen = screen;
65  templ.depth = 32;
66  templ.c_class = TrueColor;
67  XVisualInfo *xvi = XGetVisualInfo(dpy, VisualScreenMask |
68  VisualDepthMask |
69  VisualClassMask,
70  &templ, &nvi);
71  for (int i = 0; i < nvi; ++i) {
72  XRenderPictFormat *format = XRenderFindVisualFormat(dpy,
73  xvi[i].visual);
74  if (format->type == PictTypeDirect && format->direct.alphaMask) {
75  visual = xvi[i].visual;
76  colormap = XCreateColormap(dpy, RootWindow(dpy, screen),
77  visual, AllocNone);
78  break;
79  }
80  }
81  }
82  }
83 
84  KAboutData about("superkaramba", 0, ki18n("SuperKaramba"),
85  version, ki18n(description),
86  KAboutData::License_GPL,
87  ki18n("(c) 2003-2007 The SuperKaramba developers"), KLocalizedString(),
88  "http://utils.kde.org/projects/superkaramba");
89  about.addAuthor(ki18n("Adam Geitgey"), KLocalizedString(), "adam@rootnode.org");
90  about.addAuthor(ki18n("Hans Karlsson"), KLocalizedString(), "karlsson.h@home.se");
91  about.addAuthor(ki18n("Ryan Nickell"), KLocalizedString(), "p0z3r@earthlink.net");
92  about.addAuthor(ki18n("Petri Damstén"), KLocalizedString(), "petri.damsten@iki.fi");
93  about.addAuthor(ki18n("Alexander Wiedenbruch"), KLocalizedString(), "mail@wiedenbruch.de");
94  about.addAuthor(ki18n("Luke Kenneth Casson Leighton"), KLocalizedString(), "lkcl@lkcl.net");
95  about.addCredit(ki18n("Sebastian Sauer"), ki18n("Work on Kross, tutorials and examples"), "mail@dipe.org");
96  KCmdLineArgs::init(argc, argv, &about);
97 
98  KCmdLineOptions options;
99  // { "+[URL]", I18N_NOOP( "Document to open" ), 0 },
100 // { "!nosystray", I18N_NOOP("Disable systray icon"), 0 },
101 #ifdef PYTHON_INCLUDE_PATH
102  options.add("usefallback", ki18n("Use the original python bindings as scripting backend. Off by default."));
103 #endif
104  options.add("+file", ki18n("A required argument 'file'"));
105  KCmdLineArgs::addCmdLineOptions(options);
106  KarambaApplication::addCmdLineOptions();
107  KarambaSessionManaged ksm;
108 
109  if (!KarambaApplication::start()) {
110  fprintf(stderr, "SuperKaramba is already running!\n");
111  exit(0);
112  }
113 
114 #ifdef PYTHON_INCLUDE_PATH
115  bool noUseKross = false;
116  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
117  if (args->isSet("usefallback")) {
118  noUseKross = true;
119  kDebug() << "Using fallback python scripting backend!" ;
120  }
121 #endif
122 
123  KarambaApplication app(dpy, Qt::HANDLE(visual), Qt::HANDLE(colormap));
124 
125  app.setupSysTray(&about);
126  int ret = 0;
127 
128 #ifdef PYTHON_INCLUDE_PATH
129  if (noUseKross) {
130  KarambaPython::initPython();
131  }
132 #endif
133 
134  ret = app.exec();
135 
136 #ifdef PYTHON_INCLUDE_PATH
137  if (noUseKross) {
138  KarambaPython::shutdownPython();
139  }
140 #endif
141 
142  return ret;
143 }
KarambaSessionManaged
Definition: karambasessionmanaged.h:28
karambasessionmanaged.h
main
int main(int argc, char **argv)
Definition: main.cpp:46
karamba.h
KarambaPython::initPython
static void initPython()
Definition: python/karamba.cpp:412
KarambaPython::shutdownPython
static void shutdownPython()
Definition: python/karamba.cpp:427
KarambaApplication
Definition: karambaapp.h:30
description
static const char description[]
Definition: main.cpp:41
karambaapp.h
KarambaApplication::setupSysTray
void setupSysTray(KAboutData *about)
Definition: karambaapp.cpp:251
version
static const char version[]
Definition: main.cpp:44
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:07:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

superkaramba

Skip menu "superkaramba"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeutils API Reference

Skip menu "kdeutils API Reference"
  • ark
  • filelight
  • kcalc
  • kcharselect
  • kdf
  • kfloppy
  • kgpg
  • kremotecontrol
  • ktimer
  • kwallet
  • superkaramba
  • sweeper

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal