Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

/src/main.cc

Go to the documentation of this file.
00001 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
00002 
00003 /*! @file main.cc
00004   @brief Main entry point for the application
00005 */
00006 
00007 #ifdef    HAVE_CONFIG_H
00008 #  include "../config.h"
00009 #endif // HAVE_CONFIG_H
00010 
00011 extern "C" {
00012 #ifdef    HAVE_LOCALE_H
00013 # include <locale.h>
00014 #endif // HAVE_LOCALE_H
00015 
00016 #ifdef    HAVE_STDIO_H
00017 # include <stdio.h>
00018 #endif // HAVE_STDIO_H
00019 
00020 #ifdef    HAVE_UNISTD_H
00021 #  include <sys/types.h>
00022 #  include <unistd.h>
00023 #endif // HAVE_UNISTD_H
00024 
00025 #include "gettext.h"
00026 }
00027 
00028 #include "openbox.hh"
00029 #include "otk/util.hh"
00030 
00031 int main(int argc, char **argv) {
00032   // initialize the locale
00033   if (!setlocale(LC_ALL, ""))
00034     printf("Couldn't set locale from environment.\n");
00035   bindtextdomain(PACKAGE, LOCALEDIR);
00036   bind_textdomain_codeset(PACKAGE, "UTF-8");
00037   textdomain(PACKAGE);
00038 
00039   ob::Openbox *openbox = new ob::Openbox(argc, argv);
00040   openbox->eventLoop();
00041 
00042   if (openbox->doRestart()) {
00043     std::string prog = openbox->restartProgram();
00044 
00045     delete openbox; // shutdown the current one!
00046     
00047     if (!prog.empty()) {
00048       execl("/bin/sh", "/bin/sh", "-c", prog.c_str(), NULL); 
00049       perror(prog.c_str());
00050     }
00051     
00052     // fall back in case the above execlp doesn't work
00053     execvp(argv[0], argv);
00054     execvp(otk::basename(argv[0]).c_str(), argv);
00055   }
00056 
00057   delete openbox; // shutdown
00058 }

Generated on Tue Feb 4 22:58:58 2003 for Openbox by doxygen1.3-rc2