- added "HEAD" feature to tarball creation script, for easier testing
[barry.git] / gui / src / main.cc
blobcb166f4a06d3b0b3b3b0532922792c86e1552c87
1 ///
2 /// \file main.cc
3 /// Entry point for barrybackup GUI
4 ///
6 /*
7 Copyright (C) 2007, Net Direct Inc. (http://www.netdirect.ca/)
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU General Public License in the COPYING file at the
19 root directory of this project for more details.
22 #include <iostream>
23 #include <stdexcept>
24 #include <gtkmm.h>
25 #include <libglademm.h>
26 #include <barry/barry.h>
27 #include "BackupWindow.h"
28 #include "util.h"
31 // The catch-all handler for exceptions that occur inside signals
33 void main_exception_handler()
35 try {
36 throw;
38 catch( Glib::Exception &e ) {
39 std::cerr << "Glib::Exception caught in main: " << std::endl;
40 std::cerr << e.what() << std::endl;
41 Gtk::MessageDialog msg(e.what());
42 msg.run();
44 catch( std::exception &e ) {
45 std::cerr << "std::exception caught in main: " << std::endl;
46 std::cerr << e.what() << std::endl;
47 Gtk::MessageDialog msg(e.what());
48 msg.run();
54 // These are for debugging... hopefully should never need them in the field,
55 // but you never know...
58 void (*old_unexpected_handler)() = 0;
59 void unexpected_handler()
61 std::cerr << "main.cc: Unexpected exception detected - check your throw() specifications" << std::endl;
62 (*old_unexpected_handler)();
65 void (*old_terminate_handler)() = 0;
66 void terminate_handler()
68 std::cerr << "main.cc: terminate_handler() called - exception handling "
69 "could not complete, most likely due to exception inside "
70 "a destructor or catch()" << std::endl;
71 (*old_terminate_handler)();
76 int main(int argc, char *argv[])
78 old_unexpected_handler = std::set_unexpected(&unexpected_handler);
79 old_terminate_handler = std::set_terminate(&terminate_handler);
81 Barry::Init(true);
82 Glib::thread_init();
83 Gtk::Main app(argc, argv);
84 Glib::add_exception_handler( sigc::ptr_fun(main_exception_handler) );
86 try {
88 Glib::RefPtr<Gnome::Glade::Xml> refXml = LoadXml("BackupWindow.glade");
90 BackupWindow *pWnd = 0;
91 refXml->get_widget_derived("BackupWindow", pWnd);
92 std::auto_ptr<BackupWindow> apWnd(pWnd);
94 Gtk::Main::run(*pWnd);
97 catch(...) {
98 main_exception_handler();
99 return 1;