Commit b3e6d7c5 authored by Christian Hergert's avatar Christian Hergert

terminal: add debug-terminal action

This provides an easy way to access a debug terminal inside the
namespace of the Builder application. "debug-terminal" from the
command bar will place you in the mount/pid namespace for
troubleshooting Builder issues.
parent 55b60fd3
......@@ -60,6 +60,7 @@ struct _GbTerminalView
guint manage_spawn : 1;
guint top_has_spawned : 1;
guint top_has_needs_attention : 1;
guint run_on_host : 1;
};
G_END_DECLS
......
......@@ -43,6 +43,7 @@ enum {
PROP_MANAGE_SPAWN,
PROP_PTY,
PROP_RUNTIME,
PROP_RUN_ON_HOST,
LAST_PROP
};
......@@ -278,7 +279,7 @@ gb_terminal_respawn (GbTerminalView *self,
launcher = ide_subprocess_launcher_new (0);
ide_subprocess_launcher_set_flags (launcher, 0);
ide_subprocess_launcher_set_run_on_host (launcher, TRUE);
ide_subprocess_launcher_set_run_on_host (launcher, self->run_on_host);
ide_subprocess_launcher_set_clear_env (launcher, FALSE);
ide_subprocess_launcher_set_cwd (launcher, workpath);
ide_subprocess_launcher_push_argv (launcher, shell);
......@@ -620,6 +621,10 @@ gb_terminal_view_get_property (GObject *object,
g_value_set_object (value, self->runtime);
break;
case PROP_RUN_ON_HOST:
g_value_set_boolean (value, self->run_on_host);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -651,6 +656,10 @@ gb_terminal_view_set_property (GObject *object,
self->runtime = g_value_dup_object (value);
break;
case PROP_RUN_ON_HOST:
self->run_on_host = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
......@@ -709,6 +718,13 @@ gb_terminal_view_class_init (GbTerminalViewClass *klass)
IDE_TYPE_RUNTIME,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
properties [PROP_RUN_ON_HOST] =
g_param_spec_boolean ("run-on-host",
"Run on Host",
"If the process should be spawned on the host",
TRUE,
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, LAST_PROP, properties);
g_type_ensure (GB_TYPE_TERMINAL);
......@@ -720,6 +736,7 @@ gb_terminal_view_init (GbTerminalView *self)
GtkStyleContext *style_context;
g_autoptr(GSettings) settings = NULL;
self->run_on_host = TRUE;
self->manage_spawn = TRUE;
self->tsearch = g_object_new (GB_TYPE_TERMINAL_SEARCH, NULL);
......
......@@ -76,17 +76,24 @@ new_terminal_activate (GSimpleAction *action,
GbTerminalView *view;
IdePerspective *perspective;
IdeRuntime *runtime = NULL;
const gchar *name;
gboolean run_on_host = TRUE;
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (GB_IS_TERMINAL_WORKBENCH_ADDIN (self));
if (g_strcmp0 (g_action_get_name (G_ACTION (action)), "new-terminal-in-runtime") == 0)
name = g_action_get_name (G_ACTION (action));
if (g_strcmp0 (name, "new-terminal-in-runtime") == 0)
runtime = find_runtime (self->workbench);
else if (g_strcmp0 (name, "debug-terminal") == 0)
run_on_host = FALSE;
perspective = ide_workbench_get_perspective_by_name (self->workbench, "editor");
ide_workbench_set_visible_perspective (self->workbench, perspective);
view = g_object_new (GB_TYPE_TERMINAL_VIEW,
"run-on-host", run_on_host,
"runtime", runtime,
"visible", TRUE,
NULL);
......@@ -230,6 +237,7 @@ gb_terminal_workbench_addin_load (IdeWorkbenchAddin *addin,
static const GActionEntry actions[] = {
{ "new-terminal", new_terminal_activate },
{ "new-terminal-in-runtime", new_terminal_activate },
{ "debug-terminal", new_terminal_activate },
};
g_assert (GB_IS_TERMINAL_WORKBENCH_ADDIN (self));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment