xfce4-terminal: -e some_command and args here

Danny Milosavljevic danny.milo at gmx.net
Tue Aug 24 00:09:12 CEST 2004


Hi,

Attached is a patch to make xfce4-terminal support "-e" like that:

xfce4-terminal -e ssh 192.168.2.1

It needs a helper script called "xfce4-terminal.helper" in the same
directory as the executed "xfce4-terminal", but that doesnt need to be
executable, just readable.

Please test :)

cheers,
   Danny

-- 
www.keyserver.net key id A334AEA6

-------------- next part --------------
#!/bin/sh

$*
exit "$?"
-------------- next part --------------
bin_PROGRAMS = xfce4-terminal
bin_SCRIPTS = xfce4-terminal.helper

xfce4_terminal_SOURCES = 					\
	inline-icon.h							\
    globals.h                               \
    accelerators.h                          \
    accelerators.c                          \
    callbacks.h                             \
    callbacks.c                             \
    xfce4-terminal.h                        \
	main.c								    \
	main.h

xfce4_terminal_CFLAGS =						\
	-I$(top_srcdir)							\
	-DLOCALEDIR=\"$(localedir)\"				\
	@LIBXFCEGUI4_CFLAGS@					\
	@LIBVTE_CFLAGS@				            \
    @LIBXFCEGUI4_CFLAGS@ \
	@LIBXFCE4MCS_CLIENT_CFLAGS@

xfce4_terminal_LDADD =						\
	@LIBXFCEGUI4_LIBS@					\
	@LIBVTE_LIBS@                      \
	@LIBXFCEGUI4_LIBS@ \
	@LIBXFCE4MCS_CLIENT_LIBS@

noinst_DATA =								\
	xfce4-terminal.png

inline-icon.h: $(srcdir)/xfce4-terminal.png
	gdk-pixbuf-csource --raw --build-list				\
	default_icon_data_48_48 xfce4-terminal.png > $(srcdir)/inline-icon.h

EXTRA_DIST = $(noinst_DATA)


-------------- next part --------------
--- main.c.orig	2004-08-23 21:45:24.-1144875552 +0200
+++ main.c	2004-08-24 00:00:43.-1144875552 +0200
@@ -47,10 +47,15 @@ static GtkWidget *get_menubar_menu (Term
 	return gtk_item_factory_get_widget(t->item_factory, "<main>");
 }
 
+static gchar **
+fargv = NULL;
+
 /* Build up a new terminal from given data */
 Shell *create_terminal(const gchar *shell, const gchar *pwd, const gchar *label, gpointer data)
 {
 	Shell *s = g_new(Shell, 1);
+	gchar *o;
+	int i;
 	s->vte = GTK_WIDGET(vte_terminal_new());
     s->parent = data;
     if (settings && settings->font)
@@ -59,7 +64,18 @@ Shell *create_terminal(const gchar *shel
 	   vte_terminal_set_font_from_string (VTE_TERMINAL(s->vte), DEFAULT_TERMINAL_FONTNAME);
 	s->label = (label != NULL ? gtk_label_new(label) : NULL);
 
-	vte_terminal_fork_command(VTE_TERMINAL(s->vte), shell, NULL, NULL, pwd, FALSE, FALSE, FALSE);
+	if (fargv) {
+		o = fargv[0];
+		fargv[0] = (gchar *)shell;
+		/*fargv[2] = NULL;*/
+	}
+	
+	vte_terminal_fork_command(VTE_TERMINAL(s->vte), shell, fargv, NULL, pwd, FALSE, FALSE, FALSE);
+	if (fargv) {
+		fargv[0] = o;
+		fargv = NULL; /* FIXME free ? */
+	}
+
 	g_signal_connect (s->vte, "child-exited", G_CALLBACK(cb_childexit), (gpointer)s);
 	g_signal_connect (s->vte, "window-title-changed", G_CALLBACK(cb_title_changed), (gpointer)s);
 	g_signal_connect (s->vte, "button-press-event", G_CALLBACK(cb_vte_button_press), (gpointer)data);
@@ -253,6 +269,40 @@ settings_init(Terminal *t)
 	return mcs_client;
 }
 
+static void
+fill_fargv (gint *argc, gchar ***argv)
+{
+	int i;
+	int off;
+	int cnt;
+	gchar **a;
+	if (*argc <= 1)
+		return;
+
+	for(i = 1; i < *argc; i++)
+		if (g_str_equal ((*argv)[i], "-e"))
+			break;
+		
+	if (i >= *argc)
+		return;
+
+	cnt = (*argc) - i - 1;
+	off = i + 1;
+	
+	fargv = g_new0 (char *, cnt + 30);
+	fargv[0] = "someshell";
+	/*fargv[1] = "/usr/local/bin/xfce4-terminal.helper";*/
+	fargv[1] = "xfce4-terminal.helper";
+	fargv[1] = g_strconcat ((*argv)[0], ".helper", NULL);
+	
+	a = &(*argv)[off];
+	
+	for(i = 0; i <= cnt; i++)
+		fargv[i + 2] = *(a++);
+	
+	/*fargv = &(*argv)[i-1];*/
+}
+
 /* Main function */
 gint
 main (gint argc, gchar **argv)
@@ -261,6 +311,8 @@ main (gint argc, gchar **argv)
 
 	gtk_init(&argc, &argv);
 
+	fill_fargv (&argc, &argv);
+
 	t = create_interface();
 	gtk_main();
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
URL: <http://mail.xfce.org/pipermail/xfce4-dev/attachments/20040824/eac794d3/attachment.pgp>


More information about the Xfce4-dev mailing list