2 ** OpenURL - MUI preferences for openurl.library
4 ** Written by Troels Walsted Hansen <troels@thule.no>
5 ** Placed in the public domain.
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
18 #define CATCOMP_NUMBERS
20 #include "libraries/openurl.h"
22 /**************************************************************************/
41 struct URL_FTPNode
*fn
;
51 /**************************************************************************/
53 static STRPTR syms
[] =
60 static STRPTR names
[] =
62 (STRPTR
)MSG_Edit_PopURL
,
63 (STRPTR
)MSG_Edit_PopScreen
,
68 mNew(struct IClass
*cl
,Object
*obj
,struct opSet
*msg
)
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
);
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
,
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
),
105 Child
, temp
.removeScheme
= ocheckmark(MSG_FTP_RemoveURLQualifier
,MSG_FTP_RemoveURLQualifier_Help
),
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
),
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
),
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
);
150 /**************************************************************************/
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 /**************************************************************************/
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
;
188 /**************************************************************************/
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
);
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
);
222 DoMethod(data
->FTPList
,MUIM_List_Redraw
,i
);
228 set(obj
,MUIA_Window_CloseRequest
,TRUE
);
233 /**************************************************************************/
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 /**************************************************************************/
257 initFTPEditWinClass(void)
259 if (g_FTPEditWinClass
= MUI_CreateCustomClass(NULL
,MUIC_Window
,NULL
,sizeof(struct data
),DISP(dispatcher
)))
261 localizeStrings(names
);
269 /**************************************************************************/
272 disposeFTPEditWinClass(void)
274 if (g_FTPEditWinClass
) MUI_DeleteCustomClass(g_FTPEditWinClass
);
277 /**************************************************************************/