[grisbi-cvs] [SCM] grisbi branch, master, updated. upstream_version_0_9_1-50-g93db2a5
Pierre Biava
nobody at users.sourceforge.net
Tue May 17 22:08:21 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 93db2a5e7da540c0691664779c6e67bdd440dad8 (commit)
via b27c50fb2f7c24e3112225930592eec797b3ab32 (commit)
from 9be76fa94a6ab0dfc3f2bf067b7ce97b8e90c3bb (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 93db2a5e7da540c0691664779c6e67bdd440dad8
Author: pbiava <pierre.biava at nerim.net>
Date: Tue May 17 22:07:46 2011 +0200
Adding the ability to undo changes the data of bank in account properties.
commit b27c50fb2f7c24e3112225930592eec797b3ab32
Author: pbiava <pierre.biava at nerim.net>
Date: Sun May 15 21:27:11 2011 +0200
Selection of suitable reconciliation to the transaction
(cherry picked from commit 0a3444ae09d8f09db0fe26a0a7ddab2fbeb926db)
-----------------------------------------------------------------------
Changes:
diff --git a/src/gsb_account_property.c b/src/gsb_account_property.c
index 46c73be..006c87a 100644
--- a/src/gsb_account_property.c
+++ b/src/gsb_account_property.c
@@ -385,14 +385,10 @@ GtkWidget *gsb_account_property_create_page ( void )
gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group ), label );
gtk_box_pack_start ( GTK_BOX(hbox), label, FALSE, FALSE, 0);
- bank_list_combobox = gsb_bank_create_combobox ( 0,
- NULL,
- NULL,
- G_CALLBACK (gsb_data_account_set_bank),
- 0 );
- g_signal_connect ( G_OBJECT (bank_list_combobox),
+ bank_list_combobox = gsb_bank_create_combobox ( 0 );
+ g_signal_connect ( G_OBJECT ( bank_list_combobox ),
"changed",
- G_CALLBACK (gsb_account_property_changed_bank_label),
+ G_CALLBACK ( gsb_account_property_changed_bank_label ),
NULL );
gtk_box_pack_start ( GTK_BOX(hbox), bank_list_combobox, TRUE, TRUE, 0);
@@ -1144,9 +1140,7 @@ gboolean gsb_account_property_iban_set_bank_from_iban ( gchar *iban )
g_signal_handlers_block_by_func ( G_OBJECT ( bank_list_combobox ),
G_CALLBACK ( gsb_account_property_changed_bank_label ),
NULL );
- gsb_bank_list_set_bank ( bank_list_combobox,
- bank_number,
- current_account );
+ gsb_bank_list_set_bank ( bank_list_combobox, bank_number );
g_signal_handlers_unblock_by_func ( G_OBJECT ( bank_list_combobox ),
G_CALLBACK ( gsb_account_property_changed_bank_label ),
NULL );
diff --git a/src/gsb_assistant_account.c b/src/gsb_assistant_account.c
index 72d2790..40dcc0f 100644
--- a/src/gsb_assistant_account.c
+++ b/src/gsb_assistant_account.c
@@ -284,15 +284,15 @@ static GtkWidget *gsb_assistant_account_page_3 ( GtkWidget *assistant )
GTK_SHRINK | GTK_FILL,
0, 0 );
- account_combobox_bank = gsb_bank_create_combobox (0, NULL, NULL, NULL, 0);
+ account_combobox_bank = gsb_bank_create_combobox (0 );
if ( gsb_data_bank_max_number() != 0 )
{
- gsb_bank_list_set_bank ( account_combobox_bank, 1, 0 );
+ gsb_bank_list_set_bank ( account_combobox_bank, 1 );
}
else
{
- gsb_bank_list_set_bank ( account_combobox_bank, 0, 0 );
+ gsb_bank_list_set_bank ( account_combobox_bank, 0 );
}
gtk_table_attach ( GTK_TABLE ( table ), account_combobox_bank,
1, 2, 1, 2,
diff --git a/src/gsb_bank.c b/src/gsb_bank.c
index d3738e9..01c924b 100644
--- a/src/gsb_bank.c
+++ b/src/gsb_bank.c
@@ -43,10 +43,13 @@
#include "gsb_autofunc.h"
#include "gsb_data_account.h"
#include "gsb_data_bank.h"
+#include "gsb_transactions_list.h"
+#include "navigation.h"
+#include "structures.h"
#include "traitement_variables.h"
#include "utils.h"
-#include "structures.h"
-#include "gsb_transactions_list.h"
+#include "utils_editables.h"
+#include "erreur.h"
/*END_INCLUDE*/
/*START_STATIC*/
@@ -54,8 +57,6 @@ static gboolean gsb_bank_add ( GtkWidget *button,
gpointer null );
static void gsb_bank_bic_code_changed ( GtkEntry *entry, gpointer data );
static void gsb_bank_code_changed ( GtkEntry *entry, gpointer data );
-static gboolean gsb_bank_combobox_changed ( GtkWidget *combobox,
- gboolean default_func (gint, gint));
static gboolean gsb_bank_create_combobox_model ( void );
static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
GtkWidget *combobox );
@@ -70,6 +71,7 @@ static gboolean gsb_bank_list_changed ( GtkWidget *combobox,
static gboolean gsb_bank_list_check_separator ( GtkTreeModel *model,
GtkTreeIter *iter,
gpointer null );
+static void gsb_bank_update_bank_data ( gint bank_number );
static gboolean gsb_bank_update_form ( gint bank_number,
GtkWidget *frame );
static gboolean gsb_bank_update_selected_line ( GtkEntry *entry,
@@ -102,8 +104,8 @@ static GtkWidget *delete_bank_button;
static GtkWidget *bank_name;
static GtkWidget *bank_code;
static GtkWidget *bank_BIC;
-static GtkWidget *bank_tel;
static GtkWidget *bank_adr;
+static GtkWidget *bank_tel;
static GtkWidget *bank_mail;
static GtkWidget *bank_web;
static GtkWidget *bank_contact_name;
@@ -134,20 +136,16 @@ static GtkWidget *bank_notes;
*
* \return GtkWidget * the combo_box
* */
-GtkWidget *gsb_bank_create_combobox ( gint index,
- GCallback hook,
- gpointer data,
- GCallback default_func,
- gint number_for_func )
+GtkWidget *gsb_bank_create_combobox ( gint index )
{
GtkWidget *combo_box;
GtkCellRenderer *renderer;
/* create the model if not done */
- if (!bank_list_model)
- gsb_bank_update_selected_line_model (NULL);
+ if ( !bank_list_model )
+ gsb_bank_update_selected_line_model ( NULL );
- combo_box = gtk_combo_box_new_with_model (bank_list_model);
+ combo_box = gtk_combo_box_new_with_model ( bank_list_model );
/* show the text column */
renderer = gtk_cell_renderer_text_new ();
@@ -161,27 +159,15 @@ GtkWidget *gsb_bank_create_combobox ( gint index,
(GtkTreeViewRowSeparatorFunc) gsb_bank_list_check_separator,
NULL, NULL );
+ /* set the index */
+ gsb_bank_list_set_bank ( combo_box, index );
+
/* the signal just check if we select new bank, to show the dialog to add a new bank */
g_signal_connect ( G_OBJECT (combo_box),
"changed",
- G_CALLBACK (gsb_bank_list_changed),
+ G_CALLBACK ( gsb_bank_list_changed ),
NULL );
- /* add the defaut func if exists */
- g_object_set_data ( G_OBJECT (combo_box),
- "number_for_func", GINT_TO_POINTER (number_for_func));
- if (default_func)
- g_object_set_data ( G_OBJECT (combo_box), "changed",
- (gpointer) g_signal_connect_after (G_OBJECT(combo_box), "changed",
- G_CALLBACK (gsb_bank_combobox_changed), default_func ));
- /* add the hook if exists */
- if ( hook )
- g_object_set_data ( G_OBJECT (combo_box), "changed-hook",
- (gpointer) g_signal_connect_after (G_OBJECT(combo_box), "changed",
- ((GCallback) hook), data ));
-
- /* set the index */
- gsb_bank_list_set_bank (combo_box, index, number_for_func);
return combo_box;
}
@@ -223,95 +209,48 @@ gint gsb_bank_list_get_bank_number ( GtkWidget *combobox )
* \return FALSE
* */
gboolean gsb_bank_list_set_bank ( GtkWidget *combobox,
- gint bank_number,
- gint number_for_func )
+ gint bank_number )
{
GtkTreeIter iter;
- if (!combobox)
- return FALSE;
+ if ( !combobox )
+ return FALSE;
- if (!gtk_tree_model_get_iter_first ( GTK_TREE_MODEL (bank_list_model),
- &iter ))
- return FALSE;
+ if ( !gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( bank_list_model ), &iter ) )
+ return FALSE;
- /* Block hook and default_func */
- if ( g_object_get_data (G_OBJECT (combobox), "changed") > 0 )
- g_signal_handler_block ( G_OBJECT(combobox),
- (gulong) g_object_get_data (G_OBJECT (combobox),
- "changed"));
- if ( g_object_get_data (G_OBJECT (combobox), "changed-hook") > 0 )
- g_signal_handler_block ( G_OBJECT(combobox),
- (gulong) g_object_get_data (G_OBJECT (combobox),
- "changed-hook"));
+ /* on bloque la fonction de callback */
+ g_signal_handlers_block_by_func ( G_OBJECT ( combobox ),
+ gsb_bank_list_changed,
+ NULL );
do
{
- gint current_bank;
-
- gtk_tree_model_get ( GTK_TREE_MODEL (bank_list_model),
- &iter,
- BANK_NUMBER_COL, ¤t_bank,
- -1 );
-
- if (bank_number == current_bank)
- {
- /* bank found */
- gtk_combo_box_set_active_iter ( GTK_COMBO_BOX (combobox),
- &iter );
- break;
- }
+ gint current_bank;
+
+ gtk_tree_model_get ( GTK_TREE_MODEL ( bank_list_model ),
+ &iter,
+ BANK_NUMBER_COL, ¤t_bank,
+ -1 );
+
+ if ( bank_number == current_bank )
+ {
+ /* bank found */
+ gtk_combo_box_set_active_iter ( GTK_COMBO_BOX ( combobox ), &iter );
+ break;
+ }
}
- while (gtk_tree_model_iter_next (GTK_TREE_MODEL (bank_list_model), &iter));
-
- g_object_set_data ( G_OBJECT (combobox),
- "number_for_func", GINT_TO_POINTER (number_for_func));
-
- /* Unblock everything */
- if ( g_object_get_data (G_OBJECT (combobox), "changed") > 0 )
- g_signal_handler_unblock ( G_OBJECT(combobox),
- (gulong) g_object_get_data (G_OBJECT (combobox),
- "changed"));
- if ( g_object_get_data (G_OBJECT (combobox), "changed-hook") > 0 )
- g_signal_handler_unblock ( G_OBJECT(combobox),
- (gulong) g_object_get_data (G_OBJECT (combobox),
- "changed-hook"));
- return FALSE;
-}
-
-
-
-/**
- * called when the place change in the bank combobox
- *
- * \param combobox The reference Combobox
- * \param default_func the function to call to change the value in memory
- *
- * \return FALSE
- */
-static gboolean gsb_bank_combobox_changed ( GtkWidget *combobox,
- gboolean default_func (gint, gint))
-{
- gint number_for_func;
+ while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( bank_list_model ), &iter ) );
- /* just to be sure... */
- if (!default_func || !combobox)
- return FALSE;
-
- number_for_func = GPOINTER_TO_INT ( g_object_get_data (G_OBJECT (combobox), "number_for_func"));
- default_func ( number_for_func,
- gsb_bank_list_get_bank_number (combobox));
-
- /* Mark file as modified */
- if ( etat.modification_fichier == 0 )
- modification_fichier ( TRUE );
+ /* on débloque la fonction de callback */
+ g_signal_handlers_unblock_by_func ( G_OBJECT ( combobox ),
+ gsb_bank_list_changed,
+ NULL );
return FALSE;
}
-
-
/**
* callback called when click on the edit-bank in the property of account
* show a window with the parameters of the bank in the combobox
@@ -326,14 +265,13 @@ gboolean gsb_bank_edit_from_button ( GtkWidget *button,
{
gint bank_number;
- bank_number = gsb_bank_list_get_bank_number (combobox);
+ bank_number = gsb_bank_list_get_bank_number ( combobox );
/* if bank_number = 0, it's none ; -1 : it's new bank, so don't edit */
if ( bank_number <= 0 )
return FALSE;
- gsb_bank_edit_bank ( bank_number,
- combobox );
+ gsb_bank_edit_bank ( bank_number, combobox );
return FALSE;
}
@@ -367,68 +305,63 @@ static gboolean gsb_bank_update_selected_line_model ( GtkWidget *combobox )
GtkTreeIter iter;
GSList *list_tmp;
gint save_bank_number = -1;
- gint number_for_func = 0;
/* save the selection */
if (combobox)
{
- save_bank_number = gsb_bank_list_get_bank_number (combobox);
- number_for_func = GPOINTER_TO_INT ( g_object_get_data (G_OBJECT (combobox), "number_for_func"));
+ save_bank_number = gsb_bank_list_get_bank_number ( combobox );
}
/* if no bank model, create it */
- if (!bank_list_model)
- gsb_bank_create_combobox_model ();
- gtk_list_store_clear (GTK_LIST_STORE (bank_list_model));
+ if ( !bank_list_model )
+ gsb_bank_create_combobox_model ( );
+
+ gtk_list_store_clear ( GTK_LIST_STORE ( bank_list_model ) );
/* first : none, whith 0 at number (no bank at 0) */
- gtk_list_store_append ( GTK_LIST_STORE (bank_list_model),
- &iter );
- gtk_list_store_set ( GTK_LIST_STORE (bank_list_model),
- &iter,
- BANK_NAME_COL, _("None"),
- BANK_NUMBER_COL, 0,
- -1 );
+ gtk_list_store_append ( GTK_LIST_STORE ( bank_list_model ), &iter );
+ gtk_list_store_set ( GTK_LIST_STORE ( bank_list_model ),
+ &iter,
+ BANK_NAME_COL, _("None"),
+ BANK_NUMBER_COL, 0,
+ -1 );
/* set the names */
list_tmp = gsb_data_bank_get_bank_list ();
while ( list_tmp )
{
- gint bank_number;
+ gint bank_number;
- bank_number = gsb_data_bank_get_no_bank (list_tmp->data);
+ bank_number = gsb_data_bank_get_no_bank ( list_tmp->data );
- gtk_list_store_append ( GTK_LIST_STORE (bank_list_model),
- &iter );
- gtk_list_store_set ( GTK_LIST_STORE (bank_list_model),
- &iter,
- BANK_NAME_COL, gsb_data_bank_get_name (bank_number),
- BANK_NUMBER_COL, bank_number,
- -1 );
- list_tmp = list_tmp -> next;
+ gtk_list_store_append ( GTK_LIST_STORE ( bank_list_model ), &iter );
+ gtk_list_store_set ( GTK_LIST_STORE ( bank_list_model ),
+ &iter,
+ BANK_NAME_COL, gsb_data_bank_get_name ( bank_number ),
+ BANK_NUMBER_COL, bank_number,
+ -1 );
+ list_tmp = list_tmp -> next;
}
/* separator line : the name of bank is null */
- gtk_list_store_append ( GTK_LIST_STORE (bank_list_model),
- &iter );
- gtk_list_store_set ( GTK_LIST_STORE (bank_list_model),
- &iter,
- BANK_NAME_COL, NULL,
- -1 );
+ gtk_list_store_append ( GTK_LIST_STORE ( bank_list_model ), &iter );
+ gtk_list_store_set ( GTK_LIST_STORE ( bank_list_model ),
+ &iter,
+ BANK_NAME_COL, NULL,
+ -1 );
/* item to add a bank : the number is -2 */
- gtk_list_store_append ( GTK_LIST_STORE (bank_list_model),
- &iter );
- gtk_list_store_set ( GTK_LIST_STORE (bank_list_model),
- &iter,
- BANK_NAME_COL, _("Add new bank"),
- BANK_NUMBER_COL, -2,
- -1 );
+ gtk_list_store_append ( GTK_LIST_STORE ( bank_list_model ), &iter );
+ gtk_list_store_set ( GTK_LIST_STORE ( bank_list_model ),
+ &iter,
+ BANK_NAME_COL, _("Add new bank"),
+ BANK_NUMBER_COL, -2,
+ -1 );
/* restore the selection */
- if (combobox)
- gsb_bank_list_set_bank (combobox, save_bank_number, number_for_func);
+ if ( combobox )
+ gsb_bank_list_set_bank ( combobox, save_bank_number );
return TRUE;
}
@@ -475,21 +408,27 @@ static gboolean gsb_bank_list_changed ( GtkWidget *combobox,
gint bank_number;
if (!combobox)
- return FALSE;
+ return FALSE;
bank_number = gsb_bank_list_get_bank_number (combobox);
/* check if not new bank, ie -2 */
- if (bank_number != -2)
- return FALSE;
+ if ( bank_number != -2 )
+ {
+ gsb_data_account_set_bank ( gsb_gui_navigation_get_current_account ( ), bank_number );
+ /* Mark file as modified */
+ if ( etat.modification_fichier == 0 )
+ modification_fichier ( TRUE );
+ return FALSE;
+ }
/* asked to add a new bank */
- bank_number = gsb_bank_add (combobox, NULL);
+ bank_number = gsb_bank_edit_bank ( bank_number, combobox );
+
return FALSE;
}
-
/* ---------------- the second part is on the parameters page of the banks ------------------------ */
@@ -716,19 +655,17 @@ static gboolean gsb_bank_list_change_selection ( GtkTreeSelection *selection,
static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
GtkWidget *combobox )
{
- GtkWidget * paddingbox, *table, *label, *scrolled_window;
+ GtkWidget *paddingbox, *table, *label, *scrolled_window;
GtkSizeGroup * size_group;
/* Bank details */
- paddingbox = new_paddingbox_with_title ( parent, TRUE,
- _("Bank details") );
+ paddingbox = new_paddingbox_with_title ( parent, TRUE, _("Bank details") );
/* Create a table to align things nicely */
table = gtk_table_new ( 10, 2, FALSE );
gtk_table_set_col_spacings ( GTK_TABLE ( table ), 5 );
gtk_table_set_row_spacings ( GTK_TABLE ( table ), 5 );
- gtk_box_pack_start ( GTK_BOX ( paddingbox ), table,
- TRUE, TRUE, 5 );
+ gtk_box_pack_start ( GTK_BOX ( paddingbox ), table, TRUE, TRUE, 5 );
size_group = gtk_size_group_new ( GTK_SIZE_GROUP_HORIZONTAL );
/* Bank name item */
@@ -736,10 +673,18 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
gtk_misc_set_alignment (GTK_MISC (label), 0, 1);
gtk_label_set_justify ( GTK_LABEL(label), GTK_JUSTIFY_RIGHT );
gtk_table_attach ( GTK_TABLE ( table ),
- label, 0, 1, 0, 1,
+ label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_name = gsb_autofunc_entry_new ( NULL, G_CALLBACK(gsb_bank_update_selected_line), combobox, G_CALLBACK (gsb_data_bank_set_name), 0);
+
+ if ( combobox )
+ bank_name = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_name = gsb_autofunc_entry_new ( NULL,
+ G_CALLBACK ( gsb_bank_update_selected_line ),
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_name ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_name );
gtk_table_attach ( GTK_TABLE ( table ),
bank_name, 1, 2, 0, 1,
@@ -754,7 +699,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_code = gsb_autofunc_entry_new ( NULL, G_CALLBACK (gsb_bank_code_changed), NULL, G_CALLBACK (gsb_data_bank_set_code), 0);
+
+ if ( combobox )
+ bank_code = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_code = gsb_autofunc_entry_new ( NULL,
+ G_CALLBACK ( gsb_bank_code_changed ),
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_code ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_code );
gtk_table_attach ( GTK_TABLE ( table ),
bank_code, 1, 2, 1, 2,
@@ -769,9 +722,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 2, 3,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_BIC = gsb_autofunc_entry_new ( NULL,
- G_CALLBACK (gsb_bank_bic_code_changed), NULL,
- G_CALLBACK (gsb_data_bank_set_bic), 0);
+
+ if ( combobox )
+ bank_BIC = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_BIC = gsb_autofunc_entry_new ( NULL,
+ G_CALLBACK ( gsb_bank_bic_code_changed ),
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_bic ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_BIC );
gtk_table_attach ( GTK_TABLE ( table ),
bank_BIC, 1, 2, 2, 3,
@@ -792,8 +751,16 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
GTK_POLICY_AUTOMATIC );
gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW(scrolled_window),
GTK_SHADOW_IN );
+
/* Create the text view */
- bank_adr = gsb_autofunc_textview_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_bank_address), 0);
+ if ( combobox )
+ bank_adr = gsb_autofunc_textview_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_adr = gsb_autofunc_textview_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_bank_address ),
+ 0 );
gtk_container_add ( GTK_CONTAINER ( scrolled_window ), bank_adr );
gtk_size_group_add_widget ( size_group, bank_adr );
gtk_table_attach ( GTK_TABLE ( table ),
@@ -809,7 +776,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 5, 6,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_tel = gsb_autofunc_entry_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_bank_tel), 0);
+
+ if ( combobox )
+ bank_tel = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_tel = gsb_autofunc_entry_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_bank_tel ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_tel );
gtk_table_attach ( GTK_TABLE ( table ),
bank_tel, 1, 2, 5, 6,
@@ -824,7 +799,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 7, 8,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_mail = gsb_autofunc_entry_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_bank_mail), 0);
+
+ if ( combobox )
+ bank_mail = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_mail = gsb_autofunc_entry_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_bank_mail ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_mail );
gtk_table_attach ( GTK_TABLE ( table ),
bank_mail, 1, 2, 7, 8,
@@ -839,7 +822,14 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 9, 10,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_web = gsb_autofunc_entry_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_bank_web), 0);
+ if ( combobox )
+ bank_web = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_web = gsb_autofunc_entry_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_bank_web ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_web );
gtk_table_attach ( GTK_TABLE ( table ),
bank_web, 1, 2, 9, 10,
@@ -862,7 +852,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 0, 1,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_contact_name = gsb_autofunc_entry_new ( NULL, G_CALLBACK(gsb_bank_update_selected_line), NULL, G_CALLBACK (gsb_data_bank_set_correspondent_name), 0);
+
+ if ( combobox )
+ bank_contact_name = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_contact_name = gsb_autofunc_entry_new ( NULL,
+ G_CALLBACK ( gsb_bank_update_selected_line ),
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_correspondent_name ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_contact_name );
gtk_table_attach ( GTK_TABLE ( table ),
bank_contact_name, 1, 2, 0, 1,
@@ -877,7 +875,16 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 1, 2,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_contact_tel = gsb_autofunc_entry_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_correspondent_tel), 0);
+
+
+ if ( combobox )
+ bank_contact_tel = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_contact_tel = gsb_autofunc_entry_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_correspondent_tel ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_contact_tel );
gtk_table_attach ( GTK_TABLE ( table ),
bank_contact_tel, 1, 2, 1, 2,
@@ -892,7 +899,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 3, 4,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_contact_fax = gsb_autofunc_entry_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_correspondent_fax), 0);
+
+ if ( combobox )
+ bank_contact_fax = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_contact_fax = gsb_autofunc_entry_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_correspondent_fax ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_contact_fax );
gtk_table_attach ( GTK_TABLE ( table ),
bank_contact_fax, 1, 2, 3, 4,
@@ -907,7 +922,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
label, 0, 1, 2, 3,
GTK_SHRINK | GTK_FILL, 0,
0, 0 );
- bank_contact_mail = gsb_autofunc_entry_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_correspondent_mail), 0);
+
+ if ( combobox )
+ bank_contact_mail = gsb_autofunc_entry_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_contact_mail = gsb_autofunc_entry_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_correspondent_mail ),
+ 0 );
gtk_size_group_add_widget ( size_group, bank_contact_mail );
gtk_table_attach ( GTK_TABLE ( table ),
bank_contact_mail, 1, 2, 2, 3,
@@ -924,7 +947,15 @@ static GtkWidget *gsb_bank_create_form ( GtkWidget *parent,
GTK_SHADOW_IN );
gtk_box_pack_start ( GTK_BOX ( paddingbox ), scrolled_window,
TRUE, TRUE, 5 );
- bank_notes = gsb_autofunc_textview_new ( NULL, NULL, NULL, G_CALLBACK (gsb_data_bank_set_bank_note), 0);
+
+ if ( combobox )
+ bank_notes = gsb_autofunc_textview_new ( NULL, NULL, NULL, NULL, 0 );
+ else
+ bank_notes = gsb_autofunc_textview_new ( NULL,
+ NULL,
+ NULL,
+ G_CALLBACK ( gsb_data_bank_set_bank_note ),
+ 0 );
gtk_widget_set_size_request ( bank_notes, -1, 100 );
gtk_container_add ( GTK_CONTAINER ( scrolled_window ), bank_notes );
@@ -990,15 +1021,14 @@ static gboolean gsb_bank_update_form ( gint bank_number,
static gboolean gsb_bank_edit_bank ( gint bank_number,
GtkWidget *combobox )
{
- GtkWidget *dialog, *form, * scrolled_window, *vbox;
-
- if (bank_number <= 0)
- return FALSE;
+ GtkWidget *dialog, *form, *scrolled_window, *vbox;
+ gint result;
dialog = gtk_dialog_new_with_buttons ( _("Edit bank"),
GTK_WINDOW ( run.window ),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_APPLY, GTK_RESPONSE_APPLY,
NULL );
gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
@@ -1014,18 +1044,54 @@ static gboolean gsb_bank_edit_bank ( gint bank_number,
vbox = gtk_vbox_new ( FALSE, 6 );
gtk_container_set_border_width ( GTK_CONTAINER (vbox), 12 );
- form = gsb_bank_create_form ( vbox,
- combobox );
+ form = gsb_bank_create_form ( vbox, combobox );
gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled_window), vbox);
gtk_viewport_set_shadow_type ( GTK_VIEWPORT (GTK_BIN(scrolled_window) -> child ),
GTK_SHADOW_NONE );
gtk_widget_show_all ( GTK_DIALOG(dialog)->vbox );
- gsb_bank_update_form ( bank_number, GTK_DIALOG(dialog)->vbox );
+ if ( bank_number == -2 )
+ {
+ gchar *tmp_str;
+
+ tmp_str = g_strdup ( _("New bank") );
+ gtk_entry_set_text ( GTK_ENTRY ( bank_name ), tmp_str );
+ g_free ( tmp_str );
+
+ }
+ else
+ gsb_bank_update_form ( bank_number, GTK_DIALOG(dialog)->vbox );
+
+ result = gtk_dialog_run ( GTK_DIALOG(dialog ) );
+
+ if ( result == GTK_RESPONSE_APPLY )
+ {
+ if ( bank_number == -2 )
+ bank_number = gsb_data_bank_new ( _("New bank") );
+
+ gsb_bank_update_bank_data ( bank_number );
+ gsb_bank_update_selected_line_model ( combobox );
+ gsb_bank_list_set_bank ( combobox, bank_number );
+
+ /* Mark file as modified */
+ if ( etat.modification_fichier == 0 )
+ modification_fichier ( TRUE );
+ }
+ else
+ {
+ if ( bank_number == -2 )
+ {
+ gint account_number;
+
+ account_number = gsb_gui_navigation_get_current_account ( );
+ gsb_bank_list_set_bank ( combobox,
+ gsb_data_account_get_bank ( account_number ) );
+ }
+ }
- gtk_dialog_run (GTK_DIALOG(dialog));
gtk_widget_destroy ( dialog );
+
return FALSE;
}
@@ -1051,33 +1117,33 @@ static gboolean gsb_bank_update_selected_line ( GtkEntry *entry,
&&
GTK_IS_TREE_VIEW (bank_list_tree_view))
{
- GtkTreeSelection *selection;
- GtkTreeModel *model;
-
- selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (bank_list_tree_view));
-
- if ( gtk_tree_selection_get_selected ( GTK_TREE_SELECTION (selection),
- &model, &iter ))
- gtk_list_store_set ( GTK_LIST_STORE (model),
- &iter,
- BANK_VIEW_NAME_COL, gtk_entry_get_text ( GTK_ENTRY(bank_name)),
- BANK_TALKER_COL, gtk_entry_get_text (GTK_ENTRY(bank_contact_name)),
- -1 );
+ GtkTreeSelection *selection;
+ GtkTreeModel *model;
+
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (bank_list_tree_view));
+
+ if ( gtk_tree_selection_get_selected ( GTK_TREE_SELECTION (selection),
+ &model, &iter ))
+ gtk_list_store_set ( GTK_LIST_STORE (model),
+ &iter,
+ BANK_VIEW_NAME_COL, gtk_entry_get_text ( GTK_ENTRY(bank_name)),
+ BANK_TALKER_COL, gtk_entry_get_text (GTK_ENTRY(bank_contact_name)),
+ -1 );
}
/* we update the combobox model if exists */
- if (GTK_IS_COMBO_BOX (combobox))
+ if ( GTK_IS_COMBO_BOX ( combobox ) )
{
- if (gtk_combo_box_get_active_iter ( GTK_COMBO_BOX (combobox),
- &iter ))
- gtk_list_store_set ( GTK_LIST_STORE (bank_list_model),
- &iter,
- BANK_NAME_COL, gtk_entry_get_text ( GTK_ENTRY(bank_name)),
- -1 );
- gsb_bank_update_selected_line_model (combobox);
+ if ( gtk_combo_box_get_active_iter ( GTK_COMBO_BOX ( combobox ), &iter ) )
+ gtk_list_store_set ( GTK_LIST_STORE ( bank_list_model ),
+ &iter,
+ BANK_NAME_COL, gtk_entry_get_text ( GTK_ENTRY ( bank_name ) ),
+ -1 );
+ gsb_bank_update_selected_line_model ( combobox );
}
else
- gsb_bank_update_selected_line_model (NULL);
+ gsb_bank_update_selected_line_model (NULL);
+
return FALSE;
}
@@ -1093,6 +1159,7 @@ static gboolean gsb_bank_add ( GtkWidget *button,
gpointer null )
{
gint bank_number;
+
/* create the new bank */
bank_number = gsb_data_bank_new (_("New bank"));
@@ -1138,8 +1205,8 @@ static gboolean gsb_bank_add ( GtkWidget *button,
else
{
/* it's a combobox, come here via add new bank */
- gsb_bank_list_set_bank (button, bank_number, 0);
- gsb_bank_edit_bank (bank_number, button);
+ gsb_bank_list_set_bank ( button, bank_number );
+ gsb_bank_edit_bank ( bank_number, button );
}
if ( etat.modification_fichier == 0 )
@@ -1267,6 +1334,99 @@ static void gsb_bank_bic_code_changed ( GtkEntry *entry, gpointer data )
gsb_account_property_set_label_code_bic ( bank_number );
}
+
+/**
+ * create or update bank data
+ * when it's change in the edit_bank form.
+ *
+ * \param entry
+ * \param null
+ *
+ * */
+static void gsb_bank_update_bank_data ( gint bank_number )
+{
+ GtkTextBuffer *buffer;
+
+ devel_debug_int ( bank_number );
+ /* set bank_name */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_name ) ) > 0 )
+ gsb_data_bank_set_name ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_name ) ) );
+ else
+ gsb_data_bank_set_name ( bank_number, _("New bank") );
+
+ /* set bank_code */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_code ) ) > 0 )
+ gsb_data_bank_set_code ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_code ) ) );
+ else
+ gsb_data_bank_set_code ( bank_number, "" );
+
+ /* set bank_BIC */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_BIC ) ) > 0 )
+ gsb_data_bank_set_bic ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_BIC ) ) );
+ else
+ gsb_data_bank_set_bic ( bank_number, "" );
+
+ /* set bank_adr */
+ buffer = gtk_text_view_get_buffer ( GTK_TEXT_VIEW ( bank_adr ) );
+ if ( gtk_text_buffer_get_char_count ( buffer ) > 0 )
+ gsb_data_bank_set_bank_address ( bank_number,
+ gsb_editable_text_view_get_content ( bank_adr ) );
+ else
+ gsb_data_bank_set_bank_address ( bank_number, "" );
+
+ /* set bank_tel */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_tel ) ) > 0 )
+ gsb_data_bank_set_bank_tel ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_tel ) ) );
+ else
+ gsb_data_bank_set_bank_tel ( bank_number, "" );
+
+ /* set bank_mail */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_mail ) ) > 0 )
+ gsb_data_bank_set_bank_mail ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_mail ) ) );
+ else
+ gsb_data_bank_set_bank_mail ( bank_number, "" );
+
+ /* set bank_web */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_web ) ) > 0 )
+ gsb_data_bank_set_bank_web ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_web ) ) );
+ else
+ gsb_data_bank_set_bank_web ( bank_number, "" );
+
+ /* set contact_name */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_contact_name ) ) > 0 )
+ gsb_data_bank_set_correspondent_name ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_contact_name ) ) );
+ else
+ gsb_data_bank_set_correspondent_name ( bank_number, "" );
+
+ /* set contact_tel */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_contact_tel ) ) > 0 )
+ gsb_data_bank_set_correspondent_tel ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_contact_tel ) ) );
+ else
+ gsb_data_bank_set_correspondent_tel ( bank_number, "" );
+
+ /* set contact_mail */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_contact_mail ) ) > 0 )
+ gsb_data_bank_set_correspondent_mail ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_contact_mail ) ) );
+ else
+ gsb_data_bank_set_correspondent_mail ( bank_number, "" );
+
+ /* set contact_fax */
+ if ( gtk_entry_get_text_length ( GTK_ENTRY ( bank_contact_fax ) ) > 0 )
+ gsb_data_bank_set_correspondent_fax ( bank_number, gtk_entry_get_text ( GTK_ENTRY ( bank_contact_fax ) ) );
+ else
+ gsb_data_bank_set_correspondent_fax ( bank_number, "" );
+
+ /* set bank_notes */
+ buffer = gtk_text_view_get_buffer ( GTK_TEXT_VIEW ( bank_adr ) );
+ if ( gtk_text_buffer_get_char_count ( buffer ) > 0 )
+ gsb_data_bank_set_bank_note ( bank_number,
+ gsb_editable_text_view_get_content ( bank_notes ) );
+ else
+ gsb_data_bank_set_bank_note ( bank_number, "" );
+
+}
+
+
/* Local Variables: */
/* c-basic-offset: 4 */
/* End: */
diff --git a/src/gsb_bank.h b/src/gsb_bank.h
index 6673569..7d63514 100644
--- a/src/gsb_bank.h
+++ b/src/gsb_bank.h
@@ -8,17 +8,12 @@
/* START_DECLARATION */
-GtkWidget *gsb_bank_create_combobox ( gint index,
- GCallback hook,
- gpointer data,
- GCallback default_func,
- gint number_for_func );
+GtkWidget *gsb_bank_create_combobox ( gint index );
GtkWidget *gsb_bank_create_page ( gboolean default_sensitive );
gboolean gsb_bank_edit_from_button ( GtkWidget *button,
GtkWidget *combobox );
gint gsb_bank_list_get_bank_number ( GtkWidget *combobox );
gboolean gsb_bank_list_set_bank ( GtkWidget *combobox,
- gint bank_number,
- gint number_for_func );
+ gint bank_number );
/* END_DECLARATION */
#endif
diff --git a/src/gsb_transactions_list.c b/src/gsb_transactions_list.c
index 4544041..de13533 100644
--- a/src/gsb_transactions_list.c
+++ b/src/gsb_transactions_list.c
@@ -92,7 +92,7 @@ static gboolean gsb_transactions_list_change_sort_type ( GtkWidget *menu_item,
gint *no_column );
static gboolean gsb_transactions_list_check_mark ( gint transaction_number );
static gint gsb_transactions_list_choose_reconcile ( gint account_number,
- gint selected_reconcile_number );
+ gint transaction_number );
static gboolean gsb_transactions_list_clone_template ( GtkWidget *menu_item,
gpointer null );
static gint gsb_transactions_list_clone_transaction ( gint transaction_number,
@@ -1925,8 +1925,7 @@ gboolean gsb_transactions_list_switch_R_mark ( gint transaction_number )
* associate the transaction with a reconcile */
gint reconcile_number;
- reconcile_number = gsb_transactions_list_choose_reconcile ( account_number,
- gsb_data_transaction_get_reconcile_number (transaction_number));
+ reconcile_number = gsb_transactions_list_choose_reconcile ( account_number,transaction_number );
if (!reconcile_number)
return FALSE;
@@ -1992,12 +1991,12 @@ gboolean gsb_transactions_list_switch_R_mark ( gint transaction_number )
* to choose one
*
* \param account_number
- * \param selected_reconcile_number if not null, we will select that reconcile in the list
+ * \param transaction_number, we will select that reconcile in the list
*
* \return the number of the chosen reconcile or 0 if cancel
* */
gint gsb_transactions_list_choose_reconcile ( gint account_number,
- gint selected_reconcile_number )
+ gint transaction_number )
{
GtkWidget *dialog;
GtkWidget *tree_view;
@@ -2097,35 +2096,65 @@ gint gsb_transactions_list_choose_reconcile ( gint account_number,
/* fill the list */
tmp_list = gsb_data_reconcile_get_reconcile_list ();
+
while (tmp_list)
{
- reconcile_number = gsb_data_reconcile_get_no_reconcile (tmp_list -> data);
+ reconcile_number = gsb_data_reconcile_get_no_reconcile ( tmp_list -> data );
- if (gsb_data_reconcile_get_account (reconcile_number) == account_number)
- {
- gchar *init_date, *final_date;
-
- init_date = gsb_format_gdate (gsb_data_reconcile_get_init_date (reconcile_number));
- final_date = gsb_format_gdate (gsb_data_reconcile_get_final_date (reconcile_number));
-
- gtk_list_store_append ( GTK_LIST_STORE (store),
- &iter );
- gtk_list_store_set ( GTK_LIST_STORE (store),
- &iter,
- RECONCILE_CHOOSE_NAME, gsb_data_reconcile_get_name (reconcile_number),
- RECONCILE_CHOOSE_INIT_DATE, init_date,
- RECONCILE_CHOOSE_FINAL_DATE, final_date,
- RECONCILE_NUMBER, reconcile_number,
- -1 );
- g_free (init_date);
- g_free (final_date);
-
- /* if we are on the reconcile to select, do it here */
- if (selected_reconcile_number == reconcile_number)
- gtk_tree_selection_select_iter ( selection,
- &iter );
- }
- tmp_list = tmp_list -> next;
+ if ( gsb_data_reconcile_get_account ( reconcile_number ) == account_number )
+ {
+ GtkTreePath *path;
+ gchar *init_date, *final_date;
+ gint tmp_reconcile_number;
+
+ init_date = gsb_format_gdate (gsb_data_reconcile_get_init_date ( reconcile_number ) );
+ final_date = gsb_format_gdate (gsb_data_reconcile_get_final_date ( reconcile_number) );
+
+ gtk_list_store_append ( GTK_LIST_STORE (store), &iter );
+ gtk_list_store_set ( GTK_LIST_STORE (store),
+ &iter,
+ RECONCILE_CHOOSE_NAME, gsb_data_reconcile_get_name (reconcile_number),
+ RECONCILE_CHOOSE_INIT_DATE, init_date,
+ RECONCILE_CHOOSE_FINAL_DATE, final_date,
+ RECONCILE_NUMBER, reconcile_number,
+ -1 );
+
+ /* select the reconcile here */
+ tmp_reconcile_number = gsb_data_transaction_get_reconcile_number ( transaction_number );
+ if ( tmp_reconcile_number == 0 )
+ {
+ GDate *date_debut;
+ GDate *date_fin;
+ const GDate *date;
+
+ date_debut = gsb_parse_date_string ( init_date );
+ date_fin = gsb_parse_date_string ( final_date );
+ date = gsb_data_transaction_get_date ( transaction_number );
+ if ( g_date_compare ( date, date_debut ) >= 0
+ &&
+ g_date_compare ( date, date_fin ) <= 0 )
+ {
+ path = gtk_tree_model_get_path ( GTK_TREE_MODEL ( store ), &iter );
+ gtk_tree_selection_select_iter ( selection, &iter );
+ gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW ( tree_view ), path, NULL, FALSE, 0.0, 0.0 );
+
+ gtk_tree_path_free ( path );
+ }
+ g_date_free ( date_debut );
+ g_date_free ( date_fin );
+ }
+ else if ( tmp_reconcile_number == reconcile_number )
+ {
+ path = gtk_tree_model_get_path ( GTK_TREE_MODEL ( store ), &iter );
+ gtk_tree_selection_select_iter ( selection, &iter );
+ gtk_tree_view_scroll_to_cell ( GTK_TREE_VIEW ( tree_view ), path, NULL, FALSE, 0.0, 0.0 );
+ }
+
+ g_free ( init_date );
+ g_free ( final_date );
+
+ }
+ tmp_list = tmp_list -> next;
}
/* run the dialog */
hooks/post-receive
--
grisbi
More information about the cvs
mailing list