Beispiel #1
0
void
qtv_sbar_init (void)
{
	view_t     *status;
	view_t     *view;

	if (!con_module || !con_module->data->console->status_view)
		return;
	status = con_module->data->console->status_view;

	view = view_new (0, 0, 8, 1, grav_northwest);
	view->draw = draw_servers;
	view->data = status->data;
	view_add (status, view);

	view = view_new (8, 0, 9, 1, grav_northwest);
	view->draw = draw_clients;
	view->data = status->data;
	view_add (status, view);
}
Beispiel #2
0
/* session_restore(const char *name) {{{*/
gboolean
session_restore(char *name, int flags) 
{
    gboolean is_marked = false;
    char *uri = NULL;
    GList *currentview = NULL, *lastview = NULL;
    WebKitWebBackForwardList *bf_list = NULL;
    int last = 1;
    char *end;
    gboolean ret = false;
    int locked_state = 0;
    if (name == NULL) 
        s_session_name = g_strdup("default");
    else 
        s_session_name = name;

    char *group = session_get_group(s_session_name, &is_marked);
    if (is_marked && (flags & SESSION_FORCE) == 0) 
    {
        fprintf(stderr, "Warning: Session '%s' will not be restored.\n", s_session_name);
        fprintf(stderr, "There is already a restored session open with name '%s'.\n", s_session_name);
        fputs("To force opening a saved session use -f or --force.\n", stderr);
        s_has_marked = false;
        goto clean;
    }
    if (group == NULL) 
        return false;

    char *group_begin = strchr(group, '\n');
    session_save_file(s_session_name, group_begin+1, true);
    if (flags & SESSION_ONLY_MARK) 
        goto clean;

    char  **lines = g_strsplit(group, "\n", -1);
    int length = g_strv_length(lines) - 1;
    for (int i=1; i<=length; i++) 
    {
        char **line = g_strsplit(lines[i], " ", 4);
        if (line[0] && line[1] && line[2]) 
        {
            int current = strtol(line[0], &end, 10);

            if (current <= last) 
            {
                currentview = view_add(NULL, false);
                bf_list = webkit_web_view_get_back_forward_list(WEBVIEW(currentview));
                if (lastview) 
                {
                    session_load_webview(lastview, uri, last, locked_state);
                    locked_state = 0;
                }
                lastview = currentview;
            }
            if (current == 0 && *end == '|') 
                locked_state = strtol(end+1, NULL, 10);
            if (bf_list != NULL) 
            {
                WebKitWebHistoryItem *item = webkit_web_history_item_new_with_data(line[1], line[2]);
                webkit_web_back_forward_list_add_item(bf_list, item);
            }
            last = current;
            g_free(uri);
            uri = g_strdup(line[1]);
        }
        if (i == length && lastview)
            session_load_webview(lastview, uri, last, locked_state);

        g_strfreev(line);
    }
    g_strfreev(lines);

    if (!dwb.state.views) 
    {
        view_add(NULL, false);
        dwb_open_startpage(dwb.state.fview);
    }
    dwb_focus(dwb.state.fview);
    g_free(uri);
    ret = true;

clean:
    g_free(group);
    return ret;
}/*}}}*/