GncCurrencyEdit
[GUI]


Files

file  gnc-currency-edit.c
 Currency selection widget.
file  gnc-currency-edit.h
 Currency selection widget.

Data Structures

struct  _GNCCurrencyEditPrivate
struct  GNCCurrencyEdit
struct  GNCCurrencyEditClass

Basic Object Implementation



GType gnc_currency_edit_get_type (void)
GtkWidget * gnc_currency_edit_new (void)

Get/Set Functions



void gnc_currency_edit_set_currency (GNCCurrencyEdit *gce, const gnc_commodity *currency)
gnc_commoditygnc_currency_edit_get_currency (GNCCurrencyEdit *gce)

Basic Object Implementation



#define GNC_TYPE_CURRENCY_EDIT   (gnc_currency_edit_get_type())
#define GNC_CURRENCY_EDIT(o)   (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_CURRENCY_EDIT, GNCCurrencyEdit))
#define GNC_CURRENCY_EDIT_CLASS(k)   (G_TYPE_CHECK_CLASS_CAST ((k), GNC_TYPE_CURRENCY_EDIT, GNCCurrencyEditClass))
#define GNC_IS_CURRENCY_EDIT(o)   (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_CURRENCY_EDIT))

Defines

#define GET_PRIVATE(o)   (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_CURRENCY_EDIT, GNCCurrencyEditPrivate))

Typedefs

typedef _GNCCurrencyEditPrivate GNCCurrencyEditPrivate


Define Documentation

#define GNC_TYPE_CURRENCY_EDIT   (gnc_currency_edit_get_type())

Definition at line 63 of file gnc-currency-edit.h.


Typedef Documentation

typedef struct _GNCCurrencyEditPrivate GNCCurrencyEditPrivate

The instance private data for a content plugin.


Function Documentation

gnc_commodity * gnc_currency_edit_get_currency ( GNCCurrencyEdit gce  ) 

Retrieve the displayed currency of the widget.

Parameters:
gce The currency editor widget whose values should be retrieved.
Returns:
A pointer to the selected currency (a gnc_commodity structure).

Definition at line 250 of file gnc-currency-edit.c.

00251 {
00252         gnc_commodity *commodity;
00253         const char *fullname;
00254         char *mnemonic, *name;
00255         GtkTreeModel *model;
00256         GtkTreeIter iter;
00257         GValue value = { 0 };
00258 
00259         g_return_val_if_fail(gce != NULL, NULL);
00260         g_return_val_if_fail(GNC_IS_CURRENCY_EDIT(gce), NULL);
00261 
00262         if (gtk_combo_box_get_active_iter(GTK_COMBO_BOX(gce), &iter)) {
00263                 model = gtk_combo_box_get_model(GTK_COMBO_BOX(gce));
00264                 gtk_tree_model_get_value(model, &iter, 0, &value);
00265                 fullname = g_value_get_string(&value);
00266                 mnemonic = g_strdup(fullname);
00267                 g_value_unset(&value);
00268 
00269                 name = strchr(mnemonic, ' ');
00270                 if (name != NULL)
00271                         *name = '\0';
00272                 commodity = gnc_commodity_table_lookup (gnc_get_current_commodities (),
00273                                                         GNC_COMMODITY_NS_CURRENCY,
00274                                                         mnemonic);
00275                 g_free(mnemonic);
00276         } else {
00277                 g_warning("Combo box returned 'inactive'. Using locale default currency.");
00278                 commodity = gnc_locale_default_currency();
00279         }
00280 
00281 
00282         return commodity;
00283 }

GType gnc_currency_edit_get_type ( void   ) 

Definition at line 90 of file gnc-currency-edit.c.

00091 {
00092         static GType currency_edit_type = 0;
00093 
00094         if (currency_edit_type == 0) {
00095                 static const GTypeInfo currency_edit_info = {
00096                         sizeof (GNCCurrencyEditClass),
00097                         NULL,
00098                         NULL,
00099                         (GClassInitFunc) gnc_currency_edit_class_init,
00100                         NULL,
00101                         NULL,
00102                         sizeof (GNCCurrencyEdit),
00103                         0, /* n_preallocs */
00104                         (GInstanceInitFunc) gnc_currency_edit_init,
00105                         NULL
00106                 };
00107 
00108                 currency_edit_type = g_type_register_static (GTK_TYPE_COMBO_BOX_ENTRY, 
00109                                                              "GNCCurrencyEdit",
00110                                                              &currency_edit_info, 0);
00111         }
00112 
00113         return currency_edit_type;
00114 }

GtkWidget * gnc_currency_edit_new ( void   ) 

Create a new GNCCurrencyEdit widget which can be used to provide an easy way to enter ISO currency codes.

Returns:
A GNCCurrencyEdit widget.

Definition at line 191 of file gnc-currency-edit.c.

00192 {
00193         GNCCurrencyEdit *gce;
00194         GtkListStore *store;
00195 
00196         store = gtk_list_store_new (1, G_TYPE_STRING);
00197         gce = g_object_new (GNC_TYPE_CURRENCY_EDIT,
00198                             "model", store,
00199                             "text-column", 0,
00200                             NULL);
00201         g_object_unref (store);
00202 
00203         /* Now the signals to make sure the user can't leave the
00204            widget without a valid currency. */
00205         gnc_cbe_require_list_item(GTK_COMBO_BOX_ENTRY(gce));
00206 
00207         /* Fill in all the data. */
00208         fill_currencies (gce);
00209         gtk_tree_sortable_set_sort_column_id
00210                 (GTK_TREE_SORTABLE(store), 0, GTK_SORT_ASCENDING);
00211 
00212         return GTK_WIDGET (gce);
00213 }

void gnc_currency_edit_set_currency ( GNCCurrencyEdit gce,
const gnc_commodity currency 
)

Definition at line 228 of file gnc-currency-edit.c.

00230 {
00231         const gchar *printname;
00232 
00233         g_return_if_fail(gce != NULL);
00234         g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
00235         g_return_if_fail(currency != NULL);
00236         
00237         printname = gnc_commodity_get_printname(currency);
00238         gnc_cbe_set_by_string(GTK_COMBO_BOX_ENTRY(gce), printname);
00239 }


Generated on Sun Sep 7 05:07:55 2008 for GnuCash by  doxygen 1.5.2