Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * main.cpp - Plugin Tool Gui 00004 * 00005 * Created: Thu Nov 09 20:13:45 2007 00006 * Copyright 2007 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/plugin_gui/plugin_gui.h> 00025 #ifdef HAVE_GCONFMM 00026 # include <gconfmm.h> 00027 #endif 00028 #include <iostream> 00029 00030 #if GTK_VERSION_GE(3,0) 00031 # define UI_FILE RESDIR"/guis/plugin_tool/plugin_gui.ui" 00032 #else 00033 # define UI_FILE RESDIR"/guis/plugin_tool/plugin_gui_gtk2.ui" 00034 #endif 00035 00036 00037 using namespace std; 00038 00039 int main(int argc, char** argv) 00040 { 00041 try 00042 { 00043 Gtk::Main kit(argc, argv); 00044 #ifdef HAVE_GCONFMM 00045 Gnome::Conf::init(); 00046 #endif 00047 00048 Glib::RefPtr<Gtk::Builder> builder; 00049 #ifdef GLIBMM_EXCEPTIONS_ENABLED 00050 try { 00051 builder = 00052 Gtk::Builder::create_from_file(UI_FILE); 00053 } catch (Gtk::BuilderError &e) { 00054 printf("Failed to create GUI: %s\n", e.what().c_str()); 00055 } 00056 #else 00057 std::auto_ptr<Gtk::BuilderError> error; 00058 Glib::RefPtr<Gtk::Builder> builder = 00059 Gtk::Builder::create_from_file(UI_FILE, error); 00060 if (error.get()) { 00061 throw fawkes::Exception("Failed to load Glade file: %s", 00062 error->what().c_str()); 00063 } 00064 #endif 00065 00066 PluginGuiGtkWindow *window = NULL; 00067 builder->get_widget_derived("wndMain", window); 00068 00069 kit.run( *window ); 00070 00071 delete window; 00072 } 00073 catch (std::exception const& e) 00074 { 00075 std::cerr << "Error: " << e.what() << std::endl; 00076 } 00077 00078 return 0; 00079 }