Commit af9610ad authored by Danilo Galete's avatar Danilo Galete 💬
Browse files

Change project

parent 587adc20
......@@ -2,6 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/finance/transaction/entries">
<file compressed="true">finance-date-entry.ui</file>
<file compressed="true">finance-entry-monetary.ui</file>
<file compressed="true">finance-monetary-entry.ui</file>
</gresource>
</gresources>
......@@ -46,39 +46,6 @@ enum {
static GParamSpec *properties[N_PROPS] = { NULL, };
static void
date_update (FinanceDateEntry *self)
{
GDateTime *date_time;
GDate date;
g_date_clear (&date, 1);
g_date_set_parse (&date, gtk_entry_get_text (GTK_ENTRY (self)));
if (!g_date_valid (&date))
{
date_time = g_date_time_new_now_local ();
finance_date_entry_set_date (self, date_time);
gtk_entry_set_text (GTK_ENTRY (self), "");
g_clear_pointer (&date_time, g_date_time_unref);
return;
}
date_time = g_date_time_new_local (g_date_get_year (&date),
g_date_get_month (&date),
g_date_get_day (&date),
0, 0, 0);
finance_date_entry_set_date (self, date_time);
g_clear_pointer (&date_time, g_date_time_unref);
}
static void
on_automatic_date_formatting (GtkEditable *editable,
const gchar *text,
......@@ -151,7 +118,7 @@ on_calendar_day_selected (GtkCalendar *calendar,
gtk_calendar_get_date (calendar, &year, &month, &day);
g_date_time_unref (self->date_time);
g_clear_pointer (&self->date_time, g_date_time_unref);
self->date_time = g_date_time_new_local (year,
month + 1,
......@@ -170,7 +137,40 @@ on_calendar_day_selected (GtkCalendar *calendar,
on_automatic_date_formatting,
self);
g_free (format_date);
g_clear_pointer (&format_date, g_free);
}
static void
finance_date_entry_update (FinanceDateEntry *self)
{
GDateTime *date_time;
GDate date;
g_date_clear (&date, 1);
g_date_set_parse (&date, gtk_entry_get_text (GTK_ENTRY (self)));
if (!g_date_valid (&date))
{
date_time = g_date_time_new_now_local ();
finance_date_entry_set_date (self, date_time);
gtk_entry_set_text (GTK_ENTRY (self), "");
g_clear_pointer (&date_time, g_date_time_unref);
return;
}
date_time = g_date_time_new_local (g_date_get_year (&date),
g_date_get_month (&date),
g_date_get_day (&date),
0, 0, 0);
finance_date_entry_set_date (self, date_time);
g_clear_pointer (&date_time, g_date_time_unref);
}
GtkWidget *
......@@ -193,7 +193,7 @@ static gboolean
finance_date_entry_focus_out_event (GtkWidget *widget,
GdkEventFocus *event)
{
date_update (FINANCE_DATE_ENTRY (widget));
finance_date_entry_update (FINANCE_DATE_ENTRY (widget));
return GTK_WIDGET_CLASS (finance_date_entry_parent_class)->focus_out_event (widget, event);
}
......@@ -391,3 +391,21 @@ finance_date_entry_set_formatting (FinanceDateEntry *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FORMATTING]);
}
/**
* finance_date_entry_clear:
* @self: a #FinanceDateEntry
*
* Restores the date to the initial value and sets the text to empty
*
* Since: 1.0
*/
void
finance_date_entry_clear (FinanceDateEntry *self)
{
g_return_if_fail (FINANCE_IS_DATE_ENTRY (self));
gtk_entry_set_text (GTK_ENTRY (self), "");
finance_date_entry_update (self);
}
......@@ -41,6 +41,8 @@ gboolean finance_date_entry_get_formatting (FinanceDateEntry *self);
void finance_date_entry_set_formatting (FinanceDateEntry *self,
gboolean formatting);
void finance_date_entry_clear (FinanceDateEntry *self);
G_END_DECLS
#endif /* __FINANCE_DATE_ENTRY_H__ */
/* finance-entry-monetary.c
/* finance-monetary-entry.c
*
* Copyright 2020 galetedanilo <galetedanilo@gmail.com>
* Copyright 2020 - 2021 galetedanilo <galetedanilo@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -21,7 +21,7 @@
#include "finance-config.h"
#include "finance-enums.h"
#include "finance-entry-monetary.h"
#include "finance-monetary-entry.h"
struct _FinanceEntryMonetary
{
......
/* finance-entry-monetary.h
/* finance-monetary-entry.h
*
* Copyright 2020 galetedanilo <galetedanilo@gmail.com>
* Copyright 2020 - 2021 galetedanilo <galetedanilo@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -18,44 +18,44 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef __FINANCE_ENTRY_MONETARY_H__
#define __FINANCE_ENTRY_MONETARY_H__
#ifndef __FINANCE_MONETARY_ENTRY_H__
#define __FINANCE_MONETARY_ENTRY_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define FINANCE_TYPE_ENTRY_MONETARY (finance_entry_monetary_get_type())
#define FINANCE_TYPE_MONETARY_ENTRY (finance_monetary_entry_get_type())
G_DECLARE_FINAL_TYPE (FinanceEntryMonetary, finance_entry_monetary, FINANCE, ENTRY_MONETARY, GtkEntry)
G_DECLARE_FINAL_TYPE (FinanceMonetaryEntry, finance_monetary_entry, FINANCE, MONETARY_ENTRY, GtkEntry)
GtkWidget* finance_entry_monetary_new (void);
GtkWidget* finance_monetary_entry_new (void);
gdouble finance_entry_monetary_get_amount (FinanceEntryMonetary *self);
gdouble finance_monetary_entry_get_amount (FinanceMonetaryEntry *self);
void finance_entry_monetary_set_amount (FinanceEntryMonetary *self,
gdouble amount);
void finance_monetary_entry_set_amount (FinanceMonetaryEntry *self,
gdouble amount);
gboolean finance_entry_monetary_get_currency_symbol (FinanceEntryMonetary *self);
gboolean finance_monetary_entry_get_currency_symbol (FinanceMonetaryEntry *self);
void finance_entry_monetary_set_currency_symbol (FinanceEntryMonetary *self,
gboolean currency_symbol);
void finance_monetary_entry_set_currency_symbol (FinanceMonetaryEntry *self,
gboolean currency_symbol);
gint finance_entry_monetary_get_decimal_places (FinanceEntryMonetary *self);
gint finance_monetary_entry_get_decimal_places (FinanceMonetaryEntry *self);
void finance_entry_monetary_set_decimal_places (FinanceEntryMonetary *self,
gint value);
void finance_monetary_entry_set_decimal_places (FinanceMonetaryEntry *self,
gint value);
gboolean finance_entry_monetary_get_formatting (FinanceEntryMonetary *self);
gboolean finance_monetary_entry_get_formatting (FinanceMonetaryEntry *self);
void finance_entry_monetary_set_formatting (FinanceEntryMonetary *self,
gboolean formatting);
void finance_monetary_entry_set_formatting (FinanceMonetaryEntry *self,
gboolean formatting);
gint finance_entry_monetary_get_symbol (FinanceEntryMonetary *self);
gint finance_monetary_entry_get_symbol (FinanceMonetaryEntry *self);
void finance_entry_monetary_set_symbol (FinanceEntryMonetary *self,
gint symbol);
void finance_monetary_entry_set_symbol (FinanceMonetaryEntry *self,
gint symbol);
G_END_DECLS
#endif /* __FINANCE_ENTRY_MONETARY_H__ */
#endif /* __FINANCE_MONETARY_ENTRY_H__ */
......@@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="FinanceEntryMonetary" parent="GtkEntry">
<template class="FinanceMonetaryEntry" parent="GtkEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="input-purpose">digits</property>
......
......@@ -6,5 +6,5 @@ built_sources += gnome.compile_resources(
sources += files(
'finance-date-entry.c',
'finance-entry-monetary.c',
'finance-monetary-entry.c',
)
/* finance-transaction-editor.c
*
* Copyright 2020 galetedanilo <galetedanilo@gmail.com>
* Copyright 2020 - 2021 galetedanilo <galetedanilo@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -100,7 +100,7 @@ on_combo_box_frequency_changed (GtkComboBox *widget,
gtk_spin_button_set_value (GTK_SPIN_BUTTON (self->spin_frequency_number), 2);
gtk_entry_set_text (GTK_ENTRY (self->entry_frequency_date), "");
finance_date_entry_clear (FINANCE_DATE_ENTRY (self->entry_frequency_date));
switch (frequency)
{
......@@ -355,7 +355,7 @@ finance_transaction_editor_class_init (FinanceTransactionEditorClass *klass)
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
g_type_ensure (FINANCE_TYPE_DATE_ENTRY);
g_type_ensure (FINANCE_TYPE_ENTRY_MONETARY);
g_type_ensure (FINANCE_TYPE_MONETARY_ENTRY);
object_class->finalize = finance_transaction_editor_finalize;
object_class->dispose = finance_transaction_editor_dispose;
......@@ -1181,8 +1181,7 @@ finance_transaction_editor_clear (FinanceTransactionEditor *self)
create_icon (self);
//Do not forget
finance_entry_monetary_set_amount (FINANCE_ENTRY_MONETARY (self->entry_amount), 0.0);
finance_date_entry_clear (FINANCE_DATE_ENTRY (self->entry_date));
gtk_text_buffer_set_text (GTK_TEXT_BUFFER (self->buffer_notes),
self->notes, -1);
......@@ -1190,8 +1189,6 @@ finance_transaction_editor_clear (FinanceTransactionEditor *self)
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combo_payment), 0);
gtk_combo_box_set_active (GTK_COMBO_BOX (self->combo_repeat), 0);
gtk_entry_set_text (GTK_ENTRY (self->entry_amount), "");
gtk_entry_set_text (GTK_ENTRY (self->entry_date), "");
gtk_entry_set_text (GTK_ENTRY (self->entry_name), "");
gtk_entry_set_text (GTK_ENTRY (self->entry_payee_name), "");
gtk_entry_set_text (GTK_ENTRY (self->entry_payment_info), "");
......
/* finance-transaction-editor.h
*
* Copyright 2020 galetedanilo <galetedanilo@gmail.com>
* Copyright 2020 - 2021 galetedanilo <galetedanilo@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -24,7 +24,7 @@
#include <gtk/gtk.h>
#include "finance-date-entry.h"
#include "finance-entry-monetary.h"
#include "finance-monetary-entry.h"
#include "finance-utils.h"
G_BEGIN_DECLS
......
......@@ -91,7 +91,7 @@
</packing>
</child>
<child>
<object class="FinanceEntryMonetary" id="entry_amount">
<object class="FinanceMonetaryEntry" id="entry_amount">
<property name="height-request">40</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
......
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