Commit 1148b4bd authored by Danilo Galete's avatar Danilo Galete 💬
Browse files

Change project

parent 309dd106
......@@ -117,7 +117,7 @@ finance_controller_transactions_class_init (FinanceControllerTransactionsClass *
properties[PROP_PANE] = g_param_spec_object ("pane",
"The Pane",
"The left pane in the main window",
FINANCE_TYPE_PANE,
FINANCE_TYPE_LEFT_PANEL,
G_PARAM_READWRITE);
/**
......@@ -146,8 +146,8 @@ finance_controller_transactions_startup (FinanceControllerTransactions *self)
for(int x = 0; x < 5; x++)
{
//this is a test
GtkWidget *summary = finance_child_summary_new ();
GtkWidget *row = finance_pane_row_new ();
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,
......@@ -173,22 +173,22 @@ finance_controller_transactions_startup (FinanceControllerTransactions *self)
"amount",
G_BINDING_DEFAULT);
finance_child_summary_set_color (FINANCE_CHILD_SUMMARY (summary),
finance_summary_child_set_color (FINANCE_SUMMARY_CHILD (summary),
color);
finance_child_summary_set_icon (FINANCE_CHILD_SUMMARY (summary), "ID");
finance_summary_child_set_icon (FINANCE_SUMMARY_CHILD (summary), "ID");
finance_child_summary_set_name (FINANCE_CHILD_SUMMARY (summary),
finance_summary_child_set_name (FINANCE_SUMMARY_CHILD (summary),
"Cadastro para Teste");
finance_child_summary_set_amount_string (FINANCE_CHILD_SUMMARY (summary),
finance_summary_child_set_amount_string (FINANCE_SUMMARY_CHILD (summary),
"R$ 500,00");
finance_view_insert_child (FINANCE_VIEW (self->view_transactions), summary);
finance_pane_prepend_row (FINANCE_PANE (self->pane), row);
finance_left_panel_prepend_row (FINANCE_LEFT_PANEL (self->pane), row);
g_clear_pointer (&color, gdk_rgba_free);
}
......
......@@ -23,9 +23,9 @@
#include <glib-object.h>
#include "finance-child-summary.h"
#include "finance-pane.h"
#include "finance-pane-row.h"
#include "finance-left-panel.h"
#include "finance-summary-child.h"
#include "finance-transaction-row.h"
#include "finance-view.h"
#include "finance-utils.h"
......
......@@ -156,7 +156,7 @@ finance_window_class_init (FinanceWindowClass *klass)
g_type_ensure (FINANCE_TYPE_LEFT_PANEL);
g_type_ensure (FINANCE_TYPE_TRANSACTION);
g_type_ensure (FINANCE_TYPE_VIEW_TRANSACTIONS);
g_type_ensure (FINANCE_TYPE_TRANSACTION_VIEW);
G_OBJECT_CLASS (klass)->dispose = finance_window_dispose;
......@@ -196,7 +196,7 @@ finance_window_init (FinanceWindow *self)
self->settings = g_settings_new ("org.gnome.finance");
self->controller_transactions = g_object_new (FINANCE_TYPE_CONTROLLER_TRANSACTIONS,
"pane", self->pane,
"pane", self->left_panel,
"view", self->view_transactions,
NULL);
......
......@@ -23,9 +23,9 @@
#include <handy.h>
#include "finance-controller-transactions.h"
#include "finance-panel.h"
#include "finance-left-panel.h"
#include "finance-transaction.h"
#include "finance-view-transactions.h"
#include "finance-transaction-view.h"
G_BEGIN_DECLS
......
......@@ -430,12 +430,12 @@
</packing>
</child>
<child>
<object class="FinanceViewTransactions" id="view_transactions">
<object class="FinanceTransactionView" id="transaction_view">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="name">transactions</property>
<property name="name">transaction_view</property>
<property name="title" translatable="yes">Transactions</property>
<property name="position">1</property>
</packing>
......
......@@ -25,10 +25,10 @@ struct _FinanceLeftPanel
GtkBox parent_instance;
/* The Widgets */
GtkWidget *list;
GtkWidget *search;
GtkWidget *sort_ascending;
GtkWidget *sort_descending;
GtkWidget *button_ascending;
GtkWidget *button_descending;
GtkWidget *entry_search;
GtkWidget *list_box;
GtkSortType sort;
};
......@@ -36,13 +36,13 @@ struct _FinanceLeftPanel
G_DEFINE_TYPE (FinanceLeftPanel, finance_left_panel, GTK_TYPE_BOX)
static gboolean
listbox_list_func (GtkListBoxRow *row,
gpointer user_data)
list_box_filter_func (GtkListBoxRow *row,
gpointer user_data)
{
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
if (strcasestr (finance_transaction_row_get_title (FINANCE_TRANSACTION_ROW (row)),
gtk_entry_get_text (GTK_ENTRY (self->search))))
gtk_entry_get_text (GTK_ENTRY (self->entry_search))))
return TRUE;
return FALSE;
......@@ -50,9 +50,9 @@ listbox_list_func (GtkListBoxRow *row,
}
static gint
listbox_sort_func (GtkListBoxRow *row1,
GtkListBoxRow *row2,
gpointer user_data)
list_box_sort_func (GtkListBoxRow *row1,
GtkListBoxRow *row2,
gpointer user_data)
{
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
......@@ -72,7 +72,7 @@ on_left_panel_search_changed (GtkSearchEntry *entry,
(void)entry;
gtk_list_box_invalidate_filter (GTK_LIST_BOX (self->list));
gtk_list_box_invalidate_filter (GTK_LIST_BOX (self->list_box));
}
static void
......@@ -84,35 +84,33 @@ on_list_box_row_activated (GtkListBox *box,
}
static void
on_sort_ascending_clicked (GtkButton *button,
gpointer user_data)
on_button_ascending_clicked (GtkButton *button,
gpointer user_data)
{
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
(void)button;
gtk_widget_set_visible (button, FALSE);
gtk_widget_set_visible (self->sort_ascending, FALSE);
gtk_widget_set_visible (self->sort_descending, TRUE);
gtk_widget_set_visible (self->button_descending, TRUE);
self->sort = GTK_SORT_ASCENDING;
gtk_list_box_invalidate_sort (GTK_LIST_BOX (self->list));
gtk_list_box_invalidate_sort (GTK_LIST_BOX (self->list_box));
}
static void
on_sort_descending_clicked (GtkButton *button,
gpointer user_data)
on_button_descending_clicked (GtkButton *button,
gpointer user_data)
{
FinanceLeftPanel *self = FINANCE_LEFT_PANEL (user_data);
(void)button;
gtk_widget_set_visible (button, FALSE);
gtk_widget_set_visible (self->sort_descending, FALSE);
gtk_widget_set_visible (self->sort_ascending, TRUE);
gtk_widget_set_visible (self->button_ascending, TRUE);
self->sort = GTK_SORT_DESCENDING;
gtk_list_box_invalidate_sort (GTK_LIST_BOX (self->list));
gtk_list_box_invalidate_sort (GTK_LIST_BOX (self->list_box));
}
GtkWidget *
......@@ -131,16 +129,16 @@ finance_left_panel_class_init (FinanceLeftPanelClass *klass)
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, 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);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftPanel, button_ascending);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftPanel, button_descending);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftPanel, entry_search);
gtk_widget_class_bind_template_child (widget_class, FinanceLeftPanel, list_box);
/* The CallBacks */
gtk_widget_class_bind_template_callback (widget_class, on_list_box_row_activated);
gtk_widget_class_bind_template_callback (widget_class, on_button_ascending_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_button_descending_clicked);
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);
gtk_widget_class_bind_template_callback (widget_class, on_list_box_row_activated);
}
static void
......@@ -150,13 +148,13 @@ finance_left_panel_init (FinanceLeftPanel *self)
self->sort = GTK_SORT_ASCENDING;
gtk_list_box_set_filter_func (GTK_LIST_BOX (self->list),
(GtkListBoxFilterFunc)listbox_list_func,
gtk_list_box_set_filter_func (GTK_LIST_BOX (self->list_box),
(GtkListBoxFilterFunc)list_box_filter_func,
(gpointer) self,
FALSE);
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->list),
(GtkListBoxSortFunc)listbox_sort_func,
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->list_box),
(GtkListBoxSortFunc)list_box_sort_func,
(gpointer) self,
FALSE);
}
......@@ -173,10 +171,10 @@ finance_left_panel_init (FinanceLeftPanel *self)
* Since: 1.0
*/
void
finance_left_panel_prepend_row (FinancePane *self,
GtkWidget *row)
finance_left_panel_prepend_row (FinanceLeftPanel *self,
GtkWidget *row)
{
g_return_if_fail (FINANCE_IS_LEFT_PANEL (self));
gtk_list_box_prepend (GTK_LIST_BOX (self->list), row);
gtk_list_box_prepend (GTK_LIST_BOX (self->list_box), row);
}
......@@ -7,7 +7,7 @@
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkSearchEntry" id="search">
<object class="GtkSearchEntry" id="entry_search">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">8</property>
......@@ -52,12 +52,12 @@
</packing>
</child>
<child>
<object class="GtkButton" id="sort_ascending">
<object class="GtkButton" id="button_ascending">
<property name="visible">False</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="relief">none</property>
<signal name="clicked" handler="on_sort_ascending_clicked" swapped="no"/>
<signal name="clicked" handler="on_button_ascending_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -74,12 +74,12 @@
</packing>
</child>
<child>
<object class="GtkButton" id="sort_descending">
<object class="GtkButton" id="button_descending">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="relief">none</property>
<signal name="clicked" handler="on_sort_descending_clicked" swapped="no"/>
<signal name="clicked" handler="on_button_descending_clicked" swapped="no"/>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -113,7 +113,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkListBox" id="list">
<object class="GtkListBox" id="list_box">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="selection-mode">none</property>
......
......@@ -24,17 +24,18 @@
struct _FinanceTransactionRow
{
GtkListBoxRow parent_instance;
GtkListBoxRow parent_instance;
/* The Widgets */
GtkWidget *amount;
GtkWidget *check;
GtkWidget *image;
GtkWidget *revealer;
GtkWidget *title;
GdkRGBA *color;
gchar *icon;
GtkWidget *check_button;
GtkWidget *image_icon;
GtkWidget *label_amount;
GtkWidget *label_title;
GtkWidget *revealer_check;
GdkRGBA *color;
gchar *icon;
};
G_DEFINE_TYPE (FinanceTransactionRow, finance_transaction_row, GTK_TYPE_LIST_BOX_ROW)
......@@ -64,6 +65,15 @@ create_icon (FinanceTransactionRow *self)
g_clear_pointer (&surface, cairo_surface_destroy);
}
static void
on_check_button_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
FinanceTransactionRow *self = FINANCE_TRANSACTION_ROW (user_data);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED]);
}
/*
* Show the check button, when the mouse is over the row.
*/
......@@ -76,11 +86,10 @@ on_row_state_flags_changed (GtkWidget *object,
flags = gtk_widget_get_state_flags (object);
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->check)))
{
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer),
(flags & GTK_STATE_FLAG_PRELIGHT) != 0);
}
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->check_button)))
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer_check),
(flags & GTK_STATE_FLAG_PRELIGHT) != 0);
}
GtkWidget *
......@@ -249,16 +258,17 @@ finance_transaction_row_class_init (FinanceTransactionRowClass *klass)
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/pane/rows/finance-transaction-row.ui");
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/finance/panel/rows/finance-transaction-row.ui");
/* The Widgets */
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, image);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, title);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, amount);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, revealer);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, check);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, check_button);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, image_icon);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, label_amount);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, label_title);
gtk_widget_class_bind_template_child (widget_class, FinanceTransactionRow, revealer_check);
/* The CallBacks */
gtk_widget_class_bind_template_callback (widget_class, on_check_button_toggled);
gtk_widget_class_bind_template_callback (widget_class, on_row_state_flags_changed);
}
......@@ -273,48 +283,43 @@ finance_transaction_row_init (FinanceTransactionRow *self)
}
/**
* finance_transaction_row_get_icon:
* finance_transaction_row_get_amount:
* @self: a #FinanceTransactionRow
*
* Returns the two letters that are part of the icon image
* Returns the amount as a string
*
* Returns: A two-letter string , or %NULL.
* Returns: The amount 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_transaction_row_get_icon (FinanceTransactionRow *self)
finance_transaction_row_get_amount (FinanceTransactionRow *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTION_ROW (self), NULL);
return self->icon;
return gtk_label_get_text (GTK_LABEL (self->label_amount));
}
/**
* finance_transaction_row_set_icon:
* finance_transaction_row_set_amount:
* @self: a #FinanceTransactionRow
* @icon: the icon to set, as a two-letter string
* @amount: the amount to set, as a string
*
* Sets the two letters that are part of the icon image,
* replacing the current contents.
* Sets the amount, replacing the current contents
*
* Since:1.0
* Since: 1.0
*/
void
finance_transaction_row_set_icon (FinanceTransactionRow *self,
const gchar *icon)
finance_transaction_row_set_amount (FinanceTransactionRow *self,
const gchar *amount)
{
g_return_if_fail (FINANCE_IS_TRANSACTION_ROW (self));
g_clear_pointer (&self->icon, g_free);
self->icon = g_strdup (icon);
create_icon (self);
gtk_label_set_text (GTK_LABEL (self->label_amount), amount);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_AMOUNT]);
}
/**
......@@ -360,119 +365,124 @@ finance_transaction_row_set_color (FinanceTransactionRow *self,
}
/**
* finance_transaction_row_get_title:
* finance_transaction_row_get_icon:
* @self: a #FinanceTransactionRow
*
* Returns the title
* Returns the two letters that are part of the icon image
*
* Returns: The title as a string, or %NULL.
* Returns: A two-letter 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_transaction_row_get_title (FinanceTransactionRow *self)
finance_transaction_row_get_icon (FinanceTransactionRow *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTION_ROW (self), NULL);
return gtk_label_get_text (GTK_LABEL (self->title));
return self->icon;
}
/**
* finance_transaction_row_set_title:
* finance_transaction_row_set_icon:
* @self: a #FinanceTransactionRow
* @title: the title to set, as a string
* @icon: the icon to set, as a two-letter string
*
* Sets the title, replacing the current contents
* Sets the two letters that are part of the icon image,
* replacing the current contents.
*
* Since: 1.0
* Since:1.0
*/
void
finance_transaction_row_set_title (FinanceTransactionRow *self,
const gchar *title)
finance_transaction_row_set_icon (FinanceTransactionRow *self,
const gchar *icon)
{
g_return_if_fail (FINANCE_IS_TRANSACTION_ROW (self));
gtk_label_set_text (GTK_LABEL (self->title), title);
g_clear_pointer (&self->icon, g_free);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TITLE]);
self->icon = g_strdup (icon);
create_icon (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON]);
}
/**
* finance_transaction_row_get_amount:
* finance_transaction_row_get_selected:
* @self: a #FinanceTransactionRow
*
* Returns the amount as a string
* Returns whether the row is in its “on” or “off” state
*
* Returns: The amount as a string, or %NULL.
* This string points to internally allocated storage in the object
* and must not be freed, modified or stored.
* Returns: #TRUE if the row is selected, and #FALSE otherwise
*
* Since: 1.0
*/
const gchar *
finance_transaction_row_get_amount (FinanceTransactionRow *self)
gboolean
finance_transaction_row_get_selected (FinanceTransactionRow *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTION_ROW (self), NULL);
g_return_val_if_fail (FINANCE_IS_TRANSACTION_ROW (self), FALSE);
return gtk_label_get_text (GTK_LABEL (self->amount));
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->check_button));
}
/**
* finance_transaction_row_set_amount:
* finance_transaction_row_set_selected:
* @self: a #FinanceTransactionRow
* @amount: the amount to set, as a string
* @selected: #TRUE if row is to be selected, and #FALSE otherwise
*
* Sets the amount, replacing the current contents
* Changes the state of #FinanceTransactionRow to the desired one
*
* Since: 1.0
*/
void
finance_transaction_row_set_amount (FinanceTransactionRow *self,
const gchar *amount)
finance_transaction_row_set_selected (FinanceTransactionRow *self,
gboolean selected)
{
g_return_if_fail (FINANCE_IS_TRANSACTION_ROW (self));
gtk_label_set_text (GTK_LABEL (self->amount), amount);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->check_button), selected);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_AMOUNT]);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED]);
}
/**
* finance_transaction_row_get_selected:
* finance_transaction_row_get_title:
* @self: a #FinanceTransactionRow
*
* Returns whether the row is in its “on” or “off” state
* Returns the title
*
* Returns: #TRUE if the row is selected, and #FALSE otherwise
* Returns: The 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
*/
gboolean
finance_transaction_row_get_selected (FinanceTransactionRow *self)
const gchar *
finance_transaction_row_get_title (FinanceTransactionRow *self)
{
g_return_val_if_fail (FINANCE_IS_TRANSACTION_ROW (self), FALSE);
g_return_val_if_fail (FINANCE_IS_TRANSACTION_ROW (self), NULL);
return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (self->check));
return gtk_label_get_text (GTK_LABEL (self->label_title));
}
/**
* finance_transaction_row_set_selected:
* finance_transaction_row_set_title:
* @self: a #FinanceTransactionRow
* @selected: #TRUE if row is to be selected, and #FALSE otherwise
* @title: the title to set, as a string
*
* Changes the state of #FinanceTransactionRow to the desired one
* Sets the title, replacing the current contents
*
* Since: 1.0
*/
void
finance_transaction_row_set_selected (FinanceTransactionRow *self,