Commit 2088d57d authored by Danilo Galete's avatar Danilo Galete 💬
Browse files

Change Project

parent 50443b28
/* finance-controller-transactions.c
*
* Copyright 2021 Danilo Fernandes Galete <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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "finance-controller-transactions.h"
struct _FinanceControllerTransactions
{
GObject parent_instance;
/* The Objects */
GObject *pane;
GObject *view_transactions;
GPtrArray *childs;
GPtrArray *rows;
};
G_DEFINE_TYPE (FinanceControllerTransactions, finance_controller_transactions, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_PANE,
PROP_VIEW,
N_PROPS
};
static GParamSpec *properties [N_PROPS] = { NULL, };
static void
finance_controller_transactions_finalize (GObject *object)
{
FinanceControllerTransactions *self = (FinanceControllerTransactions *)object;
g_clear_object (&self->pane);
g_clear_object (&self->view_transactions);
G_OBJECT_CLASS (finance_controller_transactions_parent_class)->finalize (object);
}
static void
finance_controller_transactions_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
FinanceControllerTransactions *self = FINANCE_CONTROLLER_TRANSACTIONS (object);
switch (prop_id)
{
case PROP_PANE:
g_value_set_object (value, self->pane);
break;
case PROP_VIEW:
g_value_set_object (value, self->view_transactions);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
finance_controller_transactions_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
FinanceControllerTransactions *self = FINANCE_CONTROLLER_TRANSACTIONS (object);
switch (prop_id)
{
case PROP_PANE:
g_assert (self->pane == NULL);
self->pane = g_value_get_object (value);
break;
case PROP_VIEW:
g_assert (self->view_transactions == NULL);
self->view_transactions = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
finance_controller_transactions_class_init (FinanceControllerTransactionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = finance_controller_transactions_finalize;
object_class->get_property = finance_controller_transactions_get_property;
object_class->set_property = finance_controller_transactions_set_property;
/**
* FinanceControllerTransaction::pane:
*
* Sets pane
*/
properties[PROP_PANE] = g_param_spec_object ("pane",
"The Pane",
"The left pane in the main window",
FINANCE_TYPE_PANE,
G_PARAM_READWRITE);
/**
* FinanceControllerTransaction::view:
*
* Sets view
*/
properties[PROP_VIEW] = g_param_spec_object ("view",
"The View",
"The view transactions",
FINANCE_TYPE_VIEW,
G_PARAM_READWRITE);
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
finance_controller_transactions_init (FinanceControllerTransactions *self)
{
self->child = g_ptr_array_new
}
void
finance_controller_transactions_startup (FinanceControllerTransactions *self)
{
for(int x = 0; x < 2; x++)
{
//this is a test
GtkWidget *row = finance_pane_row_new ();
finance_pane_row_set_icon (row, "TR");
finance_pane_row_set_title (row, "Transaction Name Title");
finance_pane_row_set_amount (row, "R$2,540.45");
finance_pane_add_row (FINANCE_PANE (self->pane), row);
}
}
/* finance-controller-transactions.h
*
* Copyright 2021 Danilo Fernandes Galete <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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef __FINANCE_CONTROLLER_TRANSACTIONS_H__
#define __FINANCE_CONTROLLER_TRANSACTIONS_H__
#include <glib-object.h>
#include "finance-pane.h"
#include "finance-pane-row.h"
#include "finance-view.h"
#include "finance-view-child.h"
G_BEGIN_DECLS
#define FINANCE_TYPE_CONTROLLER_TRANSACTIONS (finance_controller_transactions_get_type ())
G_DECLARE_FINAL_TYPE (FinanceControllerTransactions, finance_controller_transactions, FINANCE, CONTROLLER_TRANSACTIONS, GObject)
void finance_controller_transactions_startup (FinanceControllerTransactions *self);
G_END_DECLS
#endif /* ___FINANCE_CONTROLLER_TRANSACTIONS_H__ */
sources += files(
'finance-controller-transactions.c',
)
finance_incs += include_directories('controllers')
subdir('controllers')
......@@ -19,6 +19,7 @@
#include <glib/gi18n.h>
#include "finance-config.h"
#include "finance-view.h"
#include "finance-window.h"
struct _FinanceWindow
......@@ -32,6 +33,7 @@ struct _FinanceWindow
GtkWidget *header_bar_squeezer;
GtkWidget *label_title;
GtkWidget *leaflet;
GtkWidget *pane;
GtkWidget *scrolled_window_transaction;
GtkWidget *stack;
GtkWidget *stack_switcher_top;
......@@ -40,6 +42,7 @@ struct _FinanceWindow
GtkWidget *view_transactions;
GSettings *settings;
GObject *controller_transactions;
};
static void finance_window_prepare_new_transaction (FinanceWindow *self);
......@@ -141,6 +144,7 @@ finance_window_dispose (GObject *object)
FinanceWindow *self = FINANCE_WINDOW (object);
g_clear_object (&self->settings);
g_clear_object (&self->controller_transactions);
G_OBJECT_CLASS (finance_window_parent_class)->dispose (object);
}
......@@ -165,6 +169,7 @@ finance_window_class_init (FinanceWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, header_bar_squeezer);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, label_title);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, leaflet);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, pane);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, scrolled_window_transaction);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, stack);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, stack_switcher_top);
......@@ -189,4 +194,11 @@ finance_window_init (FinanceWindow *self)
hdy_init();
self->settings = g_settings_new ("org.gnome.finance");
self->controller_transactions = g_object_new (FINANCE_TYPE_CONTROLLER_TRANSACTIONS,
"pane", self->pane,
"view", self->view_transactions,
NULL);
finance_controller_transactions_startup (self->controller_transactions);
}
......@@ -22,6 +22,7 @@
#include <gtk/gtk.h>
#include <handy.h>
#include "finance-controller-transactions.h"
#include "finance-pane.h"
#include "finance-transaction.h"
#include "finance-view-transactions.h"
......
......@@ -138,6 +138,12 @@ on_combo_repeat_changed (GtkComboBox *widget,
static void
finance_transaction_responsive_layout (FinanceTransaction *self)
{
gtk_widget_set_visible (self->image_icon, !self->mobile);
gtk_widget_set_visible (self->label_category, !self->mobile);
gtk_widget_set_visible (self->label_notes, !self->mobile);
gtk_widget_set_visible (self->label_payment, !self->mobile);
gtk_widget_set_visible (self->label_repeat, !self->mobile);
if (self->mobile)
{
gtk_widget_set_size_request (self->combo_category, -1, 40);
......@@ -151,11 +157,6 @@ finance_transaction_responsive_layout (FinanceTransaction *self)
gtk_widget_set_size_request (self->entry_payee_name, -1, 40);
gtk_widget_set_size_request (self->entry_payment_info, -1, 40);
gtk_widget_set_size_request (self->entry_date, -1, 40);
gtk_widget_set_visible (self->image_icon, FALSE);
gtk_widget_set_visible (self->label_category, FALSE);
gtk_widget_set_visible (self->label_notes, FALSE);
gtk_widget_set_visible (self->label_payment, FALSE);
gtk_widget_set_visible (self->label_repeat, FALSE);
gtk_widget_set_size_request (self->spin_frequency_number, -1, 40);
return;
......@@ -172,11 +173,6 @@ finance_transaction_responsive_layout (FinanceTransaction *self)
gtk_widget_set_size_request (self->entry_payee_name, -1, 50);
gtk_widget_set_size_request (self->entry_payment_info, -1, 50);
gtk_widget_set_size_request (self->entry_date, -1, 50);
gtk_widget_set_visible (self->image_icon, TRUE);
gtk_widget_set_visible (self->label_category, TRUE);
gtk_widget_set_visible (self->label_notes, TRUE);
gtk_widget_set_visible (self->label_payment, TRUE);
gtk_widget_set_visible (self->label_repeat, TRUE);
gtk_widget_set_size_request (self->spin_frequency_number, -1, 50);
}
......@@ -373,7 +369,7 @@ finance_transaction_class_init (FinanceTransactionClass *klass)
*/
properties[PROP_ICON] = g_param_spec_string ("icon",
"Icon",
"TThe two letters that are part of the icon image",
"The two letters that are part of the icon image",
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
......@@ -559,7 +555,7 @@ finance_transaction_init (FinanceTransaction *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
self->icon = g_strdup ("");
self->icon = g_strdup ("NW");
self->color = finance_utils_random_rgba_color ();
......@@ -1121,7 +1117,9 @@ finance_transaction_set_notes (FinanceTransaction *self,
* finance_transaction_get_mobile:
* @self: a #FinanceTransaction instance.
*
* Returns:
* Gets whether the mobile layout is in its “on” or “off” state.
*
* Returns: %TRUE if the mobile layout is active, and %FALSE otherwise.
*
* Since: 1.0
*/
......@@ -1138,6 +1136,7 @@ finance_transaction_get_mobile (FinanceTransaction *self)
* @self: a #FinanceTransaction object.
* @mobile: a #gboolean to set it to.
*
* Change mobile layout states. %TRUE if the mobile layout is active, and %FALSE otherwise.
*
* Since: 1.0
*/
......@@ -1155,35 +1154,39 @@ finance_transaction_set_mobile (FinanceTransaction *self,
}
/**
* finance_transaction_clear:
* finance_transaction_create_new:
* @self: a #FinanceTransaction object.
*
* Clears all data entry fields.
* Clears all data entry fields to create a new transaction.
*
* Since: 1.0
*/
/* void */
/* finance_transaction_clear (FinanceTransaction *self) */
/* { */
/* g_return_if_fail (FINANCE_IS_TRANSACTION (self)); */
/* g_free (self->icon); */
/* g_free (self->notes); */
/* self->icon = g_strdup ("NT"); */
/* self->notes = g_strdup (""); */
/* self->color = finance_utils_random_rgba_color (); */
/* gtk_text_buffer_set_text (GTK_TEXT_BUFFER (self->notes_buffer), */
/* self->notes, -1); */
/* create_icon (self); */
/* gtk_entry_set_text (GTK_ENTRY (self->name), ""); */
/* gtk_entry_set_text (GTK_ENTRY (self->amount), ""); */
/* gtk_entry_set_text (GTK_ENTRY (self->date), ""); */
/* gtk_entry_set_text (GTK_ENTRY (self->payee_name), ""); */
/* gtk_combo_box_set_active (GTK_COMBO_BOX (self->payment), 0); */
/* gtk_entry_set_text (GTK_ENTRY (self->payment_info), ""); */
/* gtk_combo_box_set_active (GTK_COMBO_BOX (self->repeat), 0); */
/* } */
void
finance_transaction_create_new (FinanceTransaction *self)
{
g_return_if_fail (FINANCE_IS_TRANSACTION (self));
g_free (self->icon);
g_free (self->notes);
gdk_rgba_free (self->color);
self->icon = g_strdup ("NW");
self->notes = g_strdup ("");
self->color = finance_utils_random_rgba_color ();
create_icon (self);
gtk_text_buffer_set_text (GTK_TEXT_BUFFER (self->buffer_notes),
self->notes, -1);
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), "");
}
......@@ -100,13 +100,13 @@ const gchar * finance_transaction_get_notes (FinanceTransaction *sel
void finance_transaction_set_notes (FinanceTransaction *self,
const gchar *notes);
void finance_transaction_clear (FinanceTransaction *self);
gboolean finance_transaction_get_mobile (FinanceTransaction *self);
void finance_transaction_set_mobile (FinanceTransaction *self,
gboolean mobile);
void finance_transaction_create_new (FinanceTransaction *self);
G_END_DECLS
#endif /* __FINANCE_TRANSACTION_H__ */
......@@ -18,28 +18,52 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "finance-view.h"
#include "finance-view-transactions.h"
struct _FinanceViewTransactions
{
GtkBox parent_instance;
};
GtkBox parent_instance;
G_DEFINE_TYPE (FinanceViewTransactions, finance_view_transactions, GTK_TYPE_BOX)
/* The Widgets */
GtkWidget *flow_box;
};
enum {
PROP_0,
N_PROPS
};
static void finance_view_interface_init (FinanceViewInterface *iface);
static GParamSpec *properties [N_PROPS];
G_DEFINE_TYPE_WITH_CODE (FinanceViewTransactions, finance_view_transactions, GTK_TYPE_BOX,
G_IMPLEMENT_INTERFACE (FINANCE_TYPE_VIEW, finance_view_interface_init))
/* FinanceView implementation */
static void
finance_view_transactions_insert_child (FinanceView *view,
GtkWidget *child)
{
FinanceViewTransactions *self = FINANCE_VIEW_TRANSACTIONS (view);
gtk_flow_box_insert (GTK_FLOW_BOX (self->flow_box), child, -1);
}
GtkWidget *
finance_view_transactions_new (void)
{
return g_object_new (FINANCE_TYPE_VIEW_TRANSACTIONS, NULL);
}
static void
finance_view_interface_init (FinanceViewInterface *iface)
{
iface->insert_child = finance_view_transactions_insert_child;
}
static void
finance_view_transactions_finalize (GObject *object)
{
......@@ -81,14 +105,21 @@ finance_view_transactions_set_property (GObject *object,
static void
finance_view_transactions_class_init (FinanceViewTransactionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = finance_view_transactions_finalize;
object_class->get_property = finance_view_transactions_get_property;
object_class->set_property = finance_view_transactions_set_property;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/views/finance-view-transactions.ui");
object_class->finalize = finance_view_transactions_finalize;
object_class->get_property = finance_view_transactions_get_property;
object_class->set_property = finance_view_transactions_set_property;
/* The Widgets */
gtk_widget_class_bind_template_child (widget_class, FinanceViewTransactions, flow_box);
}
static void
finance_view_transactions_init (FinanceViewTransactions *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
......@@ -9,10 +9,10 @@
<object class="GtkSearchEntry" id="search_entry">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="margin-start">15</property>
<property name="margin-end">15</property>
<property name="margin-top">8</property>
<property name="margin-bottom">8</property>
<property name="primary-icon-name">edit-find-symbolic</property>
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
......
/* finance-view.c
*
* Copyright 2021 Danilo Fernandes Galete <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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "finance-view.h"
G_DEFINE_INTERFACE (FinanceView, finance_view, G_TYPE_OBJECT)
static void
finance_view_default_init (FinanceViewInterface *iface)
{
}
void
finance_view_insert_child (FinanceView *view,
GtkWidget *widget)
{
g_return_if_fail (FINANCE_IS_VIEW (view));
g_return_if_fail (FINANCE_VIEW_GET_IFACE (view)->insert_child);
FINANCE_VIEW_GET_IFACE (view)->insert_child (view, widget);
}
/* finance-view.h
*
* Copyright 2021 Danilo Fernandes Galete <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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef __FINANCE_VIEW_H__
#define __FINANCE_VIEW_H__
#include <gtk/gtk.h>
G_BEGIN_DECLS
#define FINANCE_TYPE_VIEW (finance_view_get_type ())
G_DECLARE_INTERFACE (FinanceView, finance_view, FINANCE, VIEW, GtkWidget)
struct _FinanceViewInterface
{
GTypeInterface parent;
void (*insert_child) (FinanceView *view,
GtkWidget *child);
};
void finance_view_insert_child (FinanceView *view,
GtkWidget *child);
G_END_DECLS
#endif /* __FINANCE_VIEW_H__ */
......@@ -5,6 +5,7 @@ built_sources += gnome.compile_resources(
)
sources += files(
'finance-view.c',
'finance-view-child.c',
'finance-view-transactions.c',
)