Example #1
0
void LabelStack::updateTemporaryStatus() {
    if (temporary_epoch_.elapsed() >= temporary_msg_timeout_) {
        popText(temporary_ctx_);
        emit toggleTemporaryFlash(false);
        temporary_timer_.stop();
    } else {
        for (int i = (num_flashes_ * 2); i > 0; i--) {
            if (temporary_epoch_.elapsed() >= temporary_flash_timeout_ * i) {
                emit toggleTemporaryFlash(i % 2);
                break;
            }
        }
    }
}
Example #2
0
void LabelStack::pushText(QString &text, int ctx) {
    StackItem *si = new StackItem;

    if (ctx == temporary_ctx_) {
        temporary_timer_.stop();
        popText(temporary_ctx_);

        temporary_epoch_.start();
        temporary_timer_.start(temporary_flash_timeout_);
        emit toggleTemporaryFlash(true);
    }

    si->text = text;
    si->ctx = ctx;
    labels_.prepend(si);
    fillLabel();
}
Example #3
0
char *
acceptableMimeTypes()
{
    static Str types = NULL;
    TextList *l;
    Hash_si *mhash;
    char *p;
    int i;

    if (types != NULL)
	return types->ptr;

    /* generate acceptable media types */
    l = newTextList();
    mhash = newHash_si(16);	/* XXX */
    /* pushText(l, "text"); */
    putHash_si(mhash, "text", 1);
    pushText(l, "image");
    putHash_si(mhash, "image", 1);
    for (i = 0; i < mailcap_list->nitem; i++) {
	struct mailcap *mp = UserMailcap[i];
	char *mt;
	if (mp == NULL)
	    continue;
	for (; mp->type; mp++) {
	    p = strchr(mp->type, '/');
	    if (p == NULL)
		continue;
	    mt = allocStr(mp->type, p - mp->type);
	    if (getHash_si(mhash, mt, 0) == 0) {
		pushText(l, mt);
		putHash_si(mhash, mt, 1);
	    }
	}
    }
    types = Strnew();
    Strcat_charp(types, "text/html, text/*;q=0.5");
    while ((p = popText(l)) != NULL) {
	Strcat_charp(types, ", ");
	Strcat_charp(types, p);
	Strcat_charp(types, "/*");
    }
    return types->ptr;
}
Example #4
0
ProgressFrame::ProgressFrame( QWidget *parent ) :
    QFrame( parent ),
    m_itemType( 0 ),
    m_progressEnabled( false ),
    m_clockEnabled( false ),
    m_reverse( false ),
    m_watch( NULL ),
    m_value( 0 )
{
    m_textPushTimer.setSingleShot( true );
    connect( &m_textPushTimer, SIGNAL( timeout() ), this, SLOT( popText() ) );
    m_clockPushTimer.setSingleShot( true );
    connect( &m_clockPushTimer, SIGNAL( timeout() ), this, SLOT( popClockText() ) );

    setMinimumHeight( 22 );
    setMinimumWidth( 22 );
    setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
    setLineWidth( 1 );
}
Example #5
0
void LabelStack::popTemporaryText() {
    popText(m_temporaryCtx);
}
Example #6
0
int
insert_bookmark(char *bmark, struct parsed_tagarg *data)
{
    char *url, *title, *section;
    FILE *f;
    TextList *tl = newTextList();
    int section_found = 0;
    int bmark_added = 0;
    Str tmp, section_tmp;

    url = tag_get_value(data, "url");
    title = tag_get_value(data, "title");
    section = tag_get_value(data, "newsection");
    if (section == NULL || *section == '\0')
	section = tag_get_value(data, "section");
    if (section == NULL || *section == '\0')
	section = DEFAULT_SECTION;

    if (url == NULL || *url == '\0' || title == NULL || *title == '\0') {
	/* Bookmark not added */
	return FALSE;
    }
    url = html_quote(url);
    title = html_quote(title);
    section = html_quote(section);

    f = fopen(bmark, "r");
    if (f == NULL)
	return create_new_bookmark(bmark, section, title, url, "w");

    section_tmp = Sprintf("<h2>%s</h2>\n", section);
    for (;;) {
	tmp = Strfgets(f);
	if (tmp->length == 0)
	    break;
	if (Strcasecmp(tmp, section_tmp) == 0)
	    section_found = 1;
	if (section_found && !bmark_added) {
	    Strremovefirstspaces(tmp);
	    if (Strcmp_charp(tmp, end_section) == 0) {
		pushText(tl,
			 Sprintf("<li><a href=\"%s\">%s</a>\n", url,
				 title)->ptr);
		bmark_added = 1;
	    }
	}
	if (!bmark_added && Strcasecmp_charp(tmp, "</body>\n") == 0) {
	    pushText(tl, Sprintf("<h2>%s</h2>\n<ul>\n", section)->ptr);
	    pushText(tl,
		     Sprintf("<li><a href=\"%s\">%s</a>\n", url, title)->ptr);
	    pushText(tl, end_section);
	    pushText(tl, "</ul>\n");
	    bmark_added = 1;
	}
	pushText(tl, tmp->ptr);
    }
    fclose(f);
    if (!bmark_added) {
	/* Bookmark not added; perhaps the bookmark file is ill-formed */
	/* In this case, a new bookmark is appeneded after the bookmark file */
	return create_new_bookmark(bmark, section, title, url, "a");
    }
    f = fopen(bmark, "w");
    while (tl->nitem) {
	fputs(popText(tl), f);
    }
    fclose(f);
    return TRUE;
}