mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-25 05:27:00 +03:00
Show an icon under the pointer for drag save operations. Might need disabling under
4.0. svn path=/trunk/netsurf/; revision=10670
This commit is contained in:
parent
229393e22e
commit
b6b86e8acc
103
amiga/download.c
103
amiga/download.c
@ -42,6 +42,7 @@
|
||||
#include "desktop/save_complete.h"
|
||||
|
||||
#include "utils/errors.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
@ -55,6 +56,12 @@
|
||||
|
||||
#include <reaction/reaction_macros.h>
|
||||
|
||||
ULONG drag_icon_width;
|
||||
ULONG drag_icon_height;
|
||||
|
||||
struct Window *ami_drag_icon_show(char *type, ULONG *x, ULONG *y);
|
||||
void ami_drag_icon_close(struct Window *win);
|
||||
|
||||
struct gui_download_window *gui_download_window_create(download_context *ctx,
|
||||
struct gui_window *gui)
|
||||
{
|
||||
@ -326,21 +333,46 @@ gui_window_save_link(struct gui_window *g, const char *url, const char *title)
|
||||
void gui_drag_save_object(gui_save_type type, hlcache_handle *c,
|
||||
struct gui_window *g)
|
||||
{
|
||||
char *filetype;
|
||||
|
||||
if(strcmp(option_use_pubscreen,"Workbench")) return;
|
||||
|
||||
gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG);
|
||||
drag_save_data = c;
|
||||
drag_save_gui = g;
|
||||
drag_save = type;
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case GUI_SAVE_OBJECT_ORIG: // object
|
||||
case GUI_SAVE_SOURCE:
|
||||
filetype = ami_content_type_to_file_type(content_get_type(c));
|
||||
break;
|
||||
case GUI_SAVE_COMPLETE:
|
||||
filetype = "drawer";
|
||||
break;
|
||||
case GUI_SAVE_OBJECT_NATIVE:
|
||||
if(content_get_type(c) == CONTENT_SVG)
|
||||
{
|
||||
filetype = "dr2d";
|
||||
}
|
||||
else
|
||||
{
|
||||
filetype = "ilbm";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
drag_icon = ami_drag_icon_show(filetype, &drag_icon_width, &drag_icon_height);
|
||||
}
|
||||
|
||||
void gui_drag_save_selection(struct selection *s, struct gui_window *g)
|
||||
{
|
||||
// if(strcmp(option_use_pubscreen,"Workbench")) return;
|
||||
|
||||
gui_window_set_pointer(g,AMI_GUI_POINTER_DRAG);
|
||||
drag_save_data = s;
|
||||
drag_save = GUI_SAVE_TEXT_SELECTION;
|
||||
|
||||
drag_icon = ami_drag_icon_show("ascii", &drag_icon_width, &drag_icon_height);
|
||||
}
|
||||
|
||||
void ami_drag_save(struct Window *win)
|
||||
@ -350,6 +382,8 @@ void ami_drag_save(struct Window *win)
|
||||
char *source_data;
|
||||
ULONG source_size;
|
||||
|
||||
if(drag_icon) ami_drag_icon_close(drag_icon);
|
||||
|
||||
if(strcmp(option_use_pubscreen,"Workbench") == 0)
|
||||
{
|
||||
which = WhichWorkbenchObject(NULL,scrn->MouseX,scrn->MouseY,
|
||||
@ -448,6 +482,10 @@ void ami_drag_save(struct Window *win)
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG(("Unsupported drag save operation %ld",drag_save));
|
||||
break;
|
||||
}
|
||||
|
||||
drag_save = 0;
|
||||
@ -455,6 +493,67 @@ void ami_drag_save(struct Window *win)
|
||||
ami_update_pointer(win,GUI_POINTER_DEFAULT);
|
||||
}
|
||||
|
||||
struct Window *ami_drag_icon_show(char *type, ULONG *x, ULONG *y)
|
||||
{
|
||||
struct Window *win;
|
||||
struct DiskObject *dobj = NULL;
|
||||
ULONG *icondata1;
|
||||
ULONG width, height;
|
||||
long format = 0;
|
||||
int err = 0;
|
||||
int deftype = WBPROJECT;
|
||||
|
||||
if(type == "drawer") deftype = WBDRAWER;
|
||||
|
||||
dobj = GetIconTags(NULL, ICONGETA_GetDefaultName, type,
|
||||
ICONGETA_GetDefaultType, deftype,
|
||||
TAG_DONE);
|
||||
|
||||
err = IconControl(dobj,
|
||||
ICONCTRLA_GetWidth,&width,
|
||||
ICONCTRLA_GetHeight,&height,
|
||||
TAG_DONE);
|
||||
|
||||
*x = width;
|
||||
*y = height;
|
||||
|
||||
win = OpenWindowTags(NULL,
|
||||
WA_Left, scrn->MouseX - (width/2),
|
||||
WA_Top, scrn->MouseY - (height/2),
|
||||
WA_Width, width,
|
||||
WA_Height, height,
|
||||
WA_PubScreen, scrn,
|
||||
WA_Borderless, TRUE,
|
||||
WA_ToolBox, TRUE,
|
||||
WA_StayTop, TRUE,
|
||||
WA_Opaqueness, 128,
|
||||
WA_OverrideOpaqueness, TRUE,
|
||||
TAG_DONE);
|
||||
|
||||
/* probably need layouticon and drawinfo stuff too */
|
||||
|
||||
DrawIconState(win->RPort, dobj, NULL, 0, 0, IDS_NORMAL,
|
||||
ICONDRAWA_Frameless, TRUE,
|
||||
ICONDRAWA_Borderless, TRUE,
|
||||
// ICONDRAWA_Transparency, 128,
|
||||
TAG_DONE);
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
void ami_drag_icon_move(struct Window *win)
|
||||
{
|
||||
ChangeWindowBox(win, scrn->MouseX - (drag_icon_width / 2),
|
||||
scrn->MouseY - (drag_icon_height / 2),
|
||||
drag_icon_width, drag_icon_height);
|
||||
}
|
||||
|
||||
void ami_drag_icon_close(struct Window *win)
|
||||
{
|
||||
CloseWindow(win);
|
||||
drag_icon = NULL;
|
||||
}
|
||||
|
||||
void ami_superimpose_favicon(STRPTR path, struct hlcache_handle *icon, STRPTR type)
|
||||
{
|
||||
struct DiskObject *dobj = NULL;
|
||||
|
@ -45,10 +45,14 @@ struct gui_download_window {
|
||||
int drag_save;
|
||||
void *drag_save_data;
|
||||
struct gui_window *drag_save_gui;
|
||||
struct Window *drag_icon;
|
||||
|
||||
void ami_download_window_abort(struct gui_download_window *dw);
|
||||
BOOL ami_download_window_event(struct gui_download_window *dw);
|
||||
void ami_drag_save(struct Window *win);
|
||||
void ami_drag_icon_move(struct Window *win);
|
||||
void ami_free_download_list(struct List *dllist);
|
||||
void ami_superimpose_favicon(STRPTR path, struct hlcache_handle *icon, STRPTR type);
|
||||
|
||||
const char *ami_content_type_to_file_type(content_type type);
|
||||
#endif
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "content/fetch.h"
|
||||
#include "content/content_type.h"
|
||||
#include "utils/log.h"
|
||||
#include "utils/utils.h"
|
||||
#include <proto/icon.h>
|
||||
@ -130,3 +131,73 @@ char *fetch_mimetype(const char *ro_path)
|
||||
{
|
||||
return strdup(fetch_filetype(ro_path));
|
||||
}
|
||||
|
||||
const char *ami_content_type_to_file_type(content_type type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case CONTENT_HTML:
|
||||
return "html";
|
||||
break;
|
||||
|
||||
case CONTENT_TEXTPLAIN:
|
||||
return "ascii";
|
||||
break;
|
||||
|
||||
case CONTENT_CSS:
|
||||
return "css";
|
||||
break;
|
||||
|
||||
#ifdef WITH_JPEG
|
||||
case CONTENT_JPEG:
|
||||
return "jpeg";
|
||||
break;
|
||||
#endif
|
||||
#ifdef WITH_GIF
|
||||
case CONTENT_GIF:
|
||||
return "gif";
|
||||
break;
|
||||
#endif
|
||||
#ifdef WITH_BMP
|
||||
case CONTENT_BMP:
|
||||
return "bmp";
|
||||
break;
|
||||
|
||||
case CONTENT_ICO:
|
||||
return "ico";
|
||||
break;
|
||||
#endif
|
||||
#if defined(WITH_MNG) || defined(WITH_PNG)
|
||||
case CONTENT_PNG:
|
||||
return "png";
|
||||
break;
|
||||
#endif
|
||||
#ifdef WITH_MNG
|
||||
case CONTENT_JNG:
|
||||
return "jng";
|
||||
break;
|
||||
|
||||
case CONTENT_MNG:
|
||||
return "mng";
|
||||
break;
|
||||
#endif
|
||||
#if defined(WITH_SPRITE) || defined(WITH_NSSPRITE)
|
||||
case CONTENT_SPRITE:
|
||||
return "rosprite";
|
||||
break;
|
||||
#endif
|
||||
|
||||
case CONTENT_DIRECTORY:
|
||||
return "drawer";
|
||||
break;
|
||||
|
||||
#if defined(WITH_NS_SVG) || defined(WITH_RSVG)
|
||||
case CONTENT_SVG:
|
||||
return "svg";
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
return "project";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user