Exemplo n.º 1
0
struct layout * layout_new(struct attr *parent, struct attr **attrs)
{
	struct layout *l;
	struct color def_color = {COLOR_BACKGROUND_};
	struct attr *name_attr,*color_attr,*order_delta_attr,*font_attr,*day_attr,*night_attr,*active_attr;

	if (! (name_attr=attr_search(attrs, NULL, attr_name)))
		return NULL;
	l = g_new0(struct layout, 1);
	l->func=&layout_func;
	navit_object_ref((struct navit_object *)l);
	l->name = g_strdup(name_attr->u.str);
	if ((font_attr=attr_search(attrs, NULL, attr_font))) {
		l->font = g_strdup(font_attr->u.str);
	}
	if ((day_attr=attr_search(attrs, NULL, attr_daylayout))) {
		l->dayname = g_strdup(day_attr->u.str);
	}
	if ((night_attr=attr_search(attrs, NULL, attr_nightlayout))) {
		l->nightname = g_strdup(night_attr->u.str);
	}
	if ((color_attr=attr_search(attrs, NULL, attr_color)))
		l->color = *color_attr->u.color;
	else
		l->color = def_color;
	if ((order_delta_attr=attr_search(attrs, NULL, attr_order_delta)))
		l->order_delta=order_delta_attr->u.num;
	if ((active_attr=attr_search(attrs, NULL, attr_active)))
		l->active = active_attr->u.num;
	l->navit=parent->u.navit;
	return l;
}
Exemplo n.º 2
0
static struct profile_option *
profile_option_new(struct attr *parent, struct attr **attrs)
{
	struct profile_option *po=g_new0(struct profile_option, 1);
	po->func=&profile_option_func;
	navit_object_ref((struct navit_object *)po);
	po->attrs=attr_list_dup(attrs);
	dbg(lvl_debug,"return %p\n",po);
	return po;
}
Exemplo n.º 3
0
Arquivo: log.c Projeto: Jalakas/navit
struct log *
log_new(struct attr * parent,struct attr **attrs)
{
	struct log *ret=g_new0(struct log, 1);
	struct attr *data,*overwrite,*lazy,*mkdir,*flush_size,*flush_time;
	struct file_wordexp *wexp;
	char *filename, **wexp_data;

	dbg(1,"enter\n");
	ret->func=&log_func;
	navit_object_ref((struct navit_object *)ret);
	data=attr_search(attrs, NULL, attr_data);
	if (! data)
		return NULL;
	filename=data->u.str;
	wexp=file_wordexp_new(filename);
	if (wexp && file_wordexp_get_count(wexp) > 0) {
		wexp_data=file_wordexp_get_array(wexp);
		filename=wexp_data[0];
	}
	if (filename)
		ret->filename=g_strdup(filename);
	if (wexp)
		file_wordexp_destroy(wexp);
	overwrite=attr_search(attrs, NULL, attr_overwrite);
	if (overwrite)
		ret->overwrite=overwrite->u.num;
	lazy=attr_search(attrs, NULL, attr_lazy);
	if (lazy)
		ret->lazy=lazy->u.num;
	mkdir=attr_search(attrs, NULL, attr_mkdir);
	if (mkdir)
		ret->mkdir=mkdir->u.num;
	flush_size=attr_search(attrs, NULL, attr_flush_size);
	if (flush_size)
		ret->flush_size=flush_size->u.num;
	flush_time=attr_search(attrs, NULL, attr_flush_time);
	if (flush_time)
		ret->flush_time=flush_time->u.num;
	if (ret->flush_time) {
		dbg(1,"interval %d\n", ret->flush_time*1000);
		ret->timer_callback=callback_new_1(callback_cast(log_timer), ret);
		ret->timer=event_add_timeout(ret->flush_time*1000, 1, ret->timer_callback);
	}
	expand_filenames(ret);
	if (ret->lazy)
		log_set_last_flush(ret);
	else
		log_open(ret);
	ret->attrs=attr_list_dup(attrs);
	return ret;
}
Exemplo n.º 4
0
static struct script *
script_new(struct attr *parent, struct attr **attrs)
{
    struct script *scr=g_new0(struct script, 1);
    scr->func=&script_func;
    navit_object_ref((struct navit_object *)scr);
    scr->attrs=attr_list_dup(attrs);
    attrs=scr->attrs;
    scr->cb=callback_new_1(callback_cast(script_run), scr);
    scr->parent=*parent;
    while (attrs && *attrs)
        script_set_attr_int(scr, *attrs++);
    dbg(lvl_debug,"return %p\n",scr);
    return scr;
}