Fawkes API  Fawkes Development Version
main.cpp
00001 
00002 /***************************************************************************
00003  *  main.cpp - Fawkes Config Editor
00004  *
00005  *  Created: Tue Sep 23 13:26:18 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #include <core/exception.h>
00024 #include <tools/config_editor/config_editor.h>
00025 #include <iostream>
00026 
00027 #if GTK_VERSION_GE(3,0)
00028 #  define UI_FILE RESDIR"/guis/config_editor/config_editor.ui"
00029 #else
00030 #  define UI_FILE RESDIR"/guis/config_editor/config_editor_gtk2.ui"
00031 #endif
00032 
00033 using namespace std;
00034 
00035 int main(int argc, char** argv)
00036 {
00037   std::locale::global( std::locale( "" ) ); 
00038 
00039   try
00040   {
00041     Gtk::Main kit(argc, argv);
00042 #ifdef GLIBMM_EXCEPTIONS_ENABLED
00043     Glib::RefPtr<Gtk::Builder> builder =
00044       Gtk::Builder::create_from_file(UI_FILE);
00045 #else
00046     std::auto_ptr<Gtk::BuilderError> error;
00047     Glib::RefPtr<Gtk::Builder> builder =
00048       Gtk::Builder::create_from_file(UI_FILE, error);
00049     if (error.get()) {
00050       printf("Failed to load UI file: %s", error->what().c_str());
00051       exit(-1);
00052     }
00053 #endif
00054 
00055     FawkesConfigEditor fce(builder);
00056 
00057     kit.run(fce.get_window());
00058   }
00059   catch (Gtk::BuilderError &e)
00060   {
00061     printf("Failed to instantiate window: %s\n", e.what().c_str());
00062   }
00063   catch (const std::exception& e)
00064   {
00065     cerr << "Error: " << e.what() << endl;
00066   }
00067 
00068   return 0;
00069 }