[grisbi-cvs] [SCM] grisbi branch, grisbi-0.8.x, updated. upstream_version_0_8_9-12-gc58874a

Pierre Biava nobody at users.sourceforge.net
Mon Jan 16 23:07:26 CET 2012


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, grisbi-0.8.x has been updated
       via  c58874ae105fb24c9afcafc59fa42f3a47de18c4 (commit)
      from  223bdf8fde05ee4bdac473fc61ba4d0202543df2 (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 c58874ae105fb24c9afcafc59fa42f3a47de18c4
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Jan 16 23:06:49 2012 +0100

    Adding the option to remove orphaned transactions

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

Changes:
diff --git a/src/gsb_data_scheduled.c b/src/gsb_data_scheduled.c
index 00683be..a84d0bc 100644
--- a/src/gsb_data_scheduled.c
+++ b/src/gsb_data_scheduled.c
@@ -40,6 +40,8 @@
 #include "gsb_data_currency.h"
 #include "gsb_data_currency_link.h"
 #include "gsb_real.h"
+#include "structures.h"
+#include "traitement_variables.h"
 #include "utils_dates.h"
 #include "utils_str.h"
 #include "erreur.h"
@@ -1638,6 +1640,9 @@ gboolean gsb_data_scheduled_remove_scheduled ( gint scheduled_number )
     scheduled_list = g_slist_remove ( scheduled_list,
 				      scheduled );
 
+    if ( etat.modification_fichier == 0 )
+        modification_fichier ( TRUE );
+
     _gsb_data_scheduled_free ( scheduled );
     return TRUE;
 }
diff --git a/src/gsb_data_transaction.c b/src/gsb_data_transaction.c
index 2367796..34726d7 100644
--- a/src/gsb_data_transaction.c
+++ b/src/gsb_data_transaction.c
@@ -46,6 +46,7 @@
 #include "gsb_data_currency_link.h"
 #include "gsb_data_payee.h"
 #include "gsb_data_payment.h"
+#include "traitement_variables.h"
 #include "utils_dates.h"
 #include "gsb_real.h"
 #include "utils_str.h"
@@ -2313,6 +2314,8 @@ gboolean gsb_data_transaction_remove_transaction ( gint transaction_number )
 
     /* force the update module budget */
     gsb_data_account_set_bet_maj ( transaction -> account_number, BET_MAJ_ALL );
+    if ( etat.modification_fichier == 0 )
+        modification_fichier ( TRUE );
 
     return TRUE;
 }
diff --git a/src/gsb_scheduler_list.c b/src/gsb_scheduler_list.c
index c343f45..99257aa 100644
--- a/src/gsb_scheduler_list.c
+++ b/src/gsb_scheduler_list.c
@@ -85,6 +85,8 @@ static GtkTreeModel *gsb_scheduler_list_get_model ( void );
 static gboolean gsb_scheduler_list_key_press ( GtkWidget *tree_view,
                         GdkEventKey *ev );
 static gboolean gsb_scheduler_list_popup_custom_periodicity_dialog (void);
+static void gsb_scheduler_list_process_orphan_list ( GSList *orphan_scheduled,
+                        GDate *end_date );
 static gboolean gsb_scheduler_list_selection_changed ( GtkTreeSelection *selection,
                         gpointer null );
 static void gsb_scheduler_list_set_model ( GtkTreeModel *model );
