Commit 937aa6fd authored by Danilo Galete's avatar Danilo Galete 💬
Browse files

Rename: finance-transaction-view to finance-transactions-view

parent d43ab056
/* finance-transaction-view-controller.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-transaction-view-controller.h"
struct _FinanceTransactionViewController
{
GObject parent_instance;
/* The Objects */
GObject *pane;
GObject *view;
};
G_DEFINE_TYPE (FinanceTransactionViewController, finance_transaction_view_controller, G_TYPE_OBJECT)
enum {
PROP_0,
PROP_PANE,
PROP_VIEW,
N_PROPS
};
static GParamSpec *properties [N_PROPS] = { NULL, };
static void
finance_transaction_view_controller_finalize (GObject *object)
{
FinanceTransactionViewController *self = (FinanceTransactionViewController *)object;
g_clear_object (&self->pane);
g_clear_object (&self->view);
G_OBJECT_CLASS (finance_transaction_view_controller_parent_class)->finalize (object);
}
static void
finance_transaction_view_controller_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
FinanceTransactionViewController *self = FINANCE_TRANSACTION_VIEW_CONTROLLER (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);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
finance_transaction_view_controller_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
FinanceTransactionViewController *self = FINANCE_TRANSACTION_VIEW_CONTROLLER (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 == NULL);
self->view = g_value_dup_object (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
finance_transaction_view_controller_class_init (FinanceTransactionViewControllerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = finance_transaction_view_controller_finalize;
object_class->get_property = finance_transaction_view_controller_get_property;
object_class->set_property = finance_transaction_view_controller_set_property;
/**
* FinanceTransactionViewController::pane:
*
* Sets pane
*/
properties[PROP_PANE] = g_param_spec_object ("pane",
"The Pane",
"The left pane in the main window",
FINANCE_TYPE_LEFT_PANEL,
G_PARAM_READWRITE);
/**
* FinancerTransactionViewControlle::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_transaction_view_controller_init (FinanceTransactionViewController *self)
{
}
void
finance_transaction_view_controller_startup (FinanceTransactionViewController *self)
{
for(int x = 0; x < 1; x++)
{
//this is a test
GtkWidget *summary = finance_summary_child_new ();
GtkWidget *row = finance_transaction_row_new ();
GdkRGBA *color = finance_utils_random_rgba_color ();
g_object_bind_property ((gpointer)summary,
"icon-text",
(gpointer)row,
"icon-text",
G_BINDING_DEFAULT);
g_object_bind_property ((gpointer)summary,
"color",
(gpointer)row,
"color",
G_BINDING_DEFAULT);
g_object_bind_property ((gpointer)summary,
"name",
(gpointer)row,
"title",
G_BINDING_DEFAULT);
g_object_bind_property ((gpointer)summary,
"amount",
(gpointer)row,
"amount",
G_BINDING_DEFAULT);
g_object_bind_property ((gpointer)summary,
"selected",
(gpointer)row,
"selected",
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
finance_summary_child_set_name (FINANCE_SUMMARY_CHILD (summary),
"Cadastro para Teste");
finance_summary_child_set_amount (FINANCE_SUMMARY_CHILD (summary),
"R$ 500,00");
finance_view_add_child (FINANCE_VIEW (self->view), summary);
finance_left_panel_add_row (FINANCE_LEFT_PANEL (self->pane), row);
g_clear_pointer (&color, gdk_rgba_free);
}
}
/* finance-transaction-view-controller.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_TRANSACTION_VIEW_CONTROLLER_H__
#define __FINANCE_TRANSACTION_VIEW_CONTROLLER_H__
#include <glib-object.h>
#include "finance-left-panel.h"
#include "finance-summary-child.h"
#include "finance-transaction-row.h"
#include "finance-view.h"
G_BEGIN_DECLS
#define FINANCE_TYPE_TRANSACTION_VIEW_CONTROLLER (finance_transaction_view_controller_get_type ())
G_DECLARE_FINAL_TYPE (FinanceTransactionViewController, finance_transaction_view_controller, FINANCE, TRANSACTION_VIEW_CONTROLLER, GObject)
void finance_transaction_view_controller_start (FinanceTransactionViewController *self);
G_END_DECLS
#endif /* ___FINANCE_TRANSACTION_VIEW_CONTROLLER_H__ */
sources += files(
'finance-transaction-view-controller.c',
)
finance_incs += include_directories('controllers')
subdir('controllers')
......@@ -38,11 +38,10 @@ struct _FinanceWindow
GtkWidget *stack;
GtkWidget *stack_switcher_top;
GtkWidget *transaction_editor;
GtkWidget *transaction_view;
GtkWidget *transactions_view;
GtkWidget *view_switcher_bottom;
GSettings *settings;
GObject *controller_transactions;
};
static void finance_window_prepare_new_transaction (FinanceWindow *self);
......@@ -143,7 +142,6 @@ 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);
}
......@@ -155,7 +153,7 @@ finance_window_class_init (FinanceWindowClass *klass)
g_type_ensure (FINANCE_TYPE_LEFT_PANEL);
g_type_ensure (FINANCE_TYPE_TRANSACTION_EDITOR);
g_type_ensure (FINANCE_TYPE_TRANSACTION_VIEW);
g_type_ensure (FINANCE_TYPE_TRANSACTIONS_VIEW);
G_OBJECT_CLASS (klass)->dispose = finance_window_dispose;
......@@ -173,7 +171,7 @@ finance_window_class_init (FinanceWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, stack);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, stack_switcher_top);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, transaction_editor);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, transaction_view);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, transactions_view);
gtk_widget_class_bind_template_child (widget_class, FinanceWindow, view_switcher_bottom);
/* The CallBacks */
......@@ -194,10 +192,4 @@ finance_window_init (FinanceWindow *self)
self->settings = g_settings_new ("org.gnome.finance");
self->controller_transactions = g_object_new (FINANCE_TYPE_TRANSACTION_VIEW_CONTROLLER,
"pane", self->left_panel,
"view", self->transaction_view,
NULL);
finance_transaction_view_controller_startup (self->controller_transactions);
}
......@@ -22,10 +22,9 @@
#include <gtk/gtk.h>
#include <handy.h>
#include "finance-transaction-view-controller.h"
#include "finance-left-panel.h"
#include "finance-transaction-editor.h"
#include "finance-transaction-view.h"
#include "finance-transactions-view.h"
G_BEGIN_DECLS
......
......@@ -430,7 +430,7 @@
</packing>
</child>
<child>
<object class="FinanceTransactionView" id="transaction_view">
<object class="FinanceTransactionsView" id="transactions_view">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
......
......@@ -32,10 +32,10 @@ struct _FinanceTransactionsSummary
GtkWidget *label_amount;
GtkWidget *label_category;
GtkWidget *label_date;
GtkWidget *label_name;
GtkWidget *label_payee_name;
GtkWidget *label_payment;
GtkWidget *label_repeat;
GtkWidget *label_title;
gchar *icon_name;
......@@ -50,11 +50,11 @@ enum {
PROP_CATEGORY,
PROP_DATE,
PROP_ICON_NAME,
PROP_NAME,
PROP_PAYEE_NAME,
PROP_PAYMENT,
PROP_REPEAT,
PROP_SELECTED,
PROP_TITLE,
PROP_TRANSACTION,
N_PROPS
};
......@@ -114,10 +114,6 @@ finance_transactions_summary_get_property (GObject *object,
g_value_set_string (value, finance_transactions_summary_get_icon_name (self));
break;
case PROP_NAME:
g_value_set_string (value, finance_transactions_summary_get_name (self));
break;
case PROP_PAYEE_NAME:
g_value_set_string (value, finance_transactions_summary_get_payee_name (self));
break;
......@@ -134,6 +130,10 @@ finance_transactions_summary_get_property (GObject *object,
g_value_set_boolean (value, finance_transactions_summary_get_selected (self));
break;
case PROP_TITLE:
g_value_set_string (value, finance_transactions_summary_get_title (self));
break;
case PROP_TRANSACTION:
g_value_set_enum (value, finance_transactions_summary_get_transaction (self));
break;
......@@ -170,10 +170,6 @@ finance_transactions_summary_set_property (GObject *object,
finance_transactions_summary_set_icon_name (self, g_value_get_string (value));
break;
case PROP_NAME:
finance_transactions_summary_set_name (self, g_value_get_string (value));
break;
case PROP_PAYEE_NAME:
finance_transactions_summary_set_payee_name (self, g_value_get_string (value));
break;
......@@ -190,6 +186,10 @@ finance_transactions_summary_set_property (GObject *object,
finance_transactions_summary_set_selected (self, g_value_get_boolean (value));
break;
case PROP_TITLE:
finance_transactions_summary_set_title (self, g_value_get_string (value));
break;
case PROP_TRANSACTION:
finance_transactions_summary_set_transaction (self, g_value_get_enum (value));
break;
......@@ -254,17 +254,6 @@ finance_transactions_summary_class_init (FinanceTransactionsSummaryClass *klass)
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* FinanceTransactionsSummary::name:
*
* The transaction name
*/
properties[PROP_NAME] = g_param_spec_string ("name",
"Name",
"The transaction name",
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* FinanceTransactionsSummary::payee_name:
*
......@@ -309,6 +298,17 @@ finance_transactions_summary_class_init (FinanceTransactionsSummaryClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* FinanceTransactionsSummary::title:
*
* The transaction title
*/
properties[PROP_TITLE] = g_param_spec_string ("title",
"title",
"The transaction title",
NULL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* FinanceTransactionsSummary::transaction:
*
......@@ -331,10 +331,10 @@ finance_transactions_summary_class_init (FinanceTransactionsSummaryClass *klass)
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_amount);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_category);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_date);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_name);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_payee_name);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_payment);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_repeat);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionsSummary, label_title);
/* The CallBacks */
gtk_widget_class_bind_template_callback (widget_class, on_check_button_toggled);
......@@ -513,47 +513,6 @@ finance_transactions_summary_set_icon_name (FinanceTransactionsSummary *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON_NAME]);
}
/**
* finance_transactions_summary_get_name:
* @self: a #FinanceTransactionsSummary
*
* Returns the transaction name
*
* Returns: The transaction name as a string, or %NULL.
* This string points to internally allocated storage in the object
* and must not be freed, modified or stored.
*
* Since: 1.0
*/
const gchar *
finance_transactions_summary_get_name (FinanceTransactionsSummary *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTIONS_SUMMARY (self), NULL);
return gtk_label_get_text (GTK_LABEL (self->label_name));
}
/**
* finance_transactions_summary_set_name:
* @self: a #FinanceTransactionsSummary
* @name: the name to set, as a string
*
* Sets the transaction name, replacing the current contents.
*
* Since: 1.0
*/
void
finance_transactions_summary_set_name (FinanceTransactionsSummary *self,
const gchar *name)
{
g_return_if_fail (FINANCE_IS_TRANSACTIONS_SUMMARY (self));
g_return_if_fail (name == NULL);
gtk_label_set_text (GTK_LABEL (self->label_name), name);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_NAME]);
}
/**
* finance_transactions_summary_get_payee_name:
* @self: a #FinanceTransactionsSummary
......@@ -715,6 +674,47 @@ finance_transactions_summary_set_selected (FinanceTransactionsSummary *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED]);
}
/**
* finance_transactions_summary_get_title:
* @self: a #FinanceTransactionsSummary
*
* Returns the transaction title
*
* Returns: The transaction title as a string, or %NULL.
* This string points to internally allocated storage in the object
* and must not be freed, modified or stored.
*
* Since: 1.0
*/
const gchar *
finance_transactions_summary_get_title (FinanceTransactionsSummary *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTIONS_SUMMARY (self), NULL);
return gtk_label_get_text (GTK_LABEL (self->label_title));
}
/**
* finance_transactions_summary_set_title:
* @self: a #FinanceTransactionsSummary
* @title: the title to set, as a string
*
* Sets the transaction title, replacing the current contents.
*
* Since: 1.0
*/
void
finance_transactions_summary_set_title (FinanceTransactionsSummary *self,
const gchar *title)
{
g_return_if_fail (FINANCE_IS_TRANSACTIONS_SUMMARY (self));
g_return_if_fail (title == NULL);
gtk_label_set_text (GTK_LABEL (self->label_title), title);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
}
/**
* finance_transactions_summary_get_transaction:
* @self: a #FinanceTransactionsSummary
......
......@@ -66,7 +66,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="label_name">
<object class="GtkLabel" id="label_title">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
......
......@@ -56,11 +56,20 @@ finance_view_interface_init (FinanceViewInterface *iface)
iface->add_child = finance_transactions_view_add_child;
}
static void
finance_transactions_view_dispose (GObject *object)
{
G_OBJECT_CLASS (finance_transactions_view_parent_class)->dispose (object);
}
static void
finance_transactions_view_class_init (FinanceTransactionsViewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = finance_transactions_view_dispose;
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/views/transactions/finance-transactions-view.ui");
/* The Widgets */
......@@ -71,4 +80,10 @@ static void
finance_transactions_view_init (FinanceTransactionsView *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
for (int x = 0; x < 10; x++) {
GtkWidget *child = finance_transactions_summary_new ();
gtk_flow_box_insert (GTK_FLOW_BOX (self->flow_box), child, 1);
}
}
......@@ -23,6 +23,8 @@
#include <gtk/gtk.h>
#include "finance-transactions-summary.h"
G_BEGIN_DECLS
#define FINANCE_TYPE_TRANSACTIONS_VIEW (finance_transactions_view_get_type())
......
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