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