Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07 / src / gtkmm / main.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file gtkmm/main.cpp
3 **      \brief Synfig Studio Entrypoint
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2007 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === H E A D E R S ======================================================= */
25
26 #ifdef USING_PCH
27 #       include "pch.h"
28 #else
29 #ifdef HAVE_CONFIG_H
30 #       include <config.h>
31 #endif
32
33 #include "app.h"
34 #include <iostream>
35 #include "ipc.h"
36 #include <stdexcept>
37
38 #endif
39
40 /* === U S I N G =========================================================== */
41
42 using namespace std;
43 using namespace etl;
44 using namespace synfig;
45 using namespace studio;
46
47 /* === M A C R O S ========================================================= */
48
49 /* === G L O B A L S ======================================================= */
50
51 /* === P R O C E D U R E S ================================================= */
52
53 /* === M E T H O D S ======================================================= */
54
55 /* === E N T R Y P O I N T ================================================= */
56
57 int main(int argc, char **argv)
58 {
59         {
60                 SmartFILE file(IPC::make_connection());
61                 if(file)
62                 {
63                         fprintf(file.get(),"F\n");
64
65                         // Hey, another copy of us is open!
66                         // don't bother opening us, just go ahead and
67                         // tell the other copy to load it all up
68                         if(argc>=1)
69                         {
70                                 for(;argc>=1;(argc)--)
71                                         if((argv)[argc] && (argv)[argc][0]!='-')
72                                         {
73                                                 fprintf(file.get(),"O %s\n",etl::absolute_path((argv)[argc]).c_str());
74                                         }
75                         }
76
77                         fprintf(file.get(),"F\n");
78
79                         return 0;
80                 }
81         }
82
83         try
84         {
85                 studio::App app(&argc, &argv);
86
87                 app.run();
88         }
89         catch(synfig::SoftwareExpired)
90         {
91                 cerr<<"FATAL: Software Expired"<<endl;
92                 return 39;
93         }
94         catch(int ret)
95         {
96                 std::cerr<<"Application shutdown with errors ("<<ret<<')'<<std::endl;
97                 return ret;
98         }
99         catch(string str)
100         {
101                 std::cerr<<"Uncaught Exception:string: "<<str<<std::endl;
102                 throw;
103         }
104         catch(std::exception x)
105         {
106                 std::cerr<<"Standard Exception: "<<x.what()<<std::endl;
107                 throw;
108         }
109         catch(Glib::Exception& x)
110         {
111                 std::cerr<<"GLib Exception: "<<x.what()<<std::endl;
112                 throw;
113         }
114         catch(...)
115         {
116                 std::cerr<<"Uncaught Exception"<<std::endl;
117                 throw;
118         }
119
120         std::cerr<<"Application appears to have terminated successfully"<<std::endl;
121
122         return 0;
123 }