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 ***************************************************************************/
25 #include "gui_global.h"
30 #include <libraries/openurl.h>
32 #include <classes/window.h>
34 #include <gadgets/chooser.h>
35 #include <gadgets/getfile.h>
36 #include <gadgets/listbrowser.h>
38 #include <reaction/reaction_macros.h>
40 #include <proto/dos.h>
41 #include <proto/intuition.h>
43 extern struct Window
*window
;
44 extern struct Window
*edit_brow_window
;
45 extern struct Window
*edit_mail_window
;
46 extern struct Window
*edit_ftp_window
;
49 extern Object
*edit_brow_win
;
50 extern Object
*edit_mail_win
;
51 extern Object
*edit_ftp_win
;
53 CONST_STRPTR hidden_strings
[] =
62 /// HandleInput_Main_Win
63 BOOL
HandleInput_Main_Win(void)
69 while ((result
= RA_HandleInput(win
, &code
)))
71 switch(result
& WMHI_CLASSMASK
)
73 case WMHI_CLOSEWINDOW
:
77 switch (result
& WMHI_GADGETMASK
)
79 case OBJ_LBROWSER_BROW
:
81 uint32 retval
= iget(OBJ(OBJ_LBROWSER_BROW
), LISTBROWSER_RelEvent
);
88 struct URL_BrowserNode
*bn
;
90 bn
= (struct URL_BrowserNode
*)iget(OBJ(OBJ_LBROWSER_BROW
), LISTBROWSER_SelectedNode
);
91 if (retval
== LBRE_UNCHECKED
)
92 SET_FLAG(bn
->ubn_Flags
,UNF_DISABLED
);
94 CLEAR_FLAG(bn
->ubn_Flags
,UNF_DISABLED
);
97 if (retval
!= LBRE_DOUBLECLICK
)break;
98 // we deliberately go on executing following case OBJ_EDIT_BROW
99 // because a double click mean the same as clicking edit button
103 struct URL_BrowserNode
*bn
;
105 bn
= (struct URL_BrowserNode
*)iget(OBJ(OBJ_LBROWSER_BROW
), LISTBROWSER_SelectedNode
);
106 updateBrowserWindow(bn
);
107 edit_brow_window
= RA_OpenWindow(edit_brow_win
);
110 case OBJ_LBROWSER_MAIL
:
112 uint32 retval
= iget(OBJ(OBJ_LBROWSER_MAIL
), LISTBROWSER_RelEvent
);
119 struct URL_MailerNode
*mn
;
121 mn
= (struct URL_MailerNode
*)iget(OBJ(OBJ_LBROWSER_MAIL
), LISTBROWSER_SelectedNode
);
122 if (retval
== LBRE_UNCHECKED
)
123 SET_FLAG(mn
->umn_Flags
,UNF_DISABLED
);
125 CLEAR_FLAG(mn
->umn_Flags
,UNF_DISABLED
);
128 if (retval
!= LBRE_DOUBLECLICK
) break;
129 // we deliberately go on executing following case OBJ_EDIT_MAIL
130 // because a double click mean the same as clicking edit button
134 struct URL_MailerNode
*mn
;
136 mn
= (struct URL_MailerNode
*)iget(OBJ(OBJ_LBROWSER_MAIL
), LISTBROWSER_SelectedNode
);
137 updateMailerWindow(mn
);
138 edit_mail_window
= RA_OpenWindow(edit_mail_win
);
141 case OBJ_LBROWSER_FTP
:
143 uint32 retval
= iget(OBJ(OBJ_LBROWSER_FTP
), LISTBROWSER_RelEvent
);
150 struct URL_FTPNode
*fn
;
152 fn
= (struct URL_FTPNode
*)iget(OBJ(OBJ_LBROWSER_FTP
), LISTBROWSER_SelectedNode
);
153 if (retval
== LBRE_UNCHECKED
)
154 SET_FLAG(fn
->ufn_Flags
,UNF_DISABLED
);
156 CLEAR_FLAG(fn
->ufn_Flags
,UNF_DISABLED
);
159 if (retval
!= LBRE_DOUBLECLICK
) break;
160 // we deliberately go on executing following case OBJ_EDIT_FTP
161 // because a double click mean the same as clicking edit button
165 struct URL_FTPNode
*fn
;
167 fn
= (struct URL_FTPNode
*)iget(OBJ(OBJ_LBROWSER_FTP
), LISTBROWSER_SelectedNode
);
169 edit_ftp_window
= RA_OpenWindow(edit_ftp_win
);
175 storePrefs((result
& WMHI_GADGETMASK
)==OBJ_SAVE
);
176 if((result
& WMHI_GADGETMASK
)!=OBJ_APPLY
)
188 if (edit_brow_window
)
190 RA_CloseWindow(edit_brow_win
);
191 edit_brow_window
= NULL
;
193 if (edit_mail_window
)
195 RA_CloseWindow(edit_mail_win
);
196 edit_mail_window
= NULL
;
200 RA_CloseWindow(edit_ftp_win
);
201 edit_ftp_window
= NULL
;
206 window
= RA_OpenWindow(win
);
214 /// HandleInput_Edit_Brow_Win
215 void HandleInput_Edit_Brow_Win()
220 while ((result
= RA_HandleInput(edit_brow_win
, &code
)))
222 switch(result
& WMHI_CLASSMASK
)
224 case WMHI_CLOSEWINDOW
:
225 RA_CloseWindow(edit_brow_win
);
226 edit_brow_window
= NULL
;
229 switch (result
& WMHI_GADGETMASK
)
232 gadset(GAD(OBJ_LBROWSER_BROW
), window
, LISTBROWSER_Labels
, ~0);
234 gadset(GAD(OBJ_LBROWSER_BROW
), window
, LISTBROWSER_Labels
, &list_Brow
,
235 LISTBROWSER_AutoFit
, TRUE
);
236 case OBJ_BROW_CANCEL
:
237 RA_CloseWindow(edit_brow_win
);
238 edit_brow_window
= NULL
;
240 case OBJ_BROW_PATH_GET
:
241 if (gfRequestFile(OBJ(OBJ_BROW_PATH_GET
), edit_brow_window
))
245 case OBJ_BROW_PATH_CHOOSE
: // set Attrs according to the button clicked on.
246 case OBJ_BROW_OPEN_CHOOSE
:
247 case OBJ_BROW_NEW_CHOOSE
:
248 iset(OBJ(OBJ_HIDDEN_CHOOSER
), CHOOSER_LabelArray
, hidden_strings
);
249 IIntuition
->ActivateGadget(GAD(OBJ_HIDDEN_CHOOSER
),
250 edit_brow_window
, NULL
);
252 case OBJ_BROW_AREXX_CHOOSE
:
253 iset(OBJ(OBJ_HIDDEN_CHOOSER
), CHOOSER_LabelArray
, hidden_strings
);
254 IIntuition
->ActivateGadget(GAD(OBJ_HIDDEN_CHOOSER
),
255 edit_brow_window
, NULL
);
263 /// HandleInput_Edit_Mail_Win
264 void HandleInput_Edit_Mail_Win()
269 while ((result
= RA_HandleInput(edit_mail_win
, &code
)))
271 switch(result
& WMHI_CLASSMASK
)
273 case WMHI_CLOSEWINDOW
:
274 RA_CloseWindow(edit_mail_win
);
275 edit_mail_window
= NULL
;
278 switch (result
& WMHI_GADGETMASK
)
281 gadset(GAD(OBJ_LBROWSER_MAIL
), window
, LISTBROWSER_Labels
, ~0);
283 gadset(GAD(OBJ_LBROWSER_MAIL
), window
, LISTBROWSER_Labels
, &list_Mail
,
284 LISTBROWSER_AutoFit
, TRUE
);
285 case OBJ_MAIL_CANCEL
:
286 RA_CloseWindow(edit_mail_win
);
287 edit_mail_window
= NULL
;
289 case OBJ_MAIL_PATH_GET
:
290 if (gfRequestFile(OBJ(OBJ_MAIL_PATH_GET
), edit_mail_window
))
294 case OBJ_MAIL_PATH_CHOOSE
: // set Attrs according to the button clicked on.
295 case OBJ_MAIL_WRITE_CHOOSE
:
296 iset(OBJ(OBJ_HIDDEN_CHOOSER
), CHOOSER_LabelArray
, hidden_strings
);
297 IIntuition
->ActivateGadget(GAD(OBJ_HIDDEN_CHOOSER
),
298 edit_mail_window
, NULL
);
300 case OBJ_MAIL_AREXX_CHOOSE
:
301 iset(OBJ(OBJ_HIDDEN_CHOOSER
), CHOOSER_LabelArray
, hidden_strings
);
302 IIntuition
->ActivateGadget(GAD(OBJ_HIDDEN_CHOOSER
),
303 edit_mail_window
, NULL
);
311 /// HandleInput_Edit_FTP_Win
312 void HandleInput_Edit_FTP_Win()
317 while ((result
= RA_HandleInput(edit_ftp_win
, &code
)))
319 switch(result
& WMHI_CLASSMASK
)
321 case WMHI_CLOSEWINDOW
:
322 RA_CloseWindow(edit_ftp_win
);
323 edit_ftp_window
= NULL
;
326 switch (result
& WMHI_GADGETMASK
)
329 gadset(GAD(OBJ_LBROWSER_BROW
), window
, LISTBROWSER_Labels
, ~0);
331 gadset(GAD(OBJ_LBROWSER_BROW
), window
, LISTBROWSER_Labels
, &list_FTPs
,
332 LISTBROWSER_AutoFit
, TRUE
);
334 RA_CloseWindow(edit_ftp_win
);
335 edit_brow_window
= NULL
;
337 case OBJ_FTP_PATH_GET
:
338 if (gfRequestFile(OBJ(OBJ_FTP_PATH_GET
), edit_ftp_window
))
342 case OBJ_FTP_PATH_CHOOSE
: // set Attrs according to the button clicked on.
343 case OBJ_FTP_OPEN_CHOOSE
:
344 case OBJ_FTP_NEW_CHOOSE
:
345 iset( OBJ(OBJ_HIDDEN_CHOOSER
), CHOOSER_LabelArray
, hidden_strings
);
346 IIntuition
->ActivateGadget(GAD(OBJ_HIDDEN_CHOOSER
),
347 edit_ftp_window
, NULL
);
349 case OBJ_FTP_AREXX_CHOOSE
:
350 iset( OBJ(OBJ_HIDDEN_CHOOSER
), CHOOSER_LabelArray
, hidden_strings
);
351 IIntuition
->ActivateGadget(GAD(OBJ_HIDDEN_CHOOSER
),
352 edit_ftp_window
, NULL
);