Example #1
0
/**
 * callback on drag end for history viewer
 *
 * \param ami_cw The Amiga core window structure.
 * \param x mouse x co-ordinate
 * \param y mouse y co-ordinate
 * \return NSERROR_OK on success otherwise apropriate error code
 */
static nserror
ami_history_global_drag_end(struct ami_corewindow *ami_cw, int x, int y)
{
	struct nsurl *url = NULL;
	const char *title = NULL;
	bool ok = false;
	struct gui_window_2 *gwin;
	struct ami_corewindow *cw;

	if(global_history_has_selection()) {
		ok = global_history_get_selection(&url, &title);
	}
	
	if((ok == false) || (url == NULL)) {
		DisplayBeep(scrn);
	} else if(url) {
		if((gwin = ami_window_at_pointer(AMINS_WINDOW))) {
			browser_window_navigate(gwin->gw->bw,
					url,
					NULL,
					BW_NAVIGATE_HISTORY,
					NULL,
					NULL,
					NULL);
		} else if((cw = (struct ami_corewindow *)ami_window_at_pointer(AMINS_COREWINDOW)) &&
			(ami_cw->icon_drop != NULL)) {
			cw->icon_drop(cw, url, title, x, y);
		}
	}
	return NSERROR_OK;
}
Example #2
0
void ami_drag_selection(struct selection *s)
{
	struct box *text_box;
	int x;
	int y;
	char *utf8text;
	struct ami_text_selection *sel;
	struct IFFHandle *old_iffh = iffh;
	struct gui_window_2 *gwin = ami_window_at_pointer(AMINS_WINDOW);

	if(!gwin)
	{
		DisplayBeep(scrn);
		return;
	}

	x = gwin->win->MouseX;
	y = gwin->win->MouseY;

	if(text_box = ami_text_box_at_point(gwin, (ULONG *)&x, (ULONG *)&y))
	{
		ami_utf8_clipboard = true;

		iffh = ami_clipboard_init_internal(1);

		if(gui_copy_to_clipboard(s))
		{
			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;
		ami_utf8_clipboard = false;
	}
	else
	{
		x = gwin->win->MouseX;
		y = gwin->win->MouseY;

		if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
		{
			if(sel = ami_selection_to_text(gwin))
			{
				utf8text = ami_utf8_easy(sel->text);
				RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
					gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
				FreeVec(sel);
				ami_utf8_free(utf8text);
			}
		}
		else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
		{
			if(sel = ami_selection_to_text(gwin))
			{
				utf8text = ami_utf8_easy(sel->text);
				RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
					gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
				FreeVec(sel);
				ami_utf8_free(utf8text);
			}
		}
		else
		{
			DisplayBeep(scrn);
		}
	}
}
Example #3
0
void ami_drag_selection(struct gui_window *g)
{
	int x;
	int y;
	char *utf8text;
	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);
		return;
	}

	x = gwin->win->MouseX;
	y = gwin->win->MouseY;

	if(ami_text_box_at_point(gwin, (ULONG *)&x, (ULONG *)&y))
	{
		iffh = ami_clipboard_init_internal(1);

		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;
	}
	else
	{
		x = gwin->win->MouseX;
		y = gwin->win->MouseY;

		if(ami_gadget_hit(gwin->objects[GID_URL], x, y))
		{
			if(sel = browser_window_get_selection(g->shared->bw))
			{
				utf8text = ami_utf8_easy(sel);
				RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_URL],
					gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
				free(sel);
				ami_utf8_free(utf8text);
			}
		}
		else if(ami_gadget_hit(gwin->objects[GID_SEARCHSTRING], x, y))
		{
			if(sel = browser_window_get_selection(g->shared->bw))
			{
				utf8text = ami_utf8_easy(sel);
				RefreshSetGadgetAttrs((struct Gadget *)gwin->objects[GID_SEARCHSTRING],
					gwin->win, NULL, STRINGA_TextVal, utf8text, TAG_DONE);
				free(sel);
				ami_utf8_free(utf8text);
			}
		}
		else
		{
			DisplayBeep(scrn);
		}
	}
}