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