@@ -715,44 +717,8 @@ gboolean gsb_scheduler_list_fill_list ( GtkWidget *tree_view )
     /* if there are some orphan sheduler (children of breakdonw wich didn't find their mother */
     if ( orphan_scheduled )
     {
-        gchar *string = NULL;
-
-        tmp_list = orphan_scheduled;
-        while (tmp_list)
-        {
-            gint scheduled_number;
-
-            scheduled_number = gsb_data_scheduled_get_scheduled_number (tmp_list -> data);
-
-            if (!gsb_scheduler_list_append_new_scheduled ( scheduled_number,
-                                   end_date ))
-            {
-                if ( string == NULL )
-                    string = utils_str_itoa ( scheduled_number );
-                else
-                    string = g_strconcat ( string, " - ",
-                        utils_str_itoa ( scheduled_number ), NULL );
-            }
-
-            tmp_list = tmp_list -> next;
-        }
-
-        /* if string is not null, there is still some children
-         * wich didn't find their mother. show them now */
-        if ( string )
-        {
-            gchar *message;
-
-            message = _("Some scheduled children didn't find their mother in the list, "
-            "this shouldn't happen and there is probably a bug behind that. Please contact "
-            "the Grisbi team.\n\nThe concerned children number are :\n");
-
-            message = g_strconcat (message, string, NULL);
-            dialogue_warning ( message );
-            g_free ( message );
-            g_free ( string );
-        }
-        g_slist_free (orphan_scheduled);
+        gsb_scheduler_list_process_orphan_list ( orphan_scheduled, end_date );
+        g_slist_free ( orphan_scheduled );
     }
 
     /* create and append the white line */
@@ -2601,6 +2567,72 @@ gboolean gsb_scheduler_list_update_white_child ( gint white_line_number,
 }
 
 
+/**
+ * remove the orphan transactions
+ *
+ * \param orphan list
+ *
+ * \return void
+ */
+void gsb_scheduler_list_process_orphan_list ( GSList *orphan_scheduled,
+                        GDate *end_date )
+{
+    GSList *tmp_list;
+    gchar *string = NULL;
+    GArray *garray;
+
+    garray = g_array_new ( FALSE, FALSE, sizeof ( gint ) );
+    tmp_list = orphan_scheduled;
+    while (tmp_list)
+    {
+        gint scheduled_number;
+
+        scheduled_number = gsb_data_scheduled_get_scheduled_number ( tmp_list -> data );
+
+        if ( !gsb_scheduler_list_append_new_scheduled ( scheduled_number, end_date ) )
+        {
+            /* on sauvegarde le numéro de l'opération */
+            g_array_append_val ( garray, scheduled_number );
+            if ( string == NULL )
+                string = utils_str_itoa ( scheduled_number );
+            else
+                string = g_strconcat ( string, " - ",
+                    utils_str_itoa ( scheduled_number ), NULL );
+        }
+
+        tmp_list = tmp_list -> next;
+    }
+
+    /* if string is not null, there is still some children
+     * wich didn't find their mother. show them now */
+    if ( string )
+    {
+        gchar *message;
+        gint result;
+
+        message = g_strdup_printf ( _("Some scheduled children didn't find their mother in the list, "
+                        "this shouldn't happen and there is probably a bug behind that.\n\n"
+                        "The concerned children number are :\n %s\n\n"
+                        "Do you want to delete it"),
+                        string );
+
+        result = question_yes_no_hint (_("Remove orphan children"), message, GTK_RESPONSE_CANCEL );
+
+        if (result == TRUE)
+        {
+            gint i;
+
+            for ( i = 0; i < garray->len; i++ )
+                gsb_data_scheduled_remove_scheduled ( g_array_index ( garray, gint, i ) );
+
+        }
+
+        g_free ( message );
+        g_free ( string );
+        g_array_free ( garray, TRUE );
+    }
+}
+
 
 /* Local Variables: */
 /* c-basic-offset: 4 */
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index 5759ac7..3dc211a 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -48,6 +48,7 @@
 #include "gsb_data_payee.h"
 #include "gsb_data_payment.h"
 #include "gsb_data_reconcile.h"
+#include "gsb_data_import_rule.h"
 #include "gsb_data_scheduled.h"
 #include "gsb_data_transaction.h"
 #include "gsb_form.h"
@@ -102,6 +103,7 @@ static gboolean gsb_transactions_list_key_press ( GtkWidget *widget,
                         GdkEventKey *ev );
 static gboolean gsb_transactions_list_move_transaction_to_account ( gint transaction_number,
                         gint target_account );
