Fawkes API  Fawkes Development Version
main.cpp
1 
2 /***************************************************************************
3  * main.cpp - Plugin Tool Gui
4  *
5  * Created: Thu Nov 09 20:13:45 2007
6  * Copyright 2007 Daniel Beck
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #include <core/exception.h>
24 #include <tools/plugin_gui/plugin_gui.h>
25 #ifdef HAVE_GCONFMM
26 # include <gconfmm.h>
27 #endif
28 #include <iostream>
29 
30 #if GTK_VERSION_GE(3,0)
31 # define UI_FILE RESDIR"/guis/plugin_tool/plugin_gui.ui"
32 #else
33 # define UI_FILE RESDIR"/guis/plugin_tool/plugin_gui_gtk2.ui"
34 #endif
35 
36 
37 using namespace std;
38 
39 int main(int argc, char** argv)
40 {
41  try
42  {
43  Gtk::Main kit(argc, argv);
44 #ifdef HAVE_GCONFMM
45  Gnome::Conf::init();
46 #endif
47 
48  Glib::RefPtr<Gtk::Builder> builder;
49 #ifdef GLIBMM_EXCEPTIONS_ENABLED
50  try {
51  builder =
52  Gtk::Builder::create_from_file(UI_FILE);
53  } catch (Gtk::BuilderError &e) {
54  printf("Failed to create GUI: %s\n", e.what().c_str());
55  }
56 #else
57  std::auto_ptr<Gtk::BuilderError> error;
58  Glib::RefPtr<Gtk::Builder> builder =
59  Gtk::Builder::create_from_file(UI_FILE, error);
60  if (error.get()) {
61  throw fawkes::Exception("Failed to load Glade file: %s",
62  error->what().c_str());
63  }
64 #endif
65 
66  PluginGuiGtkWindow *window = NULL;
67  builder->get_widget_derived("wndMain", window);
68 
69  kit.run( *window );
70 
71  delete window;
72  }
73  catch (std::exception const& e)
74  {
75  std::cerr << "Error: " << e.what() << std::endl;
76  }
77 
78  return 0;
79 }
Graphical plugin management tool.
Definition: plugin_gui.h:36
STL namespace.
Base class for exceptions in Fawkes.
Definition: exception.h:36