client: legacy: Improve --tab behaviour to open a new tab in an existing window

An often-requested feature has been for "gnome-terminal --tab" to open a
new tab in an existing window, see the discussion in bug 83203. While
in general, when called from an external source, it's often unclear
which window to choose, we can at least provide this when called from
within gnome-terminal.

For this, introduce some environment variables GNOME_TERMINAL_SERVICE
that is the D-Bus unique name of the gnome-terminal-server instance for
the terminal, and GNOME_TERMINAL_SCREEN that is the D-Bus object path
for the D-Bus controller for that terminal.

On the server side, these variables will be set for each terminal
created in the environment of the child process.

On the client side, these variables will be used to define which
window the "--tab" option refers to. Also, optionally, when using
the new "--print-environment" option, the client will print the
corresponding variables for the *newly created* terminal.

https://bugzilla.gnome.org/show_bug.cgi?id=83203
parent 94f1c04b
......@@ -38,7 +38,7 @@ AM_GLIB_GNU_GETTEXT
GLIB_REQUIRED=2.42.0
GLIB_MIN_REQUIRED=2.42
GLIB_MAX_ALLOWED=2.42
GLIB_MAX_ALLOWED=2.50
GIO_REQUIRED=2.34.0
GSETTINGS_DESKTOP_SCHEMAS_REQUIRED=0.1.0
......
......@@ -975,29 +975,104 @@ TerminalScreen *
terminal_app_get_screen_by_uuid (TerminalApp *app,
const char *uuid)
{
g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
return g_hash_table_lookup (app->screen_map, uuid);
}
char *
terminal_app_dup_screen_object_path (TerminalApp *app,
TerminalScreen *screen)
{
char *object_path = g_strdup_printf (TERMINAL_RECEIVER_OBJECT_PATH_FORMAT,
terminal_screen_get_uuid (screen));
object_path = g_strdelimit (object_path, "-", '_');
g_assert (g_variant_is_object_path (object_path));
return object_path;
}
/**
* terminal_app_get_receiver_impl_by_object_path:
* @app:
* @object_path:
*
* Returns: (transfer full): the #TerminalReceiverImpl for @object_path, or %NULL
*/
static TerminalReceiverImpl *
terminal_app_get_receiver_impl_by_object_path (TerminalApp *app,
const char *object_path)
{
gs_unref_object GDBusObject *skeleton =
g_dbus_object_manager_get_object (G_DBUS_OBJECT_MANAGER (app->object_manager),
object_path);
if (skeleton == NULL || !TERMINAL_IS_OBJECT_SKELETON (skeleton))
return NULL;
TerminalReceiverImpl *impl = NULL;
g_object_get (skeleton, "receiver", &impl, NULL);
if (impl == NULL)
return NULL;
g_assert (TERMINAL_IS_RECEIVER_IMPL (impl));
return impl;
}
/**
* terminal_app_get_screen_by_object_path:
* @app:
* @object_path:
*
* Returns: (transfer full): the #TerminalScreen for @object_path, or %NULL
*/
TerminalScreen *
terminal_app_get_screen_by_object_path (TerminalApp *app,
const char *object_path)
{
gs_unref_object TerminalReceiverImpl *impl =
terminal_app_get_receiver_impl_by_object_path (app, object_path);
if (impl == NULL)
return NULL;
return terminal_receiver_impl_get_screen (impl);
}
void
terminal_app_register_screen (TerminalApp *app,
TerminalScreen *screen)
{
const char *uuid;
uuid = terminal_screen_get_uuid (screen);
const char *uuid = terminal_screen_get_uuid (screen);
g_hash_table_insert (app->screen_map, g_strdup (uuid), screen);
gs_free char *object_path = terminal_app_dup_screen_object_path (app, screen);
TerminalObjectSkeleton *skeleton = terminal_object_skeleton_new (object_path);
TerminalReceiverImpl *impl = terminal_receiver_impl_new (screen);
terminal_object_skeleton_set_receiver (skeleton, TERMINAL_RECEIVER (impl));
g_object_unref (impl);
g_dbus_object_manager_server_export (app->object_manager,
G_DBUS_OBJECT_SKELETON (skeleton));
}
void
terminal_app_unregister_screen (TerminalApp *app,
TerminalScreen *screen)
{
gboolean found;
const char *uuid;
const char *uuid = terminal_screen_get_uuid (screen);
gboolean found = g_hash_table_remove (app->screen_map, uuid);
g_warn_if_fail (found);
if (!found)
return; /* repeat unregistering */
gs_free char *object_path = terminal_app_dup_screen_object_path (app, screen);
gs_unref_object TerminalReceiverImpl *impl =
terminal_app_get_receiver_impl_by_object_path (app, object_path);
g_warn_if_fail (impl != NULL);
if (impl != NULL)
terminal_receiver_impl_unset_screen (impl);
uuid = terminal_screen_get_uuid (screen);
found = g_hash_table_remove (app->screen_map, uuid);
g_assert (found == TRUE);
g_dbus_object_manager_server_unexport (app->object_manager, object_path);
}
GdkAtom *
......
......@@ -79,9 +79,15 @@ TerminalScreen *terminal_app_new_terminal (TerminalApp *app,
char **child_env,
double zoom);
char *terminal_app_dup_screen_object_path (TerminalApp *app,
TerminalScreen *screen);
TerminalScreen *terminal_app_get_screen_by_uuid (TerminalApp *app,
const char *uuid);
TerminalScreen *terminal_app_get_screen_by_object_path (TerminalApp *app,
const char *object_path);
void terminal_app_register_screen (TerminalApp *app,
TerminalScreen *screen);
......
......@@ -22,6 +22,7 @@
#include "config.h"
#include "terminal-client-utils.h"
#include "terminal-defines.h"
#include "terminal-libgsystem.h"
#include <string.h>
......@@ -47,7 +48,7 @@
*
* Appends common options to @builder.
*/
void
void
terminal_client_append_create_instance_options (GVariantBuilder *builder,
const char *display_name,
const char *startup_id,
......@@ -106,7 +107,7 @@ terminal_client_append_create_instance_options (GVariantBuilder *builder,
*
* Appends the environment and the working directory to @builder.
*/
void
void
terminal_client_append_exec_options (GVariantBuilder *builder,
const char *working_directory,
PassFdElement *fd_array,
......@@ -127,6 +128,8 @@ terminal_client_append_exec_options (GVariantBuilder *builder,
envv = g_environ_unsetenv (envv, "TERM");
envv = g_environ_unsetenv (envv, "VTE_VERSION");
envv = g_environ_unsetenv (envv, "WINDOWID");
envv = g_environ_unsetenv (envv, TERMINAL_ENV_SERVICE_NAME);
envv = g_environ_unsetenv (envv, TERMINAL_ENV_SCREEN);
g_variant_builder_add (builder, "{sv}",
"environ",
......
......@@ -35,11 +35,14 @@ enum {
#define TERMINAL_FACTORY_OBJECT_PATH TERMINAL_OBJECT_PATH_PREFIX "/Factory0"
#define TERMINAL_FACTORY_INTERFACE_NAME TERMINAL_OBJECT_INTERFACE_PREFIX ".Factory0"
#define TERMINAL_RECEIVER_OBJECT_PATH_FORMAT TERMINAL_OBJECT_PATH_PREFIX "/window/%u/terminal/%s"
#define TERMINAL_RECEIVER_OBJECT_PATH_FORMAT TERMINAL_OBJECT_PATH_PREFIX "/screen/%s"
#define TEMRINAL_RECEIVER_INTERFACE_NAME TERMINAL_OBJECT_INTERFACE_PREFIX ".Terminal0"
#define TERMINAL_SEARCH_PROVIDER_PATH TERMINAL_OBJECT_PATH_PREFIX "/SearchProvider"
#define TERMINAL_ENV_SERVICE_NAME "GNOME_TERMINAL_SERVICE"
#define TERMINAL_ENV_SCREEN "GNOME_TERMINAL_SCREEN"
G_END_DECLS
#endif /* !TERMINAL_DEFINES_H */
......@@ -28,6 +28,7 @@
#include "terminal-mdi-container.h"
#include "terminal-util.h"
#include "terminal-window.h"
#include "terminal-libgsystem.h"
/* ------------------------------------------------------------------------- */
......@@ -44,17 +45,6 @@ enum {
/* helper functions */
static char *
get_object_path_for_screen (TerminalWindow *window,
TerminalScreen *screen)
{
return g_strdelimit (g_strdup_printf (TERMINAL_RECEIVER_OBJECT_PATH_FORMAT,
gtk_application_window_get_id (GTK_APPLICATION_WINDOW (window)),
terminal_screen_get_uuid (screen)),
"-", '_');
}
static void
child_exited_cb (VteTerminal *terminal,
int exit_code,
......@@ -65,7 +55,7 @@ child_exited_cb (VteTerminal *terminal,
static void
terminal_receiver_impl_set_screen (TerminalReceiverImpl *impl,
TerminalScreen *screen)
TerminalScreen *screen)
{
TerminalReceiverImplPrivate *priv;
......@@ -85,11 +75,8 @@ terminal_receiver_impl_set_screen (TerminalReceiverImpl *impl,
priv->screen = screen;
if (screen) {
g_signal_connect (screen, "child-exited",
G_CALLBACK (child_exited_cb),
G_CALLBACK (child_exited_cb),
impl);
g_signal_connect_swapped (screen, "destroy",
G_CALLBACK (_terminal_receiver_impl_unset_screen),
impl);
}
g_object_notify (G_OBJECT (impl), "screen");
......@@ -97,7 +84,7 @@ terminal_receiver_impl_set_screen (TerminalReceiverImpl *impl,
/* Class implementation */
static gboolean
static gboolean
terminal_receiver_impl_exec (TerminalReceiver *receiver,
GDBusMethodInvocation *invocation,
GUnixFDList *fd_list,
......@@ -292,15 +279,15 @@ terminal_receiver_impl_class_init (TerminalReceiverImplClass *klass)
TerminalReceiverImpl *
terminal_receiver_impl_new (TerminalScreen *screen)
{
return g_object_new (TERMINAL_TYPE_RECEIVER_IMPL,
"screen", screen,
return g_object_new (TERMINAL_TYPE_RECEIVER_IMPL,
"screen", screen,
NULL);
}
/**
* terminal_receiver_impl_get_screen:
* @impl: a #TerminalReceiverImpl
*
*
* Returns: (transfer none): the impl's #TerminalScreen, or %NULL
*/
TerminalScreen *
......@@ -312,13 +299,13 @@ terminal_receiver_impl_get_screen (TerminalReceiverImpl *impl)
}
/**
* terminal_receiver_impl_get_screen:
* terminal_receiver_impl_unget_screen:
* @impl: a #TerminalReceiverImpl
*
*
* Unsets the impls #TerminalScreen.
*/
void
_terminal_receiver_impl_unset_screen (TerminalReceiverImpl *impl)
terminal_receiver_impl_unset_screen (TerminalReceiverImpl *impl)
{
g_return_if_fail (TERMINAL_IS_RECEIVER_IMPL (impl));
......@@ -334,86 +321,70 @@ struct _TerminalFactoryImplPrivate {
gpointer dummy;
};
#define RECEIVER_IMPL_SKELETON_DATA_KEY "terminal-object-skeleton"
static void
screen_destroy_cb (GObject *screen,
gpointer user_data)
{
GDBusObjectManagerServer *object_manager;
GDBusObjectSkeleton *skeleton;
const char *object_path;
skeleton = g_object_get_data (screen, RECEIVER_IMPL_SKELETON_DATA_KEY);
if (skeleton == NULL)
return;
object_manager = terminal_app_get_object_manager (terminal_app_get ());
object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (skeleton));
g_dbus_object_manager_server_unexport (object_manager, object_path);
g_object_set_data (screen, RECEIVER_IMPL_SKELETON_DATA_KEY, NULL);
}
static gboolean
terminal_factory_impl_create_instance (TerminalFactory *factory,
GDBusMethodInvocation *invocation,
GVariant *options)
{
TerminalApp *app = terminal_app_get ();
TerminalSettingsList *profiles_list;
GDBusObjectManagerServer *object_manager;
TerminalWindow *window;
TerminalScreen *screen;
TerminalReceiverImpl *impl;
TerminalObjectSkeleton *skeleton;
char *object_path;
GSettings *profile = NULL;
const char *profile_uuid, *title, *encoding;
gboolean zoom_set = FALSE;
gdouble zoom = 1.0;
guint window_id;
gboolean show_menubar;
gboolean active;
gboolean have_new_window, present_window, present_window_set;
GError *err = NULL;
/* Look up the profile */
if (!g_variant_lookup (options, "profile", "&s", &profile_uuid))
profile_uuid = NULL;
if (!g_variant_lookup (options, "encoding", "&s", &encoding))
encoding = NULL; /* use profile encoding */
/* If a parent screen is specified, use that to fill in missing information */
TerminalScreen *parent_screen = NULL;
const char *parent_screen_object_path;
if (g_variant_lookup (options, "parent-screen", "&o", &parent_screen_object_path)) {
parent_screen = terminal_app_get_screen_by_object_path (app, parent_screen_object_path);
if (parent_screen == NULL) {
g_dbus_method_invocation_return_error (invocation,
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"Failed to get screen from object path %s",
parent_screen_object_path);
return TRUE;
}
}
profiles_list = terminal_app_get_profiles_list (app);
profile = terminal_profiles_list_ref_profile_by_uuid (profiles_list, profile_uuid, &err);
if (profile == NULL)
{
g_dbus_method_invocation_return_gerror (invocation, err);
g_error_free (err);
goto out;
/* Try getting a parent window, first by parent screen then by window ID;
* if that fails, create a new window.
*/
TerminalWindow *window = NULL;
gboolean have_new_window = FALSE;
const char *window_from_screen_object_path;
if (g_variant_lookup (options, "window-from-screen", "&o", &window_from_screen_object_path)) {
TerminalScreen *window_screen =
terminal_app_get_screen_by_object_path (app, window_from_screen_object_path);
if (window_screen == NULL) {
g_dbus_method_invocation_return_error (invocation,
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"Failed to get screen from object path %s",
parent_screen_object_path);
return TRUE;
}
if (g_variant_lookup (options, "window-id", "u", &window_id)) {
GtkWindow *win;
GtkWidget *win = gtk_widget_get_toplevel (GTK_WIDGET (window_screen));
if (TERMINAL_IS_WINDOW (win))
window = TERMINAL_WINDOW (win);
}
win = gtk_application_get_window_by_id (GTK_APPLICATION (app), window_id);
/* Support old client */
guint window_id;
if (window == NULL && g_variant_lookup (options, "window-id", "u", &window_id)) {
GtkWindow *win = gtk_application_get_window_by_id (GTK_APPLICATION (app), window_id);
if (!TERMINAL_IS_WINDOW (win)) {
g_dbus_method_invocation_return_error (invocation,
G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS,
"Nonexisting window %u referenced",
window_id);
goto out;
return TRUE;
}
window = TERMINAL_WINDOW (win);
have_new_window = FALSE;
} else {
}
/* Still no parent window? Create a new one */
if (window == NULL) {
const char *startup_id, *role;
gboolean start_maximized, start_fullscreen;
/* Create a new window */
/* We don't do multi-display anymore */
#if 0
const char *display_name;
......@@ -429,8 +400,8 @@ terminal_factory_impl_create_instance (TerminalFactory *factory,
#endif
int monitor = 0;
window = terminal_app_new_window (app, monitor);
have_new_window = TRUE;
if (g_variant_lookup (options, "desktop-startup-id", "^&ay", &startup_id))
gtk_window_set_startup_id (GTK_WINDOW (window), startup_id);
......@@ -439,6 +410,7 @@ terminal_factory_impl_create_instance (TerminalFactory *factory,
if (g_variant_lookup (options, "role", "&s", &role))
gtk_window_set_role (GTK_WINDOW (window), role);
gboolean show_menubar;
if (g_variant_lookup (options, "show-menubar", "b", &show_menubar))
terminal_window_set_menubar_visible (window, show_menubar);
......@@ -454,43 +426,62 @@ terminal_factory_impl_create_instance (TerminalFactory *factory,
have_new_window = TRUE;
}
g_assert (window != NULL);
g_assert_nonnull (window);
const char *title;
if (!g_variant_lookup (options, "title", "&s", &title))
title = NULL;
if (g_variant_lookup (options, "zoom", "d", &zoom))
zoom_set = TRUE;
screen = terminal_screen_new (profile, encoding, NULL, title, NULL, NULL,
zoom_set ? zoom : 1.0);
terminal_window_add_screen (window, screen, -1);
double zoom;
if (!g_variant_lookup (options, "zoom", "d", &zoom)) {
if (parent_screen != NULL)
zoom = vte_terminal_get_font_scale (VTE_TERMINAL (parent_screen));
else
zoom = 1.0;
}
object_path = get_object_path_for_screen (window, screen);
g_assert (g_variant_is_object_path (object_path));
const char *encoding;
if (!g_variant_lookup (options, "encoding", "&s", &encoding)) {
if (parent_screen != NULL)
encoding = vte_terminal_get_encoding (VTE_TERMINAL (parent_screen));
else
encoding = NULL; /* use profile encoding */
}
skeleton = terminal_object_skeleton_new (object_path);
impl = terminal_receiver_impl_new (screen);
terminal_object_skeleton_set_receiver (skeleton, TERMINAL_RECEIVER (impl));
g_object_unref (impl);
/* Look up the profile */
gs_unref_object GSettings *profile = NULL;
const char *profile_uuid;
if (!g_variant_lookup (options, "profile", "&s", &profile_uuid))
profile_uuid = NULL;
object_manager = terminal_app_get_object_manager (app);
g_dbus_object_manager_server_export (object_manager, G_DBUS_OBJECT_SKELETON (skeleton));
g_object_set_data_full (G_OBJECT (screen), RECEIVER_IMPL_SKELETON_DATA_KEY,
skeleton, (GDestroyNotify) g_object_unref);
g_signal_connect (screen, "destroy",
G_CALLBACK (screen_destroy_cb), app);
if (profile_uuid == NULL && parent_screen != NULL) {
profile = terminal_screen_ref_profile (parent_screen);
} else {
GError *err = NULL;
profile = terminal_profiles_list_ref_profile_by_uuid (terminal_app_get_profiles_list (app),
profile_uuid /* default if NULL */,
&err);
if (profile == NULL) {
g_dbus_method_invocation_return_gerror (invocation, err);
g_error_free (err);
return TRUE;
}
}
g_assert_nonnull (profile);
/* Now we can create the new screen */
TerminalScreen *screen = terminal_screen_new (profile, encoding, NULL, title, NULL, NULL, zoom);
terminal_window_add_screen (window, screen, -1);
/* Apply window properties */
gboolean active;
if (g_variant_lookup (options, "active", "b", &active) &&
active) {
terminal_window_switch_screen (window, screen);
gtk_widget_grab_focus (GTK_WIDGET (screen));
}
if (g_variant_lookup (options, "present-window", "b", &present_window))
present_window_set = TRUE;
else
present_window_set = FALSE;
if (have_new_window) {
const char *geometry;
......@@ -500,17 +491,15 @@ terminal_factory_impl_create_instance (TerminalFactory *factory,
"Invalid geometry string \"%s\"", geometry);
}
gboolean present_window;
gboolean present_window_set = g_variant_lookup (options, "present-window", "b", &present_window);
if (have_new_window || (present_window_set && present_window))
gtk_window_present (GTK_WINDOW (window));
gs_free char *object_path = terminal_app_dup_screen_object_path (app, screen);
terminal_factory_complete_create_instance (factory, invocation, object_path);
g_free (object_path);
out:
if (profile)
g_object_unref (profile);
return TRUE; /* handled */
}
......@@ -532,7 +521,7 @@ terminal_factory_impl_init (TerminalFactoryImpl *impl)
static void
terminal_factory_impl_class_init (TerminalFactoryImplClass *klass)
{
g_type_class_add_private (klass, sizeof (TerminalFactoryImplPrivate));
/* g_type_class_add_private (klass, sizeof (TerminalFactoryImplPrivate)); */
}
/**
......
......@@ -55,7 +55,7 @@ TerminalReceiverImpl *terminal_receiver_impl_new (TerminalScreen *screen);
TerminalScreen *terminal_receiver_impl_get_screen (TerminalReceiverImpl *impl);
void _terminal_receiver_impl_unset_screen (TerminalReceiverImpl *impl);
void terminal_receiver_impl_unset_screen (TerminalReceiverImpl *impl);
/* ------------------------------------------------------------------------- */
......
......@@ -3,7 +3,7 @@
* Copyright © 2002 Red Hat, Inc.
* Copyright © 2002 Sun Microsystems
* Copyright © 2003 Mariano Suarez-Alvarez
* Copyright © 2008 Christian Persch
* Copyright © 2008, 2017 Christian Persch
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -31,6 +31,7 @@
#include "terminal-options.h"
#include "terminal-client-utils.h"
#include "terminal-defines.h"
#include "terminal-screen.h"
#include "terminal-app.h"
#include "terminal-util.h"
......@@ -39,21 +40,50 @@
static int verbosity = 1;
static char * G_GNUC_FORMAT (1)
format_as_comment (const char *format)
{
return g_strdup_printf ("# %s", format);
}
void
terminal_fprintf (FILE* fp,
int verbosity_level,
char const* format,
const char* format,
...)
{
if (verbosity < verbosity_level)
return;
gs_free char *commented_format = format_as_comment (format);
va_list args;
va_start(args, format);
g_vfprintf(fp, format, args);
g_vfprintf(fp, commented_format, args);
va_end(args);
}
#if GLIB_CHECK_VERSION (2, 50, 0)
/* Need to install a special log writer so we never output
* anything without the '# ' prepended, in case --print-environment
* is used.
*/
GLogWriterOutput
terminal_log_writer (GLogLevelFlags log_level,
const GLogField *fields,
gsize n_fields,
gpointer user_data)
{
for (gsize i = 0; i < n_fields; i++) {
if (g_str_equal (fields[i].key, "MESSAGE"))
terminal_printerr ("%s\n", (const char*)fields[i].value);
}
return G_LOG_WRITER_HANDLED;
}
#endif /* GLIB 2.50 */
static GOptionContext *get_goption_context (TerminalOptions *options);
static TerminalSettingsList *
......@@ -163,7 +193,7 @@ initial_window_free (InitialWindow *iw)
static void
apply_defaults (TerminalOptions *options,
InitialWindow *iw)
InitialWindow *iw)
{
if (options->default_role)
{
......@@ -187,24 +217,34 @@ apply_defaults (TerminalOptions *options,
}
static InitialWindow*
ensure_top_window (TerminalOptions *options)
add_new_window (TerminalOptions *options,
char *profile /* adopts */,
gboolean implicit_if_first_window)
{
InitialWindow *iw;
if (options->initial_windows == NULL)
{
iw = initial_window_new (0);
iw->tabs = g_list_append (NULL, initial_tab_new (NULL));
apply_defaults (options, iw);
iw = initial_window_new (0);
iw->implicit_first_window = (options->initial_windows == NULL) && implicit_if_first_window;
iw->tabs = g_list_prepend (NULL, initial_tab_new (profile));
apply_defaults (options, iw);
options->initial_windows = g_list_append (options->initial_windows, iw);
}
options->initial_windows = g_list_append (options->initial_windows, iw);
return iw;
}
static InitialWindow*
ensure_top_window (TerminalOptions *options,
gboolean implicit_if_first_window)
{
InitialWindow *iw;
if (options->initial_windows == NULL)
iw = add_new_window (options, NULL /* profile */, implicit_if_first_window);
else
{
iw = g_list_last (options->initial_windows)->data;
}
g_assert (iw->tabs);
g_assert_nonnull (iw->tabs);
return iw;
}
......@@ -215,30 +255,15 @@ ensure_top_tab (TerminalOptions *options)
InitialWindow *iw;
InitialTab *it;
iw = ensure_top_window (options);
iw = ensure_top_window (options, TRUE);
g_assert (iw->tabs);
g_assert_nonnull (iw->tabs);
it = g_list_last (iw->tabs)->data;
return it;
}
static InitialWindow*
add_new_window (TerminalOptions *options,
char *profile /* adopts */)
{
InitialWindow *iw;
iw = initial_window_new (0);
iw->tabs = g_list_prepend (NULL, initial_tab_new (profile));
apply_defaults (options, iw);
options->initial_windows = g_list_append (options->initial_windows, iw);
return iw;
}
/* handle deprecated command line options */
static void
......@@ -453,22 +478,24 @@ option_window_callback (const gchar *option_name,
TerminalOptions *options = data;
char *profile;
profile = terminal_profiles_list_dup_uuid_or_name (terminal_options_ensure_profiles_list (options),
value, error);
if (value != NULL) {
profile = terminal_profiles_list_dup_uuid_or_name (terminal_options_ensure_profiles_list (options),
value, error);
if (value && profile == NULL)
{
if (value && profile == NULL) {
terminal_printerr ("Profile '%s' specified but not found. Attempting to fall back "
"to the default profile.\n", value);
g_clear_error (error);
profile = terminal_profiles_list_dup_uuid_or_name (terminal_options_ensure_profiles_list (options),
NULL, error);
}
}
if (profile == NULL)
return FALSE;
if (profile == NULL)
return FALSE;
} else
profile = NULL;
add_new_window (options, profile /* adopts */);
add_new_window (options, profile /* adopts */, FALSE);
return TRUE;
}
......@@ -482,10 +509,13 @@ option_tab_callback (const gchar *option_name,
TerminalOptions *options = data;
char *profile;
profile = terminal_profiles_list_dup_uuid_or_name (terminal_options_ensure_profiles_list (options),
value, error);
if (profile == NULL)
return FALSE;
if (value != NULL) {
profile = terminal_profiles_list_dup_uuid_or_name (terminal_options_ensure_profiles_list (options),
value, error);
if (profile == NULL)
return FALSE;