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/
19 ***************************************************************************/
23 #include "gui_global.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)
58 WA_ScreenTitle
, getString(MSG_App_ScreenTitle
),
59 WA_Title
, getString(MSG_Browser_WinTitle
),
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
,
82 // STRINGA_Buffer, buffer,
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
,
91 GETFILE_TitleText
, "Select Path To Browser",
93 LAYOUT_AddChild
, OBJ(OBJ_BROW_PATH_CHOOSE
) = ButtonObject
,
94 GA_ID
, OBJ_BROW_PATH_CHOOSE
,
96 GA_Image
, &chooser_image
,
98 CHILD_WeightedWidth
, 0,
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
,
108 // STRINGA_Buffer, buffer,
110 LAYOUT_AddChild
, OBJ(OBJ_BROW_AREXX_CHOOSE
) = ButtonObject
,
111 GA_ID
, OBJ_BROW_AREXX_CHOOSE
,
113 GA_Image
, &chooser_image
,
115 CHILD_WeightedWidth
, 0,
117 Label(getString(MSG_Edit_Port
)),
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
,
131 // STRINGA_Buffer, buffer,
133 Label(getString(MSG_Edit_Show
)),
135 LAYOUT_AddChild
, OBJ(OBJ_BROW_FRONT_STR
) = StringObject
,
136 GA_ID
, OBJ_BROW_FRONT_STR
,
139 // STRINGA_Buffer, buffer,
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
,
149 // STRINGA_Buffer, buffer,
151 LAYOUT_AddChild
, OBJ(OBJ_BROW_OPEN_CHOOSE
) = ButtonObject
,
152 GA_ID
, OBJ_BROW_OPEN_CHOOSE
,
154 GA_Image
, &chooser_image
,
156 CHILD_WeightedWidth
, 0,
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
,
166 // STRINGA_Buffer, buffer,
168 LAYOUT_AddChild
, OBJ(OBJ_BROW_NEW_CHOOSE
) = ButtonObject
,
169 GA_ID
, OBJ_BROW_NEW_CHOOSE
,
171 GA_Image
, &chooser_image
,
173 CHILD_WeightedWidth
, 0,
175 Label(getString(MSG_Edit_NewWin
)), // space before `New` to give a better look
179 LAYOUT_AddChild
, HLayoutObject
,
180 LAYOUT_AddChild
, SpaceObject
,
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,
194 LAYOUT_AddChild
, SpaceObject
,
197 CHILD_WeightedWidth
, 0,
199 CHILD_MinWidth
, 300, // sets a more attractive size for the whole Layout
205 BOOL
updateBrowserList(struct List
* list
, struct MinList PrefsBrowserList
)
207 struct URL_BrowserNode
* bn
= NULL
,
210 // libération de la liste
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
),
221 LBNA_Checked
, isFlagClear(bn
->ubn_Flags
, UNF_DISABLED
),
228 IExec
->CopyMem(bn
, newNode
, sizeof(struct URL_BrowserNode
));
229 IListBrowser
->SetListBrowserNodeAttrs((struct Node
*)newNode
, LBNA_Column
, 1,
230 LBNCA_Text
, newNode
->ubn_Name
,
232 LBNCA_Text
, newNode
->ubn_Path
,
234 IExec
->AddTail(list
, (struct Node
*)newNode
);
238 IDOS
->Printf(" AllocListBrowserNode() failed\n");
246 void updateBrowserWindow(struct URL_BrowserNode
* pBrowser
)
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
);
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
)
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
,
289 LBNCA_Text
, pBrowser
->ubn_Path
,