summaryrefslogtreecommitdiff
path: root/amiga/tree.c
diff options
context:
space:
mode:
authorChris Young <chris@unsatisfactorysoftware.co.uk>2013-09-14 12:12:12 +0100
committerChris Young <chris@unsatisfactorysoftware.co.uk>2013-09-14 23:52:28 +0100
commit250338ba7c1bcf976399d29af9ed56de966ae816 (patch)
tree1ff9bfd6caab246a8be572aca5027f1cf9964d2a /amiga/tree.c
parentb96222d8571237919bbfc7d85d43a2d46cfe262f (diff)
downloadnetsurf-250338ba7c1bcf976399d29af9ed56de966ae816.tar.gz
netsurf-250338ba7c1bcf976399d29af9ed56de966ae816.tar.bz2
Re-implement dragging to/from treeview (not working)
Diffstat (limited to 'amiga/tree.c')
-rw-r--r--amiga/tree.c75
1 files changed, 25 insertions, 50 deletions
diff --git a/amiga/tree.c b/amiga/tree.c
index a8f22e985..466348477 100644
--- a/amiga/tree.c
+++ b/amiga/tree.c
@@ -261,9 +261,8 @@ void ami_tree_scroll(struct treeview_window *twin, int sx, int sy)
void ami_tree_drag_icon_show(struct treeview_window *twin)
{
const char *type = "project";
- const char *url;
- const struct url_data *data;
- struct node *node = NULL;
+ nsurl *url = NULL;
+ const char *title = NULL;
if((tree_drag_status(twin->tree) == TREE_NO_DRAG) ||
(tree_drag_status(twin->tree) == TREE_SELECT_DRAG) ||
@@ -272,60 +271,46 @@ void ami_tree_drag_icon_show(struct treeview_window *twin)
if((twin->type == AMI_TREE_COOKIES) ||
(twin->type == AMI_TREE_SSLCERT)) return; /* No permissable drag operations */
-#if 0
- node = tree_get_selected_node(tree_get_root(twin->tree));
- if(node && tree_node_is_folder(node))
+ if((twin->type == AMI_TREE_HOTLIST) && (hotlist_has_selection())) {
+ hotlist_get_selection(&url, &title);
+ } else if((twin->type == AMI_TREE_HISTORY) && (global_history_has_selection())) {
+ global_history_get_selection(&url, &title);
+ }
+
+ if(title && (url == NULL))
{
ami_drag_icon_show(twin->win, "drawer");
}
else
{
- if(node && (url = tree_url_node_get_url(node)))
- {
- nsurl *nsurl;
- if (nsurl_create(url, &nsurl) != NSERROR_OK)
- return;
- if(data = urldb_get_url_data(nsurl))
- {
- type = ami_content_type_to_file_type(data->type);
- }
- nsurl_unref(nsurl);
- }
ami_drag_icon_show(twin->win, type);
}
-#endif
}
void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
{
struct gui_window_2 *gwin;
struct treeview_window *tw;
- struct node *selected_node;
BOOL drag;
+ nsurl *url = NULL;
+ const char *title = NULL;
if(drag = ami_drag_in_progress()) ami_drag_icon_close(twin->win);
-#if 0
+
if(drag && (twin != ami_window_at_pointer(AMINS_TVWINDOW)))
{
- selected_node = tree_get_selected_node(tree_get_root(twin->tree));
+ if((twin->type == AMI_TREE_HOTLIST) && (hotlist_has_selection())) {
+ hotlist_get_selection(&url, &title);
+ } else if((twin->type == AMI_TREE_HISTORY) && (global_history_has_selection())) {
+ global_history_get_selection(&url, &title);
+ }
- if((selected_node == NULL) || (tree_node_is_folder(selected_node)))
- {
+ if((title == NULL) || (title && (url == NULL))) {
DisplayBeep(scrn);
- }
- else
- {
- if(gwin = ami_window_at_pointer(AMINS_WINDOW))
- {
- nsurl *url;
- nserror error;
-
- error = nsurl_create(tree_url_node_get_url(selected_node), &url);
- if (error != NSERROR_OK) {
- warn_user(messages_get_errorcode(error), 0);
- } else {
- browser_window_navigate(gwin->bw,
+ } else {
+ if(gwin = ami_window_at_pointer(AMINS_WINDOW)) {
+ browser_window_navigate(gwin->bw,
url,
NULL,
BROWSER_WINDOW_HISTORY |
@@ -333,25 +318,15 @@ void ami_tree_drag_end(struct treeview_window *twin, int x, int y)
NULL,
NULL,
NULL);
- nsurl_unref(url);
- }
-
- }
-#if 0
- else if((tw = ami_window_at_pointer(AMINS_TVWINDOW)) &&
- (tw != twin) && (tw->type == AMI_TREE_HOTLIST))
- {
- hotlist_add_entry(tree_url_node_get_url(selected_node), NULL, true, y);
+ } else if((tw = ami_window_at_pointer(AMINS_TVWINDOW)) &&
+ (tw != twin) && (tw->type == AMI_TREE_HOTLIST)) {
+ hotlist_add_entry(url, title, true, y);
}
-#endif
}
tree_drag_end(twin->tree, twin->mouse_state,
twin->drag_x, twin->drag_y,
twin->drag_x, twin->drag_y); /* Keep the tree happy */
- }
- else
-#endif
- {
+ } else {
if(tree_drag_status(twin->tree) == TREE_UNKNOWN_DRAG)
DisplayBeep(scrn);