Commit 309dd106 authored by Danilo Galete's avatar Danilo Galete 💬
Browse files

Change project

parent 18c6b363
......@@ -143,22 +143,55 @@ finance_controller_transactions_init (FinanceControllerTransactions *self)
void
finance_controller_transactions_startup (FinanceControllerTransactions *self)
{
for(int x = 0; x < 200; x++)
for(int x = 0; x < 5; x++)
{
//this is a test
GtkWidget *summary = finance_child_summary_new ();
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_child_summary_set_name (summary, "Teste");
GdkRGBA *color = finance_utils_random_rgba_color ();
g_object_bind_property ((gpointer)summary,
"icon",
(gpointer)row,
"icon",
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-string",
(gpointer)row,
"amount",
G_BINDING_DEFAULT);
finance_child_summary_set_color (FINANCE_CHILD_SUMMARY (summary),
color);
finance_child_summary_set_icon (FINANCE_CHILD_SUMMARY (summary), "ID");
finance_child_summary_set_name (FINANCE_CHILD_SUMMARY (summary),
"Cadastro para Teste");
finance_child_summary_set_amount_string (FINANCE_CHILD_SUMMARY (summary),
"R$ 500,00");
finance_view_insert_child (FINANCE_VIEW (self->view_transactions), summary);
finance_pane_prepend_row (FINANCE_PANE (self->pane), row);
g_clear_pointer (&color, gdk_rgba_free);
}
}
......@@ -23,10 +23,11 @@
#include <glib-object.h>
#include "finance-child-summary.h"
#include "finance-pane.h"
#include "finance-pane-row.h"
#include "finance-view.h"
#include "finance-child-summary.h"
#include "finance-utils.h"
G_BEGIN_DECLS
......
......@@ -20,6 +20,19 @@
#include "finance-enum-types.h"
// /**
// * FinanceTransaction:
// * @FINANCE_CREDIT:
// * @FINANCE_DEBIT:
// *
// * Enum with available transactions type
// */
// typedef enum
// {
// FINANCE_CREDIT,
// FINANCE_DEBIT,
// } FinanceTransaction;
/**
* FinanceRepeat:
* @FINANCE_NO_REPEAT:
......
......@@ -33,7 +33,7 @@ struct _FinanceWindow
GtkWidget *header_bar_squeezer;
GtkWidget *label_title;
GtkWidget *leaflet;
GtkWidget *pane;
GtkWidget *left_panel;
GtkWidget *scrolled_window_transaction;
GtkWidget *stack;
GtkWidget *stack_switcher_top;
......@@ -154,7 +154,7 @@ finance_window_class_init (FinanceWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
g_type_ensure (FINANCE_TYPE_PANE);
g_type_ensure (FINANCE_TYPE_LEFT_PANEL);
g_type_ensure (FINANCE_TYPE_TRANSACTION);
g_type_ensure (FINANCE_TYPE_VIEW_TRANSACTIONS);
......@@ -169,7 +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, left_panel);
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);
......
......@@ -23,7 +23,7 @@
#include <handy.h>
#include "finance-controller-transactions.h"
#include "finance-pane.h"
#include "finance-panel.h"
#include "finance-transaction.h"
#include "finance-view-transactions.h"
......
......@@ -281,7 +281,7 @@
</packing>
</child>
<child>
<object class="FinancePane" id="pane">
<object class="FinanceLeftPanel" id="left_panel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
......
finance_incs += include_directories('transaction')
finance_incs += include_directories('pane')
finance_incs += include_directories('panel')
finance_incs += include_directories('views')
built_sources += gnome.compile_resources(
......@@ -15,6 +15,6 @@ sources += files(
'finance-window.c',
)
subdir('pane')
subdir('panel')
subdir('transaction')
subdir('views')
built_sources += gnome.compile_resources(
'pane-resources',
'pane.gresource.xml',
c_name: 'pane',
)
sources += files(
'finance-pane.c',
'finance-pane-row.c',
)
/* finance-pane.c
/* finance-left-panel.c
*
* Copyright 2021 galetedanilo <galetedanilo@gmail.com>
*
......@@ -18,9 +18,9 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "finance-pane.h"
#include "finance-left-panel.h"
struct _FinancePane
struct _FinanceLeftPanel
{
GtkBox parent_instance;
......@@ -33,15 +33,15 @@ struct _FinancePane
GtkSortType sort;
};
G_DEFINE_TYPE (FinancePane, finance_pane, GTK_TYPE_BOX)
G_DEFINE_TYPE (FinanceLeftPanel, finance_left_panel, GTK_TYPE_BOX)
static gboolean
listbox_list_func (GtkListBoxRow *row,
gpointer user_data)
{
FinancePane *self = FINANCE_PANE (user_data);
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
if (strcasestr (finance_pane_row_get_title (FINANCE_PANE_ROW (row)),
if (strcasestr (finance_transaction_row_get_title (FINANCE_TRANSACTION_ROW (row)),
gtk_entry_get_text (GTK_ENTRY (self->search))))
return TRUE;
......@@ -54,41 +54,40 @@ listbox_sort_func (GtkListBoxRow *row1,
GtkListBoxRow *row2,
gpointer user_data)
{
FinancePane *self = FINANCE_PANE (user_data);
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
if (self->sort == GTK_SORT_ASCENDING)
return strcasecmp (finance_pane_row_get_title (FINANCE_PANE_ROW (row1)),
finance_pane_row_get_title (FINANCE_PANE_ROW (row2)));
return strcasecmp (finance_transaction_row_get_title (FINANCE_TRANSACTION_ROW (row1)),
finance_transaction_row_get_title (FINANCE_TRANSACTION_ROW (row2)));
return -1 * strcasecmp (finance_pane_row_get_title (FINANCE_PANE_ROW (row1)),
finance_pane_row_get_title (FINANCE_PANE_ROW (row2)));
return -1 * strcasecmp (finance_transaction_row_get_title (FINANCE_TRANSACTION_ROW (row1)),
finance_transaction_row_get_title (FINANCE_TRANSACTION_ROW (row2)));
}
static void
on_list_box_row_activated (GtkListBox *box,
GtkListBoxRow *row,
gpointer user_data)
{
FinancePane *self = FINANCE_PANE (user_data);
}
static void
on_pane_search_changed (GtkSearchEntry *entry,
gpointer user_data)
on_left_panel_search_changed (GtkSearchEntry *entry,
gpointer user_data)
{
FinancePane *self = FINANCE_PANE (user_data);
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
(void)entry;
gtk_list_box_invalidate_filter (GTK_LIST_BOX (self->list));
}
static void
on_list_box_row_activated (GtkListBox *box,
GtkListBoxRow *row,
gpointer user_data)
{
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
}
static void
on_sort_ascending_clicked (GtkButton *button,
gpointer user_data)
{
FinancePane *self = FINANCE_PANE (user_data);
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
(void)button;
......@@ -104,7 +103,7 @@ static void
on_sort_descending_clicked (GtkButton *button,
gpointer user_data)
{
FinancePane *self = FINANCE_PANE (user_data);
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
(void)button;
......@@ -117,35 +116,35 @@ on_sort_descending_clicked (GtkButton *button,
}
GtkWidget *
finance_pane_new (void)
finance_left_panel_new (void)
{
return g_object_new (FINANCE_TYPE_PANE, NULL);
return g_object_new (FINANCE_TYPE_LEFT_PANEL, NULL);
}
static void
finance_pane_class_init (FinancePaneClass *klass)
finance_left_panel_class_init (FinanceLeftPanelClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
g_type_ensure (FINANCE_TYPE_PANE_ROW);
g_type_ensure (FINANCE_TYPE_TRANSACTION_ROW);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/pane/finance-pane.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/panel/finance-left-panel.ui");
/* The Widgets */
gtk_widget_class_bind_template_child (widget_class, FinancePane, list);
gtk_widget_class_bind_template_child (widget_class, FinancePane, search);
gtk_widget_class_bind_template_child (widget_class, FinancePane, sort_ascending);
gtk_widget_class_bind_template_child (widget_class, FinancePane, sort_descending);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftfPanel, list);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftfPanel, search);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftfPanel, sort_ascending);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftfPanel, sort_descending);
/* The CallBacks */
gtk_widget_class_bind_template_callback (widget_class, on_list_box_row_activated);
gtk_widget_class_bind_template_callback (widget_class, on_pane_search_changed);
gtk_widget_class_bind_template_callback (widget_class, on_left_panel_search_changed);
gtk_widget_class_bind_template_callback (widget_class, on_sort_ascending_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_sort_descending_clicked);
}
static void
finance_pane_init (FinancePane *self)
finance_left_panel_init (FinanceLeftPanel *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
......@@ -163,9 +162,9 @@ finance_pane_init (FinancePane *self)
}
/**
* finance_pane_prepend_row:
* @self: a #FinancePane instance.
* @row: a #GtkWidget to add.
* finance_left_panel_prepend_row:
* @self: a #FinanceLeftPanel
* @row: a #GtkWidget to add
*
* Prepend a widget to the list. If a sort function is set,
* the widget will actually be inserted at the calculated position
......@@ -174,10 +173,10 @@ finance_pane_init (FinancePane *self)
* Since: 1.0
*/
void
finance_pane_prepend_row (FinancePane *self,
GtkWidget *row)
finance_left_panel_prepend_row (FinancePane *self,
GtkWidget *row)
{
g_return_if_fail (FINANCE_IS_PANE (self));
g_return_if_fail (FINANCE_IS_LEFT_PANEL (self));
gtk_list_box_prepend (GTK_LIST_BOX (self->list), row);
}
/* finance-pane.h
/* finance-left-panel.h
*
* Copyright 2021 galetedanilo <galetedanilo@gmail.com>
*
......@@ -18,24 +18,24 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#ifndef __FINANCE_PANE_H__
#define __FINANCE_PANE_H__
#ifndef __FINANCE_LEFT_PANEL_H__
#define __FINANCE_LEFT_PANEL_H__
#include <gtk/gtk.h>
#include "finance-pane-row.h"
#include "finance-transaction-row.h"
G_BEGIN_DECLS
#define FINANCE_TYPE_PANE (finance_pane_get_type ())
#define FINANCE_TYPE_LEFT_PANEL (finance_left_panel_get_type ())
G_DECLARE_FINAL_TYPE (FinancePane, finance_pane, FINANCE, PANE, GtkBox)
G_DECLARE_FINAL_TYPE (FinanceLeftPanel, finance_left_panel, FINANCE, LEFT_PANEL, GtkBox)
GtkWidget * finance_pane_new (void);
GtkWidget * finance_left_panel_new (void);
void finance_pane_prepend_row (FinancePane *self,
GtkWidget *row);
void finance_left_panel_prepend_row (FinanceLeftPanel *self,
GtkWidget *row);
G_END_DECLS
#endif /* __FINANCE_PANE_H__ */
#endif /* __FINANCE_LEFT_PANE_H__ */
......@@ -2,7 +2,7 @@
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="FinancePane" parent="GtkBox">
<template class="FinanceLeftPanel" parent="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
......@@ -17,7 +17,7 @@
<property name="primary-icon-name">edit-find-symbolic</property>
<property name="primary-icon-activatable">False</property>
<property name="primary-icon-sensitive">False</property>
<signal name="search-changed" handler="on_pane_search_changed" swapped="no"/>
<signal name="search-changed" handler="on_left_panel_search_changed" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
......
finance_incs += include_directories('rows')
built_sources += gnome.compile_resources(
'panel-resources',
'panel.gresource.xml',
c_name: 'panel',
)
sources += files(
'finance-left-panel.c',
)
subdir('rows')
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/finance/pane">
<file compressed="true">finance-pane.ui</file>
<file compressed="true">finance-pane-row.ui</file>
<gresource prefix="/org/gnome/finance/panel">
<file compressed="true">finance-left-panel.ui</file>
</gresource>
</gresources>
/* finance-pane-row.c
/* finance-transaction-row.c
*
* Copyright 2021 galetedanilo <galetedanilo@gmail.com>
*
......@@ -20,9 +20,9 @@
#include "finance-config.h"
#include "finance-pane-row.h"
#include "finance-transaction-row.h"
struct _FinancePaneRow
struct _FinanceTransactionRow
{
GtkListBoxRow parent_instance;
......@@ -37,7 +37,7 @@ struct _FinancePaneRow
gchar *icon;
};
G_DEFINE_TYPE (FinancePaneRow, finance_pane_row, GTK_TYPE_LIST_BOX_ROW)
G_DEFINE_TYPE (FinanceTransactionRow, finance_transaction_row, GTK_TYPE_LIST_BOX_ROW)
enum {
PROP_0,
......@@ -49,14 +49,20 @@ enum {
N_PROPS,
};
enum {
CHANGE,
N_SIGNALS
};
static GParamSpec *properties [N_PROPS] = { NULL, };
static guint signals[N_SIGNALS] = { 0, };
static void
create_icon (FinanceTransactionRow *self)
{
cairo_surface_t *surface;
surface = finance_utils_create_circle (self->color, 45, self->icon);
gtk_image_set_from_surface (GTK_IMAGE (self->image_icon), surface);
g_clear_pointer (&surface, cairo_surface_destroy);
}
/*
* Show the check button, when the mouse is over the row.
......@@ -66,7 +72,7 @@ on_row_state_flags_changed (GtkWidget *object,
GtkStateFlags flags,
gpointer user_data)
{
FinancePaneRow *self = FINANCE_PANE_ROW (user_data);
FinanceTransactionRow *self = FINANCE_TRANSACTION_ROW (user_data);
flags = gtk_widget_get_state_flags (object);
......@@ -77,71 +83,60 @@ on_row_state_flags_changed (GtkWidget *object,
}
}
static void
on_check_toggled (GtkToggleButton *button,
gpointer user_data)
{
FinancePaneRow *self = FINANCE_PANE_ROW (user_data);
(void)button;
g_signal_emit(self, signals[CHANGE], 0);
}
GtkWidget *
finance_pane_row_new (void)
finance_transaction_row_new (void)
{
return g_object_new (FINANCE_TYPE_PANE_ROW, NULL);
return g_object_new (FINANCE_TYPE_TRANSACTION_ROW, NULL);
}
static void
finance_pane_row_finalize (GObject *object)
finance_transaction_row_finalize (GObject *object)
{
FinancePaneRow *self = (FinancePaneRow *)object;
FinanceTransactionRow *self = (FinanceTransactionRow *)object;
g_clear_pointer (&self->icon, g_free);
G_OBJECT_CLASS (finance_pane_row_parent_class)->finalize (object);
G_OBJECT_CLASS (finance_transaction_row_parent_class)->finalize (object);
}
static void
finance_pane_row_dispose (GObject *object)
finance_transaction_row_dispose (GObject *object)
{
FinancePaneRow *self = (FinancePaneRow *)object;
FinanceTransactionRow *self = (FinanceTransactionRow *)object;
g_clear_pointer (&self->color, gdk_rgba_free);
G_OBJECT_CLASS (finance_pane_row_parent_class)->dispose (object);
G_OBJECT_CLASS (finance_transaction_row_parent_class)->dispose (object);
}
static void
finance_pane_row_get_property (GObject *object,
finance_transaction_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
FinancePaneRow *self = FINANCE_PANE_ROW (object);
FinanceTransactionRow *self = FINANCE_TRANSACTION_ROW (object);
switch (prop_id)
{
case PROP_AMOUNT:
g_value_set_string (value, finance_pane_row_get_amount (self));
g_value_set_string (value, finance_transaction_row_get_amount (self));
break;
case PROP_COLOR:
g_value_set_boxed (value, finance_pane_row_get_color (self));
g_value_set_boxed (value, finance_transaction_row_get_color (self));
break;
case PROP_ICON:
g_value_set_string (value, finance_pane_row_get_icon (self));
g_value_set_string (value, finance_transaction_row_get_icon (self));
break;
case PROP_SELECTED:
g_value_set_boolean (value, finance_pane_row_is_selected (self));
g_value_set_boolean (value, finance_transaction_row_get_selected (self));
break;
case PROP_TITLE:
g_value_set_string (value, finance_pane_row_get_title (self));
g_value_set_string (value, finance_transaction_row_get_title (self));
break;
default:
......@@ -151,33 +146,33 @@ finance_pane_row_get_property (GObject *object,
}
static void
finance_pane_row_set_property (GObject *object,
finance_transaction_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
FinancePaneRow *self = FINANCE_PANE_ROW (object);
FinanceTransactionRow *self = FINANCE_TRANSACTION_ROW (object);
switch (prop_id)
{
case PROP_AMOUNT:
finance_pane_row_set_amount (self, g_value_get_string (value));
finance_transaction_row_set_amount (self, g_value_get_string (value));
break;
case PROP_COLOR:
finance_pane_row_set_color (self, g_value_get_boxed (value));
finance_transaction_row_set_color (self, g_value_get_boxed (value));
break;
case PROP_ICON:
finance_pane_row_set_icon (self, g_value_get_string (value));
finance_transaction_row_set_icon (self, g_value_get_string (value));
break;
case PROP_TITLE:
finance_pane_row_set_title (self, g_value_get_string (value));
finance_transaction_row_set_title (self, g_value_get_string (value));
break;
case PROP_SELECTED:
finance_pane_row_set_selected (self, g_value_get_boolean (value));
finance_transaction_row_set_selected (self, g_value_get_boolean (value));
break;
default:
......@@ -187,42 +182,29 @@ finance_pane_row_set_property (GObject *object,
}