~ubuntu-branches/debian/sid/gnome-terminal/sid

« back to all changes in this revision

Viewing changes to src/server.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl, Emilio Pozuelo Monfort, Michael Biebl
  • Date: 2013-06-05 22:23:26 UTC
  • mfrom: (1.6.15) (10.1.9 experimental)
  • Revision ID: package-import@ubuntu.com-20130605222326-ymxsw4ia0vri1zwh
Tags: 3.8.2-1
[ Emilio Pozuelo Monfort ]
* Remove obsolete build dependency on scrollkeeper.

[ Michael Biebl ]
* Upload to unstable.
* New upstream release.
* Bump Standards-Version to 3.9.4. No further changes.
* Add Build-Depends on autotools-dev as lintian was complaining about
  outdated config.{guess,sub}.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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
 
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 3 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
 
 
24
#include <errno.h>
 
25
#include <locale.h>
 
26
#include <stdlib.h>
 
27
#include <time.h>
 
28
#include <unistd.h>
 
29
 
 
30
#include <glib.h>
 
31
#include <glib/gi18n.h>
 
32
#include <glib/gstdio.h>
 
33
#include <gio/gio.h>
 
34
 
 
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"
 
40
 
 
41
static char *app_id = NULL;
 
42
 
 
43
static gboolean
 
44
option_app_id_cb (const gchar *option_name,
 
45
                    const gchar *value,
 
46
                    gpointer     data,
 
47
                    GError     **error)
 
48
{
 
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);
 
52
    return FALSE;
 
53
  }
 
54
 
 
55
  g_free (app_id);
 
56
  app_id = g_strdup (value);
 
57
 
 
58
  return TRUE;
 
59
}
 
60
 
 
61
static const GOptionEntry options[] = {
 
62
  { "app-id", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_app_id_cb, "Application ID", "ID" },
 
63
  { NULL }
 
64
};
 
65
 
 
66
int
 
67
main (int argc, char **argv)
 
68
{
 
69
  GApplication *app;
 
70
  int exit_code = EXIT_FAILURE;
 
71
  const char *home_dir;
 
72
  GError *error = NULL;
 
73
 
 
74
  setlocale (LC_ALL, "");
 
75
 
 
76
  terminal_i18n_init (TRUE);
 
77
 
 
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
 
80
   * behaviour.
 
81
   */
 
82
  g_setenv ("LIBOVERLAY_SCROLLBAR", "0", TRUE);
 
83
  g_setenv ("UBUNTU_MENUPROXY", "0", TRUE);
 
84
  g_setenv ("NO_UNITY_GTK_MODULE", "1", TRUE);
 
85
 
 
86
#if !GLIB_CHECK_VERSION (2, 35, 3)
 
87
  g_type_init ();
 
88
#endif
 
89
 
 
90
  _terminal_debug_init ();
 
91
 
 
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 /.
 
96
   */
 
97
  home_dir = g_get_home_dir ();
 
98
  if (home_dir == NULL || chdir (home_dir) < 0)
 
99
    (void) chdir ("/");
 
100
 
 
101
  g_set_prgname ("gnome-terminal-server");
 
102
  g_set_application_name (_("Terminal"));
 
103
 
 
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);
 
107
    exit (EXIT_FAILURE);
 
108
  }
 
109
 
 
110
  app = terminal_app_new (app_id);
 
111
  g_free (app_id);
 
112
 
 
113
  if (!g_application_register (app, NULL, &error)) {
 
114
    g_printerr ("Failed to register application: %s\n", error->message);
 
115
    g_error_free (error);
 
116
    goto out;
 
117
  }
 
118
 
 
119
  if (g_application_get_is_remote (app)) {
 
120
    /* How the fuck did this happen? */
 
121
    g_printerr ("Cannot be remote instance!\n");
 
122
    goto out;
 
123
  }
 
124
 
 
125
  exit_code = g_application_run (app, 0, NULL);
 
126
 
 
127
out:
 
128
  g_object_unref (app);
 
129
 
 
130
  return exit_code;
 
131
}