Create a new GNCCurrencyEdit widget which can be used to provide an easy way to enter ISO currency codes.
352{
353 GNCCurrencyEdit *gce;
354 GtkListStore *store;
355 GtkEntryCompletion* completion;
356
357 store = gtk_list_store_new (NUM_CURRENCY_COLS, G_TYPE_STRING, G_TYPE_STRING);
358 gce = GNC_CURRENCY_EDIT(g_object_new (GNC_TYPE_CURRENCY_EDIT,
359 "model", store,
360 "has-entry", true,
361 nullptr));
362 g_object_unref (store);
363
364
365 gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX(gce), CURRENCY_COL_NAME);
366
367
368
369 gnc_cbwe_require_list_item(GTK_COMBO_BOX(gce));
370
371
372 fill_currencies (gce);
373 gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(store),
374 CURRENCY_COL_NAME,
375 GTK_SORT_ASCENDING);
376
377 completion = gtk_entry_completion_new ();
378 gtk_entry_completion_set_model (completion, GTK_TREE_MODEL(store));
379 gtk_entry_completion_set_text_column (completion, CURRENCY_COL_NAME);
380 gtk_entry_completion_set_match_func (completion,
381 (GtkEntryCompletionMatchFunc)match_func,
382 GTK_TREE_MODEL(store), nullptr);
383 gtk_entry_set_completion (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (gce))),
384 completion);
385
386 return GTK_WIDGET (gce);
387}