1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2
3 /*
4 * Brasero is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * Brasero is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to:
16 * The Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor
18 * Boston, MA 02110-1301, USA.
19 */
20 /***************************************************************************
21 * main.c
22 *
23 * Sat Jun 11 12:00:29 2005
24 * Copyright 2005 Philippe Rouquier
25 * <brasero-app@wanadoo.fr>
26 ****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include <config.h>
30 #endif
31
32 #include <string.h>
33 #include <locale.h>
34
35 #include <glib.h>
36 #include <glib/gi18n-lib.h>
37
38 #include <gtk/gtk.h>
39
40 #include <gst/gst.h>
41
42
43 #include "brasero-burn-lib.h"
44 #include "brasero-misc.h"
45
46 #include "brasero-multi-dnd.h"
47 #include "brasero-app.h"
48 #include "brasero-cli.h"
49
50 static BraseroApp *current_app = NULL;
51
52 /**
53 * This is actually declared in brasero-app.h
54 */
55
56 BraseroApp *
brasero_app_get_default(void)57 brasero_app_get_default (void)
58 {
59 return current_app;
60 }
61
62 int
main(int argc,char ** argv)63 main (int argc, char **argv)
64 {
65 GApplication *gapp = NULL;
66 GOptionContext *context;
67
68 #ifdef ENABLE_NLS
69 bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
70 bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
71 textdomain (GETTEXT_PACKAGE);
72 #endif
73
74 g_thread_init (NULL);
75 g_type_init ();
76
77 /* Though we use gtk_get_option_group we nevertheless want gtk+ to be
78 * in a usable state to display our error messages while brasero
79 * specific options are parsed. Otherwise on error that crashes. */
80 gtk_init (&argc, &argv);
81
82 memset (&cmd_line_options, 0, sizeof (cmd_line_options));
83
84 context = g_option_context_new (_("[URI] [URI] …"));
85 g_option_context_add_main_entries (context,
86 prog_options,
87 GETTEXT_PACKAGE);
88 g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
89
90 g_option_context_add_group (context, gtk_get_option_group (TRUE));
91 g_option_context_add_group (context, brasero_media_get_option_group ());
92 g_option_context_add_group (context, brasero_burn_library_get_option_group ());
93 g_option_context_add_group (context, brasero_utils_get_option_group ());
94 g_option_context_add_group (context, gst_init_get_option_group ());
95 if (g_option_context_parse (context, &argc, &argv, NULL) == FALSE) {
96 g_print (_("Please type \"%s --help\" to see all available options\n"), argv [0]);
97 g_option_context_free (context);
98 return FALSE;
99 }
100 g_option_context_free (context);
101
102 if (cmd_line_options.not_unique == FALSE) {
103 GError *error = NULL;
104 /* Create GApplication and check if there is a process running already */
105 gapp = g_application_new ("org.gnome.Brasero", G_APPLICATION_FLAGS_NONE);
106
107 if (!g_application_register (gapp, NULL, &error)) {
108 g_warning ("Brasero registered");
109 g_error_free (error);
110 return 1;
111 }
112
113 if (g_application_get_is_remote (gapp)) {
114 g_warning ("An instance of Brasero is already running, exiting");
115 return 0;
116 }
117 }
118
119 brasero_burn_library_start (&argc, &argv);
120 brasero_enable_multi_DND ();
121
122 current_app = brasero_app_new (gapp);
123 if (current_app == NULL)
124 return 1;
125
126 brasero_cli_apply_options (current_app);
127
128 g_object_unref (current_app);
129 current_app = NULL;
130
131 brasero_burn_library_stop ();
132
133 gst_deinit ();
134
135 return 0;
136 }
137