2
* Copyright © 2001, 2002 Havoc Pennington
3
* Copyright © 2002 Red Hat, Inc.
4
* Copyright © 2002 Sun Microsystems
5
* Copyright © 2003 Mariano Suarez-Alvarez
6
* Copyright © 2008, 2010, 2011 Christian Persch
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 3 of the License, or
11
* (at your option) any later version.
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.
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/>.
31
#include <glib/gi18n.h>
32
#include <glib/gstdio.h>
35
#include "terminal-app.h"
36
#include "terminal-debug.h"
37
#include "terminal-gdbus.h"
38
#include "terminal-i18n.h"
39
#include "terminal-defines.h"
41
static char *app_id = NULL;
44
option_app_id_cb (const gchar *option_name,
49
if (!g_application_id_is_valid (value)) {
50
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
51
"\"%s\" is not a valid application ID", value);
56
app_id = g_strdup (value);
61
static const GOptionEntry options[] = {
62
{ "app-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_app_id_cb, "Application ID", "ID" },
67
main (int argc, char **argv)
70
int exit_code = EXIT_FAILURE;
74
setlocale (LC_ALL, "");
76
terminal_i18n_init (TRUE);
78
/* Set some env vars to disable ubuntu crap. They'll certainly patch this
79
* out in their package, but anyone running from git will get the right
82
g_setenv ("LIBOVERLAY_SCROLLBAR", "0", TRUE);
83
g_setenv ("UBUNTU_MENUPROXY", "0", TRUE);
84
g_setenv ("NO_UNITY_GTK_MODULE", "1", TRUE);
86
#if !GLIB_CHECK_VERSION (2, 35, 3)
90
_terminal_debug_init ();
92
// FIXMEchpe: just use / here but make sure #565328 doesn't regress
93
/* Change directory to $HOME so we don't prevent unmounting, e.g. if the
94
* factory is started by nautilus-open-terminal. See bug #565328.
95
* On failure back to /.
97
home_dir = g_get_home_dir ();
98
if (home_dir == NULL || chdir (home_dir) < 0)
101
g_set_prgname ("gnome-terminal-server");
102
g_set_application_name (_("Terminal"));
104
if (!gtk_init_with_args (&argc, &argv, NULL, options, NULL, &error)) {
105
g_printerr ("Failed to parse arguments: %s\n", error->message);
106
g_error_free (error);
110
app = terminal_app_new (app_id);
113
if (!g_application_register (app, NULL, &error)) {
114
g_printerr ("Failed to register application: %s\n", error->message);
115
g_error_free (error);
119
if (g_application_get_is_remote (app)) {
120
/* How the fuck did this happen? */
121
g_printerr ("Cannot be remote instance!\n");
125
exit_code = g_application_run (app, 0, NULL);
128
g_object_unref (app);