1 /* deleteop.h
2  * This file belongs to Worker, a file manager for UN*X/X11.
3  * Copyright (C) 2001-2021 Ralf Hoffmann.
4  * You can contact me at: ralf@boomerangsworld.de
5  *   or http://www.boomerangsworld.de/worker
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 
22 #ifndef DELETEOP_H
23 #define DELETEOP_H
24 
25 #include "wdefines.h"
26 #include "functionproto.h"
27 #include "aguix/request.h"
28 
29 class AGUIX;
30 class AWindow;
31 class Text;
32 class SolidButton;
33 class Button;
34 class BevelBox;
35 class AFontWidth;
36 
37 class DeleteOp:public FunctionProto
38 {
39 public:
40   DeleteOp();
41   virtual ~DeleteOp();
42   DeleteOp( const DeleteOp &other );
43   DeleteOp &operator=( const DeleteOp &other );
44 
45   DeleteOp *duplicate() const override;
46   bool isName(const char *) override;
47   const char *getName() override;
48   int run( std::shared_ptr< WPUContext > wpu, ActionMessage* ) override;
49   const char *getDescription() override;
50   int configure() override;
51   bool save(Datei *) override;
52 
53   void setAlsoActive( bool );
54 protected:
55   static const char *name;
56   // Infos to save
57   bool also_active;
58 
59   // temp variables
60   Lister *startlister;
61 
62   int normalmodedelete( ActionMessage *am );
63 };
64 
65 class DeleteOpWin
66 {
67 public:
68   DeleteOpWin(AGUIX*);
69   ~DeleteOpWin();
70   DeleteOpWin( const DeleteOpWin &other );
71   DeleteOpWin &operator=( const DeleteOpWin &other );
72 
73   int open();
74   void close();
75   // called once:
76   void set_files_to_delete(long nfiles);
77   void set_dirs_to_delete(long ndirs);
78 
79   void dir_finished();
80   void file_finished();
81   void setfilename(char *name);
82   // for setting a message in the two lines used for display copy source/dest
83   void setmessage( const char *msg );
84   // for dec file/dir-counter (mainly in case of skiped files/dirs
85   void dec_file_counter(unsigned long f);
86   void dec_dir_counter(unsigned long d);
87 
88   /* should be called in copy-loop
89    * does the update of the window AND process X-events
90    * returnvalues: 0 - normal exists
91    *               1 - cancel/close window pressed */
92   int redraw();
93   int request( const char *title,
94                const char *text,
95                const char *buttons,
96                Requester::request_flags_t flags = Requester::REQUEST_NONE );
97   int string_request( const char *title,
98                       const char *lines,
99                       const char *default_str,
100                       const char *buttons,
101                       char **return_str,
102                       Requester::request_flags_t flags = Requester::REQUEST_NONE );
103 protected:
104   char *source;
105   long deleted_files,files;
106   long deleted_dirs,dirs;
107   int sbw;
108 
109   AGUIX *aguix;
110   AWindow *window;
111   Text *sourcetext,*files2gotext,*dirs2gotext;
112   SolidButton *gsb;
113   Button *cb;
114   bool update_sourcetext,update_files2gotext,update_dirs2gotext;
115   BevelBox *bb1, *bb2, *bb3;
116   int melw;
117   int filenamespace;
118   bool ismessage;
119   AFontWidth *lencalc;
120 };
121 
122 #endif
123 
124 /* Local Variables: */
125 /* mode:c++ */
126 /* End: */
127