1 /*
2 SANE EPSON backend
3 Copyright (C) 2001 SEIKO EPSON Corporation
4
5 Date Author Reason
6 06/01/2001 N.Sasaki New
7
8 This file is part of the `iscan' program.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 This program 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
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
24 As a special exception, the copyright holders give permission
25 to link the code of this program with the esmod library and
26 distribute linked combinations including the two. You must obey
27 the GNU General Public License in all respects for all of the
28 code used other then esmod.
29 */
30
31 #include <config.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <libintl.h>
35 #include <locale.h>
36
37 #include "pisa_main.h"
38 #include "pisa_gimp.h"
39 #include "pisa_view_manager.h"
40 #include "pisa_error.h"
41
42 int g_gimp_plugin = 1;
43
44 /*----------------------------------------------------------*/
main(int argc,char * argv[])45 int main ( int argc, char * argv [ ] )
46 {
47 int result;
48
49 setlocale ( LC_ALL, "" );
50 bindtextdomain ( PACKAGE, LOCALEDIR );
51 #ifdef HAVE_GTK_2
52 bind_textdomain_codeset (PACKAGE, "UTF-8");
53 #endif
54 textdomain ( PACKAGE );
55
56 if ( 1 < argc )
57 result = pisa_gimp_main ( argc, argv );
58 else
59 result = 1;
60
61 if ( result )
62 {
63 g_gimp_plugin = 0;
64 pisa_start ( argc, argv );
65 }
66
67 exit ( EXIT_SUCCESS );
68 }
69
70 /*----------------------------------------------------------*/
pisa_gimp_plugin(void)71 int pisa_gimp_plugin ( void )
72 {
73 return g_gimp_plugin;
74 }
75
76 /*----------------------------------------------------------*/
pisa_start(int argc,char * argv[],int gimpversion)77 void pisa_start ( int argc, char * argv [ ] , int gimpversion)
78 {
79 if ( PISA_ERR_SUCCESS != view_manager::create_view_manager ( argc, argv ) )
80 {
81 if ( g_gimp_plugin )
82 pisa_gimp_quit ( );
83 else
84 exit ( EXIT_FAILURE );
85 }
86
87 if ( g_gimp_plugin )
88 {
89 #ifdef HAVE_ANY_GIMP
90 gtk_rc_parse ( pisa_gimp_gtkrc ( ) );
91 if (gimpversion == 1)
92 {
93 gdk_set_use_xshm ( pisa_gimp_use_xshm ( ) );
94 }
95 else
96 {
97 gdk_set_use_xshm ( TRUE );
98 }
99 #endif // HAVE_ANY_GIMP
100 }
101
102 g_view_manager->create_window ( ID_WINDOW_MAIN );
103 g_view_manager->main ( );
104 }
105
106 /*----------------------------------------------------------*/
pisa_quit(void)107 void pisa_quit ( void )
108 {
109 g_view_manager->release_view_manager ( );
110
111 if ( g_gimp_plugin )
112 ::pisa_gimp_quit ( );
113
114 exit ( EXIT_SUCCESS );
115 }
116
117