[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_1-17-gb7bebd8
Pierre Biava
nobody at users.sourceforge.net
Sat Apr 30 23:33:01 CEST 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 b7bebd81e03af1c4e90b3a4f3295a262f9f372db (commit)
via 9f5a4cfffb41ee46a4262dcd5ab786ccd9d24122 (commit)
from a4caa3bbc36b9d13d2f6d02d26753d8b59f201f9 (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 b7bebd81e03af1c4e90b3a4f3295a262f9f372db
Author: pbiava <pierre.biava at nerim.net>
Date: Sat Apr 30 23:31:44 2011 +0200
Fixed a bug of selecting archived transactions from the category view
commit 9f5a4cfffb41ee46a4262dcd5ab786ccd9d24122
Author: pbiava <pierre.biava at nerim.net>
Date: Sat Apr 30 20:44:55 2011 +0200
minor changes
-----------------------------------------------------------------------
Changes:
diff --git a/src/gsb_data_archive_store.c b/src/gsb_data_archive_store.c
index 26670b2..c282afe 100644
--- a/src/gsb_data_archive_store.c
+++ b/src/gsb_data_archive_store.c
@@ -46,6 +46,7 @@
#include "gsb_data_transaction.h"
#include "gsb_real.h"
#include "transaction_list.h"
+#include "erreur.h"
/*END_INCLUDE*/
@@ -68,6 +69,9 @@ typedef struct
/* number of transactions in the archive for that account */
gint nb_transactions;
+
+ /* les transactions archivées sont visibles dans la vue des opérations FALSE par défaut */
+ gboolean transactions_visibles;
} struct_store_archive;
@@ -493,6 +497,11 @@ static gint gsb_data_archive_store_new ( void )
}
+/**
+ *
+ *
+ *
+ */
gsb_real gsb_data_archive_store_get_archives_balance ( gint account_number )
{
GSList *tmp_list;
@@ -514,6 +523,50 @@ gsb_real gsb_data_archive_store_get_archives_balance ( gint account_number )
return balance;
}
+
+
+/**
+ *
+ *
+ *
+ */
+gboolean gsb_data_archive_store_get_transactions_visibles ( gint archive_number,
+ gint account_number )
+{
+ struct_store_archive *archive_store;
+
+ archive_store = gsb_data_archive_store_find_struct ( archive_number, account_number );
+
+ if ( archive_store )
+ return archive_store -> transactions_visibles;
+ else
+ return FALSE;
+}
+
+
+/**
+ *
+ *
+ *
+ */
+gboolean gsb_data_archive_store_set_transactions_visibles ( gint archive_number,
+ gint account_number,
+ gboolean transactions_visibles )
+{
+ struct_store_archive *archive_store;
+
+ archive_store = gsb_data_archive_store_find_struct ( archive_number, account_number );
+
+ if ( archive_store )
+ {
+ archive_store -> transactions_visibles = transactions_visibles;
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
diff --git a/src/gsb_data_archive_store.h b/src/gsb_data_archive_store.h
index 0d74b92..dfecf0a 100644
--- a/src/gsb_data_archive_store.h
+++ b/src/gsb_data_archive_store.h
@@ -16,8 +16,13 @@ gsb_real gsb_data_archive_store_get_balance ( gint archive_store_number );
gint gsb_data_archive_store_get_number ( gpointer archive_ptr );
gpointer gsb_data_archive_store_get_structure ( gint archive_store_number );
gint gsb_data_archive_store_get_transactions_number ( gint archive_store_number );
+gboolean gsb_data_archive_store_get_transactions_visibles ( gint archive_number,
+ gint account_number );
gboolean gsb_data_archive_store_init_variables ( void );
gboolean gsb_data_archive_store_remove ( gint archive_store_number );
gboolean gsb_data_archive_store_remove_by_archive ( gint archive_number );
+gboolean gsb_data_archive_store_set_transactions_visibles ( gint archive_number,
+ gint account_number,
+ gboolean transactions_visibles );
/* END_DECLARATION */
#endif
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index 0d479d0..6053b38 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -1426,9 +1426,11 @@ gboolean gsb_transactions_list_button_press ( GtkWidget *tree_view,
if (ev -> type == GDK_2BUTTON_PRESS)
{
gint archive_number;
+ gint archive_store_number;
const gchar *name;
- archive_number = gsb_data_archive_store_get_archive_number (gsb_data_archive_store_get_number (transaction_pointer));
+ archive_store_number = gsb_data_archive_store_get_number ( transaction_pointer );
+ archive_number = gsb_data_archive_store_get_archive_number ( archive_store_number );
/* i don't know why but i had a crash with a NULL name of archive, so prevent here */
name = gsb_data_archive_get_name (archive_number);
@@ -1439,7 +1441,10 @@ gboolean gsb_transactions_list_button_press ( GtkWidget *tree_view,
"into the list ?"),
name );
if (question_yes_no ( tmpstr , GTK_RESPONSE_CANCEL ))
- gsb_transactions_list_restore_archive (archive_number, TRUE);
+ gsb_transactions_list_add_transactions_from_archive (archive_number,
+ gsb_data_archive_store_get_account_number ( archive_store_number ),
+ TRUE );
+
g_free(tmpstr);
}
else
@@ -3804,9 +3809,7 @@ gboolean gsb_transactions_list_restore_archive ( gint archive_number,
devel_debug_int (archive_number);
/* remove the lines of the archive in the model */
- exist = transaction_list_remove_archive (archive_number);
- /* remove the structures of archive_model */
- gsb_data_archive_store_remove_by_archive (archive_number);
+ exist = transaction_list_remove_archive ( archive_number );
/* si l'archive existait bien on ajoute les transactions dans la liste et dans le
* tree_view. Evite de charger deux fois les données si on supprime l'archive
@@ -3820,17 +3823,21 @@ gboolean gsb_transactions_list_restore_archive ( gint archive_number,
tmp_list = gsb_data_transaction_get_complete_transactions_list ();
while (tmp_list)
{
- transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data);
+ gint account_number;
- if ( gsb_data_transaction_get_archive_number (transaction_number) == archive_number)
- {
- /* append the transaction to the list of non archived transactions */
- gsb_data_transaction_add_archived_to_list (transaction_number);
+ transaction_number = gsb_data_transaction_get_transaction_number (tmp_list -> data);
+ account_number = gsb_data_transaction_get_account_number ( transaction_number );
+ if ( gsb_data_transaction_get_archive_number ( transaction_number ) == archive_number
+ &&
+ gsb_data_archive_store_get_transactions_visibles ( archive_number, account_number ) == FALSE )
+ {
+ /* append the transaction to the list of non archived transactions */
+ gsb_data_transaction_add_archived_to_list (transaction_number);
- /* the transaction belongs to the archive we want to show, so append it to the list store */
- transaction_list_append_transaction ( transaction_number);
- }
- tmp_list = tmp_list -> next;
+ /* the transaction belongs to the archive we want to show, so append it to the list store */
+ transaction_list_append_transaction ( transaction_number);
+ }
+ tmp_list = tmp_list -> next;
}
/* if orphan_child_transactions if filled, there are some children wich didn't find their
@@ -3878,6 +3885,9 @@ gboolean gsb_transactions_list_restore_archive ( gint archive_number,
}
}
+ /* remove the structures of archive_model */
+ gsb_data_archive_store_remove_by_archive ( archive_number );
+
/* all the transactions of the archive have been added, we just need to clean the list,
* but don't touch to the main page and to the current balances... we didn't change anything */
account_number = gsb_gui_navigation_get_current_account ();
@@ -3894,6 +3904,116 @@ gboolean gsb_transactions_list_restore_archive ( gint archive_number,
}
+/**
+ * add in the transactions list for the account the transactions in
+ * the archive
+ * set visible the transactions in the archive_store
+ *
+ * \param archive_number the archive to restore
+ * \param account_number the account
+ *
+ * \return FALSE
+ * */
+gboolean gsb_transactions_list_add_transactions_from_archive ( gint archive_number,
+ gint account_number,
+ gboolean show_warning )
+{
+ GSList *tmp_list;
+ gint transaction_number;
+ gboolean exist = FALSE;
+
+ devel_debug_int ( archive_number );
+
+ /* remove the line of the archive in the model for the account*/
+ exist = transaction_list_remove_archive_line ( archive_number, account_number );
+ /* set visible the transactions in archive_store */
+ gsb_data_archive_store_set_transactions_visibles ( archive_number, account_number, TRUE );
+
+ /* si l'archive existait bien on ajoute les transactions dans la liste et dans le
+ * tree_view. Evite de charger deux fois les données si on supprime l'archive
+ * après avoir ajouté les lignes */
+ if ( exist )
+ {
+ orphan_child_transactions = NULL;
+
+ /* second step, we add all the archived transactions of that archive into the
+ * transactions_list and into the store */
+ tmp_list = gsb_data_transaction_get_complete_transactions_list ( );
+ while ( tmp_list )
+ {
+ transaction_number = gsb_data_transaction_get_transaction_number ( tmp_list -> data );
+
+ if ( gsb_data_transaction_get_archive_number ( transaction_number ) == archive_number
+ &&
+ gsb_data_transaction_get_account_number ( transaction_number ) == account_number )
+ {
+ /* append the transaction to the list of non archived transactions */
+ gsb_data_transaction_add_archived_to_list ( transaction_number );
+
+ /* the transaction belongs to the archive we want to show, so append it to the list store */
+ transaction_list_append_transaction ( transaction_number);
+ }
+ tmp_list = tmp_list -> next;
+ }
+
+ /* if orphan_child_transactions if filled, there are some children wich didn't find their
+ * mother, we try again now that all the mothers are in the model */
+ if ( orphan_child_transactions )
+ {
+ GSList *orphan_list_copy;
+
+ 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 );
+ }
+ }
+
+ gsb_transactions_list_update_tree_view ( account_number, TRUE );
+
+ if ( !gsb_data_account_get_r ( account_number) && show_warning )
+ dialogue ( _("You have just recovered an archive, if you don't see any new "
+ "transaction, remember that the R transactions are not showed "
+ "so the archived transactions are certainly hidden...\n\n"
+ "Show the R transactions to make them visible.") );
+ }
+
+ return FALSE;
+}
+
/**
* called when the size of the tree view changed, to keep the same ration
diff --git a/src/gsb_transactions_list.h b/src/gsb_transactions_list.h
index 9aed76f..bc60a19 100644
--- a/src/gsb_transactions_list.h
+++ b/src/gsb_transactions_list.h
@@ -48,6 +48,9 @@ gint find_element_col_split ( gint element_number );
gint find_element_line ( gint element_number );
void gsb_gui_update_transaction_toolbar ( void );
gchar *gsb_transactions_get_category_real_name ( gint transaction_number );
+gboolean gsb_transactions_list_add_transactions_from_archive ( gint archive_number,
+ gint account_number,
+ gboolean show_warning );
gboolean gsb_transactions_list_append_new_transaction ( gint transaction_number,
gboolean update_tree_view );
gboolean gsb_transactions_list_delete_transaction ( gint transaction_number,
diff --git a/src/metatree.c b/src/metatree.c
index 54a46bc..f368dfa 100644
--- a/src/metatree.c
+++ b/src/metatree.c
@@ -1139,22 +1139,26 @@ gboolean division_activated ( GtkTreeView * treeview, GtkTreePath * path,
/* We do not jump to a transaction if a division is specified */
if ( transaction_number && !no_division && !no_sub_division )
{
+ gint account_number;
+ gint archive_number;
+
+ account_number = gsb_data_transaction_get_account_number ( transaction_number );
+ archive_number = gsb_data_transaction_get_archive_number ( transaction_number );
+
/* If transaction is an archive return */
- if ( gsb_data_transaction_get_archive_number ( transaction_number ) )
+ if ( archive_number )
{
- dialogue_warning ( _("This transaction is archived.\n\n"
- "You must view the transactions in this archive for access.") );
- return FALSE;
+ gsb_transactions_list_add_transactions_from_archive (archive_number, account_number, FALSE );
}
- /* If transaction is reconciled, show reconciled
- * transactions. */
- if ( gsb_data_transaction_get_marked_transaction (transaction_number) == OPERATION_RAPPROCHEE &&
- !gsb_data_account_get_r (gsb_gui_navigation_get_current_account ()))
+ /* If transaction is reconciled, show reconciled transactions. */
+ if ( gsb_data_transaction_get_marked_transaction ( transaction_number ) == OPERATION_RAPPROCHEE
+ &&
+ gsb_data_account_get_r ( account_number ) == FALSE )
{
- mise_a_jour_affichage_r ( TRUE );
+ mise_a_jour_affichage_r ( TRUE );
}
- navigation_change_account ( GINT_TO_POINTER ( gsb_data_transaction_get_account_number (transaction_number)));
+ navigation_change_account ( GINT_TO_POINTER ( account_number ) );
gsb_account_property_fill_page ();
gsb_gui_notebook_change_page ( GSB_ACCOUNT_PAGE );
gsb_gui_navigation_set_selection ( GSB_ACCOUNT_PAGE,
diff --git a/src/transaction_list.c b/src/transaction_list.c
index 7643425..247c7d7 100644
--- a/src/transaction_list.c
+++ b/src/transaction_list.c
@@ -292,7 +292,7 @@ void transaction_list_append_transaction ( gint transaction_number )
*
* \return
* */
-void transaction_list_append_archive (gint archive_store_number)
+void transaction_list_append_archive ( gint archive_store_number )
{
gint archive_number;
gulong newsize;
@@ -323,7 +323,7 @@ void transaction_list_append_archive (gint archive_store_number)
/* create and fill the record */
newrecord = g_malloc0 (sizeof (CustomRecord));
- archive_number = gsb_data_archive_store_get_archive_number (archive_store_number);
+ archive_number = gsb_data_archive_store_get_archive_number ( archive_store_number );
if ( find_element_col ( ELEMENT_DATE ) == 0 )
element_date = find_element_col_for_archive ( );
@@ -2183,6 +2183,79 @@ gboolean transaction_list_get_variance ( gint transaction_number )
else
return FALSE;
}
+
+
+/**
+ * remove an archive line from the tree model
+ * it should be a good thing to update the tree_view after that
+ *
+ * \param archive_number the archive to remove
+ * \param account_number the account
+ *
+ * \return TRUE : archive removed, FALSE : problem, nothing done
+ * */
+gboolean transaction_list_remove_archive_line ( gint archive_number,
+ gint account_number )
+{
+ gint i;
+ CustomList *custom_list;
+ gboolean return_val = FALSE;
+
+ custom_list = transaction_model_get_model ();
+
+ if ( custom_list == NULL )
+ return FALSE;
+
+ for ( i = 0 ; i < custom_list -> num_rows ; i++ )
+ {
+ CustomRecord *record;
+ gulong newsize;
+ gint j;
+ gint archive_store_number;
+
+ record = custom_list -> rows[i];
+ archive_store_number = gsb_data_archive_store_get_number ( record -> transaction_pointer );
+ if ( record -> what_is_line != IS_ARCHIVE
+ ||
+ gsb_data_archive_store_get_archive_number ( archive_store_number ) != archive_number
+ ||
+ gsb_data_archive_store_get_account_number ( archive_store_number ) != account_number )
+ {
+ continue;
+ }
+
+ /* we are on a good archive store, delete it */
+
+ /* delete the row */
+ for ( j=0 ; j<CUSTOM_MODEL_VISIBLE_COLUMNS ; j++ )
+ if (record -> visible_col[j])
+ g_free (record -> visible_col[j]);
+
+ /* remove the row. I decrement "i" because the next line of model is shifted
+ * and has "i" for index. Otherwise we do not test. */
+ custom_list -> num_rows--;
+ i--;
+
+ for (j=record -> pos ; j < custom_list -> num_rows ; j++)
+ {
+ custom_list -> rows[j] = custom_list -> rows[j+1];
+ custom_list -> rows[j] -> pos = j;
+ }
+
+ /* resize the array */
+ newsize = custom_list->num_rows * sizeof(CustomRecord*);
+ custom_list->rows = g_realloc(custom_list->rows, newsize);
+ custom_list->visibles_rows = g_realloc(custom_list->visibles_rows, newsize);
+
+ /* free the record */
+ g_free (record);
+ return_val = TRUE;
+ }
+
+ return return_val;
+}
+
+
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
diff --git a/src/transaction_list.h b/src/transaction_list.h
index ef114c9..02bb901 100644
--- a/src/transaction_list.h
+++ b/src/transaction_list.h
@@ -17,6 +17,8 @@ gint transaction_list_get_n_children ( gint transaction_number );
gboolean transaction_list_get_variance ( gint transaction_number );
gboolean transaction_list_redraw ( void );
gboolean transaction_list_remove_archive ( gint archive_number );
+gboolean transaction_list_remove_archive_line ( gint archive_number,
+ gint account_number );
gboolean transaction_list_remove_transaction ( gint transaction_number );
void transaction_list_set ( GtkTreeIter *iter, ... );
void transaction_list_set_balances ( void );
diff --git a/src/utils_operations.c b/src/utils_operations.c
index cc904bd..ca2bd58 100644
--- a/src/utils_operations.c
+++ b/src/utils_operations.c
@@ -156,9 +156,9 @@ void delete_transaction_in_categ_tree ( gint transaction_number )
category_interface = category_get_metatree_interface ( );
gsb_data_category_remove_transaction_from_category (transaction_number);
- metatree_remove_transaction ( GTK_TREE_VIEW ( category_list_get_tree_view ( ) ),
+ metatree_remove_transaction ( GTK_TREE_VIEW ( category_list_get_tree_view ( ) ),
category_interface,
- transaction_number,
+ transaction_number,
FALSE);
}
hooks/post-receive
--
grisbi
More information about the cvs
mailing list