r1128@localhost: muntyan | 2005-11-27 14:12:07 -0600

Implemented copy/move/link
master
Yevgen Muntyan 2005-11-28 02:13:23 +00:00
parent e6ca813743
commit 1b5c624975
3 changed files with 76 additions and 12 deletions

View File

@ -24,7 +24,7 @@
</ignoreparts>
<projectdirectory>.</projectdirectory>
<absoluteprojectpath>false</absoluteprojectpath>
<description/>
<description></description>
<secondaryLanguages>
<language>C</language>
</secondaryLanguages>
@ -39,7 +39,7 @@
<mainprogram>./medit</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs/>
<programargs></programargs>
<terminal>false</terminal>
<autocompile>false</autocompile>
<envvars/>
@ -190,7 +190,7 @@
<make>
<envvars/>
<abortonerror>true</abortonerror>
<numberofjobs>3</numberofjobs>
<numberofjobs>1</numberofjobs>
<dontact>false</dontact>
<makebin/>
<prio>0</prio>
@ -198,12 +198,12 @@
</kdevautoproject>
<kdevdebugger>
<general>
<dbgshell/>
<dbgshell></dbgshell>
<programargs>--g-fatal-warnings </programargs>
<gdbpath/>
<configGdbScript/>
<runShellScript/>
<runGdbScript/>
<gdbpath></gdbpath>
<configGdbScript></configGdbScript>
<runShellScript></runShellScript>
<runGdbScript></runGdbScript>
<breakonloadinglibs>true</breakonloadinglibs>
<separatetty>false</separatetty>
<floatingtoolbar>true</floatingtoolbar>
@ -304,7 +304,7 @@
</codecompletion>
<references/>
<creategettersetter>
<prefixGet/>
<prefixGet></prefixGet>
<prefixSet>set</prefixSet>
<prefixVariable>m_,_</prefixVariable>
<parameterName>theValue</parameterName>

View File

@ -218,6 +218,7 @@ mooutils_include_headers = \
$(mooutils)/moobigpaned.h \
$(mooutils)/moocellrenderercolor.h \
$(mooutils)/mooclosure.h \
$(mooutils)/moocmd.h \
$(mooutils)/moocombo.h \
$(mooutils)/mooentry.h \
$(mooutils)/moofiltermgr.h \
@ -254,6 +255,7 @@ mooutils_sources = \
$(mooutils)/moobigpaned.c \
$(mooutils)/moocellrenderercolor.c \
$(mooutils)/mooclosure.c \
$(mooutils)/moocmd.c \
$(mooutils)/moocombo.c \
$(mooutils)/moocompat.c \
$(mooutils)/moocompat.h \

View File

@ -34,6 +34,7 @@
#include "mooutils/moofiltermgr.h"
#include "mooutils/mootoggleaction.h"
#include "mooutils/moouixml.h"
#include "mooutils/moocmd.h"
#include MOO_MARSHALS_H
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
@ -4650,12 +4651,69 @@ sync_dest_targets (MooFileView *fileview)
/* Dropping stuff
*/
static void
run_command_on_files (MooFileView *fileview,
GSList *filenames,
const char *destdir,
const char **first_args,
int n_first_args)
{
GError *error = NULL;
MooCmd *cmd;
char **argv;
int list_len, n_args, i;
GSList *l;
g_return_if_fail (filenames != NULL);
g_return_if_fail (destdir != NULL);
g_return_if_fail (n_first_args > 0);
list_len = g_slist_length (filenames);
n_args = list_len + n_first_args + 1;
argv = g_new (char*, n_args + 1);
for (i = 0; i < n_first_args; ++i)
{
g_assert (first_args[i] != NULL);
argv[i] = (char*) first_args[i];
}
argv[n_args-1] = (char*) destdir;
argv[n_args] = NULL;
for (i = 0, l = filenames; l != NULL; l = l->next, i++)
argv[n_first_args + i] = l->data;
cmd = moo_cmd_new_full (NULL, argv, NULL,
G_SPAWN_SEARCH_PATH,
MOO_CMD_STDOUT_TO_PARENT | MOO_CMD_STDERR_TO_PARENT,
NULL, NULL, &error);
if (!cmd)
{
g_critical ("%s: could not spawn '%s'",
G_STRLOC, first_args[0]);
g_critical ("%s: %s", G_STRLOC, error->message);
g_error_free (error);
goto out;
}
g_signal_connect (cmd, "cmd-exit", G_CALLBACK (g_object_unref), NULL);
out:
g_free (argv);
}
static void
copy_files (MooFileView *fileview,
GSList *filenames,
const char *destdir)
{
g_print ("copy-copy\n");
const char *args[] = {"cp", "-R", "--"};
run_command_on_files (fileview, filenames, destdir,
args, G_N_ELEMENTS (args));
}
@ -4664,7 +4722,9 @@ move_files (MooFileView *fileview,
GSList *filenames,
const char *destdir)
{
g_print ("move-move\n");
const char *args[] = {"mv", "--"};
run_command_on_files (fileview, filenames, destdir,
args, G_N_ELEMENTS (args));
}
@ -4673,7 +4733,9 @@ link_files (MooFileView *fileview,
GSList *filenames,
const char *destdir)
{
g_print ("link-link\n");
const char *args[] = {"ln", "-s", "--"};
run_command_on_files (fileview, filenames, destdir,
args, G_N_ELEMENTS (args));
}