예제 #1
0
파일: gui.c 프로젝트: mmuman/NetSurf
/**
 * Create and open a gui window for a browsing context.
 *
 * \param bw		bw to create gui_window for
 * \param existing	an existing gui_window, may be NULL
 * \param flags		flags for gui window creation
 * \return gui window, or NULL on error
 *
 * If GW_CREATE_CLONE flag is set existing is non-NULL.
 *
 * The created gui_window must include a reference to the browser
 * window passed in the bw param.
 */
static struct gui_window *
gui_window_create(struct browser_window *bw,
		  struct gui_window *existing,
		  gui_window_create_flags flags)
{
    struct gui_window *gw=NULL;
    LOG("gw: %p, BW: %p, existing %p, flags: %d\n", gw, bw, existing, (int)flags);

    gw = calloc(1, sizeof(struct gui_window));
    if (gw == NULL)
	return NULL;

    LOG("new window: %p, bw: %p\n", gw, bw);
    window_create(gw, bw, existing, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
		  |WIDGET_SCROLL);
    if (gw->root->win) {
	GRECT pos = {
	    option_window_x, option_window_y,
	    option_window_width, option_window_height
	};
	gui_window_set_url(gw, corestring_nsurl_about_blank);
	gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
	gui_set_input_gui_window(gw);
	window_open(gw->root, gw, pos);
    }

    /* add the window to the window list: */
    if( window_list == NULL ) {
	window_list = gw;
	gw->next = NULL;
	gw->prev = NULL;
    } else {
	struct gui_window * tmp = window_list;
	while( tmp->next != NULL ) {
	    tmp = tmp->next;
	}
	tmp->next = gw;
	gw->prev = tmp;
	gw->next = NULL;
    }

    /* Loose focus: */
    window_set_focus(gw->root, WIDGET_NONE, NULL );

    /* trigger on-focus event (select all text): */
    window_set_focus(gw->root, URL_WIDGET, NULL);

    /* delete selection: */
    toolbar_key_input(gw->root->toolbar, NK_DEL);

    return( gw );

}
예제 #2
0
파일: gui.c 프로젝트: galexcode/NetSurf68k
struct gui_window *
gui_create_browser_window(struct browser_window *bw,
                          struct browser_window *clone,
                          bool new_tab) {
    struct gui_window *gw=NULL;
    LOG(( "gw: %p, BW: %p, clone %p, tab: %d\n" , gw,  bw, clone,
          (int)new_tab
        ));

    gw = calloc( sizeof(struct gui_window), 1);
    if (gw == NULL)
        return NULL;

    LOG(("new window: %p, bw: %p\n", gw, bw));
    window_create(gw, bw, clone, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE\
                  |WIDGET_SCROLL);
    if (gw->root->win) {
        GRECT pos = {
            option_window_x, option_window_y,
            option_window_width, option_window_height
        };
        gui_window_set_url(gw, "");
        gui_window_set_pointer(gw, BROWSER_POINTER_DEFAULT);
        gui_set_input_gui_window(gw);
        window_open(gw->root, gw, pos);
    }

    /* add the window to the window list: */
    if( window_list == NULL ) {
        window_list = gw;
        gw->next = NULL;
        gw->prev = NULL;
    } else {
        struct gui_window * tmp = window_list;
        while( tmp->next != NULL ) {
            tmp = tmp->next;
        }
        tmp->next = gw;
        gw->prev = tmp;
        gw->next = NULL;
    }

    return( gw );

}
예제 #3
0
bool ro_gui_url_bar_menu_select(struct url_bar *url_bar, wimp_i i,
		wimp_menu *menu, wimp_selection *selection, menu_action action)
{
	const char		*url;
	struct gui_window	*g;

	if (url_bar == NULL || url_bar->suggest_icon != i ||
			menu != ro_gui_url_suggest_menu)
		return false;

	url = ro_gui_url_suggest_get_selection(selection);
	g = ro_gui_toolbar_lookup(url_bar->window);

	if (url != NULL && g != NULL && g->bw != NULL) {
		gui_window_set_url(g, url);
		browser_window_go(g->bw, url, 0, true);
	}

	return true;
}