mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add function to clear the display of the currency edit widget
When first created, the display is blank and in this position will return the default currency. If a currency is selected, there is no way to go back to this state. The only way to do this is destroy the widget and create a new one so added a function to do this without destroying the widget. This is used in the next commit.
This commit is contained in:
parent
0b33a66326
commit
4df714037b
@ -467,6 +467,42 @@ gnc_currency_edit_get_currency (GNCCurrencyEdit *gce)
|
|||||||
return commodity;
|
return commodity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Clear the displayed currency of the widget.
|
||||||
|
*
|
||||||
|
* This will clear the currency being displayed just like when first created
|
||||||
|
* but it still returns the default currency as usual
|
||||||
|
*
|
||||||
|
* @param gce The currency editor widget whose values should be retrieved.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gnc_currency_edit_clear_display (GNCCurrencyEdit *gce)
|
||||||
|
{
|
||||||
|
GtkTreeModel *model;
|
||||||
|
GtkWidget *entry;
|
||||||
|
|
||||||
|
g_return_if_fail(gce != NULL);
|
||||||
|
g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
|
||||||
|
|
||||||
|
model = gtk_combo_box_get_model (GTK_COMBO_BOX(gce));
|
||||||
|
|
||||||
|
entry = gtk_bin_get_child (GTK_BIN(gce));
|
||||||
|
|
||||||
|
g_object_ref (model);
|
||||||
|
|
||||||
|
g_signal_handlers_block_by_func (G_OBJECT(gce),
|
||||||
|
G_CALLBACK(gnc_currency_edit_active_changed), gce);
|
||||||
|
|
||||||
|
gtk_combo_box_set_model (GTK_COMBO_BOX(gce), NULL);
|
||||||
|
gtk_entry_set_text (GTK_ENTRY(entry),"");
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX(gce), -1);
|
||||||
|
gtk_combo_box_set_model (GTK_COMBO_BOX(gce), model);
|
||||||
|
|
||||||
|
g_signal_handlers_block_by_func (G_OBJECT(gce),
|
||||||
|
G_CALLBACK(gnc_currency_edit_active_changed), gce);
|
||||||
|
|
||||||
|
g_object_unref (model);
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -114,6 +114,16 @@ void gnc_currency_edit_set_currency (GNCCurrencyEdit *gce,
|
|||||||
*/
|
*/
|
||||||
gnc_commodity *gnc_currency_edit_get_currency (GNCCurrencyEdit *gce);
|
gnc_commodity *gnc_currency_edit_get_currency (GNCCurrencyEdit *gce);
|
||||||
|
|
||||||
|
|
||||||
|
/** Clear the displayed currency of the widget.
|
||||||
|
*
|
||||||
|
* This will clear the currency being displayed just like when first created
|
||||||
|
* but it still returns the default currency as usual
|
||||||
|
*
|
||||||
|
* @param gce The currency editor widget whose values should be retrieved.
|
||||||
|
*/
|
||||||
|
void gnc_currency_edit_clear_display (GNCCurrencyEdit *gce);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user