Exemple #1
0
void gui_window_destroy(struct gui_window *w)
{
    if (w == NULL)
        return;

    LOG(("%s\n", __FUNCTION__ ));

    if (input_window == w) {
        gui_set_input_gui_window(NULL);
    }

    nsatari_search_session_destroy(w->search);
    free(w->browser);
    free(w->status);
    free(w->title);
    free(w->url);

    /* unlink the window: */
    if(w->prev != NULL ) {
        w->prev->next = w->next;
    } else {
        window_list = w->next;
    }
    if( w->next != NULL ) {
        w->next->prev = w->prev;
    }

    window_unref_gui_window(w->root, w);

    free(w);
    w = NULL;

    if(input_window == NULL) {
        w = window_list;
        while( w != NULL ) {
            if(w->root) {
                gui_set_input_gui_window(w);
                break;
            }
            w = w->next;
        }
    }
}
Exemple #2
0
/**
 * 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 );

}
Exemple #3
0
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 );

}