home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / XAP / XFILEMAN / XFILEMAN.TAR / xfilemanager / action_delete.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-22  |  3.9 KB  |  180 lines

  1. /*
  2.  * Copyright 1993 by Ove Kalkan, Cremlingen, Germany
  3.  *
  4.  * Permission to use, copy, modify, distribute and sell this software and it's
  5.  * documentation for any purpose is hereby granted without fee, rpovided that
  6.  * the above copyright notice and this permission appear in supporting
  7.  * documentation, and that the name of Ove Kalkan not to be used in
  8.  * advertising or publicity pertaining to distributiopn of the software without
  9.  * specific, written prior permission. Ove Kalkan makes no representations
  10.  * about the suitability of this software for any purpose. It is provided
  11.  * as is without express or implied warranty.
  12.  *
  13.  * OVE KALKAN DISPLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  14.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABLILITY AND FITNESS, IN NO
  15.  * EVENT SHALL OVE KALKAN BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  16.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  17.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18.  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19.  * PERFORMANCE OF THIS SOFTWARE.
  20.  *
  21.  * $Header: filename,v 1.0 yyyy/mm/dd hh:mm:ss loginname Exp $
  22.  */
  23.  
  24.  
  25. #include "global.h"
  26.  
  27. /*
  28.  * Global variables
  29.  */
  30.  
  31.  
  32.  
  33. /*********************************************************
  34.  * name:    init_delete
  35.  * description:    erzeugt ein Fenster mit 1 text zum Loeschen
  36.  * input:    char *file
  37.  * output:    none
  38.  * date:    10.5.93
  39.  *********************************************************/
  40. void    init_delete (char *file)
  41. {
  42.     Widget    but;
  43.  
  44.     /*
  45.      * Das Dialogfenster erzeugen
  46.      */
  47.     but = makeDialog(1,"File :","",file,NULL,"Remove File",TRUE,FALSE,Icon_Delete_PM);
  48.  
  49.     XtAddCallback(but,XtNcallback,(XtCallbackProc) exec_delete_cb,NULL);
  50.  
  51.     /*
  52.      * Zum Schluss die Dialogshell managen
  53.      */
  54.     XtManageChild (dialog);
  55.  
  56.     /*
  57.      * Max und Minsize setzen
  58.      */
  59.     setSize();
  60. }
  61.  
  62.  
  63. /*********************************************************
  64.  * name:    exec_delete
  65.  * description:    Operation File-Loeschen ausfuehren
  66.  * input:    none
  67.  * output:    none
  68.  * date:    14.6.93
  69.  *********************************************************/
  70. void    exec_delete_cb (void)
  71. {
  72.     char    *from;
  73.     Arg    args[1];
  74.     char    buf[1024];
  75.  
  76.     /*
  77.      * Die Texte der beiden Textfelder holen
  78.      */
  79.     XtSetArg(args[0],XtNstring,&from);
  80.     XtGetValues(text_1,args,1);
  81.  
  82.     /*
  83.      * Ueberpruefen ob in beiden ein Text steht, sonst
  84.      * Warnung ausgeben
  85.      */
  86.     if (!strlen(from)) {
  87.         WARNING ("Insuffisant Argument.\nOperation aborted.");
  88.         return;
  89.     }
  90.  
  91.     /*
  92.      * Befehl generieren und ausfuehren
  93.      */
  94.     if (!MULTI)
  95.         exec_delete(from);
  96.     else {
  97.         char    *bot,*top;
  98.  
  99.         bot = from;
  100.         top = strchr(bot,'\n');
  101.         while (top) {
  102.             *top++ = '\0';
  103.             if (defaults.trashcan)
  104.                 sprintf(buf,"%s %s %s\0",MOVE_CMD,bot,defaults.trashcan);
  105.             else
  106.                 sprintf(buf,"%s %s\0",RM_CMD,bot);
  107.             system(buf);
  108.  
  109.             bot = top;
  110.             top = strchr(bot,'\n');
  111.         }
  112.         /*
  113.          * Dialogfenster loeschen
  114.          */
  115.         if (dialog)
  116.             XtDestroyWidget(dialog);
  117.         dialog = NULL;
  118.  
  119.         /*
  120.          * Hier muss ein Update der veranderten Felder kommen
  121.          * Bisher unvollstaendig
  122.          */
  123.         bot = from;
  124.         multi_fo = NULL;
  125.         multi_vs = 16000;
  126.         multi_ve = 16000;
  127.         refreshFolderByPathname(bot);
  128. #ifdef    HAS_QUOTA
  129.         showQuota(quota_label);
  130. #endif
  131.         MULTI = FALSE;
  132.     }
  133. }
  134.  
  135.  
  136.  
  137. /*********************************************************
  138.  * name:    exec_delete
  139.  * description:    Operation File-Loeschen ausfuehren
  140.  * input:    none
  141.  * output:    none
  142.  * date:    14.6.93
  143.  *********************************************************/
  144. void    exec_delete (char *from)
  145. {
  146.     char    buf[1024];
  147.  
  148.     if (defaults.trashcan) {
  149.         exec_move(from,defaults.trashcan);
  150.         return;
  151.     }
  152.     /*
  153.      * Befehl generieren und ausfuehren
  154.      */
  155.     sprintf(buf,"%s %s",RM_CMD,from);
  156.  
  157.     system(buf);
  158.     {
  159.         /*
  160.          * Dialogfenster loeschen
  161.          */
  162.         if (dialog)
  163.             XtDestroyWidget(dialog);
  164.         dialog = NULL;
  165.  
  166.         /*
  167.          * Hier muss ein Update der veranderten Felder kommen
  168.          * Bisher unvollstaendig
  169.          */
  170.         refreshFolderByPathname(from);
  171. #ifdef    HAS_QUOTA
  172.         showQuota(quota_label);
  173. #endif
  174.     }
  175. }
  176.  
  177.  
  178.  
  179.  
  180.