Fix line endings.
This commit is contained in:
parent
53d2852efd
commit
a1974a2ea6
612
atari/toolbar.c
612
atari/toolbar.c
|
@ -1,55 +1,55 @@
|
|||
/*
|
||||
* Copyright 2012 Ole Loots <ole@monochrom.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/browser_history.h"
|
||||
/*
|
||||
* Copyright 2012 Ole Loots <ole@monochrom.net>
|
||||
*
|
||||
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
||||
*
|
||||
* NetSurf is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* NetSurf is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "utils/log.h"
|
||||
#include "desktop/gui.h"
|
||||
#include "desktop/netsurf.h"
|
||||
#include "desktop/browser.h"
|
||||
#include "desktop/browser_history.h"
|
||||
#include "desktop/browser_private.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/plot_style.h"
|
||||
#include "desktop/mouse.h"
|
||||
#include "desktop/plot_style.h"
|
||||
#include "desktop/plotters.h"
|
||||
#include "desktop/tree.h"
|
||||
#include "desktop/hotlist.h"
|
||||
#include "utils/nsoption.h"
|
||||
#include "utils/nsurl.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "atari/clipboard.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/toolbar.h"
|
||||
#include "atari/rootwin.h"
|
||||
|
||||
#include "atari/clipboard.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/plot/plot.h"
|
||||
#include "cflib.h"
|
||||
#include "utils/utf8.h"
|
||||
#include "atari/clipboard.h"
|
||||
#include "atari/gui.h"
|
||||
#include "atari/toolbar.h"
|
||||
#include "atari/rootwin.h"
|
||||
|
||||
#include "atari/clipboard.h"
|
||||
#include "atari/misc.h"
|
||||
#include "atari/plot/plot.h"
|
||||
#include "cflib.h"
|
||||
#include "atari/res/netsurf.rsh"
|
||||
|
||||
#include "desktop/textarea.h"
|
||||
|
@ -57,35 +57,35 @@
|
|||
#include "content/hlcache.h"
|
||||
#include "atari/encoding.h"
|
||||
|
||||
|
||||
#define TB_BUTTON_WIDTH 32
|
||||
#define THROBBER_WIDTH 32
|
||||
#define THROBBER_MIN_INDEX 1
|
||||
#define THROBBER_MAX_INDEX 12
|
||||
#define THROBBER_INACTIVE_INDEX 13
|
||||
|
||||
enum e_toolbar_button_states {
|
||||
button_on = 0,
|
||||
button_off = 1
|
||||
};
|
||||
#define TOOLBAR_BUTTON_NUM_STATES 2
|
||||
#define TB_BUTTON_WIDTH 32
|
||||
#define THROBBER_WIDTH 32
|
||||
#define THROBBER_MIN_INDEX 1
|
||||
#define THROBBER_MAX_INDEX 12
|
||||
#define THROBBER_INACTIVE_INDEX 13
|
||||
|
||||
enum e_toolbar_button_states {
|
||||
button_on = 0,
|
||||
button_off = 1
|
||||
};
|
||||
#define TOOLBAR_BUTTON_NUM_STATES 2
|
||||
|
||||
struct s_toolbar;
|
||||
|
||||
struct s_tb_button
|
||||
{
|
||||
short rsc_id;
|
||||
|
||||
struct s_tb_button
|
||||
{
|
||||
short rsc_id;
|
||||
void (*cb_click)(struct s_toolbar *tb);
|
||||
hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
|
||||
struct s_toolbar *owner;
|
||||
enum e_toolbar_button_states state;
|
||||
enum e_toolbar_button_states state;
|
||||
short index;
|
||||
GRECT area;
|
||||
};
|
||||
|
||||
|
||||
extern char * option_homepage_url;
|
||||
extern void * h_gem_rsrc;
|
||||
GRECT area;
|
||||
};
|
||||
|
||||
|
||||
extern char * option_homepage_url;
|
||||
extern void * h_gem_rsrc;
|
||||
extern struct gui_window * input_window;
|
||||
extern long atari_plot_flags;
|
||||
extern int atari_plot_vdi_handle;
|
||||
|
@ -98,53 +98,53 @@ static int area_navigation_height = 0;
|
|||
static int area_search_height = 0;
|
||||
static int area_full_height = 0;
|
||||
static float toolbar_url_scale = 1.0;
|
||||
|
||||
static plot_font_style_t font_style_url = {
|
||||
.family = PLOT_FONT_FAMILY_SANS_SERIF,
|
||||
.size = 14*FONT_SIZE_SCALE,
|
||||
.weight = 400,
|
||||
.flags = FONTF_NONE,
|
||||
.background = 0xffffff,
|
||||
.foreground = 0x0
|
||||
};
|
||||
|
||||
|
||||
static plot_font_style_t font_style_url = {
|
||||
.family = PLOT_FONT_FAMILY_SANS_SERIF,
|
||||
.size = 14*FONT_SIZE_SCALE,
|
||||
.weight = 400,
|
||||
.flags = FONTF_NONE,
|
||||
.background = 0xffffff,
|
||||
.foreground = 0x0
|
||||
};
|
||||
|
||||
|
||||
/* prototypes & order for button widgets: */
|
||||
|
||||
|
||||
static struct s_tb_button tb_buttons[] =
|
||||
{
|
||||
{
|
||||
TOOLBAR_BT_BACK,
|
||||
toolbar_back_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_HOME,
|
||||
toolbar_home_click,
|
||||
|
||||
static struct s_tb_button tb_buttons[] =
|
||||
{
|
||||
{
|
||||
TOOLBAR_BT_BACK,
|
||||
toolbar_back_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_FORWARD,
|
||||
toolbar_forward_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_STOP,
|
||||
toolbar_stop_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_RELOAD,
|
||||
toolbar_reload_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{ 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
|
||||
{
|
||||
TOOLBAR_BT_HOME,
|
||||
toolbar_home_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_FORWARD,
|
||||
toolbar_forward_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_STOP,
|
||||
toolbar_stop_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{
|
||||
TOOLBAR_BT_RELOAD,
|
||||
toolbar_reload_click,
|
||||
{0,0},
|
||||
0, 0, 0, {0,0,0,0}
|
||||
},
|
||||
{ 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
|
||||
};
|
||||
|
||||
struct s_toolbar_style {
|
||||
|
@ -163,12 +163,12 @@ static struct s_toolbar_style toolbar_styles[] =
|
|||
{18}
|
||||
};
|
||||
|
||||
static const struct redraw_context toolbar_rdrw_ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &atari_plotters
|
||||
};
|
||||
|
||||
static const struct redraw_context toolbar_rdrw_ctx = {
|
||||
.interactive = true,
|
||||
.background_images = true,
|
||||
.plot = &atari_plotters
|
||||
};
|
||||
|
||||
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
|
||||
static nserror toolbar_icon_callback( hlcache_handle *handle,
|
||||
const hlcache_event *event, void *pw );
|
||||
|
@ -176,22 +176,22 @@ static nserror toolbar_icon_callback( hlcache_handle *handle,
|
|||
/**
|
||||
* Find a button for a specific resource ID
|
||||
*/
|
||||
static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < tb->btcnt) {
|
||||
if (tb->buttons[i].rsc_id == rsc_id) {
|
||||
return(&tb->buttons[i]);
|
||||
}
|
||||
i++;
|
||||
static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
|
||||
{
|
||||
int i = 0;
|
||||
while (i < tb->btcnt) {
|
||||
if (tb->buttons[i].rsc_id == rsc_id) {
|
||||
return(&tb->buttons[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return(NULL);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for textarea redraw
|
||||
*/
|
||||
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
|
||||
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
|
||||
{
|
||||
|
||||
GRECT area;
|
||||
|
@ -208,7 +208,7 @@ static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
|
|||
area.g_h = h;
|
||||
//dbg_grect("tb_txt_request_redraw", &area);
|
||||
window_schedule_redraw_grect(tb->owner, &area);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
static void tb_txt_callback(void *data, struct textarea_msg *msg)
|
||||
|
@ -231,12 +231,12 @@ static void tb_txt_callback(void *data, struct textarea_msg *msg)
|
|||
}
|
||||
|
||||
static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
|
||||
struct s_tb_button * instance)
|
||||
struct s_tb_button * instance)
|
||||
{
|
||||
*instance = tb_buttons[index];
|
||||
instance->owner = tb;
|
||||
|
||||
return(instance);
|
||||
return(instance);
|
||||
}
|
||||
|
||||
|
||||
|
@ -266,7 +266,7 @@ void toolbar_init( void )
|
|||
area_search_height = aes_toolbar[TOOLBAR_AREA_SEARCH].ob_height;
|
||||
area_navigation_height = aes_toolbar[TOOLBAR_AREA_NAVIGATION].ob_height;
|
||||
|
||||
init = true;
|
||||
init = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -276,20 +276,20 @@ void toolbar_exit(void)
|
|||
}
|
||||
|
||||
|
||||
struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
|
||||
{
|
||||
struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
|
||||
{
|
||||
int i;
|
||||
struct s_toolbar *t;
|
||||
|
||||
LOG((""));
|
||||
|
||||
assert(init == true);
|
||||
|
||||
t = calloc(1, sizeof(struct s_toolbar));
|
||||
assert(init == true);
|
||||
|
||||
assert(t);
|
||||
t = calloc(1, sizeof(struct s_toolbar));
|
||||
|
||||
/* initialize the toolbar values: */
|
||||
assert(t);
|
||||
|
||||
/* initialize the toolbar values: */
|
||||
t->owner = owner;
|
||||
t->style = 1;
|
||||
t->search_visible = false;
|
||||
|
@ -298,20 +298,20 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
|
|||
|
||||
/* dublicate the form template: */
|
||||
t->form = gemtk_obj_tree_copy(aes_toolbar);
|
||||
|
||||
|
||||
/* count buttons and add them as components: */
|
||||
i = 0;
|
||||
while(tb_buttons[i].rsc_id > 0) {
|
||||
i++;
|
||||
}
|
||||
t->btcnt = i;
|
||||
|
||||
|
||||
/* count buttons and add them as components: */
|
||||
i = 0;
|
||||
while(tb_buttons[i].rsc_id > 0) {
|
||||
i++;
|
||||
}
|
||||
t->btcnt = i;
|
||||
t->buttons = malloc(t->btcnt * sizeof(struct s_tb_button));
|
||||
memset(t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
|
||||
for (i=0; i < t->btcnt; i++) {
|
||||
button_init(t, aes_toolbar, i, &t->buttons[i]);
|
||||
}
|
||||
|
||||
memset(t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
|
||||
for (i=0; i < t->btcnt; i++) {
|
||||
button_init(t, aes_toolbar, i, &t->buttons[i]);
|
||||
}
|
||||
|
||||
/* create the url widget: */
|
||||
font_style_url.size =
|
||||
toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
|
||||
|
@ -330,27 +330,27 @@ struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
|
|||
ta_setup.selected_bg = 0x000000;
|
||||
ta_setup.text = font_style_url;
|
||||
ta_setup.text.foreground = 0x000000;
|
||||
ta_setup.text.background = 0xffffff;
|
||||
t->url.textarea = textarea_create(ta_flags, &ta_setup,
|
||||
tb_txt_callback, t);
|
||||
ta_setup.text.background = 0xffffff;
|
||||
t->url.textarea = textarea_create(ta_flags, &ta_setup,
|
||||
tb_txt_callback, t);
|
||||
|
||||
/* create the throbber widget: */
|
||||
t->throbber.index = THROBBER_INACTIVE_INDEX;
|
||||
t->throbber.max_index = THROBBER_MAX_INDEX;
|
||||
/* create the throbber widget: */
|
||||
t->throbber.index = THROBBER_INACTIVE_INDEX;
|
||||
t->throbber.max_index = THROBBER_MAX_INDEX;
|
||||
t->throbber.running = false;
|
||||
|
||||
LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
|
||||
owner, t->url.textarea, t->throbber));
|
||||
return( t );
|
||||
owner, t->url.textarea, t->throbber));
|
||||
return( t );
|
||||
}
|
||||
|
||||
|
||||
void toolbar_destroy(struct s_toolbar *tb)
|
||||
{
|
||||
free(tb->buttons);
|
||||
free(tb->buttons);
|
||||
free(tb->form);
|
||||
|
||||
textarea_destroy(tb->url.textarea);
|
||||
textarea_destroy(tb->url.textarea);
|
||||
|
||||
free(tb);
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ static void toolbar_reflow(struct s_toolbar *tb)
|
|||
}
|
||||
else if (tb->buttons[i].state == button_on) {
|
||||
tb->form[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
|
||||
}
|
||||
}
|
||||
}
|
||||
tb->reflow = false;
|
||||
// TODO: iterate through all other toolbars and set reflow = true
|
||||
|
@ -449,11 +449,11 @@ void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
|
|||
if (rc_intersect(clip, &area)) {
|
||||
|
||||
plot_set_dimensions(area_ro.g_x, area_ro.g_y, area_ro.g_w, area_ro.g_h);
|
||||
struct rect r = {
|
||||
struct rect r = {
|
||||
.x0 = MAX(0,area.g_x - area_ro.g_x),
|
||||
.y0 = MAX(0,area.g_y - area_ro.g_y),
|
||||
.y0 = MAX(0,area.g_y - area_ro.g_y),
|
||||
.x1 = MAX(0,area.g_x - area_ro.g_x) + area.g_w,
|
||||
.y1 = MAX(0,area.g_y - area_ro.g_y) + area.g_h
|
||||
.y1 = MAX(0,area.g_y - area_ro.g_y) + area.g_h
|
||||
};
|
||||
//dbg_rect("tb textarea clip: ", &r);
|
||||
// TODO: let this be handled by an userdef object redraw function:
|
||||
|
@ -471,7 +471,7 @@ void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
|
|||
{
|
||||
LOG((""));
|
||||
|
||||
struct s_tb_button * bt;
|
||||
struct s_tb_button * bt;
|
||||
bool enable = false;
|
||||
GRECT area;
|
||||
nsurl * ns_url;
|
||||
|
@ -482,45 +482,45 @@ void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
|
|||
|
||||
if (button == TOOLBAR_BT_BACK || button <= 0 ) {
|
||||
bt = find_button(tb, TOOLBAR_BT_BACK);
|
||||
enable = browser_window_back_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
enable = browser_window_back_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
if (button == TOOLBAR_BT_HOME || button <= 0 ) {
|
||||
if (button == TOOLBAR_BT_HOME || button <= 0 ) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (button == TOOLBAR_BT_FORWARD || button <= 0 ) {
|
||||
bt = find_button(tb, TOOLBAR_BT_FORWARD);
|
||||
enable = browser_window_forward_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
enable = browser_window_forward_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
if (button == TOOLBAR_BT_RELOAD || button <= 0 ) {
|
||||
bt = find_button(tb, TOOLBAR_BT_RELOAD);
|
||||
enable = browser_window_reload_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
enable = browser_window_reload_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (button == TOOLBAR_BT_STOP || button <= 0) {
|
||||
bt = find_button(tb, TOOLBAR_BT_STOP);
|
||||
enable = browser_window_stop_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
enable = browser_window_stop_available(bw);
|
||||
if (enable) {
|
||||
bt->state = button_on;
|
||||
} else {
|
||||
bt->state = button_off;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -691,65 +691,65 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
|
|||
{
|
||||
|
||||
assert(tb!=NULL);
|
||||
|
||||
|
||||
GRECT work;
|
||||
bool ret = false;
|
||||
struct gui_window *gw = window_get_active_gui_window(tb->owner);
|
||||
|
||||
assert( gw != NULL );
|
||||
|
||||
long ucs4;
|
||||
long ik = nkc_to_input_key(nkc, &ucs4);
|
||||
struct gui_window *gw = window_get_active_gui_window(tb->owner);
|
||||
|
||||
if (ik == 0) {
|
||||
if ((nkc&0xFF) >= 9) {
|
||||
ret = textarea_keypress(tb->url.textarea, ucs4);
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_CR || ik == KEY_NL) {
|
||||
nsurl *url;
|
||||
char tmp_url[PATH_MAX];
|
||||
if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
|
||||
window_set_focus(tb->owner, BROWSER, gw->browser);
|
||||
if (nsurl_create((const char*)&tmp_url, &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
} else {
|
||||
browser_window_navigate(gw->browser->bw, url, NULL,
|
||||
BW_NAVIGATE_HISTORY,
|
||||
NULL, NULL, NULL);
|
||||
nsurl_unref(url);
|
||||
}
|
||||
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_COPY_SELECTION) {
|
||||
// copy whole text
|
||||
char * text;
|
||||
int len;
|
||||
len = textarea_get_text( tb->url.textarea, NULL, 0 );
|
||||
text = malloc( len+1 );
|
||||
if (text){
|
||||
textarea_get_text( tb->url.textarea, text, len+1 );
|
||||
scrap_txt_write(text);
|
||||
free( text );
|
||||
}
|
||||
assert( gw != NULL );
|
||||
|
||||
long ucs4;
|
||||
long ik = nkc_to_input_key(nkc, &ucs4);
|
||||
|
||||
if (ik == 0) {
|
||||
if ((nkc&0xFF) >= 9) {
|
||||
ret = textarea_keypress(tb->url.textarea, ucs4);
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_CR || ik == KEY_NL) {
|
||||
nsurl *url;
|
||||
char tmp_url[PATH_MAX];
|
||||
if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
|
||||
window_set_focus(tb->owner, BROWSER, gw->browser);
|
||||
if (nsurl_create((const char*)&tmp_url, &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
} else {
|
||||
browser_window_navigate(gw->browser->bw, url, NULL,
|
||||
BW_NAVIGATE_HISTORY,
|
||||
NULL, NULL, NULL);
|
||||
nsurl_unref(url);
|
||||
}
|
||||
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
else if (ik == KEY_COPY_SELECTION) {
|
||||
// copy whole text
|
||||
char * text;
|
||||
int len;
|
||||
len = textarea_get_text( tb->url.textarea, NULL, 0 );
|
||||
text = malloc( len+1 );
|
||||
if (text){
|
||||
textarea_get_text( tb->url.textarea, text, len+1 );
|
||||
scrap_txt_write(text);
|
||||
free( text );
|
||||
}
|
||||
}
|
||||
else if ( ik == KEY_PASTE) {
|
||||
char * clip = scrap_txt_read();
|
||||
char * clip = scrap_txt_read();
|
||||
if ( clip != NULL ){
|
||||
int clip_length = strlen( clip );
|
||||
if ( clip_length > 0 ) {
|
||||
char *utf8;
|
||||
nserror res;
|
||||
/* Clipboard is in local encoding so
|
||||
* convert to UTF8 */
|
||||
res = utf8_from_local_encoding( clip, clip_length, &utf8 );
|
||||
if ( res == NSERROR_OK ) {
|
||||
toolbar_set_url(tb, utf8);
|
||||
int clip_length = strlen( clip );
|
||||
if ( clip_length > 0 ) {
|
||||
char *utf8;
|
||||
nserror res;
|
||||
/* Clipboard is in local encoding so
|
||||
* convert to UTF8 */
|
||||
res = utf8_from_local_encoding( clip, clip_length, &utf8 );
|
||||
if ( res == NSERROR_OK ) {
|
||||
toolbar_set_url(tb, utf8);
|
||||
free(utf8);
|
||||
ret = true;
|
||||
}
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
free( clip );
|
||||
}
|
||||
|
@ -757,11 +757,11 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
|
|||
else if (ik == KEY_ESCAPE) {
|
||||
textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
|
||||
textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
|
||||
}
|
||||
else {
|
||||
ret = textarea_keypress( tb->url.textarea, ik );
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
ret = textarea_keypress( tb->url.textarea, ik );
|
||||
}
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
|
@ -769,8 +769,8 @@ bool toolbar_key_input(struct s_toolbar *tb, short nkc)
|
|||
void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
|
||||
{
|
||||
LOG((""));
|
||||
GRECT work;
|
||||
short mx, my, mb, kstat;
|
||||
GRECT work;
|
||||
short mx, my, mb, kstat;
|
||||
int old;
|
||||
OBJECT * toolbar_tree;
|
||||
struct gui_window * gw;
|
||||
|
@ -780,10 +780,10 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
|
|||
|
||||
graf_mkstate(&mx, &my, &mb, &kstat);
|
||||
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
|
||||
mx -= work.g_x;
|
||||
mx -= work.g_x;
|
||||
my -= work.g_y;
|
||||
|
||||
/* TODO: reset mouse state of browser window? */
|
||||
|
||||
/* TODO: reset mouse state of browser window? */
|
||||
/* select whole text when newly focused, otherwise set caret to
|
||||
end of text */
|
||||
if (!window_url_widget_has_focus(tb->owner)) {
|
||||
|
@ -792,21 +792,21 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
|
|||
/* url widget has focus and mouse button is still pressed... */
|
||||
else if (mb & 1) {
|
||||
|
||||
textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
|
||||
mx, my );
|
||||
short prev_x = mx;
|
||||
short prev_y = my;
|
||||
do {
|
||||
if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
|
||||
textarea_mouse_action( tb->url.textarea,
|
||||
BROWSER_MOUSE_HOLDING_1, mx, my );
|
||||
prev_x = mx;
|
||||
textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
|
||||
mx, my );
|
||||
short prev_x = mx;
|
||||
short prev_y = my;
|
||||
do {
|
||||
if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
|
||||
textarea_mouse_action( tb->url.textarea,
|
||||
BROWSER_MOUSE_HOLDING_1, mx, my );
|
||||
prev_x = mx;
|
||||
prev_y = my;
|
||||
window_schedule_redraw_grect(tb->owner, &work);
|
||||
window_process_redraws(tb->owner);
|
||||
}
|
||||
graf_mkstate( &mx, &my, &mb, &kstat );
|
||||
mx = mx - (work.g_x);
|
||||
window_process_redraws(tb->owner);
|
||||
}
|
||||
graf_mkstate( &mx, &my, &mb, &kstat );
|
||||
mx = mx - (work.g_x);
|
||||
my = my - (work.g_y);
|
||||
} while (mb & 1);
|
||||
|
||||
|
@ -818,19 +818,19 @@ void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
|
|||
}
|
||||
else {
|
||||
/* when execution reaches here, mouse input is a click or dclick */
|
||||
/* TODO: recognize click + shitoolbar_update_buttonsft key */
|
||||
int mstate = BROWSER_MOUSE_PRESS_1;
|
||||
if ((kstat & (K_LSHIFT|K_RSHIFT)) != 0) {
|
||||
/* TODO: recognize click + shitoolbar_update_buttonsft key */
|
||||
int mstate = BROWSER_MOUSE_PRESS_1;
|
||||
if ((kstat & (K_LSHIFT|K_RSHIFT)) != 0) {
|
||||
mstate = BROWSER_MOUSE_MOD_1;
|
||||
}
|
||||
if (aes_event_out.emo_mclicks == 2 ) {
|
||||
textarea_mouse_action( tb->url.textarea,
|
||||
textarea_mouse_action( tb->url.textarea,
|
||||
BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
|
||||
my);
|
||||
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
|
||||
window_schedule_redraw_grect(tb->owner, &work);
|
||||
} else {
|
||||
textarea_mouse_action(tb->url.textarea,
|
||||
textarea_mouse_action(tb->url.textarea,
|
||||
BROWSER_MOUSE_PRESS_1, mx, my );
|
||||
}
|
||||
}
|
||||
|
@ -936,8 +936,8 @@ OBJECT *toolbar_get_form(struct s_toolbar *tb)
|
|||
}
|
||||
|
||||
|
||||
/* public event handler */
|
||||
void toolbar_back_click(struct s_toolbar *tb)
|
||||
/* public event handler */
|
||||
void toolbar_back_click(struct s_toolbar *tb)
|
||||
{
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
@ -947,11 +947,11 @@ void toolbar_back_click(struct s_toolbar *tb)
|
|||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
if( browser_window_back_available(bw) )
|
||||
browser_window_history_back(bw, false);
|
||||
}
|
||||
|
||||
void toolbar_reload_click(struct s_toolbar *tb)
|
||||
if( browser_window_back_available(bw) )
|
||||
browser_window_history_back(bw, false);
|
||||
}
|
||||
|
||||
void toolbar_reload_click(struct s_toolbar *tb)
|
||||
{
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
@ -961,10 +961,10 @@ void toolbar_reload_click(struct s_toolbar *tb)
|
|||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
browser_window_reload(bw, true);
|
||||
}
|
||||
|
||||
void toolbar_forward_click(struct s_toolbar *tb)
|
||||
browser_window_reload(bw, true);
|
||||
}
|
||||
|
||||
void toolbar_forward_click(struct s_toolbar *tb)
|
||||
{
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
@ -973,12 +973,12 @@ void toolbar_forward_click(struct s_toolbar *tb)
|
|||
assert(gw != NULL);
|
||||
bw = gw->browser->bw;
|
||||
assert(bw != NULL);
|
||||
|
||||
if (browser_window_forward_available(bw))
|
||||
browser_window_history_forward(bw, false);
|
||||
}
|
||||
|
||||
void toolbar_home_click(struct s_toolbar *tb)
|
||||
|
||||
if (browser_window_forward_available(bw))
|
||||
browser_window_history_forward(bw, false);
|
||||
}
|
||||
|
||||
void toolbar_home_click(struct s_toolbar *tb)
|
||||
{
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
@ -995,22 +995,22 @@ void toolbar_home_click(struct s_toolbar *tb)
|
|||
use_url = (char*)"about:welcome";
|
||||
}
|
||||
|
||||
if (nsurl_create(use_url, &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
} else {
|
||||
browser_window_navigate(bw,
|
||||
url,
|
||||
NULL,
|
||||
BW_NAVIGATE_HISTORY,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nsurl_unref(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void toolbar_stop_click(struct s_toolbar *tb)
|
||||
if (nsurl_create(use_url, &url) != NSERROR_OK) {
|
||||
warn_user("NoMemory", 0);
|
||||
} else {
|
||||
browser_window_navigate(bw,
|
||||
url,
|
||||
NULL,
|
||||
BW_NAVIGATE_HISTORY,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
nsurl_unref(url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void toolbar_stop_click(struct s_toolbar *tb)
|
||||
{
|
||||
struct browser_window * bw;
|
||||
struct gui_window * gw;
|
||||
|
@ -1023,10 +1023,10 @@ void toolbar_stop_click(struct s_toolbar *tb)
|
|||
|
||||
assert(bw != NULL);
|
||||
|
||||
browser_window_stop(bw);
|
||||
browser_window_stop(bw);
|
||||
}
|
||||
|
||||
void toolbar_favorite_click(struct s_toolbar *tb)
|
||||
void toolbar_favorite_click(struct s_toolbar *tb)
|
||||
{
|
||||
nsurl * ns_url = NULL;
|
||||
char * c_url;
|
||||
|
@ -1053,7 +1053,7 @@ void toolbar_favorite_click(struct s_toolbar *tb)
|
|||
free(c_url);
|
||||
}
|
||||
|
||||
void toolbar_crypto_click(struct s_toolbar *tb)
|
||||
void toolbar_crypto_click(struct s_toolbar *tb)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue