initial version
[synfig.git] / synfig-studio / trunk / src / gtkmm / main.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file main.cpp
3 **      \brief Sinfg Studio Entrypoint
4 **
5 **      $Id: main.cpp,v 1.2 2005/01/13 18:37:30 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "app.h"
32 #include <iostream>
33 #include "ipc.h"
34 #include <stdexcept>
35
36 #endif
37
38 /* === U S I N G =========================================================== */
39
40 using namespace std;
41 using namespace etl;
42 using namespace sinfg;
43 using namespace studio;
44
45 /* === M A C R O S ========================================================= */
46
47 /* === G L O B A L S ======================================================= */
48
49 /* === P R O C E D U R E S ================================================= */
50
51 /* === M E T H O D S ======================================================= */
52
53 /* === E N T R Y P O I N T ================================================= */
54
55 int main(int argc, char **argv)
56 {
57         {
58                 SmartFILE file(IPC::make_connection());
59                 if(file)
60                 {
61                         fprintf(file.get(),"F\n");
62
63                         // Hey, another copy of us is open!
64                         // don't bother opening us, just go ahead and
65                         // tell the other copy to load it all up
66                         if(argc>=1)
67                         {
68                                 for(;argc>=1;(argc)--)
69                                         if((argv)[argc] && (argv)[argc][0]!='-')
70                                         {
71                                                 fprintf(file.get(),"O %s\n",etl::absolute_path((argv)[argc]).c_str());
72                                         }
73                         }
74                         
75                         fprintf(file.get(),"F\n");
76
77                         return 0;
78                 }
79         }
80
81         try
82         {
83                 studio::App app(&argc, &argv);
84
85                 app.run();
86         }
87         catch(sinfg::SoftwareExpired)
88         {
89                 cerr<<"FATAL: Software Expired"<<endl;
90                 return 39;
91         }
92         catch(int ret)
93         {
94                 std::cerr<<"Application shutdown with errors ("<<ret<<')'<<std::endl;
95                 return ret;
96         }
97         catch(string str)
98         {
99                 std::cerr<<"Uncaught Exception:string: "<<str<<std::endl;
100                 throw;
101         }
102         catch(std::exception x)
103         {
104                 std::cerr<<"Standard Exception: "<<x.what()<<std::endl;
105                 throw;
106         }
107         catch(Glib::Exception& x)
108         {
109                 std::cerr<<"GLib Exception: "<<x.what()<<std::endl;
110                 throw;
111         }
112         catch(...)
113         {
114                 std::cerr<<"Uncaught Exception"<<std::endl;
115                 throw;
116         }
117
118         std::cerr<<"Application appears to have terminated successfuly"<<std::endl;
119         
120         return 0;
121 }