• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • superkaramba
 

superkaramba

main.cpp

00001 /*
00002  * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
00003  * Copyright (C) 2003-2004 Adam Geitgey <adam@rootnode.org>
00004  * Copyright (c) 2005 Ryan Nickell <p0z3r@earthlink.net>
00005  *
00006  * This file is part of SuperKaramba.
00007  *
00008  *  SuperKaramba is free software; you can redistribute it and/or modify
00009  *  it under the terms of the GNU General Public License as published by
00010  *  the Free Software Foundation; either version 2 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  SuperKaramba is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  *  GNU General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU General Public License
00019  *  along with SuperKaramba; if not, write to the Free Software
00020  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00021  ****************************************************************************/
00022 
00023 #include <karambaapp.h>
00024 #include <tqobject.h>
00025 
00026 #include <kaboutdata.h>
00027 #include <kcmdlineargs.h>
00028 #include <klocale.h>
00029 #include <kconfig.h>
00030 #include <kmainwindow.h>
00031 #include <tqfileinfo.h>
00032 #include <tqstringlist.h>
00033 #include <kconfig.h>
00034 #include <kstandarddirs.h>
00035 #include <kdeversion.h>
00036 
00037 #include "karamba.h"
00038 #include "karambasessionmanaged.h"
00039 #include "karambainterface.h"
00040 #include "karamba_python.h"
00041 
00042 static const char *description =
00043     I18N_NOOP("A KDE Eye-candy Application");
00044 
00045 static const char *version = "0.42";
00046 
00047 static KCmdLineOptions options[] =
00048 {
00049   // { "+[URL]", I18N_NOOP( "Document to open" ), 0 },
00050   // { "!nosystray", I18N_NOOP("Disable systray icon"), 0 },
00051   { "+file", I18N_NOOP("A required argument 'file'"), 0 },
00052   { 0, 0, 0 }
00053 };
00054 
00055 // This is for redirecting all qWarning, qDebug,... messages to file.
00056 // Usefull when testing session management issues etc.
00057 // #define KARAMBA_LOG 1
00058 
00059 #ifdef KARAMBA_LOG
00060 
00061 void karambaMessageOutput(TQtMsgType type, const char *msg)
00062 {
00063   FILE* fp = fopen("/tmp/karamba.log", "a");
00064   if(fp)
00065   {
00066     pid_t pid = getpid();
00067 
00068     switch ( type )
00069     {
00070         case QtDebugMsg:
00071             fprintf( fp, "Debug (%d): %s\n", pid, msg );
00072             break;
00073         case QtWarningMsg:
00074             if (strncmp(msg, "X Error", 7) != 0)
00075               fprintf( fp, "Warning (%d): %s\n", pid, msg );
00076             break;
00077         case QtFatalMsg:
00078             fprintf( fp, "Fatal (%d): %s\n", pid, msg );
00079             abort();                    // deliberately core dump
00080     }
00081     fclose(fp);
00082   }
00083 }
00084 
00085 #endif
00086 
00087 int main(int argc, char **argv)
00088 {
00089 #ifdef KARAMBA_LOG
00090     tqInstallMsgHandler(karambaMessageOutput);
00091 #endif
00092     KAboutData about("superkaramba", I18N_NOOP("SuperKaramba"),
00093                      version, description,
00094                      KAboutData::License_GPL,
00095                      "(c) 2003-2006 The SuperKaramba developers");
00096     about.addAuthor("Adam Geitgey", 0, "adam@rootnode.org");
00097     about.addAuthor("Hans Karlsson", 0, "karlsson.h@home.se");
00098     about.addAuthor("Ryan Nickell", 0, "p0z3r@earthlink.net");
00099     about.addAuthor("Petri Damstén", 0, "petri.damsten@iki.fi");
00100     about.addAuthor("Alexander Wiedenbruch", 0, "mail@wiedenbruch.de");
00101     about.addAuthor("Luke Kenneth Casson Leighton", 0, "lkcl@lkcl.net");
00102     KCmdLineArgs::init(argc, argv, &about);
00103     KCmdLineArgs::addCmdLineOptions(options);
00104     KarambaSessionManaged ksm;
00105     //karamba *mainWin = 0;
00106     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00107     TQStringList lst;
00108     int ret = 0;
00109 
00110     // Create ~/.superkaramba if necessary
00111     KarambaApplication::checkSuperKarambaDir();
00112 
00113     KarambaApplication::lockKaramba();
00114 
00115     KarambaApplication app;
00116 
00117     TQString mainAppId = app.getMainKaramba();
00118     if(!mainAppId.isEmpty())
00119     {
00120       app.initDcopStub(mainAppId.ascii());
00121     }
00122     else
00123     {
00124       //Set up systray icon
00125       app.setUpSysTray(&about);
00126       app.initDcopStub();
00127     }
00128 
00129     KarambaApplication::unlockKaramba();
00130 
00131     app.connect(tqApp,TQT_SIGNAL(lastWindowClosed()),tqApp,TQT_SLOT(quit()));
00132 
00133     // Try to restore a previous session if applicable.
00134     app.checkPreviousSession(app, lst);
00135     if( (lst.size() == 0) && !app.isRestored() )
00136     {
00137       //Not a saved session - check for themes given on command line
00138       app.checkCommandLine(args, lst);
00139 
00140       if(lst.size() == 0)
00141       {
00142         //No themes given on command line and no saved session.
00143         //Show welcome dialog.
00144         app.globalShowThemeDialog();
00145       }
00146     }
00147 
00148     args->clear();
00149 
00150     KarambaPython::initPython();
00151     //qDebug("startThemes");
00152     if(app.startThemes(lst) || mainAppId.isEmpty())
00153       ret = app.exec();
00154     KarambaPython::shutdownPython();
00155     return ret;
00156 }

superkaramba

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

superkaramba

Skip menu "superkaramba"
  • kcalc
  •   knumber
  • superkaramba
Generated for superkaramba by doxygen 1.7.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |