[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_7_3-59-g38f23b5
Pierre Biava
nobody at users.sourceforge.net
Sun Sep 26 17:13:18 CEST 2010
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 38f23b5dd252f881d5e5e888a9fc8d793a3c11ce (commit)
from f1b16700eacfdcd827b84b1d3a928b4c2cc55594 (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 38f23b5dd252f881d5e5e888a9fc8d793a3c11ce
Author: pbiava <pierre.biava at nerim.net>
Date: Sun Sep 26 16:52:02 2010 +0200
Fixed bug 1132 and old bugs that affect the filtering operations
-----------------------------------------------------------------------
Changes:
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index 5e9cfbb..20bacbd 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -265,11 +265,11 @@ void gsb_transactions_list_update_tree_view ( gint account_number,
if ( keep_selected_transaction )
selected_transaction = transaction_list_select_get ( );
transaction_list_filter ( account_number );
+ transaction_list_set_balances ( );
transaction_list_sort ();
transaction_list_colorize ();
if ( conf.show_transaction_gives_balance )
transaction_list_set_color_jour ( account_number );
- transaction_list_set_balances ( );
if ( keep_selected_transaction )
transaction_list_select ( selected_transaction );
}
@@ -2375,10 +2375,10 @@ gboolean gsb_gui_change_cell_content ( GtkWidget * item, gint *element_ptr )
update_titres_tree_view ( );
/* update the sort column */
+ gsb_data_account_set_element_sort ( current_account, col, element );
if ( sort_column == last_col )
{
gsb_data_account_set_sort_column ( current_account, col );
- gsb_data_account_set_element_sort ( current_account, col, element );
transaction_list_sort_set_column ( col,
gsb_data_account_get_sort_type ( current_account ) );
}
@@ -2954,7 +2954,8 @@ gboolean gsb_transactions_list_title_column_button_press ( GtkWidget *button,
GdkEventButton *ev,
gint *no_column )
{
- GtkWidget *menu, *menu_item;
+ GtkWidget *menu = NULL;
+ GtkWidget *menu_item = NULL;
gint i;
gint active_sort;
gint column_number;
@@ -2966,91 +2967,68 @@ gboolean gsb_transactions_list_title_column_button_press ( GtkWidget *button,
{
case 3:
/* we press the right button, show the popup */
-
- menu = gtk_menu_new ();
-
- /* sort by line */
- menu_item = gtk_menu_item_new_with_label ( _("Sort list by :") );
-
- /* les 2 signaux sont bloqués pour éviter que la ligne s'affiche comme un bouton */
- /* pas réussi à faire autrement... */
-
- g_signal_connect ( G_OBJECT ( menu_item),
- "enter-notify-event",
- G_CALLBACK ( gtk_true ),
- NULL );
- g_signal_connect ( G_OBJECT ( menu_item),
- "motion-notify-event",
- G_CALLBACK ( gtk_true ),
- NULL );
-
- gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ),
- menu_item );
- gtk_widget_show_all ( menu_item );
-
- menu_item = gtk_separator_menu_item_new ();
- gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ),
- menu_item );
- gtk_widget_show ( menu_item );
-
-
active_sort = gsb_data_account_get_element_sort ( gsb_gui_navigation_get_current_account (),
column_number);
/* get the name of the labels of the columns and put them in a menu */
for ( i=0 ; i<4 ; i++ )
{
- gchar *temp;
+ gchar *temp;
- switch ( tab_affichage_ope[i][column_number] )
- {
- case 0:
- temp = NULL;
- break;
+ switch ( tab_affichage_ope[i][column_number] )
+ {
+ case 0:
+ temp = NULL;
+ break;
- default:
- temp = _(g_slist_nth_data ( liste_labels_titres_colonnes_liste_ope,
- tab_affichage_ope[i][column_number] - 1 ));
- }
+ default:
+ temp = _(g_slist_nth_data ( liste_labels_titres_colonnes_liste_ope,
+ tab_affichage_ope[i][column_number] - 1 ));
+ }
- if ( temp
- &&
- strcmp ( temp,
- N_("Balance")))
- {
- if ( i )
- menu_item = gtk_radio_menu_item_new_with_label_from_widget ( GTK_RADIO_MENU_ITEM ( menu_item ),
- temp );
- else
- menu_item = gtk_radio_menu_item_new_with_label ( NULL,
- temp );
-
- if ( tab_affichage_ope[i][column_number] == active_sort )
- gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM ( menu_item ),
- TRUE );
-
- g_object_set_data ( G_OBJECT ( menu_item ),
- "no_sort",
- GINT_TO_POINTER (tab_affichage_ope[i][column_number]));
- g_signal_connect ( G_OBJECT(menu_item),
- "activate",
- G_CALLBACK ( gsb_transactions_list_change_sort_type ),
- no_column );
- gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ),
- menu_item );
- gtk_widget_show ( menu_item );
- }
+ if ( temp && strcmp ( temp, _("Balance") ) )
+ {
+ if ( menu == NULL )
+ {
+ menu = gtk_menu_new ();
+ /* sort by line */
+ menu_item = gtk_menu_item_new_with_label ( _("Sort list by :") );
+ gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), menu_item );
+ gtk_widget_show_all ( menu_item );
+
+ menu_item = gtk_separator_menu_item_new ();
+ gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), menu_item );
+ gtk_widget_show ( menu_item );
+ }
+
+ if ( i && GTK_IS_RADIO_MENU_ITEM ( menu_item ) )
+ menu_item = gtk_radio_menu_item_new_with_label_from_widget ( GTK_RADIO_MENU_ITEM ( menu_item ),
+ temp );
+ else
+ menu_item = gtk_radio_menu_item_new_with_label ( NULL, temp );
+
+ if ( tab_affichage_ope[i][column_number] == active_sort )
+ gtk_check_menu_item_set_active ( GTK_CHECK_MENU_ITEM ( menu_item ), TRUE );
+
+ g_object_set_data ( G_OBJECT ( menu_item ),
+ "no_sort",
+ GINT_TO_POINTER (tab_affichage_ope[i][column_number]));
+ g_signal_connect ( G_OBJECT(menu_item),
+ "activate",
+ G_CALLBACK ( gsb_transactions_list_change_sort_type ),
+ no_column );
+
+ gtk_menu_shell_append ( GTK_MENU_SHELL ( menu ), menu_item );
+ gtk_widget_show ( menu_item );
+ }
}
- gtk_menu_popup ( GTK_MENU(menu),
- NULL,
- NULL,
- NULL,
- NULL,
- 3,
- gtk_get_current_event_time());
- gtk_widget_show (menu);
+ if ( menu )
+ {
+ gtk_menu_popup ( GTK_MENU ( menu ), NULL, NULL, NULL, NULL, 3, gtk_get_current_event_time () );
+ gtk_widget_show ( menu );
+ }
break;
}
return FALSE;
@@ -3118,14 +3096,19 @@ gboolean gsb_transactions_list_change_sort_column ( GtkTreeViewColumn *tree_view
gint new_column;
GSList *tmp_list;
gint selected_transaction;
+ gint element_number;
devel_debug (NULL);
account_number = gsb_gui_navigation_get_current_account ();
- transaction_list_sort_get_column ( ¤t_column,
- &sort_type );
+ transaction_list_sort_get_column ( ¤t_column, &sort_type );
new_column = GPOINTER_TO_INT (column_ptr);
+ element_number = gsb_data_account_get_element_sort ( account_number, new_column );
+
+ if ( element_number == ELEMENT_BALANCE )
+ return FALSE;
+
/* if we come here and the list was user custom sorted for reconcile,
* we stop the reconcile sort and set what is asked by the user */
if (transaction_list_sort_get_reconcile_sort ())
@@ -3183,13 +3166,13 @@ gboolean gsb_transactions_list_change_sort_column ( GtkTreeViewColumn *tree_view
selected_transaction = transaction_list_select_get ();
/* now we can sort the list */
- transaction_list_sort_set_column ( new_column,
- sort_type );
+ transaction_list_sort_set_column ( new_column, sort_type );
+ transaction_list_filter ( account_number );
+ transaction_list_set_balances ();
transaction_list_sort ();
transaction_list_colorize ();
if ( conf.show_transaction_gives_balance )
transaction_list_set_color_jour ( account_number );
- transaction_list_set_balances ();
transaction_list_select (selected_transaction);
if ( etat.modification_fichier == 0 )
diff --git a/src/gsb_transactions_list_sort.c b/src/gsb_transactions_list_sort.c
index 919416e..89e702e 100644
--- a/src/gsb_transactions_list_sort.c
+++ b/src/gsb_transactions_list_sort.c
@@ -1058,7 +1058,76 @@ gint gsb_transactions_list_sort_by_chq ( gint transaction_number_1,
}
+/**
+ * called by a click on the column, used to sort the list
+ *
+ * \param model
+ * \param iter_1
+ * \param iter_2
+ *
+ * \return -1 if iter_1 is above iter_2
+ * */
+gint gsb_transactions_list_sort_initial (CustomRecord **a,
+ CustomRecord **b,
+ CustomList *custom_list)
+{
+ gint account_number;
+ gint return_value;
+ CustomRecord *record_1 = NULL;
+ CustomRecord *record_2 = NULL;
+
+ account_number = gsb_gui_navigation_get_current_account ();
+ if (account_number == -1)
+ {
+ /* normally cannot happen, except come here at the opening
+ * of grisbi, and must return 0 if we don't want a crash */
+ return 0;
+ }
+
+ /* i don't know why but sometimes there is a comparison between the 2 same rows... */
+ if (*a == *b)
+ return 0;
+
+ /* first of all, check the archive */
+ return_value = gsb_transactions_list_sort_check_archive ( *a, *b );
+ if (!return_value)
+ {
+ /* check the general tests (white line...) */
+ /* get the records */
+ record_1 = *a;
+ record_2 = *b;
+ return_value = gsb_transactions_list_sort_general_test ( record_1, record_2 );
+ }
+
+ if (return_value)
+ {
+ /* we have already a returned value, but for archive or general test,
+ * the pos of the row need not to change, so must keep the return_value */
+ return return_value;
+ }
+ else
+ {
+ /* 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);
+
+ 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 );
+ else
+ return_value = gsb_transactions_list_sort_by_value_date ( transaction_number_1, transaction_number_2 );
+ }
+ return return_value;
+}
/* Local Variables: */
diff --git a/src/gsb_transactions_list_sort.h b/src/gsb_transactions_list_sort.h
index cb0ff54..5ce3b29 100644
--- a/src/gsb_transactions_list_sort.h
+++ b/src/gsb_transactions_list_sort.h
@@ -13,5 +13,8 @@ gint gsb_transactions_list_sort_check_archive ( CustomRecord *record_1,
CustomRecord *record_2 );
gint gsb_transactions_list_sort_general_test ( CustomRecord *record_1,
CustomRecord *record_2 );
+gint gsb_transactions_list_sort_initial (CustomRecord **a,
+ CustomRecord **b,
+ CustomList *custom_list);
/* END_DECLARATION */
#endif
diff --git a/src/transaction_list.c b/src/transaction_list.c
index f5e495b..2091ae3 100644
--- a/src/transaction_list.c
+++ b/src/transaction_list.c
@@ -44,6 +44,7 @@
#include "gsb_data_archive_store.h"
#include "gsb_data_currency.h"
#include "gsb_data_transaction.h"
+#include "gsb_transactions_list_sort.h"
#include "navigation.h"
#include "gsb_real.h"
#include "transaction_list_select.h"
@@ -612,6 +613,7 @@ void transaction_list_filter ( gint account_number )
gint previous_visible_rows;
GtkTreeIter iter;
gint i;
+ gint *neworder;
CustomList *custom_list;
custom_list = transaction_model_get_model ();
@@ -775,6 +777,29 @@ void transaction_list_filter ( gint account_number )
gtk_tree_model_row_deleted ( GTK_TREE_MODEL (custom_list),
path );
gtk_tree_path_free(path);
+
+ /* initial sort of the list */
+ g_qsort_with_data(custom_list->visibles_rows,
+ custom_list->num_visibles_rows,
+ sizeof(CustomRecord*),
+ (GCompareDataFunc) gsb_transactions_list_sort_initial,
+ custom_list);
+
+ /* let other objects know about the new order */
+ neworder = g_new0(gint, custom_list->num_visibles_rows);
+
+ for (i = 0; i < custom_list->num_visibles_rows; ++i)
+ {
+ neworder[i] = (custom_list->visibles_rows[i])->filtered_pos;
+ (custom_list->visibles_rows[i])->filtered_pos = i;
+ }
+
+ path = gtk_tree_path_new();
+
+ gtk_tree_model_rows_reordered(GTK_TREE_MODEL(custom_list), path, NULL, neworder);
+
+ gtk_tree_path_free(path);
+ g_free(neworder);
}
diff --git a/src/transaction_list_sort.c b/src/transaction_list_sort.c
index aee8098..d32c452 100644
--- a/src/transaction_list_sort.c
+++ b/src/transaction_list_sort.c
@@ -31,18 +31,20 @@
/*START_INCLUDE*/
#include "transaction_list_sort.h"
+#include "custom_list.h"
+#include "gsb_data_account.h"
#include "gsb_data_transaction.h"
-#include "utils_dates.h"
#include "gsb_reconcile_list.h"
-#include "gsb_transactions_list_sort.h"
#include "gsb_transactions_list.h"
+#include "gsb_transactions_list_sort.h"
+#include "navigation.h"
#include "transaction_model.h"
-#include "custom_list.h"
-#include "include.h"
+#include "utils_dates.h"
#include "erreur.h"
/*END_INCLUDE*/
/*START_STATIC*/
+static gboolean transaction_list_sort_get_initial_sort ( void );
/*END_STATIC*/
/*START_EXTERN*/
@@ -72,10 +74,8 @@ void transaction_list_sort (void)
gint *neworder, i;
CustomList *custom_list;
- custom_list = transaction_model_get_model ();
-
devel_debug (NULL);
-
+ custom_list = transaction_model_get_model ();
g_return_if_fail ( custom_list != NULL );
/* resort */
@@ -85,8 +85,10 @@ void transaction_list_sort (void)
sizeof(CustomRecord*),
(GCompareDataFunc) gsb_reconcile_list_sort_func,
custom_list);
+ else if ( transaction_list_sort_get_initial_sort ( ) && custom_list -> sort_order == GTK_SORT_ASCENDING )
+ return;
else
- g_qsort_with_data(custom_list->visibles_rows,
+ g_qsort_with_data(custom_list->visibles_rows,
custom_list->num_visibles_rows,
sizeof(CustomRecord*),
(GCompareDataFunc) gsb_transactions_list_sort,
@@ -97,21 +99,6 @@ void transaction_list_sort (void)
for (i = 0; i < custom_list->num_visibles_rows; ++i)
{
- /* CustomRecord *record;
- gint transaction_number;
-
- record = custom_list -> visibles_rows[i];
- transaction_number = gsb_data_transaction_get_transaction_number (
- record -> transaction_pointer);
- printf ("pos = %d date = %s transaction_number = %d\n",
- i,
- gsb_format_gdate ( gsb_data_transaction_get_date (
- transaction_number ) ),
- transaction_number);
- printf ("transaction_number = %d record -> filtered_pos = %d record -> line_in_transaction =%d\n",
- gsb_data_transaction_get_transaction_number ( record -> transaction_pointer),
- record -> filtered_pos,
- record -> line_in_transaction); */
neworder[i] = (custom_list->visibles_rows[i])->filtered_pos;
(custom_list->visibles_rows[i])->filtered_pos = i;
}
@@ -242,4 +229,27 @@ gboolean transaction_list_sort_get_reconcile_sort ( void )
}
+/**
+ * get if the sorting function is initial (by date or value_date) or not
+ *
+ * \param
+ *
+ * \return TRUE if the list is sorted by date or value_date, FALSE if not
+ * */
+gboolean transaction_list_sort_get_initial_sort ( void )
+{
+ gint account_number;
+ gint element_number;
+
+ account_number = gsb_gui_navigation_get_current_account ();
+ if (account_number == -1)
+ return FALSE;
+
+ element_number = gsb_data_account_get_element_sort ( account_number,
+ gsb_data_account_get_sort_column ( account_number ) );
+ if ( element_number == ELEMENT_DATE || element_number == ELEMENT_VALUE_DATE )
+ return TRUE;
+ else
+ return FALSE;
+}
hooks/post-receive
--
grisbi
More information about the cvs
mailing list