GtkWidget *window;
+typedef enum {
+ /** stop scanning the database */
+ FILTER_STOP,
+ /** ignore this one */
+ FILTER_PASS,
+ /** add this one to the list */
+ FILTER_ACCEPT
+} FilterResult;
+
/*
FIXME:
We should really do this by looking at the header row of the table.
g_strdup (details->fields[FieldCountry]));
}
- return TRUE;
+ return FILTER_PASS;
}
typedef struct {
country_cb_data *d = (country_cb_data *)data;
if (details->serial==0)
- return TRUE; /* header row */
+ return FILTER_PASS; /* header row */
if (strcmp(details->fields[FieldCountry], d->country_name)!=0)
- return TRUE; /* wrong country */
+ return FILTER_PASS; /* wrong country */
if (!g_hash_table_lookup_extended (d->hash,
details->fields[FieldCounty],
g_strdup (details->fields[FieldCounty]));
}
- return TRUE;
+ return FILTER_PASS;
}
static gboolean
if (strcmp(details->fields[FieldPrimaryKey], primary_key)!=0)
{
/* not this one; keep going */
- return TRUE;
+ return FILTER_PASS;
}
tower_window = hildon_stackable_window_new ();
details->fields[FieldLong]);
gtk_widget_show_all (GTK_WIDGET (tower_window));
- return FALSE;
+ return FILTER_STOP;
}
static void
parse_dove (ParseDoveCallback callback,
+ GSList **filter_results,
gpointer data)
{
FILE *dove = fopen("/usr/share/belltower/dove.txt", "r");
result.fields[FieldCountry] = "England";
}
- if (!callback (&result, data))
+ switch (callback (&result, data))
{
+ case FILTER_PASS:
+ /* nothing */
+ break;
+
+ case FILTER_STOP:
fclose (dove);
return;
+
+ case FILTER_ACCEPT:
+ if (filter_results)
+ {
+ *filter_results = g_slist_append (*filter_results,
+ result.fields[FieldPrimaryKey]);
+ }
}
result.serial++;
static void
show_tower (char *primary_key)
{
- parse_dove (single_tower_cb,
- primary_key);
+ parse_dove (single_tower_cb, NULL, primary_key);
}
static gint strcmp_f (gconstpointer a,
gtk_window_set_title (GTK_WINDOW (dialog), title);
g_free (title);
- parse_dove (get_counties_cb,
- &d);
+ parse_dove (get_counties_cb, NULL, &d);
g_hash_table_foreach (hash,
put_areas_into_list,
gtk_window_set_title (GTK_WINDOW (dialog), "Areas of the world");
- parse_dove (get_countries_cb,
- hash);
+ parse_dove (get_countries_cb, NULL, hash);
g_hash_table_foreach (hash,
put_areas_into_list,