[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_4-108-gd7d2253

Pierre Biava nobody at users.sourceforge.net
Sun Nov 27 17:59:03 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  d7d22539fcf870ecb920206e73e513048b9684d2 (commit)
       via  e121e75867d13c9ffc1df9cc4fd7d083b711bcc2 (commit)
      from  e9f772fd2eed45bdb1f309bddd20ffb1e0c0d500 (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 d7d22539fcf870ecb920206e73e513048b9684d2
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Nov 27 16:43:33 2011 +0100

    Formatting the code

commit e121e75867d13c9ffc1df9cc4fd7d083b711bcc2
Author: pbiava <pierre.biava at nerim.net>
Date:   Sun Nov 27 17:46:51 2011 +0100

    Fixed a bug sorting of transactions when changing column

-----------------------------------------------------------------------

Changes:
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index 810e7dc..94eaa82 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -105,6 +105,9 @@ static void gsb_transactions_list_display_contra_transaction ( gint *transaction
 static gboolean gsb_transactions_list_fill_model ( void );
 static gboolean gsb_transactions_list_hide_transactions_in_archive_line ( GtkWidget *button,
                         gpointer null );
+static gint gsb_transactions_list_get_valid_element_sort ( gint account_number,
+                        gint column_number,
+                        gint element_number );
 static gboolean gsb_transactions_list_key_press ( GtkWidget *widget,
                         GdkEventKey *ev );
 static gboolean gsb_transactions_list_move_transaction_to_account ( gint transaction_number,
@@ -3490,7 +3493,7 @@ gboolean gsb_transactions_list_change_sort_column ( GtkTreeViewColumn *tree_view
 
     account_number = gsb_gui_navigation_get_current_account ();
     transaction_list_sort_get_column ( &current_column, &sort_type );
-    new_column = GPOINTER_TO_INT (column_ptr);
+    new_column = GPOINTER_TO_INT ( column_ptr );
 
     element_number = gsb_data_account_get_element_sort ( account_number, new_column );
 
@@ -3499,56 +3502,67 @@ gboolean gsb_transactions_list_change_sort_column ( GtkTreeViewColumn *tree_view
 
     /* 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 ())
+    if ( transaction_list_sort_get_reconcile_sort () )
     {
-	transaction_list_sort_set_reconcile_sort (FALSE);
-	gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON (reconcile_sort_list_button),
-				       FALSE );
-	/* if we asked the same last column, we invert the value,
-	 * to come back to the last sort_type before the sort reconciliation */
-	if (new_column == current_column)
-	{
-	    if (sort_type == GTK_SORT_ASCENDING)
-		sort_type = GTK_SORT_DESCENDING;
-	    else
-		sort_type = GTK_SORT_ASCENDING;
-	}
+        transaction_list_sort_set_reconcile_sort ( FALSE );
+        gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON ( reconcile_sort_list_button ),
+                                FALSE );
+        /* if we asked the same last column, we invert the value,
+         * to come back to the last sort_type before the sort reconciliation */
+        if ( new_column == current_column )
+        {
+            if ( sort_type == GTK_SORT_ASCENDING )
+                sort_type = GTK_SORT_DESCENDING;
+            else
+                sort_type = GTK_SORT_ASCENDING;
+        }
     }
 
     /* if the new column is the same as the old one, we change
      * the sort type */
-    if (new_column == current_column)
+    if ( new_column == current_column )
     {
-	if (sort_type == GTK_SORT_ASCENDING)
-	    sort_type = GTK_SORT_DESCENDING;
-	else
-	    sort_type = GTK_SORT_ASCENDING;
+        if ( sort_type == GTK_SORT_ASCENDING )
+            sort_type = GTK_SORT_DESCENDING;
+        else
+            sort_type = GTK_SORT_ASCENDING;
     }
     else
-	/* we sort by another column, so sort type by default is descending */
-	sort_type = GTK_SORT_ASCENDING;
+    {
+        gint new_element;
+
+        /* on vérifie que l'élément de tri existe sinon on met le premier élément de la colonne */
+        new_element = gsb_transactions_list_get_valid_element_sort ( account_number,
+                        new_column,
+                        element_number );
+        if ( new_element != element_number )
+        {
+            gsb_data_account_set_element_sort ( account_number, new_column, new_element );
+            element_number = new_element;
+        }
+        /* we sort by another column, so sort type by default is descending */
+        sort_type = GTK_SORT_ASCENDING;
+    }
 
     /* now have to save the new column and sort type in the account
      * or in all account if global conf for all accounts */
     tmp_list = gsb_data_account_get_list_accounts ();
-    while (tmp_list)
+    while ( tmp_list )
     {
-	gint tmp_account;
+        gint tmp_account;
 
-	tmp_account = gsb_data_account_get_no_account (tmp_list -> data);
+        tmp_account = gsb_data_account_get_no_account ( tmp_list -> data );
 
-	if (tmp_account == account_number
-	    ||
-	    !etat.retient_affichage_par_compte)
-	{
-	    /* set the new column to sort */
-	    gsb_data_account_set_sort_column ( tmp_account,
-					       new_column );
-	    /* save the sort_type */
-	    gsb_data_account_set_sort_type ( tmp_account,
-					     sort_type );
-	}
-	tmp_list = tmp_list -> next;
+        if ( tmp_account == account_number
+            ||
+            !etat.retient_affichage_par_compte )
+        {
+            /* set the new column to sort */
+            gsb_data_account_set_sort_column ( tmp_account, new_column );
+            /* save the sort_type */
+            gsb_data_account_set_sort_type ( tmp_account, sort_type );
+        }
+        tmp_list = tmp_list -> next;
     }
 
     selected_transaction = transaction_list_select_get ();
@@ -4492,6 +4506,31 @@ gchar *gsb_transaction_list_get_titre_colonne_liste_ope ( gint element )
 }
 
 
+/**
+ * Renvoie un élément de tri valide si celui passé en paramètre n'est pas une donnée
+ * valide de la colonne
+ *
+ * \param account_number
+ * \param column_number
+ * \param element_number élement à tester
+ *
+ * \return old element or element 0 si non trouvé
+ **/
+gint gsb_transactions_list_get_valid_element_sort ( gint account_number,
+                        gint column_number,
+                        gint element_number )
+{
+    gint i;
+
+    for ( i = 0 ; i < 4 ; i++ )
+    {
+        if ( tab_affichage_ope[i][column_number] == element_number )
+            return element_number;
+    }
+
+    return tab_affichage_ope[0][column_number];
+}
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list