void FieldEditor::keystroke(const Event& e) { FieldEditorImpl& f = *impl_; if (f.editor_->keystroke(e)) { select(text()->length()); next_focus(); } }
static void changed(GtkWidget *widget, struct search_param *search) { struct search_list_result *res; GtkTreeIter iter; search->attr.u.str=(char *)gtk_entry_get_text(GTK_ENTRY(widget)); printf("changed %s partial %d\n", search->attr.u.str, search->partial); if (widget == search->entry_country) { gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING); dbg(0,"country\n"); search->attr.type=attr_country_all; set_columns(search, 0); } if (widget == search->entry_postal) { gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 1, GTK_SORT_ASCENDING); dbg(0,"postal\n"); search->attr.type=attr_town_postal; if (strlen(search->attr.u.str) < 2) return; set_columns(search, 1); } if (widget == search->entry_city) { gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 2, GTK_SORT_ASCENDING); dbg(0,"town\n"); search->attr.type=attr_town_name; if (strlen(search->attr.u.str) < 3) return; set_columns(search, 1); } if (widget == search->entry_street) { dbg(0,"street\n"); search->attr.type=attr_street_name; set_columns(search, 2); } search_list_search(search->sl, &search->attr, search->partial); gtk_list_store_clear(search->liststore); while((res=search_list_get_result(search->sl))) { gtk_list_store_append(search->liststore,&iter); gtk_list_store_set(search->liststore,&iter,COL_COUNT,res->c,-1); if (widget == search->entry_country) { if (res->country) { gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1); gtk_list_store_set(search->liststore,&iter,1,res->country->iso3,-1); gtk_list_store_set(search->liststore,&iter,2,res->country->iso2,-1); gtk_list_store_set(search->liststore,&iter,3,res->country->name,-1); } } else { if (res->country) gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1); else gtk_list_store_set(search->liststore,&iter,0,"",-1); if (res->town) { gtk_list_store_set(search->liststore,&iter,1,res->town->common.postal,-1); gtk_list_store_set(search->liststore,&iter,2,res->town->name,-1); gtk_list_store_set(search->liststore,&iter,3,res->town->district,-1); } else { gtk_list_store_set(search->liststore,&iter,1,"",-1); gtk_list_store_set(search->liststore,&iter,2,"",-1); gtk_list_store_set(search->liststore,&iter,3,"",-1); } if (res->street) gtk_list_store_set(search->liststore,&iter,4,res->street->name,-1); else gtk_list_store_set(search->liststore,&iter,4,"",-1); } } if (! search->partial) next_focus(search, widget); search->partial=1; }
static void changed(GtkWidget *widget, struct search_param *search) { struct search_list_result *res; GtkTreeIter iter; search->attr.u.str=(char *)gtk_entry_get_text(GTK_ENTRY(widget)); printf("changed %s partial %d\n", search->attr.u.str, search->partial); if (widget == search->entry_country) { gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 3, GTK_SORT_ASCENDING); dbg(0,"country\n"); search->attr.type=attr_country_all; set_columns(search, 0); } if (widget == search->entry_postal) { gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 1, GTK_SORT_ASCENDING); dbg(0,"postal\n"); search->attr.type=attr_town_postal; if (strlen(search->attr.u.str) < 2) return; set_columns(search, 1); } if (widget == search->entry_city) { gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (search->liststore2), 2, GTK_SORT_ASCENDING); dbg(0,"town\n"); search->attr.type=attr_town_name; if (strlen(search->attr.u.str) < 3) return; set_columns(search, 1); } if (widget == search->entry_street) { dbg(0,"street\n"); search->attr.type=attr_street_name; // Searching for a street by just its first letter generates too many hits to be useful, // plus it causes the GUI to become unresponsive because the search is single-threaded. // So we only start searching once we have two letters. if (strlen(search->attr.u.str) < 2) return; set_columns(search, 2); } search_list_search(search->sl, &search->attr, search->partial); gtk_list_store_clear(search->liststore); while((res=search_list_get_result(search->sl))) { gtk_list_store_append(search->liststore,&iter); gtk_list_store_set(search->liststore,&iter,COL_COUNT,res->c,-1); if (widget == search->entry_country) { if (res->country) { gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1); gtk_list_store_set(search->liststore,&iter,1,res->country->iso3,-1); gtk_list_store_set(search->liststore,&iter,2,res->country->iso2,-1); gtk_list_store_set(search->liststore,&iter,3,res->country->name,-1); } } else { if (res->country) gtk_list_store_set(search->liststore,&iter,0,res->country->car,-1); else gtk_list_store_set(search->liststore,&iter,0,"",-1); if (res->town) { gtk_list_store_set(search->liststore,&iter,1,res->town->common.postal,-1); gtk_list_store_set(search->liststore,&iter,2,res->town->common.town_name,-1); gtk_list_store_set(search->liststore,&iter,3,res->town->common.district_name,-1); } else { gtk_list_store_set(search->liststore,&iter,1,"",-1); gtk_list_store_set(search->liststore,&iter,2,"",-1); gtk_list_store_set(search->liststore,&iter,3,"",-1); } if (res->street) gtk_list_store_set(search->liststore,&iter,4,res->street->name,-1); else gtk_list_store_set(search->liststore,&iter,4,"",-1); } } if(! search->partial) { if( widget == search->entry_country ) { gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE); } if( widget == search->entry_city ) { gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE); } if( widget == search->entry_street ) { gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), TRUE); } } else { if( widget == search->entry_country ) { gtk_widget_set_sensitive(GTK_WIDGET(search->entry_city), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE); } if( widget == search->entry_city ) { gtk_widget_set_sensitive(GTK_WIDGET(search->entry_street), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE); } if( widget == search->entry_street ) { gtk_widget_set_sensitive(GTK_WIDGET(search->entry_number), FALSE); } } if (! search->partial) next_focus(search, widget); search->partial=1; }