Esempio n. 1
0
static int
country_attr_get(void *priv_data, enum attr_type attr_type, struct attr *attr)
{
	struct country_search *this_=priv_data;
	struct country *country=this_->country;

	attr->type=attr_type;
	switch (attr_type) {
	case attr_any:
			while (this_->attr_next != attr_none) {
					if (country_attr_get(this_, this_->attr_next, attr))
							return 1;
			}
			return 0;
	// Cast to char* necessary but safe, because our callers know
	// not to modify attr->u.str (hopefully).
	case attr_label:
		attr->u.str=(char*)navit_nls_gettext(country->name);
		this_->attr_next=attr_country_id;
		return 1;
	case attr_country_id:
		attr->u.num=country->id;
		this_->attr_next=country->car ? attr_country_car : attr_country_iso2;
		return 1;
	case attr_country_car:
		attr->u.str=(char*)country->car;
		this_->attr_next=attr_country_iso2;
		return attr->u.str ? 1 : 0;
	case attr_country_iso2:
		attr->u.str=(char*)country->iso2;
		this_->attr_next=attr_country_iso3;
		return 1;
	case attr_country_iso3:
		attr->u.str=(char*)country->iso3;
		this_->attr_next=attr_country_name;
		return 1;
	case attr_country_name:
		attr->u.str=(char*)navit_nls_gettext(country->name);
		this_->attr_next=attr_none;
		return 1;
	default:
		return 0;
	}
}
Esempio n. 2
0
struct item *
country_search_get_item(struct country_search *this_)
{
	for (;;) {
		if (this_->count >= sizeof(country)/sizeof(struct country))
			return NULL;
		this_->country=&country[this_->count++];
		if ((this_->search.type == attr_country_id && this_->search.u.num == this_->country->id) ||
                    match(this_, attr_country_iso3, this_->country->iso3) ||
		    match(this_, attr_country_iso2, this_->country->iso2) ||
		    match(this_, attr_country_car, this_->country->car) ||
		    match(this_, attr_country_name, navit_nls_gettext(this_->country->name))) {
			this_->item.id_lo=this_->country->id;
			return &this_->item;
		}
	}
}
Esempio n. 3
0
static void set_columns(struct search_param *param, int mode)
{
	GList *columns_list,*columns;
	char **column_text=columns_text[mode];
	int i=0;

	columns_list=gtk_tree_view_get_columns(GTK_TREE_VIEW(param->treeview));
	columns=columns_list;
	while (columns) {
		gtk_tree_view_remove_column(GTK_TREE_VIEW(param->treeview), columns->data);
		columns=g_list_next(columns);
	}
	g_list_free(columns_list);
	while (*column_text) {
		GtkCellRenderer *cell=gtk_cell_renderer_text_new();
		gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (param->treeview),-1, navit_nls_gettext(*column_text), cell, "text", i, NULL);
		i++;
		column_text++;
	}

}