[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_5-54-g87078b5

Pierre Biava nobody at users.sourceforge.net
Mon Jan 16 22:33:24 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, master has been updated
       via  87078b524693fe49c24463ee0764ec0132e62169 (commit)
      from  a3f9d076f70ee9271b5701ef3139a9fdb2aacbf8 (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 87078b524693fe49c24463ee0764ec0132e62169
Author: pbiava <pierre.biava at nerim.net>
Date:   Mon Jan 16 22:02:48 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 bd34126..f06dba0 100644
--- a/src/gsb_data_scheduled.c
+++ b/src/gsb_data_scheduled.c
@@ -39,6 +39,7 @@
 #include "gsb_currency.h"
 #include "gsb_data_currency.h"
 #include "gsb_data_currency_link.h"
+#include "gsb_file.h"
 #include "gsb_real.h"
 #include "utils_dates.h"
 #include "utils_str.h"
@@ -1615,34 +1616,35 @@ gboolean gsb_data_scheduled_remove_scheduled ( gint scheduled_number )
     scheduled = gsb_data_scheduled_get_scheduled_by_no ( scheduled_number);
 
     if ( !scheduled )
-	return FALSE;
+        return FALSE;
 
     if ( scheduled -> split_of_scheduled )
     {
-	GSList *list_tmp;
+        GSList *list_tmp;
 
-	list_tmp = gsb_data_scheduled_get_children (scheduled_number, FALSE);
+        list_tmp = gsb_data_scheduled_get_children (scheduled_number, FALSE);
 
-	while ( list_tmp )
-	{
-	    struct_scheduled *scheduled_child;
+        while ( list_tmp )
+        {
+            struct_scheduled *scheduled_child;
 
-	    scheduled_child = list_tmp -> data;
+            scheduled_child = list_tmp -> data;
 
-	    if ( scheduled_child )
-	    {
-		scheduled_list = g_slist_remove ( scheduled_list,
-						  scheduled_child );
-		_gsb_data_scheduled_free ( scheduled_child );
-	    }
-	    list_tmp = list_tmp -> next;
-	}
+            if ( scheduled_child )
+            {
+                scheduled_list = g_slist_remove ( scheduled_list, scheduled_child );
+                _gsb_data_scheduled_free ( scheduled_child );
+            }
+            list_tmp = list_tmp -> next;
+        }
     }
 
-    scheduled_list = g_slist_remove ( scheduled_list,
-				      scheduled );
+    scheduled_list = g_slist_remove ( scheduled_list, scheduled );
 
     _gsb_data_scheduled_free ( scheduled );
+
+    gsb_file_set_modified ( TRUE );
+
     return TRUE;
 }
 
diff --git a/src/gsb_data_transaction.c b/src/gsb_data_transaction.c
index 7203dba..2d9e6e4 100644
--- a/src/gsb_data_transaction.c
+++ b/src/gsb_data_transaction.c
@@ -47,10 +47,11 @@
 #include "gsb_data_currency_link.h"
 #include "gsb_data_payee.h"
 #include "gsb_data_payment.h"
-#include "utils_dates.h"
+#include "gsb_file.h"
 #include "gsb_real.h"
-#include "utils_str.h"
 #include "structures.h"
+#include "utils_dates.h"
+#include "utils_str.h"
 #include "erreur.h"
 /*END_INCLUDE*/
 
@@ -2304,13 +2305,12 @@ gboolean gsb_data_transaction_remove_transaction ( gint transaction_number )
     gsb_data_budget_remove_transaction_from_budget (transaction_number);
 
     /* now can remove safely the transaction */
-    transactions_list = g_slist_remove ( transactions_list,
-					 transaction );
-    complete_transactions_list = g_slist_remove ( complete_transactions_list,
-						  transaction );
+    transactions_list = g_slist_remove ( transactions_list, transaction );
+    complete_transactions_list = g_slist_remove ( complete_transactions_list, transaction );
 
     /* force the update module budget */
     gsb_data_account_set_bet_maj ( transaction -> account_number, BET_MAJ_ALL );
+    gsb_file_set_modified ( TRUE );
 
     gsb_data_transaction_free (transaction);
 
diff --git a/src/gsb_scheduler_list.c b/src/gsb_scheduler_list.c
index f4f083b..8ebe72a 100644
--- a/src/gsb_scheduler_list.c
+++ b/src/gsb_scheduler_list.c
@@ -92,6 +92,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 gboolean gsb_scheduler_list_set_color_of_mother ( gint mother_scheduled_number,
@@ -872,44 +874,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 */
@@ -2814,6 +2780,73 @@ gboolean gsb_scheduler_list_set_color_of_mother ( gint mother_scheduled_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 */
 /* End: */
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index d8a1607..bef8215 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -113,6 +113,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,
@@ -824,49 +825,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;
 }
@@ -4573,6 +4537,69 @@ gboolean gsb_transactions_list_delete_import_rule ( gint import_rule_number )
     return TRUE;
 }
 
+
+/**
+ * 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