[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_7_98-1-ga95e48a
Pierre Biava
nobody at users.sourceforge.net
Sat Jan 8 17:44:22 CET 2011
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grisbi".
The branch, master has been updated
via a95e48a17267cefb9a151db41060c5fe2400cb36 (commit)
from bc199843821e7c6da70b81989e2b76a563750d0c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit a95e48a17267cefb9a151db41060c5fe2400cb36
Author: pbiava <pierre.biava at nerim.net>
Date: Sat Jan 8 17:32:53 2011 +0100
Working on the sort of operations in the transaction list. Added sorting by date and payees.
-----------------------------------------------------------------------
Changes:
diff --git a/src/affichage_liste.c b/src/affichage_liste.c
index 7569a48..2481988 100644
--- a/src/affichage_liste.c
+++ b/src/affichage_liste.c
@@ -51,8 +51,9 @@ static gboolean display_mode_button_changed ( GtkWidget *button,
static gboolean gsb_transactions_list_display_change_max_items ( GtkWidget *entry,
gpointer null );
static void gsb_transactions_list_display_show_gives_balance ( void );
-static gboolean gsb_transactions_list_display_sort_by_value_date ( GtkWidget *checkbutton,
- gpointer null );
+static gboolean gsb_transactions_list_display_sort_changed ( GtkWidget *checkbutton,
+ GdkEventButton *event,
+ gint *pointeur );
static gboolean gsb_transactions_list_display_update_auto_completion ( GtkWidget *checkbutton,
GtkWidget *button );
static gboolean gsb_transactions_list_display_update_combofix ( void );
@@ -167,12 +168,10 @@ GtkWidget *onglet_affichage_operations ( void )
gtk_combo_box_set_active ( GTK_COMBO_BOX (button), position);
}
-
/* pack vboxes in hbox */
gtk_box_pack_start ( GTK_BOX ( hbox ), vbox_label, FALSE, FALSE, 0 );
gtk_box_pack_start ( GTK_BOX ( hbox ), vbox_buttons, FALSE, FALSE, 0 );
-
/* do we show the content of the selected transaction in the form for
* each selection ? */
gtk_box_pack_start ( GTK_BOX ( paddingbox ),
@@ -188,26 +187,31 @@ GtkWidget *onglet_affichage_operations ( void )
&conf.show_transaction_gives_balance,
G_CALLBACK ( gsb_transactions_list_display_show_gives_balance ), NULL ),
FALSE, FALSE, 0 );
- /* Sorting the transactions by date */
- gsb_automem_radiobutton_new_with_title ( vbox_pref,
- _("Options for sorting by date"),
- _("Sort by date and transaction number"),
- _("Sort by date and transaction amount"),
- &conf.transactions_list_sort_by_date,
- G_CALLBACK ( gsb_transactions_list_display_sort_by_value_date ),
- NULL );
- /* Sorting the transactions by value date */
- gsb_automem_radiobutton_new_with_title ( vbox_pref,
- _("Options for sorting by value date"),
+ /* Primary sorting option for the transactions */
+ gsb_automem_radiobutton3_new_with_title ( vbox_pref,
+ _("Primary sorting option"),
_("Sort by value date (if fail, try with the date)"),
_("Sort by value date and then by date"),
- &conf.transactions_list_sort_by_value_date,
- G_CALLBACK ( gsb_transactions_list_display_sort_by_value_date ),
- NULL );
+ NULL,
+ &conf.transactions_list_primary_sorting,
+ G_CALLBACK ( gsb_transactions_list_display_sort_changed ),
+ &conf.transactions_list_primary_sorting,
+ GTK_ORIENTATION_VERTICAL );
+
+ /* Secondary sorting option for the transactions */
+ gsb_automem_radiobutton3_new_with_title ( vbox_pref,
+ _("Secondary sorting option"),
+ _("Sort by transaction number"),
+ _("Sort by type of amount (credit debit)"),
+ _("Sort by payee name (if fail, by transaction number)"),
+ &conf.transactions_list_secondary_sorting,
+ G_CALLBACK ( gsb_transactions_list_display_sort_changed ),
+ &conf.transactions_list_secondary_sorting,
+ GTK_ORIENTATION_VERTICAL );
/* Account distinction */
- paddingbox = new_paddingbox_with_title (vbox_pref, FALSE,
+ paddingbox = new_paddingbox_with_title (vbox_pref, FALSE,
_("Account differentiation"));
gtk_box_pack_start ( GTK_BOX ( paddingbox ),
@@ -230,14 +234,25 @@ GtkWidget *onglet_affichage_operations ( void )
*
*
* */
-gboolean gsb_transactions_list_display_sort_by_value_date ( GtkWidget *checkbutton,
- gpointer null )
+gboolean gsb_transactions_list_display_sort_changed ( GtkWidget *checkbutton,
+ GdkEventButton *event,
+ gint *pointeur )
{
gint page_number;
gint account_nb;
page_number = gsb_gui_navigation_get_current_page ( );
+ if ( pointeur )
+ {
+ gint value = 0;
+
+ value = GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( checkbutton ), "pointer" ) );
+ *pointeur = value;
+ if ( etat.modification_fichier == 0 )
+ modification_fichier ( TRUE );
+ }
+
switch ( page_number )
{
case GSB_ACCOUNT_PAGE:
diff --git a/src/bet_config.c b/src/bet_config.c
index 08c29b9..7e31e2e 100644
--- a/src/bet_config.c
+++ b/src/bet_config.c
@@ -583,7 +583,8 @@ GtkWidget *bet_config_get_select_labels_widget ( GtkWidget *container )
_("Budgetary lines"),
&select,
G_CALLBACK ( bet_config_select_label_changed ),
- GINT_TO_POINTER ( origine ) );
+ GINT_TO_POINTER ( origine ),
+ GTK_ORIENTATION_HORIZONTAL );
gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 0 );
@@ -601,7 +602,8 @@ GtkWidget *bet_config_get_select_labels_widget ( GtkWidget *container )
_("Budgetary lines"),
&select,
G_CALLBACK ( bet_config_select_label_changed ),
- GINT_TO_POINTER ( origine ) );
+ GINT_TO_POINTER ( origine ),
+ GTK_ORIENTATION_HORIZONTAL );
gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 0 );
/* set labels for futur data */
@@ -618,7 +620,8 @@ GtkWidget *bet_config_get_select_labels_widget ( GtkWidget *container )
_("Budgetary lines"),
&select,
G_CALLBACK ( bet_config_select_label_changed ),
- GINT_TO_POINTER ( origine ) );
+ GINT_TO_POINTER ( origine ),
+ GTK_ORIENTATION_HORIZONTAL );
gtk_box_pack_start ( GTK_BOX ( vbox ), button, FALSE, FALSE, 0 );
text = make_blue ( _("Order by default if the data are not zero: notes, payee, "
diff --git a/src/gsb_automem.c b/src/gsb_automem.c
index 5db6004..850b0a1 100644
--- a/src/gsb_automem.c
+++ b/src/gsb_automem.c
@@ -504,22 +504,24 @@ GtkWidget *gsb_automem_radiobutton_new ( const gchar *choice1,
*
* \return A newly created paddingbox
*/
-/*GtkWidget *gsb_automem_radiobutton3_new_with_title ( GtkWidget *parent,
+GtkWidget *gsb_automem_radiobutton3_new_with_title ( GtkWidget *parent,
const gchar *title,
const gchar *choice1, const gchar *choice2, const gchar *choice3,
- gboolean *value,
+ gint *value,
GCallback hook,
- gpointer data )
+ gpointer data,
+ gint orientation )
{
GtkWidget *paddingbox;
- paddingbox = new_paddingbox_with_title (parent, FALSE, COLON(title));
- gtk_box_pack_start (GTK_BOX(paddingbox),
+ paddingbox = new_paddingbox_with_title ( parent, FALSE, COLON ( title ) );
+
+ gtk_box_pack_start ( GTK_BOX ( paddingbox ),
gsb_automem_radiobutton3_new ( choice1, choice2, choice3,
- value, hook, data ),
+ value, hook, data, orientation ),
FALSE, FALSE, 0 );
return paddingbox;
-}*/
+}
@@ -542,29 +544,33 @@ GtkWidget *gsb_automem_radiobutton3_new ( const gchar *choice1,
const gchar *choice3,
gint *value,
GCallback callback,
- gpointer data )
+ gpointer data,
+ gint orientation )
{
- GtkWidget *hbox;
+ GtkWidget *box;
GtkWidget *button1;
GtkWidget *button2;
GtkWidget *button3 = NULL;
- hbox = gtk_hbox_new ( FALSE, 6 );
+ if ( orientation == GTK_ORIENTATION_HORIZONTAL )
+ box = gtk_hbox_new ( FALSE, 6 );
+ else
+ box = gtk_vbox_new ( FALSE, 6 );
button1 = gtk_radio_button_new_with_mnemonic ( NULL, choice1 );
- gtk_box_pack_start ( GTK_BOX ( hbox ), button1, FALSE, FALSE, 0 );
+ gtk_box_pack_start ( GTK_BOX ( box ), button1, FALSE, FALSE, 0 );
button2 = gtk_radio_button_new_with_mnemonic ( gtk_radio_button_get_group (
- GTK_RADIO_BUTTON ( button1 ) ),
+ GTK_RADIO_BUTTON ( button1 ) ),
choice2 );
- gtk_box_pack_start ( GTK_BOX ( hbox ), button2, FALSE, FALSE, 0 );
+ gtk_box_pack_start ( GTK_BOX ( box ), button2, FALSE, FALSE, 0 );
if ( choice3 && strlen ( choice3 ) )
{
button3 = gtk_radio_button_new_with_mnemonic ( gtk_radio_button_get_group (
- GTK_RADIO_BUTTON ( button1 ) ),
+ GTK_RADIO_BUTTON ( button1 ) ),
choice3 );
- gtk_box_pack_start ( GTK_BOX ( hbox ), button3, FALSE, FALSE, 0 );
+ gtk_box_pack_start ( GTK_BOX ( box ), button3, FALSE, FALSE, 0 );
}
if (value)
@@ -602,7 +608,7 @@ GtkWidget *gsb_automem_radiobutton3_new ( const gchar *choice1,
g_signal_connect ( G_OBJECT ( button3 ), "button-release-event", G_CALLBACK ( callback ), data );
}
- return hbox;
+ return box;
}
diff --git a/src/gsb_automem.h b/src/gsb_automem.h
index 3b555b1..caa9088 100644
--- a/src/gsb_automem.h
+++ b/src/gsb_automem.h
@@ -22,7 +22,15 @@ GtkWidget *gsb_automem_radiobutton3_new ( const gchar *choice1,
const gchar *choice3,
gint *value,
GCallback callback,
- gpointer data );
+ gpointer data,
+ gint orientation );
+GtkWidget *gsb_automem_radiobutton3_new_with_title ( GtkWidget *parent,
+ const gchar *title,
+ const gchar *choice1, const gchar *choice2, const gchar *choice3,
+ gint *value,
+ GCallback hook,
+ gpointer data,
+ gint orientation );
GtkWidget *gsb_automem_radiobutton_new ( const gchar *choice1,
const gchar *choice2,
gboolean *value,
diff --git a/src/gsb_file_config.c b/src/gsb_file_config.c
index 7c84a1d..4c507ed 100644
--- a/src/gsb_file_config.c
+++ b/src/gsb_file_config.c
@@ -397,14 +397,15 @@ devel_debug (NULL);
"Display",
"Show transaction gives balance",
NULL );
- conf.transactions_list_sort_by_date = g_key_file_get_integer ( config,
+
+ conf.transactions_list_primary_sorting = g_key_file_get_integer ( config,
"Display",
- "Transactions list sort by date",
+ "Transactions_list_primary_sorting",
NULL );
- conf.transactions_list_sort_by_value_date = g_key_file_get_integer ( config,
+ conf.transactions_list_secondary_sorting = g_key_file_get_integer ( config,
"Display",
- "Transactions list sort by value date",
+ "Transactions_list_secondary_sorting",
NULL );
etat.largeur_auto_colonnes = g_key_file_get_integer ( config,
@@ -801,13 +802,13 @@ gboolean gsb_file_config_save_config ( void )
g_key_file_set_integer ( config,
"Display",
- "Transactions list sort by date",
- conf.transactions_list_sort_by_date );
+ "Transactions_list_primary_sorting",
+ conf.transactions_list_primary_sorting );
g_key_file_set_integer ( config,
"Display",
- "Transactions list sort by value date",
- conf.transactions_list_sort_by_value_date );
+ "Transactions_list_secondary_sorting",
+ conf.transactions_list_secondary_sorting );
g_key_file_set_integer ( config,
"Display",
@@ -1371,8 +1372,8 @@ void gsb_file_config_clean_config ( void )
etat.show_headings_bar = TRUE; /* Show toolbar or not. */
conf.show_transaction_selected_in_form = 1; /* show selected transaction in form */
conf.show_transaction_gives_balance = 1; /* show transaction that gives the balance of the day */
- conf.transactions_list_sort_by_date = 0; /* Options for sorting by date */
- conf.transactions_list_sort_by_value_date = 1; /* Options for sorting by value date */
+ conf.transactions_list_primary_sorting = 1; /* Primary sorting option for the transactions */
+ conf.transactions_list_secondary_sorting = 0; /* Secondary sorting option for the transactions */
etat.show_closed_accounts = FALSE;
if ( conf.font_string )
diff --git a/src/gsb_transactions_list_sort.c b/src/gsb_transactions_list_sort.c
index 89e702e..1ca3eba 100644
--- a/src/gsb_transactions_list_sort.c
+++ b/src/gsb_transactions_list_sort.c
@@ -93,6 +93,10 @@ static gint gsb_transactions_list_sort_by_value_date ( gint transaction_number_1
gint transaction_number_2 );
static gint gsb_transactions_list_sort_by_voucher ( gint transaction_number_1,
gint transaction_number_2 );
+static gint gsb_transactions_list_sort_initial_by_primary_key_and_secondary_key ( gint transaction_number_1,
+ gint transaction_number_2 );
+static gint gsb_transactions_list_sort_initial_by_secondary_key ( gint transaction_number_1,
+ gint transaction_number_2 );
/*END_STATIC*/
@@ -272,7 +276,7 @@ gint gsb_transactions_list_sort_by_no_sort ( gint transaction_number_1,
gint element_number )
{
gchar* tmpstr;
-
+devel_debug_int (element_number);
switch (element_number)
{
case ELEMENT_DATE: /* = 1 */
@@ -438,13 +442,52 @@ gint gsb_transactions_list_sort_by_transaction_date_and_amount ( gint transactio
/**
+ * compared by date and by party
+ *
+ * \param none but the local variables transaction_number_1 and transaction_number_2 MUST be set
+ *
+ * \return -1 if amount_2 is above amount_number_1
+ * */
+gint gsb_transactions_list_sort_by_transaction_date_and_party ( gint transaction_number_1,
+ gint transaction_number_2 )
+{
+ gint return_value;
+ gsb_real amount_1;
+ gsb_real amount_2;
+
+ if ( !gsb_data_transaction_get_date (transaction_number_1) )
+ {
+ return 1;
+ }
+ if ( !gsb_data_transaction_get_date (transaction_number_2) )
+ {
+ return -1;
+ }
+
+ return_value = g_date_compare ( gsb_data_transaction_get_date (transaction_number_1),
+ gsb_data_transaction_get_date (transaction_number_2));
+
+ if ( return_value == 0 )
+ {
+ /* no difference in the dates, sort by amount of transaction */
+ amount_1 = gsb_data_transaction_get_amount ( transaction_number_1 );
+ amount_2 = gsb_data_transaction_get_amount ( transaction_number_2 );
+ return_value = gsb_transactions_list_sort_by_party ( transaction_number_1,
+ transaction_number_2 );
+ }
+
+ return return_value;
+}
+
+
+/**
* used to compare 2 iters and sort the by no of transaction
* always put the white line below
- *
+ *
* \param model the GtkTreeModel
* \param iter_1
* \param iter_2
- *
+ *
* \return -1 if iter_1 is above iter_2
* */
gint gsb_transactions_list_sort_by_no ( gint transaction_number_1,
@@ -457,7 +500,7 @@ gint gsb_transactions_list_sort_by_no ( gint transaction_number_1,
/**
* used to compare 2 iters and sort the by date first, and no
- * or amount transaction after
+ * or amount transaction after
* always put the white line below
* \param model the GtkTreeModel
* \param iter_1
@@ -467,11 +510,7 @@ gint gsb_transactions_list_sort_by_no ( gint transaction_number_1,
gint gsb_transactions_list_sort_by_date ( gint transaction_number_1,
gint transaction_number_2 )
{
- if ( conf.transactions_list_sort_by_date == 0 )
- return gsb_transactions_list_sort_by_transaction_date_and_no (
- transaction_number_1, transaction_number_2 );
- else
- return gsb_transactions_list_sort_by_transaction_date_and_amount (
+ return gsb_transactions_list_sort_initial_by_secondary_key (
transaction_number_1, transaction_number_2 );
}
@@ -496,11 +535,11 @@ gint gsb_transactions_list_sort_by_value_date ( gint transaction_number_1,
/* need to work a little more here because value date is not obligatory filled,
* if we compare 2 transactions and 1 has no value date, set the value date before */
value_date_1 = gsb_data_transaction_get_value_date ( transaction_number_1 );
- if ( ! value_date_1 && !conf.transactions_list_sort_by_value_date )
+ if ( ! value_date_1 && !conf.transactions_list_primary_sorting )
value_date_1 = gsb_data_transaction_get_date ( transaction_number_1 );
value_date_2 = gsb_data_transaction_get_value_date ( transaction_number_2 );
- if ( ! value_date_2 && !conf.transactions_list_sort_by_value_date )
+ if ( ! value_date_2 && !conf.transactions_list_primary_sorting )
value_date_2 = gsb_data_transaction_get_date ( transaction_number_2 );
if ( value_date_1 )
@@ -699,13 +738,13 @@ gint gsb_transactions_list_sort_by_amount ( gint transaction_number_1,
gint return_value;
/* for the amounts, we have to check also the currency */
- return_value = gsb_real_cmp ( gsb_data_transaction_get_adjusted_amount ( transaction_number_1, -1),
- gsb_data_transaction_get_adjusted_amount ( transaction_number_2, -1));
+ return_value = gsb_real_cmp ( gsb_data_transaction_get_adjusted_amount ( transaction_number_2, -1),
+ gsb_data_transaction_get_adjusted_amount ( transaction_number_1, -1));
if ( return_value )
return return_value;
else
- return gsb_transactions_list_sort_by_transaction_date_and_no(transaction_number_1, transaction_number_2);
+ return gsb_transactions_list_sort_by_transaction_date_and_no (transaction_number_1, transaction_number_2);
}
@@ -1059,7 +1098,7 @@ gint gsb_transactions_list_sort_by_chq ( gint transaction_number_1,
/**
- * called by a click on the column, used to sort the list
+ * Called to sort transactions by key primary and secondary key
*
* \param model
* \param iter_1
@@ -1110,23 +1149,102 @@ gint gsb_transactions_list_sort_initial (CustomRecord **a,
/* get the transaction numbers */
gint transaction_number_1;
gint transaction_number_2;
- gint element_number;
transaction_number_1 = gsb_data_transaction_get_transaction_number (record_1 -> transaction_pointer);
transaction_number_2 = gsb_data_transaction_get_transaction_number (record_2 -> transaction_pointer);
- element_number = gsb_data_account_get_element_sort ( account_number,
- custom_list -> sort_col);
+ return_value = gsb_transactions_list_sort_initial_by_primary_key_and_secondary_key (
+ transaction_number_1, transaction_number_2 );
+ }
- if ( element_number == ELEMENT_DATE || element_number == ELEMENT_VALUE_DATE )
- return_value = gsb_transactions_list_sort_by_no_sort ( transaction_number_1,
- transaction_number_2,
- element_number );
+ return return_value;
+}
+
+
+/**
+ * used to compare 2 iters and sort the by primary key
+ *
+ * always put the white line below
+ * \param model the GtkTreeModel
+ * \param iter_1
+ * \param iter_2
+ * \return -1 if iter_1 is above iter_2
+ * */
+gint gsb_transactions_list_sort_initial_by_primary_key_and_secondary_key ( gint transaction_number_1,
+ gint transaction_number_2 )
+{
+ gint return_value;
+ const GDate *value_date_1;
+ const GDate *value_date_2;
+
+ /* need to work a little more here because value date is not obligatory filled,
+ * if we compare 2 transactions and 1 has no value date, set the value date before */
+ value_date_1 = gsb_data_transaction_get_value_date ( transaction_number_1 );
+ if ( !value_date_1 && conf.transactions_list_primary_sorting == 0 )
+ value_date_1 = gsb_data_transaction_get_date ( transaction_number_1 );
+
+ value_date_2 = gsb_data_transaction_get_value_date ( transaction_number_2 );
+ if ( !value_date_2 && conf.transactions_list_primary_sorting == 0 )
+ value_date_2 = gsb_data_transaction_get_date ( transaction_number_2 );
+
+ if ( value_date_1 )
+ {
+ if (value_date_2)
+ return_value = g_date_compare ( value_date_1, value_date_2);
else
- return_value = gsb_transactions_list_sort_by_value_date ( transaction_number_1, transaction_number_2 );
+ return_value = -1;
+ }
+ else
+ {
+ if ( value_date_2 )
+ return_value = 1;
+ else
+ return_value = 0;
}
- return return_value;
+ if ( return_value )
+ return return_value;
+ else
+ return gsb_transactions_list_sort_initial_by_secondary_key (
+ transaction_number_1, transaction_number_2 );
+}
+
+
+/**
+ * used to compare 2 iters and sort the by secondary key:
+ * no or amount or payee_name
+ * always put the white line below
+ * \param model the GtkTreeModel
+ * \param iter_1
+ * \param iter_2
+ * \return -1 if iter_1 is above iter_2
+ * */
+gint gsb_transactions_list_sort_initial_by_secondary_key ( gint transaction_number_1,
+ gint transaction_number_2 )
+{
+ if ( conf.transactions_list_primary_sorting == 0 )
+ {
+ if ( conf.transactions_list_secondary_sorting == 1 )
+ return gsb_transactions_list_sort_by_amount (
+ transaction_number_1, transaction_number_2 );
+ else if ( conf.transactions_list_secondary_sorting == 2 )
+ return gsb_transactions_list_sort_by_party (
+ transaction_number_1, transaction_number_2 );
+ else
+ return transaction_number_1 - transaction_number_2;
+ }
+ else
+ {
+ if ( conf.transactions_list_secondary_sorting == 1 )
+ return gsb_transactions_list_sort_by_transaction_date_and_amount (
+ transaction_number_1, transaction_number_2 );
+ else if ( conf.transactions_list_secondary_sorting == 2 )
+ return gsb_transactions_list_sort_by_transaction_date_and_party (
+ transaction_number_1, transaction_number_2 );
+ else
+ return gsb_transactions_list_sort_by_transaction_date_and_no (
+ transaction_number_1, transaction_number_2 );
+ }
}
diff --git a/src/structures.h b/src/structures.h
index 536409f..201d409 100644
--- a/src/structures.h
+++ b/src/structures.h
@@ -188,8 +188,8 @@ struct gsb_conf_t
/* variables for the list of transactions */
gint show_transaction_selected_in_form; /* TRUE will show the selected transaction in the form */
gint show_transaction_gives_balance; /* TRUE si on visualise l'opération qui donne le solde du jour */
- gboolean transactions_list_sort_by_date; /* Options for sorting by date */
- gboolean transactions_list_sort_by_value_date; /* Options for sorting by value date */
+ gboolean transactions_list_primary_sorting; /* Primary sorting option for the transactions */
+ gboolean transactions_list_secondary_sorting; /* Secondary sorting option for the transactions */
/* archive stuff */
gint check_for_archival; /* TRUE if we want to check the number of non archived transactions at the opening */
hooks/post-receive
--
grisbi
More information about the cvs
mailing list