[gnome-builder/wip/gtk4-port: 1516/1774] plugins/shellcmd: run command in terminal from shortcut
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1516/1774] plugins/shellcmd: run command in terminal from shortcut
- Date: Mon, 11 Jul 2022 22:31:48 +0000 (UTC)
commit 934ca748dda70011ca7fe9e2c150e624ae5b299a
Author: Christian Hergert <chergert redhat com>
Date: Tue Jun 14 23:54:13 2022 -0700
plugins/shellcmd: run command in terminal from shortcut
These will get run differently when used as runners, but for the generic
run a shellcommand shortcut, this will start to get the job done.
.../shellcmd/gbp-shellcmd-shortcut-provider.c | 34 ++++++++++++++++++----
1 file changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/src/plugins/shellcmd/gbp-shellcmd-shortcut-provider.c
b/src/plugins/shellcmd/gbp-shellcmd-shortcut-provider.c
index cc90cb423..f133d2a7c 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-shortcut-provider.c
+++ b/src/plugins/shellcmd/gbp-shellcmd-shortcut-provider.c
@@ -22,7 +22,11 @@
#include "config.h"
+#include <glib/gi18n.h>
+
+#include <libide-editor.h>
#include <libide-gui.h>
+#include <libide-terminal.h>
#include "gbp-shellcmd-command-model.h"
#include "gbp-shellcmd-run-command.h"
@@ -40,8 +44,12 @@ gbp_shellcmd_shortcut_func (GtkWidget *widget,
gpointer user_data)
{
GbpShellcmdRunCommand *command = user_data;
+ g_autoptr(IdePanelPosition) position = NULL;
+ g_autoptr(IdeTerminalLauncher) launcher = NULL;
IdeWorkspace *workspace;
IdeContext *context;
+ const char *title;
+ IdePage *page;
IDE_ENTRY;
@@ -57,11 +65,27 @@ gbp_shellcmd_shortcut_func (GtkWidget *widget,
!(context = ide_workspace_get_context (workspace)))
IDE_RETURN (FALSE);
- /* Commands executed through shortcuts do not run with the run-manager
- * (where as they can be run through that too). Instead we just create
- * a new terminal pane if necessary and add them to that.
- */
- g_print ("TODO: Run shortcut command\n");
+ if (!IDE_IS_PRIMARY_WORKSPACE (workspace) &&
+ !IDE_IS_EDITOR_WORKSPACE (workspace))
+ IDE_RETURN (FALSE);
+
+ if (!(title = ide_run_command_get_display_name (IDE_RUN_COMMAND (command))))
+ title = _("Untitled command");
+
+ launcher = gbp_shellcmd_run_command_create_launcher (command, context);
+ page = g_object_new (IDE_TYPE_TERMINAL_PAGE,
+ "icon-name", "text-x-script-symbolic",
+ "title", title,
+ "launcher", launcher,
+ "manage-spawn", TRUE,
+ "respawn-on-exit", FALSE,
+ NULL);
+
+ position = ide_panel_position_new ();
+
+ ide_workspace_add_page (workspace, page, position);
+ panel_widget_raise (PANEL_WIDGET (page));
+ gtk_widget_grab_focus (GTK_WIDGET (page));
IDE_RETURN (TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]