Missing dependencies added.
[AROS-Contrib.git] / dopus / Program / renamedata.c
blob568512446be3bb4c8305c917e7a83d97173bb605
2 /*
4 Directory Opus 4
5 Original GPL release version 4.12
6 Copyright 1993-2000 Jonathan Potter
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 All users of Directory Opus 4 (including versions distributed
23 under the GPL) are entitled to upgrade to the latest version of
24 Directory Opus version 5 at a reduced price. Please see
25 http://www.gpsoft.com.au for more information.
27 The release of Directory Opus 4 under the GPL in NO WAY affects
28 the existing commercial status of Directory Opus 5.
32 #include "dopus.h"
34 enum {
35 RENAME_CANCEL,
36 RENAME_OKAY,
37 RENAME_SKIP,
38 RENAME_OLDNAME,
39 RENAME_NEWNAME};
41 struct RequesterBase rename_req={
42 40,5,24,30,
43 8,6,
44 0,0,0,0,NULL,NULL,NULL,NULL,
45 NULL,NULL,NULL,
46 0,0,NULL,0,NULL};
48 static char oldname_buffer[FILEBUF_SIZE],newname_buffer[FILEBUF_SIZE];
50 struct TagItem
51 rename_oldname_gadget[]={
52 {RO_Type,OBJECT_GADGET},
53 {RO_GadgetType,GADGET_STRING},
54 {RO_GadgetID,RENAME_OLDNAME},
55 {RO_LeftFine,4},
56 {RO_Top,1},
57 {RO_TopFine,2},
58 {RO_Width,40},
59 {RO_Height,1},
60 {RO_TextNum,STR_RENAME},
61 {RO_TextPos,TEXTPOS_ABOVE},
62 {RO_StringBuf,(IPTR)oldname_buffer},
63 {RO_StringLen,FILEBUF_SIZE+1},
64 {RO_StringUndo,(IPTR)str_undobuffer},
65 {TAG_END,0}},
66 rename_newname_gadget[]={
67 {RO_Type,OBJECT_GADGET},
68 {RO_GadgetType,GADGET_STRING},
69 {RO_GadgetID,RENAME_NEWNAME},
70 {RO_LeftFine,4},
71 {RO_Top,3},
72 {RO_TopFine,8},
73 {RO_Width,40},
74 {RO_Height,1},
75 {RO_TextNum,STR_AS},
76 {RO_TextPos,TEXTPOS_ABOVE},
77 {RO_StringBuf,(IPTR)newname_buffer},
78 {RO_StringLen,FILEBUF_SIZE+1},
79 {RO_StringUndo,(IPTR)str_undobuffer},
80 {TAG_END,0}},
81 rename_okay_gadget[]={
82 {RO_Type,OBJECT_GADGET},
83 {RO_GadgetType,GADGET_BOOLEAN},
84 {RO_GadgetID,RENAME_OKAY},
85 {RO_Top,4},
86 {RO_TopFine,16},
87 {RO_Width,12},
88 {RO_Height,1},
89 {RO_HeightFine,4},
90 {RO_TextNum,STR_OKAY},
91 {RO_TextPos,TEXTPOS_CENTER},
92 {RO_HighRecess,TRUE},
93 {TAG_END,0}},
94 rename_skip_gadget[]={
95 {RO_Type,OBJECT_GADGET},
96 {RO_GadgetType,GADGET_BOOLEAN},
97 {RO_GadgetID,RENAME_SKIP},
98 {RO_Top,4},
99 {RO_TopFine,16},
100 {RO_Width,12},
101 {RO_Height,1},
102 {RO_HeightFine,4},
103 {RO_Left,14},
104 {RO_LeftFine,4},
105 {RO_TextNum,STR_SKIP},
106 {RO_TextPos,TEXTPOS_CENTER},
107 {RO_HighRecess,TRUE},
108 {TAG_END,0}},
109 rename_cancel_gadget[]={
110 {RO_Type,OBJECT_GADGET},
111 {RO_GadgetType,GADGET_BOOLEAN},
112 {RO_GadgetID,RENAME_CANCEL},
113 {RO_Top,4},
114 {RO_TopFine,16},
115 {RO_Width,12},
116 {RO_Height,1},
117 {RO_HeightFine,4},
118 {RO_Left,28},
119 {RO_LeftFine,8},
120 {RO_TextNum,STR_CANCEL},
121 {RO_TextPos,TEXTPOS_CENTER},
122 {RO_HighRecess,TRUE},
123 {TAG_END,0}},
125 *rename_gadgets[]={
126 rename_oldname_gadget,
127 rename_newname_gadget,
128 rename_okay_gadget,
129 rename_skip_gadget,
130 rename_cancel_gadget,
131 NULL};
133 int getrenamedata(src,dst)
134 char *src,*dst;
136 ULONG class;
137 UWORD code,gadgetid,qual;
138 struct Window *rwindow;
139 struct Gadget *gadlist;
141 fix_requester(&rename_req,globstring[STR_ENTER_NEW_NAME]);
143 strcpy(oldname_buffer,src); strcpy(newname_buffer,dst);
145 if (!(rwindow=OpenRequester(&rename_req)) ||
146 !(gadlist=addreqgadgets(&rename_req,rename_gadgets,0,NULL))) {
147 CloseRequester(&rename_req);
148 return(0);
150 RefreshRequesterObject(&rename_req,NULL);
152 Delay(3);
153 ActivateStrGad(gadlist->NextGadget,rwindow);
155 FOREVER {
156 while (IMsg=(struct IntuiMessage *)GetMsg(rwindow->UserPort)) {
157 class=IMsg->Class; code=IMsg->Code; qual=IMsg->Qualifier;
158 if (class==IDCMP_GADGETUP)
159 gadgetid=((struct Gadget *) IMsg->IAddress)->GadgetID;
160 ReplyMsg((struct Message *) IMsg);
162 switch (class) {
163 case IDCMP_MOUSEBUTTONS:
164 gadgetid=RENAME_OLDNAME;
166 case IDCMP_GADGETUP:
167 switch (gadgetid) {
168 case RENAME_OLDNAME:
169 ActivateStrGad(gadlist->NextGadget,rwindow);
170 break;
171 case RENAME_NEWNAME:
172 if (qual&IEQUALIFIER_ANYSHIFT) {
173 ActivateStrGad(gadlist,rwindow);
174 break;
176 else if (code==0x9) break;
177 gadgetid=RENAME_OKAY;
179 case RENAME_OKAY:
180 strcpy(src,oldname_buffer);
181 strcpy(dst,newname_buffer);
182 case RENAME_SKIP:
183 case RENAME_CANCEL:
184 CloseRequester(&rename_req);
185 return((int)gadgetid);
187 break;
190 Wait(1<<rwindow->UserPort->mp_SigBit);