1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 
3 /*
4  *  GThumb
5  *
6  *  Copyright (C) 2001-2010 Free Software Foundation, Inc.
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #include <config.h>
23 #include <gtk/gtk.h>
24 #include "gth-application.h"
25 #include "gth-main.h"
26 #include "gth-window.h"
27 #include "main.h"
28 
29 
30 GtkApplication * Main_Application = NULL;
31 gboolean         NewWindow = FALSE;
32 gboolean         StartInFullscreen = FALSE;
33 gboolean         StartSlideshow = FALSE;
34 gboolean         ImportPhotos = FALSE;
35 static gboolean  Restart = FALSE;
36 
37 
38 int
main(int argc,char * argv[])39 main (int argc, char *argv[])
40 {
41 	const char *program_argv0;
42 	int         status;
43 
44 	program_argv0 = argv[0];
45 
46 	/* text domain */
47 
48 	bindtextdomain (GETTEXT_PACKAGE, GTHUMB_LOCALEDIR);
49 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
50 	textdomain (GETTEXT_PACKAGE);
51 
52 	/* run the main application */
53 
54 	Main_Application = gth_application_new ();
55 	status = g_application_run (G_APPLICATION (Main_Application), argc, argv);
56 	g_object_unref (Main_Application);
57 
58 	/* restart if requested by the user */
59 
60 	if (Restart)
61 		g_spawn_command_line_async (program_argv0, NULL);
62 
63 	return status;
64 }
65 
66 
67 void
gth_quit(gboolean restart)68 gth_quit (gboolean restart)
69 {
70 	GList *windows;
71 	GList *scan;
72 
73 	Restart = restart;
74 
75 	windows = g_list_copy (gtk_application_get_windows (Main_Application));
76 	for (scan = windows; scan; scan = scan->next)
77 		gth_window_close (GTH_WINDOW (scan->data));
78 	g_list_free (windows);
79 }
80