• Skip to content
  • Skip to link menu
KDE 4.0 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

Konsole

main.cpp

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2006-2007 by Robert Knight <robertknight@gmail.com>
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU General Public License for more details.
00013 
00014     You should have received a copy of the GNU General Public License
00015     along with this program; if not, write to the Free Software
00016     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301  USA.
00018 */
00019 
00020 // Own
00021 #include "Application.h"
00022 #include <KDebug>
00023 
00024 // X11
00025 #ifdef Q_WS_X11
00026 #include <X11/Xlib.h>
00027 #include <X11/extensions/Xrender.h>
00028 #endif
00029 
00030 // KDE
00031 #include <KAboutData>
00032 #include <KCmdLineArgs>
00033 #include <KLocale>
00034 #include <KWindowSystem>
00035 
00036 #define KONSOLE_VERSION "2.0"
00037 
00038 using namespace Konsole;
00039 
00040 #ifdef Q_WS_X11
00041 void getDisplayInformation(Display*& display , Visual*& visual , Colormap& colormap);
00042 #endif
00043 
00044 // fills the KAboutData structure with information about contributors to 
00045 // Konsole
00046 void fillAboutData(KAboutData& aboutData);
00047 void fillCommandLineOptions(KCmdLineOptions& options);
00048 
00049 // ***
00050 // 
00051 // Entry point into the Konsole terminal application.  
00052 //
00053 // If another Konsole instance
00054 // is already executing then the existing instance is asked to create a new main
00055 // window and the current process returns immediately.
00056 //
00057 // ***
00058 extern "C" int KDE_EXPORT kdemain(int argc,char** argv)
00059 {
00060     KAboutData about(   "konsole", 0,
00061                         ki18n("Konsole"),
00062                         KONSOLE_VERSION,
00063                         ki18n("Terminal emulator"),
00064                         KAboutData::License_GPL_V2
00065                     );
00066     fillAboutData(about);
00067 
00068     KCmdLineArgs::init(argc,argv,&about);
00069     KCmdLineOptions options;
00070     fillCommandLineOptions(options);
00071     KCmdLineArgs::addCmdLineOptions(options);
00072     KUniqueApplication::addCmdLineOptions();
00073 
00074     // create a new application instance if there are no running Konsole instances,
00075     // otherwise inform the existing Konsole instance and exit
00076     if ( !KUniqueApplication::start() )
00077     {
00078         exit(0);
00079     }
00080 #ifdef Q_WS_X11
00081     if ( KWindowSystem::compositingActive() && 
00082          KCmdLineArgs::parsedArgs()->isSet("enable-transparency") ) 
00083     {
00084         Display* display = 0;
00085         Visual* visual = 0;
00086         Colormap colormap = 0;
00087 
00088         getDisplayInformation(display,visual,colormap);
00089 
00090         Application app(display,(Qt::HANDLE)visual,(Qt::HANDLE)colormap);
00091         return app.exec();
00092     }
00093     else
00094 #endif 
00095     {
00096         Application app;
00097         return app.exec();
00098     }   
00099 }
00100 
00101 void fillCommandLineOptions(KCmdLineOptions& options)
00102 {
00103     options.add("profile \\<file>", ki18n("Name of profile to use for new Konsole instance"));
00104     options.add("list-profiles", ki18n("List the available profiles"));
00105     // TODO - Update this when F12 is no longer hard coded
00106     options.add("background-mode", ki18n("Start Konsole in the background"
00107                                     " and bring to the front when the F12"
00108                                     " key is pressed"));
00109     options.add("new-tab",ki18n("Create a new tab in an existing window rather than creating a new window"));
00110     options.add("workdir \\<dir>",   ki18n("Set the initial working directory of the new tab "
00111                                            "or window to 'dir'"));
00112     options.add("enable-transparency",ki18n("Enable transparent backgrounds"));
00113     // TODO - Document this option more clearly
00114     options.add("p \\<property=value>",ki18n("Change the value of a profile property."));
00115     options.add("!e \\<cmd>",ki18n("Command to execute"));
00116     options.add("+[args]",ki18n("Arguments passed to command"));
00117 
00118 }
00119 
00120 void fillAboutData(KAboutData& aboutData)
00121 {
00122   aboutData.addAuthor(ki18n("Robert Knight"),ki18n("Maintainer"), "robertknight@gmail.com");
00123   aboutData.addAuthor(ki18n("Lars Doelle"),ki18n("Author"), "lars.doelle@on-line.de");
00124   aboutData.addCredit(ki18n("Kurt V. Hindenburg"),
00125     ki18n("Bug fixes and general improvements"), 
00126     "kurt.hindenburg@gmail.com");
00127   aboutData.addCredit(ki18n("Waldo Bastian"),
00128     ki18n("Bug fixes and general improvements"),
00129     "bastian@kde.org");
00130   aboutData.addCredit(ki18n("Stephan Binner"),
00131     ki18n("Bug fixes and general improvements"),
00132     "binner@kde.org");
00133   aboutData.addCredit(ki18n("Chris Machemer"),
00134     ki18n("Bug fixes"),
00135     "machey@ceinetworks.com");
00136   aboutData.addCredit(ki18n("Stephan Kulow"),
00137     ki18n("Solaris support and history"),
00138     "coolo@kde.org");
00139   aboutData.addCredit(ki18n("Alexander Neundorf"),
00140     ki18n("Bug fixes and improved startup performance"),
00141     "neundorf@kde.org");
00142   aboutData.addCredit(ki18n("Peter Silva"),
00143     ki18n("Marking improvements"),
00144     "peter.silva@videotron.ca");
00145   aboutData.addCredit(ki18n("Lotzi Boloni"),
00146     ki18n("Embedded Konsole\n"
00147     "Toolbar and session names"),
00148     "boloni@cs.purdue.edu");
00149   aboutData.addCredit(ki18n("David Faure"),
00150     ki18n("Embedded Konsole\n"
00151     "General improvements"),
00152     "faure@kde.org");
00153   aboutData.addCredit(ki18n("Antonio Larrosa"),
00154     ki18n("Visual effects"),
00155     "larrosa@kde.org");
00156   aboutData.addCredit(ki18n("Matthias Ettrich"),
00157     ki18n("Code from the kvt project\n"
00158     "General improvements"),
00159     "ettrich@kde.org");
00160   aboutData.addCredit(ki18n("Warwick Allison"),
00161     ki18n("Schema and text selection improvements"),
00162     "warwick@troll.no");
00163   aboutData.addCredit(ki18n("Dan Pilone"),
00164     ki18n("SGI port"),
00165     "pilone@slac.com");
00166   aboutData.addCredit(ki18n("Kevin Street"),
00167     ki18n("FreeBSD port"),
00168     "street@iname.com");
00169   aboutData.addCredit(ki18n("Sven Fischer"),
00170     ki18n("Bug fixes"),
00171     "herpes@kawo2.renditionwth-aachen.de");
00172   aboutData.addCredit(ki18n("Dale M. Flaven"),
00173     ki18n("Bug fixes"),
00174     "dflaven@netport.com");
00175   aboutData.addCredit(ki18n("Martin Jones"),
00176     ki18n("Bug fixes"),
00177     "mjones@powerup.com.au");
00178   aboutData.addCredit(ki18n("Lars Knoll"),
00179     ki18n("Bug fixes"),
00180     "knoll@mpi-hd.mpg.de");
00181   aboutData.addCredit(ki18n("Thanks to many others.\n"));
00182 
00183 }
00184 
00185 // code taken from the Qt 4 graphics dojo examples
00186 // at http://labs.trolltech.com 
00187 #ifdef Q_WS_X11
00188 void getDisplayInformation(Display*& display , Visual*& visual , Colormap& colormap)
00189 {
00190     display = XOpenDisplay(0); // open default display
00191     if (!display) {
00192         kWarning("Cannot connect to the X server");
00193         exit(1);
00194     }
00195 
00196     int screen = DefaultScreen(display);
00197     int eventBase, errorBase;
00198 
00199     if (XRenderQueryExtension(display, &eventBase, &errorBase)) {
00200         int nvi;
00201         XVisualInfo templ;
00202         templ.screen  = screen;
00203         templ.depth = 32;
00204         templ.c_class = TrueColor;
00205         XVisualInfo *xvi = XGetVisualInfo(display, VisualScreenMask |
00206                                           VisualDepthMask |
00207                                           VisualClassMask, &templ, &nvi);
00208     
00209         for (int i = 0; i < nvi; ++i) {
00210             XRenderPictFormat* format = XRenderFindVisualFormat(display,
00211                                                                 xvi[i].visual);
00212             if (format->type == PictTypeDirect && format->direct.alphaMask) {
00213                 visual = xvi[i].visual;
00214                 colormap = XCreateColormap(display, RootWindow(display, screen),
00215                                            visual, AllocNone);
00216 
00217                 // found ARGB visual
00218                 break;
00219             }
00220         }
00221     }
00222 }
00223 #endif
00224 
00225 

Konsole

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

API Reference

Skip menu "API Reference"
  • Konsole
  • Libraries
  •   libkonq
Generated for API Reference by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal