static void terminal_nautilus_class_init (TerminalNautilusClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->dispose = terminal_nautilus_dispose; terminal_i18n_init (FALSE); }
int main (int argc, char **argv) { int i; char **argv_copy; const char *startup_id, *display_name; GdkDisplay *display; TerminalOptions *options; TerminalFactory *factory; GError *error = NULL; char *working_directory; int exit_code = EXIT_FAILURE; setlocale (LC_ALL, ""); terminal_i18n_init (TRUE); _terminal_debug_init (); /* Make a NULL-terminated copy since we may need it later */ argv_copy = g_new (char *, argc + 1); for (i = 0; i < argc; ++i) argv_copy [i] = argv [i]; argv_copy [i] = NULL; startup_id = g_getenv ("DESKTOP_STARTUP_ID"); working_directory = g_get_current_dir (); options = terminal_options_parse (working_directory, startup_id, &argc, &argv, &error); if (options == NULL) { g_printerr (_("Failed to parse arguments: %s\n"), error->message); g_error_free (error); g_free (working_directory); g_free (argv_copy); exit (EXIT_FAILURE); } g_set_application_name (_("Terminal")); /* Do this here so that gdk_display is initialized */ if (options->startup_id == NULL) terminal_client_get_fallback_startup_id (&options->startup_id); display = gdk_display_get_default (); display_name = gdk_display_get_name (display); options->display_name = g_strdup (display_name); factory = terminal_factory_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, options->server_app_id ? options->server_app_id : TERMINAL_APPLICATION_ID, TERMINAL_FACTORY_OBJECT_PATH, NULL /* cancellable */, &error); if (factory == NULL) { g_dbus_error_strip_remote_error (error); g_printerr ("Error constructing proxy for %s:%s: %s\n", options->server_app_id ? options->server_app_id : TERMINAL_APPLICATION_ID, TERMINAL_FACTORY_OBJECT_PATH, error->message); g_error_free (error); goto out; } if (!handle_options (factory, options, &error)) { g_dbus_error_strip_remote_error (error); g_printerr ("Failed to handle arguments: %s\n", error->message); } else { exit_code = EXIT_SUCCESS; } g_object_unref (factory); out: terminal_options_free (options); g_free (working_directory); g_free (argv_copy); return exit_code; }
int main (int argc, char **argv) { GApplication *app; int exit_code = EXIT_FAILURE; const char *home_dir, *charset; GError *error = NULL; if (G_UNLIKELY ((getuid () != geteuid () || getgid () != getegid ()) && geteuid () == 0 && getegid () == 0)) { g_printerr ("Wrong euid/egid, exiting.\n"); return _EXIT_FAILURE_WRONG_ID; } setlocale (LC_ALL, ""); terminal_i18n_init (TRUE); if (!g_get_charset (&charset)) { g_printerr ("Non UTF-8 locale (%s) is not supported!\n", charset); return _EXIT_FAILURE_NO_UTF8; } #ifndef ENABLE_DISTRO_PACKAGING #ifdef HAVE_UBUNTU /* Set some env vars to disable the ubuntu modules. Their package will be * built using --enable-distro-packaging, but anyone running from git will * get the right behaviour. */ g_setenv ("LIBOVERLAY_SCROLLBAR", "0", TRUE); g_setenv ("UBUNTU_MENUPROXY", "0", TRUE); g_setenv ("NO_UNITY_GTK_MODULE", "1", TRUE); #endif #endif _terminal_debug_init (); // FIXMEchpe: just use / here but make sure #565328 doesn't regress /* Change directory to $HOME so we don't prevent unmounting, e.g. if the * factory is started by nautilus-open-terminal. See bug #565328. * On failure back to /. */ home_dir = g_get_home_dir (); if (home_dir == NULL || chdir (home_dir) < 0) (void) chdir ("/"); g_set_prgname ("gnome-terminal-server"); g_set_application_name (_("Terminal")); if (!gtk_init_with_args (&argc, &argv, NULL, options, NULL, &error)) { g_printerr ("Failed to parse arguments: %s\n", error->message); g_error_free (error); exit (EXIT_FAILURE); } app = terminal_app_new (app_id); g_free (app_id); if (!g_application_register (app, NULL, &error)) { g_printerr ("Failed to register application: %s\n", error->message); g_error_free (error); goto out; } if (g_application_get_is_remote (app)) { /* How the f**k did this happen? */ g_printerr ("Cannot be remote instance!\n"); goto out; } exit_code = g_application_run (app, 0, NULL); out: g_object_unref (app); return exit_code; }
int main (int argc, char **argv) { gs_unref_object GApplication *app = NULL; const char *home_dir, *charset; GError *error = NULL; if (G_UNLIKELY ((getuid () != geteuid () || getgid () != getegid ()) && geteuid () == 0 && getegid () == 0)) { g_printerr ("Wrong euid/egid, exiting.\n"); return _EXIT_FAILURE_WRONG_ID; } if (setlocale (LC_ALL, "") == NULL) { g_printerr ("Locale not supported.\n"); return _EXIT_FAILURE_UNSUPPORTED_LOCALE; } terminal_i18n_init (TRUE); if (!g_get_charset (&charset)) { g_printerr ("Non UTF-8 locale (%s) is not supported!\n", charset); return _EXIT_FAILURE_NO_UTF8; } /* Sanitise environment */ g_unsetenv ("DBUS_STARTER_BUS_TYPE"); /* Not interested in silly debug spew polluting the journal, bug #749195 */ if (g_getenv ("G_ENABLE_DIAGNOSTIC") == NULL) g_setenv ("G_ENABLE_DIAGNOSTIC", "0", TRUE); #ifndef ENABLE_DISTRO_PACKAGING #ifdef HAVE_UBUNTU /* Set some env vars to disable the ubuntu modules. Their package will be * built using --enable-distro-packaging, but anyone running from git will * get the right behaviour. */ g_setenv ("LIBOVERLAY_SCROLLBAR", "0", TRUE); g_setenv ("UBUNTU_MENUPROXY", "0", TRUE); g_setenv ("NO_UNITY_GTK_MODULE", "1", TRUE); #endif #endif _terminal_debug_init (); // FIXMEchpe: just use / here but make sure #565328 doesn't regress /* Change directory to $HOME so we don't prevent unmounting, e.g. if the * factory is started by nautilus-open-terminal. See bug #565328. * On failure back to /. */ home_dir = g_get_home_dir (); if (home_dir == NULL || chdir (home_dir) < 0) (void) chdir ("/"); g_set_prgname ("gnome-terminal-server"); g_set_application_name (_("Terminal")); if (!gtk_init_with_args (&argc, &argv, NULL, options, NULL, &error)) { g_printerr ("Failed to parse arguments: %s\n", error->message); g_error_free (error); exit (_EXIT_FAILURE_GTK_INIT); } if (!increase_rlimit_nofile ()) { g_printerr ("Failed to increase RLIMIT_NOFILE: %m\n"); } /* Now we can create the app */ app = terminal_app_new (app_id); g_free (app_id); /* We stay around a bit after the last window closed */ g_application_set_inactivity_timeout (app, INACTIVITY_TIMEOUT); return g_application_run (app, 0, NULL); }