Remove ancient trunk folder from svn repository
[synfig.git] / synfig-studio / 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, 2008 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 #include "general.h"
39
40 #endif
41
42 /* === U S I N G =========================================================== */
43
44 using namespace std;
45 using namespace etl;
46 using namespace synfig;
47 using namespace studio;
48
49 /* === M A C R O S ========================================================= */
50
51 /* === G L O B A L S ======================================================= */
52
53 /* === P R O C E D U R E S ================================================= */
54
55 /* === M E T H O D S ======================================================= */
56
57 /* === E N T R Y P O I N T ================================================= */
58
59 int main(int argc, char **argv)
60 {
61
62 #ifdef ENABLE_NLS
63         setlocale(LC_ALL, "");
64         bindtextdomain("synfigstudio", LOCALEDIR);
65         bind_textdomain_codeset("synfigstudio", "UTF-8");
66         textdomain("synfigstudio");
67 #endif
68
69         {
70                 SmartFILE file(IPC::make_connection());
71                 if(file)
72                 {
73                         cout << endl;
74                         cout << "   " << _("synfig studio is already running") << endl << endl;
75                         cout << "   " << _("the existing process will be used") << endl << endl;;
76
77                         // Hey, another copy of us is open!
78                         // don't bother opening us, just go ahead and
79                         // tell the other copy to load it all up
80                         if (argc>1)
81                                 fprintf(file.get(),"F\n");
82
83                         while(--argc)
84                                 if((argv)[argc] && (argv)[argc][0]!='-')
85                                         fprintf(file.get(),"O %s\n",etl::absolute_path((argv)[argc]).c_str());
86
87                         fprintf(file.get(),"F\n");
88
89                         return 0;
90                 }
91         }
92
93         cout << endl;
94         cout << "   " << _("synfig studio -- starting up application...") << endl << endl;
95
96         try
97         {
98                 studio::App app(&argc, &argv);
99
100                 app.run();
101         }
102         catch(int ret)
103         {
104                 std::cerr<<"Application shutdown with errors ("<<ret<<')'<<std::endl;
105                 return ret;
106         }
107         catch(string str)
108         {
109                 std::cerr<<"Uncaught Exception:string: "<<str<<std::endl;
110                 throw;
111         }
112         catch(std::exception x)
113         {
114                 std::cerr<<"Standard Exception: "<<x.what()<<std::endl;
115                 throw;
116         }
117         catch(Glib::Exception& x)
118         {
119                 std::cerr<<"GLib Exception: "<<x.what()<<std::endl;
120                 throw;
121         }
122         catch(...)
123         {
124                 std::cerr<<"Uncaught Exception"<<std::endl;
125                 throw;
126         }
127
128         std::cerr<<"Application appears to have terminated successfully"<<std::endl;
129
130         return 0;
131 }