+static void gsb_transactions_list_process_orphan_list ( GSList *orphan_list );
 static void gsb_transactions_list_set_tree_view (GtkWidget *tree_view);
 static gboolean gsb_transactions_list_size_allocate ( GtkWidget *tree_view,
                         GtkAllocation *allocation,
@@ -559,49 +561,12 @@ gboolean gsb_transactions_list_fill_model ( void )
 
     /* if orphan_child_transactions if filled, there are some children wich didn't fing their
      * mother, we try again now that all the mothers are in the model */
-    if (orphan_child_transactions)
+    if ( orphan_child_transactions )
     {
-	GSList *orphan_list_copy;
+        gsb_transactions_list_process_orphan_list ( orphan_child_transactions );
 
-	orphan_list_copy = g_slist_copy (orphan_child_transactions);
-	g_slist_free (orphan_child_transactions);
-	orphan_child_transactions = NULL;
-
-	tmp_list = orphan_list_copy;
-	while (tmp_list)
-	{
-	    transaction_number = GPOINTER_TO_INT (tmp_list -> data);
-	    transaction_list_append_transaction (transaction_number);
-	    tmp_list = tmp_list -> next;
-	}
-	g_slist_free (orphan_list_copy);
-
-	/* if orphan_child_transactions is not null, there is still some children
-	 * wich didn't find their mother. show them now */
-	if (orphan_child_transactions)
-	{
-	    gchar *message = _("Some children didn't find their mother in the list, this "
-                           "shouldn't happen and there is probably a bug behind that. "
-                           "Please contact the Grisbi team.\n\nThe concerned children "
-                           "number are :\n");
-	    gchar *string_1;
-	    gchar *string_2;
-
-	    string_1 = g_strconcat (message, NULL);
-	    tmp_list = orphan_child_transactions;
-	    while (tmp_list)
-	    {
-		string_2 = g_strconcat ( string_1,
-					 utils_str_itoa (GPOINTER_TO_INT (tmp_list -> data)),
-					 " - ",
-					 NULL);
-		g_free (string_1);
-		string_1 = string_2;
-		tmp_list = tmp_list -> next;
-	    }
-	    dialogue_warning (string_1);
-	    g_free (string_1);
-	}
+        g_slist_free ( orphan_child_transactions );
+        orphan_child_transactions = NULL;
     }
     return FALSE;
 }
@@ -3906,6 +3871,68 @@ gboolean gsb_transactions_list_delete_import_rule ( gint import_rule_number )
 }
 
 
+/**
+ * remove the orphan transactions
+ *
+ * \param orphan list
+ *
+ * \return void
+ */
+void gsb_transactions_list_process_orphan_list ( GSList *orphan_list )
+{
+    GSList *tmp_list;
+    gchar *string = NULL;
+    GArray *garray;
+
+    garray = g_array_new ( FALSE, FALSE, sizeof ( gint ) );
+    tmp_list = orphan_list;
+    while (tmp_list)
+    {
+        gint transaction_number;
+
+        transaction_number = GPOINTER_TO_INT ( tmp_list -> data );
+
+        /* on sauvegarde le numéro de l'opération */
+        g_array_append_val ( garray, transaction_number );
+        if ( string == NULL )
+            string = utils_str_itoa ( transaction_number );
+        else
+            string = g_strconcat ( string, " - ",
+                utils_str_itoa ( transaction_number ), NULL );
+
+        tmp_list = tmp_list -> next;
+    }
+
+    /* if string is not null, there is still some children
+     * wich didn't find their mother. show them now */
+    if ( string )
+    {
+        gchar *message;
+        gint result;
+
+        message = g_strdup_printf ( _("Some children didn't find their mother in the list, "
+                        "this shouldn't happen and there is probably a bug behind that.\n\n"
+                        "The concerned children number are :\n %s\n\n"
+                        "Do you want to delete it"),
+                        string );
+
+        result = question_yes_no_hint (_("Remove orphan children"), message, GTK_RESPONSE_CANCEL );
+
+        if (result == TRUE)
+        {
+            gint i;
+
+            for ( i = 0; i < garray->len; i++ )
+                gsb_data_transaction_remove_transaction ( g_array_index ( garray, gint, i ) );
+        }
+
+        g_free ( message );
+        g_free ( string );
+        g_array_free ( garray, TRUE );
+    }
+}
+
+
 /* Local Variables: */
 /* c-basic-offset: 4 */
 /* End: */


hooks/post-receive
-- 
grisbi


More information about the cvs mailing list