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 browser window
18 #define CATCOMP_NUMBERS
20 #include "libraries/openurl.h"
22 /**************************************************************************/
41 struct URL_BrowserNode
*bn
;
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_BrowserNode
*bn
;
72 struct TagItem
*attrs
= msg
->ops_AttrList
;
74 memset(&temp
,0,sizeof(temp
));
76 temp
.browserList
= (Object
*)GetTagData(MUIA_BrowserEditWin_ListObj
,(ULONG
)NULL
,attrs
);
77 if (!temp
.browserList
) return 0;
79 bn
= temp
.bn
= (struct URL_BrowserNode
*)GetTagData(MUIA_BrowserEditWin_Browser
,(ULONG
)NULL
,attrs
);
83 if (obj
= (Object
*)DoSuperNew(cl
,obj
,
84 MUIA_HelpNode
, "BWIN",
85 MUIA_Window_ID
, MAKE_ID('E','D','B','R'),
86 MUIA_Window_Title
, getString(MSG_Browser_WinTitle
),
87 MUIA_Window_ScreenTitle
, getString(MSG_App_ScreenTitle
),
88 MUIA_Window_AllowTopMenus
, FALSE
,
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
),
99 Child
, olabel2(MSG_Edit_Port
),
100 Child
, temp
.port
= opopport(PORT_LEN
,MSG_Edit_Port
,MSG_Edit_Port_Help
),
104 GroupFrameT(getString(MSG_Edit_ARexx
)),
106 Child
, olabel2(MSG_Edit_Show
),
107 Child
, temp
.show
= ostring(SHOWCMD_LEN
,MSG_Edit_Show
,MSG_Edit_Show_Help
),
109 Child
, olabel2(MSG_Edit_Screen
),
110 Child
, temp
.toFront
= ostring(TOFRONTCMD_LEN
,MSG_Edit_Screen
,MSG_Edit_Screen_Help
),
112 Child
, olabel2(MSG_Edit_OpenURL
),
113 Child
, temp
.openURL
= opopph(syms
,names
,OPENURLCMD_LEN
,MSG_Edit_OpenURL
,FALSE
,MSG_Edit_OpenURL_Help
),
114 Child
, olabel2(MSG_Edit_NewWin
),
115 Child
, temp
.openURLNW
= opopph(syms
,names
,OPENURLWCMD_LEN
,MSG_Edit_NewWin
,FALSE
,MSG_Edit_NewWin_Help
),
119 Child
, temp
.use
= obutton(MSG_Edit_Use
,MSG_Edit_Use_Help
),
120 Child
, RectangleObject
, End
,
121 Child
, temp
.cancel
= obutton(MSG_Edit_Cancel
,MSG_Edit_Cancel_Help
),
126 struct data
*data
= INST_DATA(cl
,obj
);
128 CopyMem(&temp
,data
,sizeof(*data
));
130 set(data
->name
,MUIA_String_Contents
,bn
->ubn_Name
);
131 set(data
->path
,MUIA_String_Contents
,bn
->ubn_Path
);
132 set(data
->port
,MUIA_String_Contents
,bn
->ubn_Port
);
133 set(data
->show
,MUIA_String_Contents
,bn
->ubn_ShowCmd
);
134 set(data
->toFront
,MUIA_String_Contents
,bn
->ubn_ToFrontCmd
);
135 set(data
->openURL
,MUIA_String_Contents
,bn
->ubn_OpenURLCmd
);
136 set(data
->openURLNW
,MUIA_String_Contents
,bn
->ubn_OpenURLWCmd
);
142 /**************************************************************************/
145 mGet(struct IClass
*cl
,Object
*obj
,struct opGet
*msg
)
147 struct data
*data
= INST_DATA(cl
,obj
);
149 switch (msg
->opg_AttrID
)
151 case MUIA_BrowserEditWin_Browser
: *msg
->opg_Storage
= (ULONG
)data
->bn
; return TRUE
;
152 case MUIA_App_IsSubWin
: *msg
->opg_Storage
= TRUE
; return TRUE
;
153 default: return DoSuperMethodA(cl
,obj
,(Msg
)msg
);
157 /**************************************************************************/
160 mWindow_Setup(struct IClass
*cl
,Object
*obj
,struct MUIP_Window_Setup
*msg
)
162 struct data
*data
= INST_DATA(cl
,obj
);
164 if (!DoSuperMethodA(cl
,obj
,(Msg
)msg
)) return FALSE
;
166 if (!(data
->flags
& FLG_Notifies
))
168 DoMethod(data
->use
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(ULONG
)obj
,1,MUIM_BrowserEditWin_Use
);
169 DoMethod(data
->cancel
,MUIM_Notify
,MUIA_Pressed
,FALSE
,(ULONG
)obj
,3,MUIM_Set
,MUIA_Window_CloseRequest
,TRUE
);
171 DoMethod(obj
,MUIM_Notify
,MUIA_Window_CloseRequest
,TRUE
,(ULONG
)_app(obj
),6,MUIM_Application_PushMethod
,
172 (ULONG
)_app(obj
),3,MUIM_App_CloseWin
,MUIA_BrowserEditWin_Browser
,(ULONG
)data
->bn
);
174 data
->flags
|= FLG_Notifies
;
180 /**************************************************************************/
183 mUse(struct IClass
*cl
,Object
*obj
,Msg msg
)
185 struct data
*data
= INST_DATA(cl
,obj
);
186 struct URL_BrowserNode
*bn
= data
->bn
;
187 LONG i
, visible
, first
;
189 bn
->ubn_Flags
&= ~UNF_NEW
;
191 strcpy((STRPTR
)bn
->ubn_Name
,(STRPTR
)xget(data
->name
,MUIA_String_Contents
));
192 strcpy((STRPTR
)bn
->ubn_Path
,(STRPTR
)xget(data
->path
,MUIA_String_Contents
));
193 strcpy((STRPTR
)bn
->ubn_Port
,(STRPTR
)xget(data
->port
,MUIA_String_Contents
));
195 strcpy((STRPTR
)bn
->ubn_ShowCmd
,(STRPTR
)xget(data
->show
,MUIA_String_Contents
));
196 strcpy((STRPTR
)bn
->ubn_ToFrontCmd
,(STRPTR
)xget(data
->toFront
,MUIA_String_Contents
));
197 strcpy((STRPTR
)bn
->ubn_OpenURLCmd
,(STRPTR
)xget(data
->openURL
,MUIA_String_Contents
));
198 strcpy((STRPTR
)bn
->ubn_OpenURLWCmd
,(STRPTR
)xget(data
->openURLNW
,MUIA_String_Contents
));
200 get(data
->browserList
,MUIA_List_Visible
,&visible
);
203 get(data
->browserList
,MUIA_List_First
,&first
);
205 for (i
= first
; i
< (first
+ visible
); i
++)
207 DoMethod(data
->browserList
,MUIM_List_GetEntry
,i
,(ULONG
)&bn
);
212 DoMethod(data
->browserList
,MUIM_List_Redraw
,i
);
218 set(obj
,MUIA_Window_CloseRequest
,TRUE
);
223 /**************************************************************************/
229 switch (msg
->MethodID
)
231 case OM_NEW
: return mNew(cl
,obj
,(APTR
)msg
);
232 case OM_GET
: return mGet(cl
,obj
,(APTR
)msg
);
234 case MUIM_Window_Setup
: return mWindow_Setup(cl
,obj
,(APTR
)msg
);
236 case MUIM_BrowserEditWin_Use
: return mUse(cl
,obj
,(APTR
)msg
);
238 default: return DoSuperMethodA(cl
,obj
,msg
);
242 M_DISPEND(dispatcher
)
244 /**************************************************************************/
247 initBrowserEditWinClass(void)
249 if (g_browserEditWinClass
= MUI_CreateCustomClass(NULL
,MUIC_Window
,NULL
,sizeof(struct data
),DISP(dispatcher
)))
251 localizeStrings(names
);
259 /**************************************************************************/
262 disposeBrowserEditWinClass(void)
264 if (g_browserEditWinClass
) MUI_DeleteCustomClass(g_browserEditWinClass
);
267 /**************************************************************************/