Selection menu and save/download tweaks
svn path=/trunk/netsurf/; revision=6349
This commit is contained in:
parent
a15d9876ca
commit
15e8ba0270
|
@ -134,7 +134,8 @@ void selection_reinit(struct selection *s, struct box *root)
|
|||
|
||||
if (IS_INPUT(root)) {
|
||||
static int next_idx = 0;
|
||||
root_idx = (next_idx++) << 28;
|
||||
if (!++next_idx) next_idx = 1;
|
||||
root_idx = next_idx << 28;
|
||||
}
|
||||
else
|
||||
root_idx = 0;
|
||||
|
@ -191,6 +192,20 @@ void selection_init(struct selection *s, struct box *root)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicate whether the selected text is read only, ie. cannot be modified.
|
||||
*
|
||||
* \param s selection object
|
||||
* \return true iff the selection is read only
|
||||
*/
|
||||
|
||||
bool selection_read_only(struct selection *s)
|
||||
{
|
||||
return !s->root || !NUMBER_SPACE(s->root->byte_offset);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Label each text box in the given box subtree with its position
|
||||
* in a textual representation of the content.
|
||||
|
|
|
@ -77,6 +77,7 @@ void selection_reinit(struct selection *s, struct box *root);
|
|||
/* bool selection_dragging_start(struct selection *s); */
|
||||
#define selection_dragging_start(s) ((s)->drag_state == DRAG_START)
|
||||
|
||||
bool selection_read_only(struct selection *s);
|
||||
|
||||
void selection_clear(struct selection *s, bool redraw);
|
||||
void selection_select_all(struct selection *s);
|
||||
|
|
|
@ -1198,7 +1198,12 @@ void ro_gui_download_remember_dir(const char *path)
|
|||
char *lastdot = NULL;
|
||||
char *p = path;
|
||||
while (*p >= 0x20) {
|
||||
if (*p == '.') lastdot = p;
|
||||
if (*p == '.') {
|
||||
/* don't remember the directory if it's a temporary file */
|
||||
if (!lastdot && p == path + 12 &&
|
||||
!memcmp(path, "<Wimp$Scrap>", 12)) break;
|
||||
lastdot = p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
if (lastdot) {
|
||||
|
@ -1297,7 +1302,8 @@ bool ro_gui_download_save(struct gui_download_window *dw,
|
|||
dw->saved = true;
|
||||
strncpy(dw->path, file_name, sizeof dw->path);
|
||||
|
||||
ro_gui_download_remember_dir(file_name);
|
||||
if (!dw->send_dataload || dw->save_message.data.data_xfer.est_size != -1)
|
||||
ro_gui_download_remember_dir(file_name);
|
||||
|
||||
/* grey out file icon */
|
||||
error = xwimp_set_icon_state(dw->window, ICON_DOWNLOAD_ICON,
|
||||
|
|
|
@ -2099,9 +2099,9 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
|
|||
break;
|
||||
|
||||
case BROWSER_SELECTION:
|
||||
/* make menu available if there's a selection or an input field for pasting */
|
||||
/* make menu available if there's anything that /could/ be selected */
|
||||
ro_gui_menu_set_entry_shaded(current_menu, action,
|
||||
!(c && (bw->paste_callback || (bw->sel && selection_defined(bw->sel)))));
|
||||
!c || (c->type != CONTENT_HTML && c->type != CONTENT_TEXTPLAIN));
|
||||
break;
|
||||
case BROWSER_SELECTION_SAVE:
|
||||
if (c && (!bw->sel || !selection_defined(bw->sel))) c = NULL;
|
||||
|
@ -2110,10 +2110,14 @@ void ro_gui_menu_prepare_action(wimp_w owner, menu_action action,
|
|||
ro_gui_save_prepare(GUI_SAVE_TEXT_SELECTION, NULL, bw->sel, NULL, NULL);
|
||||
break;
|
||||
case BROWSER_SELECTION_COPY:
|
||||
case BROWSER_SELECTION_CUT:
|
||||
ro_gui_menu_set_entry_shaded(current_menu, action,
|
||||
!(c && bw->sel && selection_defined(bw->sel)));
|
||||
break;
|
||||
case BROWSER_SELECTION_CUT:
|
||||
ro_gui_menu_set_entry_shaded(current_menu, action,
|
||||
!(c && bw->sel && selection_defined(bw->sel)
|
||||
&& !selection_read_only(bw->sel)));
|
||||
break;
|
||||
case BROWSER_SELECTION_PASTE:
|
||||
ro_gui_menu_set_entry_shaded(current_menu, action, !(c && bw->paste_callback));
|
||||
break;
|
||||
|
|
|
@ -323,14 +323,16 @@ bool ro_gui_save_ok(wimp_w w)
|
|||
ro_gui_convert_save_path(path, sizeof path, name);
|
||||
gui_save_sourcew = w;
|
||||
saving_from_dialog = true;
|
||||
gui_save_send_dataload = false;
|
||||
gui_save_close_after = xwimp_get_pointer_info(&pointer)
|
||||
|| !(pointer.buttons & wimp_CLICK_ADJUST);
|
||||
if (!ro_gui_save_content(gui_save_content, path, !option_confirm_overwrite)) {
|
||||
memcpy(&gui_save_message.data.data_xfer.file_name, path, 1 + strlen(path));
|
||||
gui_save_send_dataload = false;
|
||||
return false;
|
||||
memcpy(&gui_save_message.data.data_xfer.file_name, path, 1 + strlen(path));
|
||||
|
||||
if (ro_gui_save_content(gui_save_content, path, !option_confirm_overwrite)) {
|
||||
ro_gui_save_done();
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -941,24 +943,32 @@ void ro_gui_save_done(void)
|
|||
}
|
||||
|
||||
if (saving_from_dialog) {
|
||||
/* */
|
||||
char *sp = gui_save_message.data.data_xfer.file_name;
|
||||
char *ep = sp + sizeof(gui_save_message.data.data_xfer.file_name);
|
||||
char *lastdot = NULL;
|
||||
char *p = sp;
|
||||
/* remember the save directory if saving to the Filer */
|
||||
if (!gui_save_send_dataload ||
|
||||
gui_save_message.data.data_xfer.est_size != -1) {
|
||||
char *sp = gui_save_message.data.data_xfer.file_name;
|
||||
char *ep = sp + sizeof(gui_save_message.data.data_xfer.file_name);
|
||||
char *lastdot = NULL;
|
||||
char *p = sp;
|
||||
|
||||
while (p < ep && *p >= 0x20) {
|
||||
if (*p == '.') lastdot = p;
|
||||
p++;
|
||||
}
|
||||
if (lastdot) {
|
||||
/* remember the directory */
|
||||
char *new_dir = realloc(save_dir, (lastdot+1)-sp);
|
||||
if (new_dir) {
|
||||
save_dir_len = lastdot - sp;
|
||||
memcpy(new_dir, sp, save_dir_len);
|
||||
new_dir[save_dir_len] = '\0';
|
||||
save_dir = new_dir;
|
||||
while (p < ep && *p >= 0x20) {
|
||||
if (*p == '.') {
|
||||
/* don't remember the directory if it's a temporary file */
|
||||
if (!lastdot && p == sp + 12 &&
|
||||
!memcmp(sp, "<Wimp$Scrap>", 12)) break;
|
||||
lastdot = p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
if (lastdot) {
|
||||
/* remember the directory */
|
||||
char *new_dir = realloc(save_dir, (lastdot+1)-sp);
|
||||
if (new_dir) {
|
||||
save_dir_len = lastdot - sp;
|
||||
memcpy(new_dir, sp, save_dir_len);
|
||||
new_dir[save_dir_len] = '\0';
|
||||
save_dir = new_dir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue