Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / openurl / prefs / ftpeditwin.c
blob2a5bc1db8948c0870798602bfcef0d01ec68b577
1 /*
2 ** OpenURL - MUI preferences for openurl.library
3 **
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
6 **
7 ** Developed by:
8 ** - Alfonso Ranieri <alforan@tin.it>
9 ** - Stefan Kost <ensonic@sonicpulse.de>
11 ** Ported to OS4 by Alexandre Balaban <alexandre@balaban.name>
13 ** Edit FTP client window
17 #include "OpenURL.h"
18 #define CATCOMP_NUMBERS
19 #include "loc.h"
20 #include "libraries/openurl.h"
22 /**************************************************************************/
24 struct data
26 Object *FTPList;
28 Object *name;
29 Object *path;
30 Object *port;
31 Object *removeScheme;
33 Object *show;
34 Object *toFront;
35 Object *openURL;
36 Object *openURLNW;
38 Object *use;
39 Object *cancel;
41 struct URL_FTPNode *fn;
43 ULONG flags;
46 enum
48 FLG_Notifies = 1<<0,
51 /**************************************************************************/
53 static STRPTR syms[] =
55 "%u",
56 "%p",
57 NULL
60 static STRPTR names[] =
62 (STRPTR)MSG_Edit_PopURL,
63 (STRPTR)MSG_Edit_PopScreen,
64 NULL
67 static ULONG
68 mNew(struct IClass *cl,Object *obj,struct opSet *msg)
70 struct data temp;
71 struct URL_FTPNode *fn;
72 struct TagItem *attrs = msg->ops_AttrList;
74 memset(&temp,0,sizeof(temp));
76 temp.FTPList = (Object *)GetTagData(MUIA_FTPEditWin_ListObj,(ULONG)NULL,attrs);
77 if (!temp.FTPList) return 0;
79 fn = temp.fn = (struct URL_FTPNode *)GetTagData(MUIA_FTPEditWin_FTP,(ULONG)NULL,attrs);
80 if (!fn) return 0;
83 if (obj = (Object *)DoSuperNew(cl,obj,
84 MUIA_HelpNode, "FWIN",
85 MUIA_Window_ID, MAKE_ID('E','D','B','R'),
86 MUIA_Window_Title, getString(MSG_FTP_WinTitle),
87 MUIA_Window_AllowTopMenus, FALSE,
88 MUIA_Window_ScreenTitle, getString(MSG_App_ScreenTitle),
90 WindowContents, VGroup,
91 Child, ColGroup(2),
92 GroupFrameT(getString(MSG_Edit_Definitions)),
94 Child, olabel2(MSG_Edit_Name),
95 Child, temp.name = ostring(NAME_LEN,MSG_Edit_Name,MSG_Edit_Name_Help),
97 Child, olabel2(MSG_Edit_Path),
98 Child, temp.path = opopph(syms,names,PATH_LEN,MSG_Edit_Path,TRUE,MSG_Edit_Path_Help),
100 Child, olabel2(MSG_Edit_Port),
101 Child, temp.port = opopport(PORT_LEN,MSG_Edit_Port,MSG_Edit_Port_Help),
103 Child, olabel2(MSG_FTP_RemoveURLQualifier),
104 Child, HGroup,
105 Child, temp.removeScheme = ocheckmark(MSG_FTP_RemoveURLQualifier,MSG_FTP_RemoveURLQualifier_Help),
106 Child, HSpace(0),
107 End,
108 End,
110 Child, ColGroup(2),
111 GroupFrameT(getString(MSG_Edit_ARexx)),
113 Child, olabel2(MSG_Edit_Show),
114 Child, temp.show = ostring(SHOWCMD_LEN,MSG_Edit_Show,MSG_Edit_Show_Help),
116 Child, olabel2(MSG_Edit_Screen),
117 Child, temp.toFront = ostring(TOFRONTCMD_LEN,MSG_Edit_Screen,MSG_Edit_Screen_Help),
119 Child, olabel2(MSG_Edit_OpenURL),
120 Child, temp.openURL = opopph(syms,names,OPENURLCMD_LEN,MSG_Edit_OpenURL,FALSE,MSG_Edit_OpenURL_Help),
121 Child, olabel2(MSG_Edit_NewWin),
122 Child, temp.openURLNW = opopph(syms,names,OPENURLWCMD_LEN,MSG_Edit_NewWin,FALSE,MSG_Edit_NewWin_Help),
123 End,
125 Child, ColGroup(3),
126 Child, temp.use = obutton(MSG_Edit_Use,MSG_Edit_Use_Help),
127 Child, RectangleObject, End,
128 Child, temp.cancel = obutton(MSG_Edit_Cancel,MSG_Edit_Cancel_Help),
129 End,
130 End,
131 TAG_MORE, attrs))
133 struct data *data = INST_DATA(cl,obj);
135 CopyMem(&temp,data,sizeof(*data));
137 set(data->name,MUIA_String_Contents,fn->ufn_Name);
138 set(data->path,MUIA_String_Contents,fn->ufn_Path);
139 set(data->port,MUIA_String_Contents,fn->ufn_Port);
140 set(data->removeScheme,MUIA_Selected,fn->ufn_Flags & UFNF_REMOVEFTP);
141 set(data->show,MUIA_String_Contents,fn->ufn_ShowCmd);
142 set(data->toFront,MUIA_String_Contents,fn->ufn_ToFrontCmd);
143 set(data->openURL,MUIA_String_Contents,fn->ufn_OpenURLCmd);
144 set(data->openURLNW,MUIA_String_Contents,fn->ufn_OpenURLWCmd);
147 return (ULONG)obj;
150 /**************************************************************************/
152 static ULONG
153 mGet(struct IClass *cl,Object *obj,struct opGet *msg)
155 struct data *data = INST_DATA(cl,obj);
157 switch (msg->opg_AttrID)
159 case MUIA_FTPEditWin_FTP: *msg->opg_Storage = (ULONG)data->fn; return TRUE;
160 case MUIA_App_IsSubWin: *msg->opg_Storage = TRUE; return TRUE;
161 default: return DoSuperMethodA(cl,obj,(Msg)msg);
165 /**************************************************************************/
167 static ULONG
168 mWindow_Setup(struct IClass *cl,Object *obj,struct MUIP_Window_Setup *msg)
170 struct data *data = INST_DATA(cl,obj);
172 if (!DoSuperMethodA(cl,obj,(Msg)msg)) return FALSE;
174 if (!(data->flags & FLG_Notifies))
176 DoMethod(data->use,MUIM_Notify,MUIA_Pressed,FALSE,(ULONG)obj,1,MUIM_FTPEditWin_Use);
177 DoMethod(data->cancel,MUIM_Notify,MUIA_Pressed,FALSE,(ULONG)obj,3,MUIM_Set,MUIA_Window_CloseRequest,TRUE);
179 DoMethod(obj,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,(ULONG)_app(obj),6,MUIM_Application_PushMethod,
180 (ULONG)_app(obj),3,MUIM_App_CloseWin,MUIA_FTPEditWin_FTP,(ULONG)data->fn);
182 data->flags |= FLG_Notifies;
185 return TRUE;
188 /**************************************************************************/
190 static ULONG
191 mUse(struct IClass *cl,Object *obj,Msg msg)
193 struct data *data = INST_DATA(cl,obj);
194 struct URL_FTPNode *fn = data->fn;
195 LONG i, visible, first;
197 fn->ufn_Flags &= ~UNF_NEW;
199 strcpy((STRPTR)fn->ufn_Name,(STRPTR)xget(data->name,MUIA_String_Contents));
200 strcpy((STRPTR)fn->ufn_Path,(STRPTR)xget(data->path,MUIA_String_Contents));
201 strcpy((STRPTR)fn->ufn_Port,(STRPTR)xget(data->port,MUIA_String_Contents));
202 if (xget(data->removeScheme,MUIA_Selected)) fn->ufn_Flags |= UFNF_REMOVEFTP;
203 else fn->ufn_Flags &= ~UFNF_REMOVEFTP;
205 strcpy((STRPTR)fn->ufn_ShowCmd,(STRPTR)xget(data->show,MUIA_String_Contents));
206 strcpy((STRPTR)fn->ufn_ToFrontCmd,(STRPTR)xget(data->toFront,MUIA_String_Contents));
207 strcpy((STRPTR)fn->ufn_OpenURLCmd,(STRPTR)xget(data->openURL,MUIA_String_Contents));
208 strcpy((STRPTR)fn->ufn_OpenURLWCmd,(STRPTR)xget(data->openURLNW,MUIA_String_Contents));
210 get(data->FTPList,MUIA_List_Visible,&visible);
211 if (visible!=-1)
213 get(data->FTPList,MUIA_List_First,&first);
215 for (i = first; i < (first + visible); i++)
217 DoMethod(data->FTPList,MUIM_List_GetEntry,i,(ULONG)&fn);
218 if (!fn) break;
220 if (fn==data->fn)
222 DoMethod(data->FTPList,MUIM_List_Redraw,i);
223 break;
228 set(obj,MUIA_Window_CloseRequest,TRUE);
230 return TRUE;
233 /**************************************************************************/
235 M_DISP(dispatcher)
237 M_DISPSTART
239 switch (msg->MethodID)
241 case OM_NEW: return mNew(cl,obj,(APTR)msg);
242 case OM_GET: return mGet(cl,obj,(APTR)msg);
244 case MUIM_Window_Setup: return mWindow_Setup(cl,obj,(APTR)msg);
246 case MUIM_FTPEditWin_Use: return mUse(cl,obj,(APTR)msg);
248 default: return DoSuperMethodA(cl,obj,msg);
252 M_DISPEND(dispatcher)
254 /**************************************************************************/
256 ULONG
257 initFTPEditWinClass(void)
259 if (g_FTPEditWinClass = MUI_CreateCustomClass(NULL,MUIC_Window,NULL,sizeof(struct data),DISP(dispatcher)))
261 localizeStrings(names);
263 return TRUE;
266 return FALSE;
269 /**************************************************************************/
271 void
272 disposeFTPEditWinClass(void)
274 if (g_FTPEditWinClass) MUI_DeleteCustomClass(g_FTPEditWinClass);
277 /**************************************************************************/