Commit 93e7af6b authored by Danilo Galete's avatar Danilo Galete 💬
Browse files

Add: finance_transaction_editor_set_type, finance_transaction_editor_get_type...

Add: finance_transaction_editor_set_type, finance_transaction_editor_get_type methods and  PROP_TYPE propet as a enum
parent 7eaf7fe8
......@@ -47,11 +47,15 @@ struct _FinanceTransactionEditor
GtkWidget *spin_frequency_number;
GdkRGBA *icon_color;
gchar *icon_text;
gchar *notes;
gboolean mobile;
GSettings *settings;
FinanceTransaction type;
};
G_DEFINE_TYPE (FinanceTransactionEditor, finance_transaction_editor, GTK_TYPE_GRID)
......@@ -73,6 +77,7 @@ enum {
PROP_PAYMENT,
PROP_PAYMENT_INFORMATION,
PROP_REPEAT,
PROP_TYPE,
N_PROPS
};
......@@ -275,6 +280,10 @@ finance_transaction_editor_get_property (GObject *object,
g_value_set_enum (value, finance_transaction_editor_get_repeat (self));
break;
case PROP_TYPE:
g_value_set_enum (value, finance_transaction_editor_get_type (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -351,6 +360,10 @@ finance_transaction_editor_set_property (GObject *object,
finance_transaction_editor_set_repeat (self, g_value_get_enum (value));
break;
case PROP_TYPE:
finance_transaction_editor_set_type (self, g_value_get_enum (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -531,6 +544,18 @@ finance_transaction_editor_class_init (FinanceTransactionEditorClass *klass)
FINANCE_NO_REPEAT,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* FinanceTransactionEditor::type:
*
* The transaction type
*/
properties[PROP_TYPE] = g_param_spec_enum ("type",
"The type",
"The transaction type",
FINANCE_TYPE_TRANSACTION,
FINANCE_CREDIT,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/editor/finance-transaction-editor.ui");
......@@ -630,6 +655,7 @@ finance_transaction_editor_set_amount (FinanceTransactionEditor *self,
gdouble amount)
{
g_return_if_fail (FINANCE_IS_TRANSACTION_EDITOR (self));
g_return_if_fail (amount < 0);
finance_monetary_entry_set_amount (FINANCE_MONETARY_ENTRY (self->entry_amount), amount);
......@@ -1160,6 +1186,44 @@ finance_transaction_editor_set_repeat (FinanceTransactionEditor *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_REPEAT]);
}
/**
* finance_transaction_editor_get_type:
* @self: a #FinanceTransactionEditor
*
* Returns the transaction type
*
* Returns: a #FinanceTransaction
*
* Since: 1.0
*/
gint
finance_transaction_editor_get_type (FinanceTransactionEditor *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTION_EDITOR (self), -1);
return self->type;
}
/**
* finance_transaction_editor_set_type:
* @self: a #FinanceTransactionEditor
* @type: a #FinanceTransaction
*
* Sets the transaction type
*
* Since: 1.0
*/
void
finance_transaction_editor_set_type (FinanceTransactionEditor *self,
gint type)
{
g_return_if_fail (FINANCE_IS_TRANSACTION_EDITOR (self));
self->type = type;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TYPE]);
}
/**
* finance_transaction_editor_clear:
* @self: a #FinanceTransactionEditor
......
......@@ -110,6 +110,11 @@ gint finance_transaction_editor_get_repeat (FinanceTr
void finance_transaction_editor_set_repeat (FinanceTransactionEditor *self,
gint repeat);
gint finance_transaction_editor_get_type (FinanceTransactionEditor *self);
void finance_transaction_editor_set_type (FinanceTransactionEditor *self,
gint type);
void finance_transaction_editor_clear (FinanceTransactionEditor *self);
G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment