Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Cameron Cawley
Browse
Commits
2f9de2c5
Commit
2f9de2c5
authored
27 years ago
by
David Brown
Browse files
Options
Download
Email Patches
Plain Diff
Added support for saving HTML files from hotlist window
parent
7497ecb1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
32 deletions
+140
-32
c/Hotlist
c/Hotlist
+139
-32
h/Hotlist
h/Hotlist
+1
-0
No files found.
c/Hotlist
View file @
2f9de2c5
...
...
@@ -159,7 +159,7 @@ static _kernel_oserror * hotlist_process_click_on_item (unsigned int itemno, h
static
_kernel_oserror
*
hotlist_process_click
(
int
x
,
int
y
,
int
buttons
);
static
void
hotlist_window_preopen
(
hl_opentype
type
);
static
void
hotlist_set_menu_details
(
ObjectId
menuid
);
static
_kernel_oserror
*
hotlist_save_entries
(
FILE
*
fileptr
,
hotlist_item
*
list
);
static
_kernel_oserror
*
hotlist_save_entries
(
FILE
*
fileptr
,
hotlist_item
*
list
,
int
type
);
static
void
hotlist_lower_tags
(
char
*
string
);
static
_kernel_oserror
*
hotlist_load_directory
(
FILE
*
fileptr
,
hotlist_item
*
target
);
static
void
hotlist_drag_renderer
(
hotlist_item
*
item
,
unsigned
int
item_height
,
unsigned
int
item_dir_width
,
unsigned
int
item_url_width
);
...
...
@@ -169,6 +169,7 @@ static _kernel_oserror * hotlist_modified (unsigned int type);
/* Save Protocol */
_kernel_oserror
*
hotlist_initiate_uri_save
(
hotlist_item
*
sourceitem
);
_kernel_oserror
*
hotlist_initiate_html_save
(
char
*
filename
);
/* List manupulation */
...
...
@@ -2195,19 +2196,22 @@ static int hotlist_menuopen_handler(int event_code, ToolboxEvent * event, IdBloc
/* the directory to save (which may */
/* itself be a directory). */
/* */
/* 0 - save all of hotlist */
/* 1 - only save selection portions */
/* */
/* Assumes: The FILE pointer must not be NULL */
/* however the hotlist_item pointer */
/* can be (e.g. an empty directory). */
/*************************************************/
static
_kernel_oserror
*
hotlist_save_entries
(
FILE
*
fileptr
,
hotlist_item
*
list
)
static
_kernel_oserror
*
hotlist_save_entries
(
FILE
*
fileptr
,
hotlist_item
*
list
,
int
type
)
{
int
written
;
_kernel_oserror
*
e
;
/* Write the entry header */
HotlistWrite
(
fprintf
(
fileptr
,
"<ul>
\n
"
));
//
HotlistWrite(fprintf(fileptr, "<ul>\n"));
/* Follow the directory list */
...
...
@@ -2218,20 +2222,27 @@ static _kernel_oserror * hotlist_save_entries(FILE * fileptr, hotlist_item * lis
/* Write a link for URLs */
case
hl_url
:
{
if
(
type
==
0
||
(
type
==
1
&&
list
->
flags
&
HOTLIST_G_IS_SELECTED
))
{
HotlistWrite
(
fprintf
(
fileptr
,
"<li><a href=
\"
%s
\"
>%s</a>
\n
"
,
list
->
data
.
url
,
list
->
name
));
}
}
break
;
/* Write a heading for directories */
case
hl_directory
:
{
if
(
type
==
0
||
!
hotlist_no_contents_selected
(
list
->
data
.
directory_content
))
{
HotlistWrite
(
fprintf
(
fileptr
,
"<h4>%s</h4>
\n
"
,
list
->
name
));
/* Recursive call for the directory contents */
RetError
(
hotlist_save_entries
(
fileptr
,
list
->
data
.
directory_content
));
HotlistWrite
(
fprintf
(
fileptr
,
"<ul>
\n
"
));
RetError
(
hotlist_save_entries
(
fileptr
,
list
->
data
.
directory_content
,
type
));
HotlistWrite
(
fprintf
(
fileptr
,
"</ul>
\n
"
));
}
}
break
;
}
...
...
@@ -2243,22 +2254,24 @@ static _kernel_oserror * hotlist_save_entries(FILE * fileptr, hotlist_item * lis
/* Write the entry footer */
HotlistWrite
(
fprintf
(
fileptr
,
"</ul>
\n
"
));
//
HotlistWrite(fprintf(fileptr, "</ul>\n"));
return
NULL
;
}
/*************************************************/
/* hotlist_save
()
*/
/* hotlist_save
_hotlist()
*/
/* */
/* This function saves the hotlist as an HTML */
/* file. */
/* */
/* Parameters: Pointer to the filename to load */
/* (null terminated). */
/* */
/* 0 - save all of hotlist */
/* 1 - only save selection portions */
/*************************************************/
_kernel_oserror
*
hotlist_save
(
char
*
filename
)
_kernel_oserror
*
hotlist_save_hotlist
(
char
*
filename
,
int
type
)
{
FILE
*
fileptr
;
_kernel_oserror
*
e
;
...
...
@@ -2280,7 +2293,7 @@ _kernel_oserror * hotlist_save(char * filename)
/* Fill in the body */
e
=
hotlist_save_entries
(
fileptr
,
hotlist_root
->
data
.
directory_content
);
e
=
hotlist_save_entries
(
fileptr
,
hotlist_root
->
data
.
directory_content
,
type
);
if
(
e
)
{
...
...
@@ -2306,6 +2319,21 @@ _kernel_oserror * hotlist_save(char * filename)
FileType_HTML
);
}
/*************************************************/
/* hotlist_save() */
/* */
/* Veneer onto hotlist_save_hotlist - saves all */
/* of the hotlist, created to preserve API */
/* */
/* Parameters: Pointer to the filename to load */
/* (null terminated). */
/*************************************************/
_kernel_oserror
*
hotlist_save
(
char
*
filename
)
{
return
hotlist_save_hotlist
(
filename
,
0
);
/* Save entire hotlist */
}
/*************************************************/
/* hotlist_lower_tags() */
/* */
...
...
@@ -3757,19 +3785,17 @@ static int hotlist_drag_completed_handler(int event_code, WimpPollBlock *event,
}
else
{
if
(
hotlist_count_selected_items
()
==
1
)
if
(
hotlist_count_selected_items
()
==
1
&&
(
sourceitem
=
hotlist_find_selected_item
())
->
type
==
hl_url
)
{
/* Dropped in non hotlist window - save as a URI file */
sourceitem
=
hotlist_find_selected_item
();
if
(
sourceitem
->
type
==
hl_url
)
{
hotlist_initiate_uri_save
(
sourceitem
);
}
}
else
{
/* Can't save URI file when saving more than one URL */
/* Can't save URI file when saving more than one URL so save HTML file instead*/
hotlist_initiate_html_save
(
"Hotlist"
);
}
/* Drag was dropped in non-hotlist window */
}
...
...
@@ -3786,11 +3812,9 @@ void hotlist_autoscroll(int x, int y, int window_handle)
BBox
extent
;
static
unsigned
int
hscroll_speed
,
vscroll_speed
;
/* Separate h/v velocities */
static
int
last_window_handle
=
0
;
_kernel_oserror
*
e
;
object
=
0
;
show_error_ret
(
window_wimp_to_toolbox
(
0
,
window_handle
,
-
1
,
&
object
,
NULL
));
if
(
!
object
)
return
;
/* No error as autoscroll not working is not a major problem */
if
(
window_wimp_to_toolbox
(
0
,
window_handle
,
-
1
,
&
object
,
NULL
))
return
;
state
.
window_handle
=
window_handle
;
...
...
@@ -3978,7 +4002,15 @@ static int hotlist_null_handler(int event_code, WimpPollBlock *event, IdBlock *i
/* Simple non-scrolling selection box, to be improved later */
int
selection_x
,
selection_y
;
/* Workarea relative corner of selection box */
/* Workarea relative corner of selection box may not be needed later */
static
int
selection_x
,
selection_y
;
/*************************************************/
/* hotlist_start_drag() */
/* */
/* This function is called to start a selection */
/* box operation in the hotlist window. */
/*************************************************/
_kernel_oserror
*
hotlist_selection_box_start
(
void
)
{
...
...
@@ -4063,8 +4095,6 @@ int hotlist_null_drag_select_handler(int event_code, WimpPollBlock * event, IdBl
maxx
=
selection_x
;
}
/* Change from here onwards */
last_item
=
hotlist_count_displayed_items
(
hotlist_root
->
data
.
directory_content
);
for
(
itemno
=
0
;
itemno
<=
last_item
;
itemno
++
)
...
...
@@ -4320,6 +4350,39 @@ _kernel_oserror *hotlist_initiate_uri_save(hotlist_item *item)
return
NULL
;
}
_kernel_oserror
*
hotlist_initiate_html_save
(
char
*
filename
)
{
WimpGetPointerInfoBlock
block
;
WimpMessage
message
;
int
new_task_handle
;
wimp_get_pointer_info
(
&
block
);
message
.
hdr
.
size
=
sizeof
(
WimpMessage
);
message
.
hdr
.
your_ref
=
0
;
message
.
hdr
.
action_code
=
Wimp_MDataSave
;
message
.
data
.
data_save
.
destination_window
=
block
.
window_handle
;
message
.
data
.
data_save
.
destination_icon
=
block
.
icon_handle
;
message
.
data
.
data_save
.
destination_x
=
block
.
x
;
message
.
data
.
data_save
.
destination_y
=
block
.
y
;
message
.
data
.
data_save
.
estimated_size
=
-
1
;
/* Dunno how big it's going to be */
message
.
data
.
data_save
.
file_type
=
FileType_HTML
;
strncpy
(
message
.
data
.
data_save
.
leaf_name
,
filename
,
212
);
wimp_send_message
(
Wimp_EUserMessageRecorded
,
&
message
,
block
.
window_handle
,
block
.
icon_handle
,
&
new_task_handle
);
hotlist_ram_transfer_sent
=
0
;
hotlist_save_type
=
HL_SAVE_HTML
;
return
NULL
;
}
int
hotlist_data_save_ack_handler
(
WimpMessage
*
message
,
void
*
handle
)
{
FILE
*
fileptr
;
...
...
@@ -4344,11 +4407,19 @@ int hotlist_data_save_ack_handler(WimpMessage *message, void *handle)
return
1
;
}
show_error_ret
(
_swix
(
OS_File
,
e
=
_swix
(
OS_File
,
_INR
(
0
,
2
),
18
,
message
->
data
.
data_save_ack
.
leaf_name
,
0xf91
));
0xf91
);
if
(
e
)
{
show_error_ret
(
e
);
hotlist_save_item
=
NULL
;
hotlist_save_type
=
HL_SAVE_NONE
;
return
1
;
}
message
->
hdr
.
action_code
=
Wimp_MDataLoad
;
message
->
hdr
.
your_ref
=
message
->
hdr
.
my_ref
;
...
...
@@ -4381,6 +4452,42 @@ int hotlist_data_save_ack_handler(WimpMessage *message, void *handle)
return
1
;
}
break
;
case
HL_SAVE_HTML
:
e
=
hotlist_save_hotlist
(
message
->
data
.
data_save_ack
.
leaf_name
,
1
);
hotlist_clear_selection
();
if
(
e
)
{
show_error_ret
(
e
);
hotlist_save_type
=
HL_SAVE_NONE
;
}
message
->
hdr
.
action_code
=
Wimp_MDataLoad
;
message
->
hdr
.
your_ref
=
message
->
hdr
.
my_ref
;
e
=
wimp_send_message
(
Wimp_EUserMessageRecorded
,
message
,
message
->
hdr
.
sender
,
0
,
&
new_task_handle
);
if
(
e
)
{
show_error_ret
(
e
);
if
(
remove
(
message
->
data
.
data_save_ack
.
leaf_name
))
{
show_error_ret
(
_kernel_last_oserror
());
}
hotlist_save_type
=
HL_SAVE_NONE
;
}
return
1
;
break
;
default:
break
;
}
...
...
This diff is collapsed.
Click to expand it.
h/Hotlist
View file @
2f9de2c5
...
...
@@ -177,6 +177,7 @@
#define HL_SAVE_NONE 0
#define HL_SAVE_URI 1
#define HL_SAVE_HTML 2
/* Various component IDs */
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment