summaryrefslogtreecommitdiff
path: root/amiga
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2013-02-22 19:02:58 +0000
committerChris Young <chris@unsatisfactorysoftware.co.uk>2013-02-22 19:02:58 +0000
commit4d9b67499727f1cce58c2bd65a06178f91fc30b4 (patch)
tree0558cd48d512e828a5cafc7ea5fd93249e619e94 /amiga
parent48bd5e1f102c7a0cf5d71c5df991329c52dccbcc (diff)
downloadnetsurf-4d9b67499727f1cce58c2bd65a06178f91fc30b4.tar.gz
netsurf-4d9b67499727f1cce58c2bd65a06178f91fc30b4.tar.bz2
Remove struct selection from ami_file_save and anywhere that feeds into it
Diffstat (limited to 'amiga')
-rw-r--r--amiga/clipboard.c29
-rwxr-xr-xamiga/clipboard.h3
-rw-r--r--amiga/context_menu.c9
-rw-r--r--amiga/drag.c4
-rw-r--r--amiga/file.c14
-rw-r--r--amiga/file.h4
-rw-r--r--amiga/gui.c2
-rw-r--r--amiga/menu.c2
8 files changed, 37 insertions, 30 deletions
diff --git a/amiga/clipboard.c b/amiga/clipboard.c
index 91dd6c790..2fe016b10 100644
--- a/amiga/clipboard.c
+++ b/amiga/clipboard.c
@@ -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);
}
}
diff --git a/amiga/clipboard.h b/amiga/clipboard.h
index 8d0d8d459..6cae3e3b8 100755
--- a/amiga/clipboard.h
+++ b/amiga/clipboard.h
@@ -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);
diff --git a/amiga/context_menu.c b/amiga/context_menu.c
index 9266350f1..c5b292927 100644
--- a/amiga/context_menu.c
+++ b/amiga/context_menu.c
@@ -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:
diff --git a/amiga/drag.c b/amiga/drag.c
index addc4b3cf..3105fc620 100644
--- a/amiga/drag.c
+++ b/amiga/drag.c
@@ -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;
diff --git a/amiga/file.c b/amiga/file.c
index 12ed12a33..68e2637c2 100644
--- a/amiga/file.c
+++ b/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);
diff --git a/amiga/file.h b/amiga/file.h
index 4569ba62e..904de69fe 100644
--- a/amiga/file.h
+++ b/amiga/file.h
@@ -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);
diff --git a/amiga/gui.c b/amiga/gui.c
index 7cee642e9..73f26ce1b 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -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':
diff --git a/amiga/menu.c b/amiga/menu.c
index 44ba1d2f2..a0abc24a1 100644
--- a/amiga/menu.c
+++ b/amiga/menu.c
@@ -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)