make sure features has been run before invoking linklibs-libatomic
[AROS.git] / external / openurl / raPrefs / browsers.c
blob3bdf49f9e998f8f73e5cb9ae4d238b40a704f41c
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 "browsers.h"
23 #include "gui_global.h"
24 #include "utility.h"
25 #include "macros.h"
27 #include <classes/window.h>
28 #include <libraries/openurl.h>
30 #include <reaction/reaction_macros.h>
32 #include <images/label.h>
34 #include <gadgets/layout.h>
35 #include <gadgets/space.h>
36 #include <gadgets/listbrowser.h>
37 #include <gadgets/string.h>
38 #include <gadgets/getfile.h>
40 #include <proto/dos.h>
41 #include <proto/exec.h>
42 #include <proto/label.h>
43 #include <proto/space.h>
44 #include <proto/layout.h>
45 #include <proto/window.h>
46 #include <proto/string.h>
47 #include <proto/getfile.h>
48 #include <proto/intuition.h>
49 #include <proto/utility.h>
50 #include <proto/listbrowser.h>
52 Object *edit_brow_win;
53 struct Window *edit_brow_window;
55 Object * make_edit_brow_win(void)
57 return WindowObject,
58 WA_ScreenTitle, getString(MSG_App_ScreenTitle),
59 WA_Title, getString(MSG_Browser_WinTitle),
60 WA_DragBar, TRUE,
61 WA_CloseGadget, TRUE,
62 WA_SizeGadget, TRUE,
63 WA_DepthGadget, TRUE,
64 WA_Activate, TRUE,
65 // WINDOW_AppPort, AppPort,
66 WINDOW_SharedPort, AppPort,
67 WINDOW_IDCMPHook, &idcmphook,
68 WINDOW_IDCMPHookBits, IDCMP_IDCMPUPDATE,
69 WINDOW_Position, WPOS_CENTERSCREEN,
70 WINDOW_LockHeight, TRUE,
71 WINDOW_Layout, VLayoutObject,
72 LAYOUT_SpaceOuter, TRUE,
73 LAYOUT_AddChild, OBJ(OBJ_BROW_ALIGN) = VLayoutObject,
74 LAYOUT_SpaceOuter, TRUE,
75 LAYOUT_BevelStyle, BVS_GROUP,
76 LAYOUT_Label, getString(MSG_Edit_Definitions),
78 LAYOUT_AddChild, OBJ(OBJ_BROW_NAME_STR) = StringObject,
79 GA_ID, OBJ_BROW_NAME_STR,
80 GA_RelVerify, TRUE,
81 GA_TabCycle, TRUE,
82 // STRINGA_Buffer, buffer,
83 End, // String
84 Label(getString(MSG_Edit_Name)),
86 LAYOUT_AddChild, HLayoutObject,
87 LAYOUT_SpaceInner, FALSE,
88 LAYOUT_AddChild, OBJ(OBJ_BROW_PATH_GET) = GetFileObject,
89 GA_ID, OBJ_BROW_PATH_GET,
90 GA_RelVerify, TRUE,
91 GETFILE_TitleText, "Select Path To Browser",
92 End, // GetFile
93 LAYOUT_AddChild, OBJ(OBJ_BROW_PATH_CHOOSE) = ButtonObject,
94 GA_ID, OBJ_BROW_PATH_CHOOSE,
95 GA_RelVerify, TRUE,
96 GA_Image, &chooser_image,
97 End, // Button
98 CHILD_WeightedWidth, 0,
99 End, // HLayout
100 Label(getString(MSG_Edit_Path)),
102 LAYOUT_AddChild, HLayoutObject,
103 LAYOUT_SpaceInner, FALSE,
104 LAYOUT_AddChild, OBJ(OBJ_BROW_AREXX_STR) = StringObject,
105 GA_ID, OBJ_BROW_AREXX_STR,
106 GA_RelVerify, TRUE,
107 GA_TabCycle, TRUE,
108 // STRINGA_Buffer, buffer,
109 End, // String
110 LAYOUT_AddChild, OBJ(OBJ_BROW_AREXX_CHOOSE) = ButtonObject,
111 GA_ID, OBJ_BROW_AREXX_CHOOSE,
112 GA_RelVerify, TRUE,
113 GA_Image, &chooser_image,
114 End, // Button
115 CHILD_WeightedWidth, 0,
116 End, // HLayout
117 Label(getString(MSG_Edit_Port)),
118 End, // VLayout
121 LAYOUT_AddChild, VLayoutObject,
122 LAYOUT_SpaceOuter, TRUE,
123 LAYOUT_BevelStyle, BVS_GROUP,
124 LAYOUT_Label, getString(MSG_Edit_ARexx),
125 LAYOUT_AlignLabels, OBJ(OBJ_BROW_ALIGN), // align with the 4 labels above
127 LAYOUT_AddChild, OBJ(OBJ_BROW_SHOW_STR) = StringObject,
128 GA_ID, OBJ_BROW_SHOW_STR,
129 GA_RelVerify, TRUE,
130 GA_TabCycle, TRUE,
131 // STRINGA_Buffer, buffer,
132 End, // String
133 Label(getString(MSG_Edit_Show)),
135 LAYOUT_AddChild, OBJ(OBJ_BROW_FRONT_STR) = StringObject,
136 GA_ID, OBJ_BROW_FRONT_STR,
137 GA_RelVerify, TRUE,
138 GA_TabCycle, TRUE,
139 // STRINGA_Buffer, buffer,
140 End, // String
141 Label(getString(MSG_Edit_Screen)),
143 LAYOUT_AddChild, HLayoutObject,
144 LAYOUT_SpaceInner, FALSE,
145 LAYOUT_AddChild, OBJ(OBJ_BROW_OPEN_STR) = StringObject,
146 GA_ID, OBJ_BROW_OPEN_STR,
147 GA_RelVerify, TRUE,
148 GA_TabCycle, TRUE,
149 // STRINGA_Buffer, buffer,
150 End, // String
151 LAYOUT_AddChild, OBJ(OBJ_BROW_OPEN_CHOOSE) = ButtonObject,
152 GA_ID, OBJ_BROW_OPEN_CHOOSE,
153 GA_RelVerify, TRUE,
154 GA_Image, &chooser_image,
155 End, // Button
156 CHILD_WeightedWidth, 0,
157 End, // HLayout
158 Label(getString(MSG_Edit_OpenURL)),
160 LAYOUT_AddChild, HLayoutObject,
161 LAYOUT_SpaceInner, FALSE,
162 LAYOUT_AddChild, OBJ(OBJ_BROW_NEW_STR) = StringObject,
163 GA_ID, OBJ_BROW_NEW_STR,
164 GA_RelVerify, TRUE,
165 GA_TabCycle, TRUE,
166 // STRINGA_Buffer, buffer,
167 End, // String
168 LAYOUT_AddChild, OBJ(OBJ_BROW_NEW_CHOOSE) = ButtonObject,
169 GA_ID, OBJ_BROW_NEW_CHOOSE,
170 GA_RelVerify, TRUE,
171 GA_Image, &chooser_image,
172 End, // Button
173 CHILD_WeightedWidth, 0,
174 End, // HLayout
175 Label(getString(MSG_Edit_NewWin)), // space before `New` to give a better look
176 End, // VLayout
179 LAYOUT_AddChild, HLayoutObject,
180 LAYOUT_AddChild, SpaceObject,
181 SPACE_MinWidth, 2,
182 End, // Space
183 CHILD_WeightedWidth, 0,
185 LAYOUT_AddChild, HLayoutObject,
186 LAYOUT_EvenSize, TRUE,
187 LAYOUT_AddChild, Button(getString(MSG_Edit_Use),OBJ_BROW_USE),
188 CHILD_WeightedWidth, 0,
190 LAYOUT_AddChild, Button(getString(MSG_Edit_Cancel),OBJ_BROW_CANCEL),
191 CHILD_WeightedWidth, 0,
192 End, // HLayout
194 LAYOUT_AddChild, SpaceObject,
195 SPACE_MinWidth, 2,
196 End, // Space
197 CHILD_WeightedWidth, 0,
198 End, // HLayout
199 CHILD_MinWidth, 300, // sets a more attractive size for the whole Layout
201 End, // VLayout
202 WindowEnd;
205 BOOL updateBrowserList(struct List * list, struct MinList PrefsBrowserList)
207 struct URL_BrowserNode * bn = NULL,
208 * newNode = NULL;
210 // libération de la liste
211 freeList(list);
213 // ajout des nouvelles données
214 for (bn = (struct URL_BrowserNode *)PrefsBrowserList.mlh_Head;
215 bn->ubn_Node.mln_Succ;
216 bn = (struct URL_BrowserNode *)bn->ubn_Node.mln_Succ)
218 if((newNode = (struct URL_BrowserNode*)IListBrowser->AllocListBrowserNode(3,
219 LBNA_NodeSize, sizeof(struct URL_BrowserNode),
220 LBNA_CheckBox, TRUE,
221 LBNA_Checked, isFlagClear(bn->ubn_Flags, UNF_DISABLED),
222 LBNA_Column, 1,
223 LBNCA_Text, "",
224 LBNA_Column, 2,
225 LBNCA_Text, "",
226 TAG_DONE)) != NULL)
228 IExec->CopyMem(bn, newNode, sizeof(struct URL_BrowserNode));
229 IListBrowser->SetListBrowserNodeAttrs((struct Node*)newNode, LBNA_Column, 1,
230 LBNCA_Text, newNode->ubn_Name,
231 LBNA_Column, 2,
232 LBNCA_Text, newNode->ubn_Path,
233 TAG_END);
234 IExec->AddTail(list, (struct Node *)newNode);
236 else
238 IDOS->Printf(" AllocListBrowserNode() failed\n");
239 return(FALSE);
243 return TRUE;
246 void updateBrowserWindow(struct URL_BrowserNode * pBrowser)
248 if(pBrowser != NULL)
250 iset(edit_brow_win, WINDOW_UserData, pBrowser);
251 gadset(GAD(OBJ_BROW_NAME_STR), edit_brow_window, STRINGA_TextVal, pBrowser->ubn_Name);
252 gadset(GAD(OBJ_BROW_PATH_GET), edit_brow_window, GETFILE_File, pBrowser->ubn_Path);
253 gadset(GAD(OBJ_BROW_AREXX_STR), edit_brow_window, STRINGA_TextVal, pBrowser->ubn_Port);
254 gadset(GAD(OBJ_BROW_SHOW_STR), edit_brow_window, STRINGA_TextVal, pBrowser->ubn_ShowCmd);
255 gadset(GAD(OBJ_BROW_FRONT_STR), edit_brow_window, STRINGA_TextVal, pBrowser->ubn_ToFrontCmd);
256 gadset(GAD(OBJ_BROW_OPEN_STR), edit_brow_window, STRINGA_TextVal, pBrowser->ubn_OpenURLCmd);
257 gadset(GAD(OBJ_BROW_NEW_STR), edit_brow_window, STRINGA_TextVal, pBrowser->ubn_OpenURLWCmd);
258 } else
259 IDOS->Printf("No browser node\n");
262 void updateBrowserNode()
264 struct URL_BrowserNode *pBrowser;
266 if((pBrowser = (struct URL_BrowserNode *)iget(edit_brow_win, WINDOW_UserData)) != NULL)
268 STRPTR strValue;
270 strValue = (STRPTR)iget(GAD(OBJ_BROW_NAME_STR), STRINGA_TextVal);
271 IUtility->Strlcpy(pBrowser->ubn_Name, strValue, sizeof(pBrowser->ubn_Name));
272 strValue = (STRPTR)iget(GAD(OBJ_BROW_PATH_GET), STRINGA_TextVal);
273 IUtility->Strlcpy(pBrowser->ubn_Path, strValue, sizeof(pBrowser->ubn_Path));
274 strValue = (STRPTR)iget(GAD(OBJ_BROW_AREXX_STR), STRINGA_TextVal);
275 IUtility->Strlcpy(pBrowser->ubn_Port, strValue, sizeof(pBrowser->ubn_Port));
276 strValue = (STRPTR)iget(GAD(OBJ_BROW_SHOW_STR), STRINGA_TextVal);
277 IUtility->Strlcpy(pBrowser->ubn_ShowCmd, strValue, sizeof(pBrowser->ubn_ShowCmd));
278 strValue = (STRPTR)iget(GAD(OBJ_BROW_FRONT_STR), STRINGA_TextVal);
279 IUtility->Strlcpy(pBrowser->ubn_ToFrontCmd, strValue, sizeof(pBrowser->ubn_ToFrontCmd));
280 strValue = (STRPTR)iget(GAD(OBJ_BROW_OPEN_STR), STRINGA_TextVal);
281 IUtility->Strlcpy(pBrowser->ubn_OpenURLCmd, strValue, sizeof(pBrowser->ubn_OpenURLCmd));
282 strValue = (STRPTR)iget(GAD(OBJ_BROW_NEW_STR), STRINGA_TextVal);
283 IUtility->Strlcpy(pBrowser->ubn_OpenURLWCmd, strValue, sizeof(pBrowser->ubn_OpenURLWCmd));
285 // now update the ListBrowser attributes
286 IListBrowser->SetListBrowserNodeAttrs((struct Node*)pBrowser, LBNA_Column, 1,
287 LBNCA_Text, pBrowser->ubn_Name,
288 LBNA_Column, 2,
289 LBNCA_Text, pBrowser->ubn_Path,
290 TAG_END);