mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-22 22:41:30 +03:00
Remove struct selection from ami_file_save and anywhere that feeds into it
This commit is contained in:
parent
48bd5e1f10
commit
4d9b674997
@ -315,15 +315,18 @@ struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin)
|
||||
return sel;
|
||||
}
|
||||
|
||||
void ami_drag_selection(struct selection *s)
|
||||
void ami_drag_selection(struct gui_window *g)
|
||||
{
|
||||
int x;
|
||||
int y;
|
||||
char *utf8text;
|
||||
struct ami_text_selection *sel;
|
||||
char *sel;
|
||||
struct IFFHandle *old_iffh = iffh;
|
||||
struct gui_window_2 *gwin = ami_window_at_pointer(AMINS_WINDOW);
|
||||
|
||||
|
||||
/* NB: 'gwin' is at the drop point, 'g' is where the selection was dragged from.
|
||||
* These may be different if the selection has been dragged between windows. */
|
||||
|
||||
if(!gwin)
|
||||
{
|
||||
DisplayBeep(scrn);
|
||||
@ -337,11 +340,9 @@ void ami_drag_selection(struct selection *s)
|
||||
{
|
||||
iffh = ami_clipboard_init_internal(1);
|
||||
|
||||
if(selection_copy_to_clipboard(s))
|
||||
{
|
||||
browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y);
|
||||
browser_window_key_press(gwin->bw, KEY_PASTE);
|
||||
}
|
||||
browser_window_key_press(g->shared->bw, KEY_COPY_SELECTION);
|
||||
browser_window_mouse_click(gwin->bw, BROWSER_MOUSE_PRESS_1, x, y);
|
||||
browser_window_key_press(gwin->bw, KEY_PASTE);
|
||||
|
||||
ami_clipboard_free_internal(iffh);
|
||||
iffh = old_iffh;
|
||||
@ -353,23 +354,23 @@ void ami_drag_selection(struct selection *s)
|
||||
|
||||
if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
|
||||
{
|
||||
if(sel = ami_selection_to_text(gwin))
|
||||
if(sel = browser_window_get_selection(g->shared->bw))
|
||||
{
|
||||
utf8text = ami_utf8_easy(sel->text);
|
||||
utf8text = ami_utf8_easy(sel);
|
||||
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
|
||||
gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
|
||||
FreeVec(sel);
|
||||
free(sel);
|
||||
ami_utf8_free(utf8text);
|
||||
}
|
||||
}
|
||||
else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
|
||||
{
|
||||
if(sel = ami_selection_to_text(gwin))
|
||||
if(sel = browser_window_get_selection(g->shared->bw))
|
||||
{
|
||||
utf8text = ami_utf8_easy(sel->text);
|
||||
utf8text = ami_utf8_easy(sel);
|
||||
RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
|
||||
gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
|
||||
FreeVec(sel);
|
||||
free(sel);
|
||||
ami_utf8_free(utf8text);
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
struct bitmap;
|
||||
struct hlcache_handle;
|
||||
struct selection;
|
||||
struct gui_window;
|
||||
struct gui_window_2;
|
||||
|
||||
struct ami_text_selection
|
||||
@ -33,7 +34,7 @@ struct ami_text_selection
|
||||
|
||||
void ami_clipboard_init(void);
|
||||
void ami_clipboard_free(void);
|
||||
void ami_drag_selection(struct selection *s);
|
||||
void ami_drag_selection(struct gui_window *g);
|
||||
bool ami_easy_clipboard(char *text);
|
||||
bool ami_easy_clipboard_bitmap(struct bitmap *bitmap);
|
||||
struct ami_text_selection *ami_selection_to_text(struct gui_window_2 *gwin);
|
||||
|
@ -892,18 +892,18 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
|
||||
case CMID_SAVEOBJ:
|
||||
case CMID_PAGESAVE:
|
||||
ami_file_save_req(AMINS_SAVE_SOURCE, gwin,
|
||||
(struct hlcache_handle *)userdata, NULL);
|
||||
(struct hlcache_handle *)userdata);
|
||||
break;
|
||||
|
||||
case CMID_PAGESAVECOMPLETE:
|
||||
case CMID_FRAMESAVECOMPLETE:
|
||||
ami_file_save_req(AMINS_SAVE_COMPLETE, gwin,
|
||||
(struct hlcache_handle *)userdata, NULL);
|
||||
(struct hlcache_handle *)userdata);
|
||||
break;
|
||||
|
||||
case CMID_SAVEIFFOBJ:
|
||||
ami_file_save_req(AMINS_SAVE_IFF, gwin,
|
||||
(struct hlcache_handle *)userdata, NULL);
|
||||
(struct hlcache_handle *)userdata);
|
||||
break;
|
||||
|
||||
case CMID_PLUGINCMD:
|
||||
@ -984,8 +984,7 @@ static uint32 ami_context_menu_hook(struct Hook *hook,Object *item,APTR reserved
|
||||
break;
|
||||
|
||||
case CMID_SELSAVE:
|
||||
ami_file_save_req(AMINS_SAVE_SELECTION, gwin, NULL,
|
||||
browser_window_get_selection(gwin->bw));
|
||||
ami_file_save_req(AMINS_SAVE_SELECTION, gwin, NULL);
|
||||
break;
|
||||
|
||||
case CMID_SELSEARCH:
|
||||
|
@ -94,7 +94,7 @@ void gui_drag_save_selection(struct selection *s, struct gui_window *g)
|
||||
ami_drag_icon_show(g->shared->win, "ascii");
|
||||
|
||||
ami_autoscroll = TRUE;
|
||||
drag_save_data = s;
|
||||
drag_save_data = g;
|
||||
drag_save = GUI_SAVE_TEXT_SELECTION;
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ void ami_drag_save(struct Window *win)
|
||||
else if(which == WBO_NONE)
|
||||
{
|
||||
if(drag_save == GUI_SAVE_TEXT_SELECTION)
|
||||
ami_drag_selection((struct selection *)drag_save_data);
|
||||
ami_drag_selection((struct gui_window *)drag_save_data);
|
||||
else DisplayBeep(scrn);
|
||||
|
||||
drag_save = 0;
|
||||
|
14
amiga/file.c
14
amiga/file.c
@ -148,7 +148,7 @@ static void ami_file_set_type(const char *path, lwc_string *mime_type)
|
||||
|
||||
void ami_file_save(int type, char *fname, struct Window *win,
|
||||
struct hlcache_handle *object, struct hlcache_handle *favicon,
|
||||
struct selection *sel)
|
||||
struct browser_window *bw)
|
||||
{
|
||||
BPTR lock = 0;
|
||||
const char *source_data;
|
||||
@ -209,7 +209,13 @@ void ami_file_save(int type, char *fname, struct Window *win,
|
||||
break;
|
||||
|
||||
case AMINS_SAVE_SELECTION:
|
||||
selection_save_text(sel, fname);
|
||||
if(source_data = browser_window_get_selection(bw)) {
|
||||
if(fh = FOpen(fname, MODE_NEWFILE,0)) {
|
||||
FWrite(fh, source_data, 1, strlen(source_data));
|
||||
FClose(fh);
|
||||
}
|
||||
free(source_data);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(object) SetComment(fname, nsurl_access(hlcache_handle_get_url(object)));
|
||||
@ -219,7 +225,7 @@ void ami_file_save(int type, char *fname, struct Window *win,
|
||||
}
|
||||
|
||||
void ami_file_save_req(int type, struct gui_window_2 *gwin,
|
||||
struct hlcache_handle *object, struct selection *sel)
|
||||
struct hlcache_handle *object)
|
||||
{
|
||||
char *fname = AllocVec(1024, MEMF_CLEAR | MEMF_PRIVATE);
|
||||
|
||||
@ -232,7 +238,7 @@ void ami_file_save_req(int type, struct gui_window_2 *gwin,
|
||||
strlcpy(fname, savereq->fr_Drawer, 1024);
|
||||
AddPart(fname, savereq->fr_File, 1024);
|
||||
|
||||
ami_file_save(type, fname, gwin->win, object, gwin->bw->window->favicon, sel);
|
||||
ami_file_save(type, fname, gwin->win, object, gwin->bw->window->favicon, gwin->bw);
|
||||
}
|
||||
|
||||
if(fname) FreeVec(fname);
|
||||
|
@ -39,7 +39,7 @@ void ami_file_req_free(void);
|
||||
|
||||
void ami_file_open(struct gui_window_2 *gwin);
|
||||
void ami_file_save_req(int type, struct gui_window_2 *gwin,
|
||||
struct hlcache_handle *object, struct selection *sel);
|
||||
struct hlcache_handle *object);
|
||||
void ami_file_save(int type, char *fname, struct Window *win,
|
||||
struct hlcache_handle *object, struct hlcache_handle *favicon,
|
||||
struct selection *sel);
|
||||
struct browser_window *bw);
|
||||
|
@ -1879,7 +1879,7 @@ void ami_handle_msg(void)
|
||||
|
||||
case 's':
|
||||
ami_file_save_req(AMINS_SAVE_SOURCE, gwin,
|
||||
gwin->bw->current_content, NULL);
|
||||
gwin->bw->current_content);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
|
@ -757,7 +757,7 @@ static void ami_menu_item_project_save(struct Hook *hook, APTR window, struct In
|
||||
|
||||
GetAttr(WINDOW_UserData, (Object *)window, (ULONG *)&gwin);
|
||||
|
||||
ami_file_save_req(type, gwin, gwin->bw->current_content, NULL);
|
||||
ami_file_save_req(type, gwin, gwin->bw->current_content);
|
||||
}
|
||||
|
||||
static void ami_menu_item_project_closetab(struct Hook *hook, APTR window, struct IntuiMessage *msg)
|
||||
|
Loading…
Reference in New Issue
Block a user