revert between 56095 -> 55830 in arch
[AROS.git] / external / openurl / prefs / browsereditwin.c
blob463c894321d09620bd69cf233b89bd9a0659b4d1
1 /***************************************************************************
3 openurl.library - universal URL display and browser launcher library
4 Copyright (C) 1998-2005 by Troels Walsted Hansen, et al.
5 Copyright (C) 2005-2013 by openurl.library Open Source Team
7 This library is free software; it has been placed in the public domain
8 and you can freely redistribute it and/or modify it. Please note, however,
9 that some components may be under the LGPL or GPL license.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 openurl.library project: http://sourceforge.net/projects/openurllib/
17 $Id$
19 ***************************************************************************/
21 #include "openurl.h"
23 #define CATCOMP_NUMBERS
24 #include "locale.h"
26 #include <libraries/openurl.h>
28 #include "SDI_hook.h"
29 #include "macros.h"
31 #include "debug.h"
33 /**************************************************************************/
35 struct data
38 Object *browserList;
40 Object *name;
41 Object *path;
42 Object *port;
44 Object *show;
45 Object *toFront;
46 Object *openURL;
47 Object *openURLNW;
49 Object *use;
50 Object *cancel;
52 struct URL_BrowserNode *bn;
54 ULONG flags;
57 enum
59 FLG_Notifies = 1<<0,
62 /**************************************************************************/
64 static CONST_STRPTR syms[] =
66 "%u",
67 "%p",
68 NULL
71 static STRPTR names[] =
73 (STRPTR)MSG_Edit_PopURL,
74 (STRPTR)MSG_Edit_PopScreen,
75 NULL
78 static IPTR mNew(struct IClass *cl, Object *obj, struct opSet *msg)
80 struct data temp;
81 struct URL_BrowserNode *bn;
82 struct TagItem *attrs = msg->ops_AttrList;
84 memset(&temp,0,sizeof(temp));
86 temp.browserList = (Object *)GetTagData(MUIA_BrowserEditWin_ListObj,(IPTR)NULL,attrs);
87 if (!temp.browserList) return 0;
89 bn = temp.bn = (struct URL_BrowserNode *)GetTagData(MUIA_BrowserEditWin_Browser,(IPTR)NULL,attrs);
90 if (!bn) return 0;
93 if((obj = (Object *)DoSuperNew(cl,obj,
94 MUIA_HelpNode, "BWIN",
95 MUIA_Window_ID, MAKE_ID('E','D','B','R'),
96 MUIA_Window_Title, getString(MSG_Browser_WinTitle),
97 MUIA_Window_ScreenTitle, getString(MSG_App_ScreenTitle),
98 MUIA_Window_AllowTopMenus, FALSE,
100 WindowContents, VGroup,
101 Child, ColGroup(2),
102 GroupFrameT(getString(MSG_Edit_Definitions)),
104 Child, olabel2(MSG_Edit_Name),
105 Child, temp.name = ostring(NAME_LEN,MSG_Edit_Name,MSG_Edit_Name_Help),
107 Child, olabel2(MSG_Edit_Path),
108 Child, temp.path = opopph(syms,names,PATH_LEN,MSG_Edit_Path,TRUE,MSG_Edit_Path_Help),
109 Child, olabel2(MSG_Edit_Port),
110 Child, temp.port = opopport(PORT_LEN,MSG_Edit_Port,MSG_Edit_Port_Help),
111 End,
113 Child, ColGroup(2),
114 GroupFrameT(getString(MSG_Edit_ARexx)),
116 Child, olabel2(MSG_Edit_Show),
117 Child, temp.show = ostring(SHOWCMD_LEN,MSG_Edit_Show,MSG_Edit_Show_Help),
119 Child, olabel2(MSG_Edit_Screen),
120 Child, temp.toFront = ostring(TOFRONTCMD_LEN,MSG_Edit_Screen,MSG_Edit_Screen_Help),
122 Child, olabel2(MSG_Edit_OpenURL),
123 Child, temp.openURL = opopph(syms,names,OPENURLCMD_LEN,MSG_Edit_OpenURL,FALSE,MSG_Edit_OpenURL_Help),
124 Child, olabel2(MSG_Edit_NewWin),
125 Child, temp.openURLNW = opopph(syms,names,OPENURLWCMD_LEN,MSG_Edit_NewWin,FALSE,MSG_Edit_NewWin_Help),
126 End,
128 Child, ColGroup(3),
129 Child, temp.use = obutton(MSG_Edit_Use,MSG_Edit_Use_Help),
130 Child, RectangleObject, End,
131 Child, temp.cancel = obutton(MSG_Edit_Cancel,MSG_Edit_Cancel_Help),
132 End,
133 End,
134 TAG_MORE, attrs)) != NULL)
136 struct data *data = INST_DATA(cl,obj);
138 CopyMem(&temp,data,sizeof(*data));
140 set(data->name,MUIA_String_Contents,bn->ubn_Name);
141 set(data->path,MUIA_String_Contents,bn->ubn_Path);
142 set(data->port,MUIA_String_Contents,bn->ubn_Port);
143 set(data->show,MUIA_String_Contents,bn->ubn_ShowCmd);
144 set(data->toFront,MUIA_String_Contents,bn->ubn_ToFrontCmd);
145 set(data->openURL,MUIA_String_Contents,bn->ubn_OpenURLCmd);
146 set(data->openURLNW,MUIA_String_Contents,bn->ubn_OpenURLWCmd);
149 return (IPTR)obj;
152 /**************************************************************************/
154 static IPTR mGet(struct IClass *cl, Object *obj, struct opGet *msg)
156 struct data *data = INST_DATA(cl,obj);
158 switch (msg->opg_AttrID)
160 case MUIA_BrowserEditWin_Browser: *msg->opg_Storage = (IPTR)data->bn; return TRUE;
161 case MUIA_App_IsSubWin: *msg->opg_Storage = TRUE; return TRUE;
162 default: return DoSuperMethodA(cl,obj,(Msg)msg);
166 /**************************************************************************/
168 static IPTR mWindow_Setup(struct IClass *cl, Object *obj, struct MUIP_Window_Setup *msg)
170 IPTR result = FALSE;
172 ENTER();
174 if(DoSuperMethodA(cl, obj, (Msg)msg))
176 struct data *data = INST_DATA(cl, obj);
178 if(isFlagClear(data->flags, FLG_Notifies))
180 DoMethod(data->use, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 1, MUIM_BrowserEditWin_Use);
181 DoMethod(data->cancel, MUIM_Notify, MUIA_Pressed, FALSE, (IPTR)obj, 3, MUIM_Set, MUIA_Window_CloseRequest, TRUE);
183 DoMethod(obj, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (IPTR)_app(obj), 6, MUIM_Application_PushMethod,
184 (IPTR)_app(obj), 3, MUIM_App_CloseWin, MUIA_BrowserEditWin_Browser, (IPTR)data->bn);
186 SET_FLAG(data->flags, FLG_Notifies);
188 result = TRUE;
192 RETURN(result);
193 return result;
196 /**************************************************************************/
198 static IPTR mUse(struct IClass *cl, Object *obj, UNUSED Msg msg)
200 struct data *data = INST_DATA(cl,obj);
201 struct URL_BrowserNode *bn = data->bn;
202 LONG i, visible, first;
204 CLEAR_FLAG(bn->ubn_Flags, UNF_NEW);
206 strlcpy(bn->ubn_Name, (STRPTR)xget(data->name,MUIA_String_Contents), sizeof(bn->ubn_Name));
207 strlcpy(bn->ubn_Path, (STRPTR)xget(data->path,MUIA_String_Contents), sizeof(bn->ubn_Path));
208 strlcpy(bn->ubn_Port, (STRPTR)xget(data->port,MUIA_String_Contents), sizeof(bn->ubn_Port));
210 strlcpy(bn->ubn_ShowCmd, (STRPTR)xget(data->show,MUIA_String_Contents), sizeof(bn->ubn_ShowCmd));
211 strlcpy(bn->ubn_ToFrontCmd, (STRPTR)xget(data->toFront,MUIA_String_Contents), sizeof(bn->ubn_ToFrontCmd));
212 strlcpy(bn->ubn_OpenURLCmd, (STRPTR)xget(data->openURL,MUIA_String_Contents), sizeof(bn->ubn_OpenURLCmd));
213 strlcpy(bn->ubn_OpenURLWCmd, (STRPTR)xget(data->openURLNW,MUIA_String_Contents), sizeof(bn->ubn_OpenURLWCmd));
215 visible = xget(data->browserList, MUIA_List_Visible);
216 if (visible!=-1)
218 first = xget(data->browserList, MUIA_List_First);
220 for (i = first; i < (first + visible); i++)
222 DoMethod(data->browserList,MUIM_List_GetEntry,i,(IPTR)&bn);
223 if (!bn) break;
225 if (bn==data->bn)
227 DoMethod(data->browserList,MUIM_List_Redraw,i);
228 break;
233 set(obj,MUIA_Window_CloseRequest,TRUE);
235 return TRUE;
238 /**************************************************************************/
240 SDISPATCHER(dispatcher)
242 switch (msg->MethodID)
244 case OM_NEW: return mNew(cl,obj,(APTR)msg);
245 case OM_GET: return mGet(cl,obj,(APTR)msg);
247 case MUIM_Window_Setup: return mWindow_Setup(cl,obj,(APTR)msg);
249 case MUIM_BrowserEditWin_Use: return mUse(cl,obj,(APTR)msg);
251 default: return DoSuperMethodA(cl,obj,msg);
255 /**************************************************************************/
257 BOOL initBrowserEditWinClass(void)
259 BOOL success = FALSE;
261 ENTER();
263 if((g_browserEditWinClass = MUI_CreateCustomClass(NULL, MUIC_Window, NULL, sizeof(struct data), ENTRY(dispatcher))) != NULL)
265 localizeStrings(names);
266 success = TRUE;
269 RETURN(success);
270 return success;
273 /**************************************************************************/
275 void disposeBrowserEditWinClass(void)
277 ENTER();
279 if(g_browserEditWinClass != NULL)
280 MUI_DeleteCustomClass(g_browserEditWinClass);
282 LEAVE();
285 /**************************************************************************/