xfrun a directory
James Tappin
james at tappin.me.uk
Fri Mar 7 20:53:38 CET 2003
Here is a updated version of the patch I submitted a while back to allow
xfrun to open a directory. Basically if you just enter a directory it
opens that dir in xffm, if you check "run in terminal" then it starts a
new terminal in the directory. This is a slight tweak of Jens' cleanup of
my original to fit with later versions of xfrun. Can others try it and see
if it works as expected; it's OK for me on Debian and RedHat, but last
time round Jens couldn't get it to work in the terminal option.
++++++CUT HERE++++++++++
--- xfrun.c.~1.5.~ 2003-02-16 10:22:28.000000000 +0000
+++ xfrun.c 2003-02-16 14:13:10.000000000 +0000
@@ -17,6 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <sys/types.h>
+#include <sys/stat.h>
#include <gtk/gtk.h>
#include <stdio.h>
#include <stdlib.h>
@@ -32,7 +34,7 @@
#define DEFAULT_LENGTH PATH_MAX
#endif
#endif
-
+
#define _(x) x
#define N_(x) x
@@ -96,10 +98,32 @@
g_return_val_if_fail(cmd != NULL, FALSE);
- if(in_terminal)
- execute = g_strdup_printf("xfterm -e %s", cmd);
+ if (g_file_test (cmd, G_FILE_TEST_IS_DIR))
+ {
+ if(in_terminal)
+ {
+ chdir(cmd);
+ /* Use +ls so that the terminal starts in the
+ requested directory even if the user has xterm
+ default to a login shell */
+ execute = g_strdup("xfterm4 +ls");
+ }
+ else
+ {
+ execute = g_strconcat("xffm ", cmd, NULL);
+ }
+ }
else
- execute = g_strdup(cmd);
+ {
+ if(in_terminal)
+ {
+ execute = g_strconcat("xfterm4 -e ", cmd, NULL);
+ }
+ else
+ {
+ execute = g_strdup(cmd);
+ }
+ }
if(!g_spawn_command_line_async(execute, &error))
{
+++++++++CUT HERE++++++++++
Best regards,
James
P.S. Does anyone have any thoughts on retaining the "run in terminal"
state in the xfrun history?
--
James Tappin, O__ "I forget the punishment for using
james at tappin.me.uk -- \/` Microsoft --- Something lingering
http://www.tappin.me.uk/ with data loss in it I fancy"
More information about the Xfce4-dev
mailing list