PageRenderTime 1380ms CodeModel.GetById 31ms RepoModel.GetById 11ms app.codeStats 1ms

/grisbi-0.8.8/src/accueil.c

#
C | 2193 lines | 1575 code | 352 blank | 266 comment | 157 complexity | 1c79e591d20fd792d986a176fa54e811 MD5 | raw file
Possible License(s): GPL-2.0
  1. /* ************************************************************************** */
  2. /* */
  3. /* Copyright (C) 2000-2008 Cédric Auger (cedric@grisbi.org) */
  4. /* 2003-2008 Benjamin Drieu (bdrieu@april.org) */
  5. /* http://www.grisbi.org */
  6. /* */
  7. /* This program is free software; you can redistribute it and/or modify */
  8. /* it under the terms of the GNU General Public License as published by */
  9. /* the Free Software Foundation; either version 2 of the License, or */
  10. /* (at your option) any later version. */
  11. /* */
  12. /* This program is distributed in the hope that it will be useful, */
  13. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  14. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  15. /* GNU General Public License for more details. */
  16. /* */
  17. /* You should have received a copy of the GNU General Public License */
  18. /* along with this program; if not, write to the Free Software */
  19. /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  20. /* */
  21. /* ************************************************************************** */
  22. #ifdef HAVE_CONFIG_H
  23. #include <config.h>
  24. #endif
  25. #include "include.h"
  26. /*START_INCLUDE*/
  27. #include "accueil.h"
  28. #include "classement_echeances.h"
  29. #include "dialog.h"
  30. #include "fenetre_principale.h"
  31. #include "gsb_automem.h"
  32. #include "gsb_data_account.h"
  33. #include "gsb_data_currency.h"
  34. #include "gsb_data_partial_balance.h"
  35. #include "gsb_data_payee.h"
  36. #include "gsb_data_scheduled.h"
  37. #include "gsb_data_transaction.h"
  38. #include "gsb_form.h"
  39. #include "gsb_form_scheduler.h"
  40. #include "gsb_real.h"
  41. #include "gsb_scheduler.h"
  42. #include "gsb_scheduler_list.h"
  43. #include "gsb_select_icon.h"
  44. #include "gsb_transactions_list.h"
  45. #include "main.h"
  46. #include "navigation.h"
  47. #include "structures.h"
  48. #include "utils.h"
  49. #include "utils_dates.h"
  50. #include "utils_str.h"
  51. #include "erreur.h"
  52. /*END_INCLUDE*/
  53. /*START_STATIC*/
  54. static void affiche_solde_des_comptes ( GtkWidget *table,
  55. gint i,
  56. gint nb_comptes,
  57. gint currency_number,
  58. gsb_real solde_global_courant,
  59. gsb_real solde_global_pointe );
  60. static gint affiche_soldes_additionnels ( GtkWidget *table, gint i, GSList *liste );
  61. static gint affiche_soldes_partiels ( GtkWidget *table,
  62. gint i,
  63. gint nb_comptes,
  64. GSList *liste,
  65. gint currency_number,
  66. gint type_compte );
  67. static gboolean gsb_config_scheduler_switch_balances_with_scheduled ( void );
  68. static void gsb_main_page_affiche_ligne_du_compte ( GtkWidget *pTable,
  69. gint account_number,
  70. gint i );
  71. static gboolean gsb_main_page_click_on_account ( gint *account_number );
  72. static GtkStyle *gsb_main_page_get_default_label_style ( );
  73. static gboolean gsb_main_page_get_devise_is_used ( gint currency_number, gint type_compte );
  74. static GtkWidget *gsb_main_page_get_table_for_accounts ( gint nb_lignes, gint nb_col );
  75. static gboolean saisie_echeance_accueil ( GtkWidget *event_box,
  76. GdkEventButton *event,
  77. gint scheduled_number );
  78. static void update_fin_comptes_passifs ( gboolean force );
  79. static void update_liste_comptes_accueil ( gboolean force );
  80. static void update_liste_echeances_auto_accueil ( gboolean force );
  81. static void update_liste_echeances_manuelles_accueil ( gboolean force );
  82. static void update_soldes_minimaux ( gboolean force );
  83. /*END_STATIC*/
  84. /*START_EXTERN*/
  85. extern GdkColor couleur_bleue;
  86. extern GdkColor couleur_jaune;
  87. extern GdkColor couleur_nom_compte_normal;
  88. extern GdkColor couleur_nom_compte_prelight;
  89. extern GdkColor couleur_solde_alarme_orange_normal;
  90. extern GdkColor couleur_solde_alarme_orange_prelight;
  91. extern GdkColor couleur_solde_alarme_rouge_normal;
  92. extern GdkColor couleur_solde_alarme_rouge_prelight;
  93. extern GdkColor couleur_solde_alarme_verte_normal;
  94. extern GdkColor couleur_solde_alarme_verte_prelight;
  95. extern GtkWidget *form_transaction_part;
  96. extern gsb_real null_real;
  97. extern GSList *scheduled_transactions_taken;
  98. extern GSList *scheduled_transactions_to_take;
  99. extern GtkWidget *window;
  100. /*END_EXTERN*/
  101. GtkWidget *logo_accueil = NULL;
  102. GtkWidget *hbox_title = NULL;
  103. GtkWidget *label_titre_fichier = NULL;
  104. static GtkWidget *frame_etat_comptes_accueil = NULL;
  105. static GtkWidget *frame_etat_fin_compte_passif = NULL;
  106. static GtkWidget *frame_etat_echeances_manuelles_accueil = NULL;
  107. static GtkWidget *frame_etat_echeances_auto_accueil = NULL;
  108. static GtkWidget *main_page_finished_scheduled_transactions_part = NULL;
  109. static GtkWidget *frame_etat_soldes_minimaux_autorises = NULL;
  110. static GtkWidget *frame_etat_soldes_minimaux_voulus = NULL;
  111. static GtkStyle *style_label;
  112. #define show_paddingbox(child) gtk_widget_show_all (gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(child)))))
  113. #define hide_paddingbox(child) gtk_widget_hide_all (gtk_widget_get_parent(gtk_widget_get_parent(gtk_widget_get_parent(GTK_WIDGET(child)))))
  114. /* ces 5 variables sont mises ŕ 1 lorsqu'il est nécessaire de rafraichir cette */
  115. /* partie la prochaine fois qu'on va sur l'accueil */
  116. gint mise_a_jour_liste_comptes_accueil;
  117. gint mise_a_jour_liste_echeances_manuelles_accueil;
  118. gint mise_a_jour_liste_echeances_auto_accueil;
  119. gint mise_a_jour_soldes_minimaux;
  120. gint mise_a_jour_fin_comptes_passifs;
  121. GtkSizeGroup * size_group_accueil;
  122. gchar *chaine_espace = " ";
  123. /**
  124. * Create the home page of Grisbi
  125. *
  126. *
  127. *
  128. * */
  129. GtkWidget *creation_onglet_accueil ( void )
  130. {
  131. GtkWidget *paddingbox, *base, *base_scroll;
  132. GtkWidget * eb;
  133. GtkStyle * style;
  134. devel_debug ( NULL );
  135. /* on crée ŕ ce niveau base_scroll qui est aussi une vbox mais qui peut
  136. scroller verticalement */
  137. base_scroll = gtk_scrolled_window_new ( NULL, NULL);
  138. gtk_scrolled_window_set_policy ( GTK_SCROLLED_WINDOW ( base_scroll ),
  139. GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
  140. gtk_scrolled_window_set_shadow_type ( GTK_SCROLLED_WINDOW ( base_scroll ),
  141. GTK_SHADOW_NONE );
  142. base = gtk_vbox_new ( FALSE, 15 );
  143. gtk_container_set_border_width ( GTK_CONTAINER ( base ), 12 );
  144. gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW ( base_scroll ), base );
  145. gtk_widget_show ( base_scroll );
  146. gtk_widget_show ( base );
  147. /* en dessous, on met le titre du fichier */
  148. hbox_title = gtk_hbox_new ( FALSE, 0 );
  149. eb = gtk_event_box_new ();
  150. style = gtk_widget_get_style ( eb );
  151. gtk_widget_modify_bg ( eb, 0, &(style -> bg[GTK_STATE_ACTIVE]) );
  152. label_titre_fichier = gtk_label_new ( NULL );
  153. if ( etat.utilise_logo )
  154. {
  155. logo_accueil = gtk_image_new_from_pixbuf ( gsb_select_icon_get_logo_pixbuf ( ) );
  156. gtk_box_pack_start ( GTK_BOX ( hbox_title ), logo_accueil, FALSE, FALSE, 20 );
  157. gtk_widget_set_size_request ( hbox_title, -1, LOGO_HEIGHT + 20 );
  158. }
  159. gtk_box_pack_end ( GTK_BOX ( hbox_title ), label_titre_fichier, TRUE, TRUE, 20 );
  160. gtk_container_set_border_width ( GTK_CONTAINER ( hbox_title ), 6 );
  161. gtk_container_add ( GTK_CONTAINER ( eb ), hbox_title );
  162. gtk_box_pack_start ( GTK_BOX ( base ), eb, FALSE, FALSE, 0 );
  163. gtk_widget_show_all ( eb );
  164. /* on crée le size_group pour l'alignement des tableaux */
  165. size_group_accueil = gtk_size_group_new ( GTK_SIZE_GROUP_HORIZONTAL );
  166. /* on crée la premičre frame dans laquelle on met les états des comptes */
  167. frame_etat_comptes_accueil = gtk_notebook_new ();
  168. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(frame_etat_comptes_accueil), FALSE );
  169. gtk_notebook_set_show_border ( GTK_NOTEBOOK(frame_etat_comptes_accueil), FALSE );
  170. gtk_container_set_border_width ( GTK_CONTAINER(frame_etat_comptes_accueil), 0 );
  171. gtk_box_pack_start ( GTK_BOX(base), frame_etat_comptes_accueil, FALSE, FALSE, 0 );
  172. /* on met la liste des comptes et leur état dans la frame */
  173. mise_a_jour_liste_comptes_accueil = 1;
  174. gtk_widget_show_all ( frame_etat_comptes_accueil );
  175. /* mise en place de la partie fin des comptes passif */
  176. paddingbox = new_paddingbox_with_title ( base, FALSE,
  177. _("Closed liabilities accounts") );
  178. frame_etat_fin_compte_passif = gtk_notebook_new ();
  179. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(frame_etat_fin_compte_passif), FALSE );
  180. gtk_notebook_set_show_border ( GTK_NOTEBOOK(frame_etat_fin_compte_passif), FALSE );
  181. gtk_box_pack_start ( GTK_BOX(paddingbox), frame_etat_fin_compte_passif, FALSE, FALSE, 0 );
  182. mise_a_jour_fin_comptes_passifs = 1;
  183. /* mise en place de la partie des échéances manuelles ( non affiché ) */
  184. /* sera mis ŕ jour automatiquement si nécessaire */
  185. paddingbox = new_paddingbox_with_title ( base, FALSE,
  186. _("Run out manual scheduled transactions") );
  187. frame_etat_echeances_manuelles_accueil = gtk_notebook_new ();
  188. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(frame_etat_echeances_manuelles_accueil),
  189. FALSE );
  190. gtk_notebook_set_show_border ( GTK_NOTEBOOK(frame_etat_echeances_manuelles_accueil),
  191. FALSE );
  192. gtk_container_set_border_width ( GTK_CONTAINER(frame_etat_echeances_manuelles_accueil),
  193. 0 );
  194. gtk_box_set_spacing ( GTK_BOX(paddingbox), 6 );
  195. gtk_box_pack_start ( GTK_BOX(paddingbox), frame_etat_echeances_manuelles_accueil,
  196. FALSE, FALSE, 6 );
  197. /* mise en place de la partie des échéances auto ( non affiché )*/
  198. /* sera mis ŕ jour automatiquement si nécessaire */
  199. paddingbox = new_paddingbox_with_title ( base, FALSE,
  200. _("Automatic scheduled transactions entered") );
  201. frame_etat_echeances_auto_accueil = gtk_notebook_new ();
  202. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(frame_etat_echeances_auto_accueil), FALSE );
  203. gtk_notebook_set_show_border ( GTK_NOTEBOOK(frame_etat_echeances_auto_accueil), FALSE );
  204. gtk_container_set_border_width ( GTK_CONTAINER(frame_etat_echeances_auto_accueil), 0 );
  205. gtk_box_set_spacing ( GTK_BOX(paddingbox), 6 );
  206. gtk_box_pack_start ( GTK_BOX(paddingbox), frame_etat_echeances_auto_accueil, FALSE, FALSE, 6 );
  207. /* partie des fin d'échéances */
  208. paddingbox = new_paddingbox_with_title ( base, FALSE,
  209. _("Closed scheduled transactions") );
  210. main_page_finished_scheduled_transactions_part = gtk_notebook_new ();
  211. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(main_page_finished_scheduled_transactions_part), FALSE );
  212. gtk_notebook_set_show_border ( GTK_NOTEBOOK(main_page_finished_scheduled_transactions_part), FALSE );
  213. gtk_container_set_border_width ( GTK_CONTAINER(main_page_finished_scheduled_transactions_part), 0 );
  214. gtk_box_set_spacing ( GTK_BOX(paddingbox), 6 );
  215. gtk_box_pack_start ( GTK_BOX(paddingbox), main_page_finished_scheduled_transactions_part, FALSE, FALSE, 6 );
  216. /* partie des soldes minimaux autorisés */
  217. paddingbox = new_paddingbox_with_title ( base, FALSE,
  218. _("Accounts under authorized balance") );
  219. frame_etat_soldes_minimaux_autorises = gtk_notebook_new ();
  220. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(frame_etat_soldes_minimaux_autorises), FALSE );
  221. gtk_notebook_set_show_border ( GTK_NOTEBOOK(frame_etat_soldes_minimaux_autorises), FALSE );
  222. gtk_container_set_border_width ( GTK_CONTAINER(frame_etat_soldes_minimaux_autorises), 0 );
  223. gtk_box_set_spacing ( GTK_BOX(paddingbox), 6 );
  224. gtk_box_pack_start ( GTK_BOX(paddingbox), frame_etat_soldes_minimaux_autorises, FALSE, FALSE, 6 );
  225. /* partie des soldes minimaux voulus */
  226. paddingbox = new_paddingbox_with_title ( base, FALSE,
  227. _("Accounts under desired balance") );
  228. frame_etat_soldes_minimaux_voulus = gtk_notebook_new ();
  229. gtk_notebook_set_show_tabs ( GTK_NOTEBOOK(frame_etat_soldes_minimaux_voulus), FALSE );
  230. gtk_notebook_set_show_border ( GTK_NOTEBOOK(frame_etat_soldes_minimaux_voulus), FALSE );
  231. gtk_container_set_border_width ( GTK_CONTAINER(frame_etat_soldes_minimaux_voulus), 0 );
  232. gtk_box_set_spacing ( GTK_BOX(paddingbox), 6 );
  233. gtk_box_pack_start ( GTK_BOX(paddingbox), frame_etat_soldes_minimaux_voulus, FALSE, FALSE, 6 );
  234. mise_a_jour_soldes_minimaux = 1;
  235. return ( base_scroll );
  236. }
  237. /**
  238. * update the first page, force the updating if asked,
  239. * else, each function will decide if it need to be
  240. * updated or not
  241. *
  242. * \param force TRUE if we want to update all
  243. *
  244. * \return
  245. * */
  246. void mise_a_jour_accueil ( gboolean force )
  247. {
  248. update_liste_comptes_accueil (force);
  249. update_liste_echeances_manuelles_accueil (force);
  250. update_liste_echeances_auto_accueil (force);
  251. update_soldes_minimaux (force);
  252. update_fin_comptes_passifs (force);
  253. }
  254. /* ************************************************************************* */
  255. /* Fonction appelée lorsqu'on clicke sur une échéance ŕ saisir */
  256. /* ************************************************************************* */
  257. gboolean saisie_echeance_accueil ( GtkWidget *event_box,
  258. GdkEventButton *event,
  259. gint scheduled_number )
  260. {
  261. GtkWidget *parent_save, *dialog, *hbox;
  262. GtkWidget *button;
  263. gint result;
  264. parent_save = form_transaction_part -> parent;
  265. /* Create the dialog */
  266. dialog = gtk_dialog_new_with_buttons ( _("Enter a scheduled transaction"),
  267. GTK_WINDOW ( window ),
  268. GTK_DIALOG_MODAL,
  269. GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
  270. GTK_STOCK_OK, GTK_RESPONSE_OK,
  271. NULL );
  272. gtk_window_set_position ( GTK_WINDOW ( dialog ), GTK_WIN_POS_CENTER_ON_PARENT );
  273. gtk_widget_set_size_request ( dialog, 700, -1 );
  274. gtk_window_set_resizable ( GTK_WINDOW ( dialog ), TRUE );
  275. gtk_dialog_set_default_response ( GTK_DIALOG (dialog), GTK_RESPONSE_OK );
  276. /* first we reparent the form in the dialog */
  277. hbox = gtk_hbox_new ( FALSE, 0 );
  278. gtk_box_pack_start ( GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox, TRUE, TRUE, 0 );
  279. gtk_container_set_border_width ( GTK_CONTAINER(hbox), 12 );
  280. gtk_widget_reparent ( form_transaction_part, hbox );
  281. gtk_widget_show_all ( hbox );
  282. /* next we fill the form,
  283. * don't use gsb_form_show because we are neither on transactions list, neither scheduled list */
  284. button = gsb_form_scheduler_get_element_widget( SCHEDULED_FORM_ACCOUNT );
  285. g_signal_handlers_block_by_func ( G_OBJECT ( button ),
  286. G_CALLBACK (gsb_form_scheduler_change_account),
  287. NULL );
  288. gsb_form_fill_from_account (gsb_data_scheduled_get_account_number (scheduled_number));
  289. /* fill the form with the scheduled transaction */
  290. gsb_scheduler_list_execute_transaction(scheduled_number);
  291. g_signal_handlers_unblock_by_func ( G_OBJECT ( button ),
  292. G_CALLBACK (gsb_form_scheduler_change_account),
  293. NULL );
  294. result = gtk_dialog_run ( GTK_DIALOG ( dialog ));
  295. if ( result == GTK_RESPONSE_OK )
  296. gsb_form_finish_edition ();
  297. gtk_widget_reparent ( form_transaction_part, parent_save );
  298. gtk_widget_destroy ( dialog );
  299. /* update the home page */
  300. update_liste_echeances_manuelles_accueil (TRUE);
  301. update_liste_comptes_accueil (TRUE);
  302. return FALSE;
  303. }
  304. /* ************************************************************************* */
  305. /* ************************************************************************* */
  306. /* Fonction update_liste_comptes_accueil */
  307. /* affiche la liste des comptes et leur solde courant dans la frame qui leur */
  308. /* est réservée dans l'accueil */
  309. /* ************************************************************************* */
  310. void update_liste_comptes_accueil ( gboolean force )
  311. {
  312. GtkWidget *pTable, *vbox, *paddingbox;
  313. GList *children;
  314. GSList *devise;
  315. GSList *list_tmp;
  316. gsb_real solde_global_courant, solde_global_pointe;
  317. gchar* tmpstr;
  318. gint i = 0;
  319. gint nb_comptes_bancaires=0, nb_comptes_passif=0, nb_comptes_actif=0;
  320. gint new_comptes_bancaires=0, new_comptes_passif=0, new_comptes_actif=0;
  321. gint soldes_mixtes = 0;
  322. if ( !force
  323. &&
  324. !( mise_a_jour_liste_comptes_accueil
  325. &&
  326. gsb_data_account_get_accounts_amount ( ) ) )
  327. return;
  328. mise_a_jour_liste_comptes_accueil = 0;
  329. /* Remove previous child */
  330. children = gtk_container_get_children(GTK_CONTAINER(frame_etat_comptes_accueil));
  331. if ( children && children -> data)
  332. gtk_container_remove ( GTK_CONTAINER(frame_etat_comptes_accueil),
  333. GTK_WIDGET(children -> data) );
  334. /* Create the handle vbox */
  335. vbox = gtk_vbox_new ( FALSE, 6 );
  336. gtk_container_add ( GTK_CONTAINER ( frame_etat_comptes_accueil ), vbox );
  337. /* Préparation de la séparation de l'affichage des comptes en fonction
  338. de leur type */
  339. list_tmp = gsb_data_account_get_list_accounts ();
  340. while ( list_tmp )
  341. {
  342. gint i;
  343. i = gsb_data_account_get_no_account ( list_tmp -> data );
  344. if ( !gsb_data_account_get_closed_account (i) )
  345. {
  346. if ( gsb_data_account_get_kind (i) == GSB_TYPE_ASSET )
  347. {
  348. nb_comptes_actif++;
  349. }
  350. else if ( gsb_data_account_get_kind (i) == GSB_TYPE_LIABILITIES )
  351. {
  352. nb_comptes_passif++;
  353. }
  354. else
  355. {
  356. nb_comptes_bancaires++;
  357. }
  358. }
  359. list_tmp = list_tmp -> next;
  360. }
  361. list_tmp = gsb_data_partial_balance_get_list ( );
  362. if ( list_tmp )
  363. {
  364. while ( list_tmp )
  365. {
  366. kind_account i;
  367. i = gsb_data_partial_balance_get_number ( list_tmp -> data );
  368. if ( gsb_data_partial_balance_get_kind ( i ) == GSB_TYPE_ASSET )
  369. {
  370. new_comptes_actif++;
  371. }
  372. else if ( gsb_data_partial_balance_get_kind ( i ) == GSB_TYPE_LIABILITIES )
  373. {
  374. new_comptes_passif++;
  375. }
  376. else if ( gsb_data_partial_balance_get_kind ( i ) == -1 )
  377. {
  378. soldes_mixtes++;
  379. }
  380. else
  381. {
  382. new_comptes_bancaires++;
  383. }
  384. list_tmp = list_tmp -> next;
  385. }
  386. }
  387. /* Affichage des comptes bancaires et de caisse */
  388. for ( devise = gsb_data_currency_get_currency_list (); devise ; devise = devise->next )
  389. {
  390. gint currency_number;
  391. currency_number = gsb_data_currency_get_no_currency (devise -> data);
  392. if ( !gsb_main_page_get_devise_is_used ( currency_number, GSB_TYPE_BANK )
  393. &&
  394. !gsb_main_page_get_devise_is_used ( currency_number, GSB_TYPE_CASH ) )
  395. continue;
  396. /* Creating the table which will store accounts with their balances. */
  397. tmpstr = g_strdup_printf ( _("Account balances in %s"),
  398. gsb_data_currency_get_name ( currency_number ) );
  399. if ( conf.balances_with_scheduled == FALSE )
  400. tmpstr = g_strconcat ( tmpstr, _(" at "), gsb_date_today (), NULL );
  401. paddingbox = new_paddingbox_with_title ( vbox, FALSE, tmpstr );
  402. g_free ( tmpstr );
  403. pTable = gsb_main_page_get_table_for_accounts (
  404. nb_comptes_bancaires + 3 + new_comptes_bancaires + 2, 3 );
  405. gtk_box_pack_start ( GTK_BOX ( paddingbox ), pTable, FALSE, FALSE, 0 );
  406. /* Affichage des comptes et de leur solde */
  407. i = 1;
  408. solde_global_courant = null_real ;
  409. solde_global_pointe = null_real;
  410. /* Pour chaque compte non cloturé (pour chaque ligne), */
  411. /* créer toutes les colonnes et les remplir */
  412. list_tmp = gsb_data_account_get_list_accounts ();
  413. while ( list_tmp )
  414. {
  415. gint account_number;
  416. account_number = gsb_data_account_get_no_account ( list_tmp -> data );
  417. if ( !gsb_data_account_get_closed_account (account_number) &&
  418. gsb_data_account_get_currency (account_number) == currency_number
  419. && gsb_data_account_get_kind (account_number) < GSB_TYPE_LIABILITIES )
  420. {
  421. /* on affiche la ligne du compte avec les soldes pointé et courant */
  422. gsb_main_page_affiche_ligne_du_compte ( pTable, account_number, i );
  423. /* ATTENTION : les sommes effectuées ici présupposent que
  424. TOUS les comptes sont dans la MĘME DEVISE !!!!! */
  425. solde_global_courant = gsb_real_add ( solde_global_courant,
  426. gsb_data_account_get_current_balance (account_number));
  427. solde_global_pointe = gsb_real_add ( solde_global_pointe,
  428. gsb_data_account_get_marked_balance (account_number));
  429. }
  430. i++;
  431. list_tmp = list_tmp -> next;
  432. }
  433. /* affichage des soldes partiels s'ils existent */
  434. if ( new_comptes_bancaires > 0 )
  435. {
  436. list_tmp = gsb_data_partial_balance_get_list ( );
  437. if ( list_tmp )
  438. i += affiche_soldes_partiels ( pTable, i, new_comptes_bancaires, list_tmp,
  439. currency_number, GSB_TYPE_BANK | GSB_TYPE_CASH );
  440. }
  441. /* Création et remplissage de la (nb_comptes + 3)ičme ligne du tableau :
  442. elle contient la somme des soldes de chaque compte */
  443. affiche_solde_des_comptes ( pTable, i, nb_comptes_bancaires, currency_number,
  444. solde_global_courant, solde_global_pointe );
  445. gtk_widget_show_all ( paddingbox );
  446. gtk_widget_show_all ( pTable );
  447. }
  448. /* Affichage des comptes de passif */
  449. for ( devise = gsb_data_currency_get_currency_list (); devise ; devise = devise->next )
  450. {
  451. GSList *list_tmp;
  452. gint currency_number;
  453. gchar* tmpstr;
  454. currency_number = gsb_data_currency_get_no_currency (devise -> data);
  455. if ( !gsb_main_page_get_devise_is_used ( currency_number, GSB_TYPE_LIABILITIES ) )
  456. continue;
  457. /* Creating the table which will store accounts with their balances */
  458. tmpstr = g_strdup_printf (_("Liabilities accounts balances in %s"),
  459. gsb_data_currency_get_name (currency_number) );
  460. if ( conf.balances_with_scheduled == FALSE )
  461. tmpstr = g_strconcat ( tmpstr, _(" at "), gsb_date_today (), NULL );
  462. paddingbox = new_paddingbox_with_title ( vbox, FALSE, tmpstr );
  463. g_free ( tmpstr );
  464. pTable = gsb_main_page_get_table_for_accounts (
  465. nb_comptes_passif + 3 + new_comptes_passif + 2, 3 );
  466. gtk_box_pack_start ( GTK_BOX ( paddingbox ), pTable, FALSE, FALSE, 0 );
  467. /* Affichage des comptes et de leur solde */
  468. i = 1;
  469. solde_global_courant = null_real;
  470. solde_global_pointe = null_real;
  471. /* Pour chaque compte non cloturé (pour chaque ligne), */
  472. /* créer toutes les colonnes et les remplir */
  473. list_tmp = gsb_data_account_get_list_accounts ();
  474. while ( list_tmp )
  475. {
  476. gint account_number;
  477. account_number = gsb_data_account_get_no_account ( list_tmp -> data );
  478. if ( !gsb_data_account_get_closed_account (account_number) &&
  479. gsb_data_account_get_currency (account_number) == currency_number
  480. &&
  481. gsb_data_account_get_kind (account_number) == GSB_TYPE_LIABILITIES )
  482. {
  483. /* on affiche la ligne du compte avec les soldes pointé et courant */
  484. gsb_main_page_affiche_ligne_du_compte ( pTable, account_number, i );
  485. /* ATTENTION : les sommes effectuées ici présupposent que
  486. TOUS les comptes sont dans la MĘME DEVISE !!!!! */
  487. solde_global_courant = gsb_real_add ( solde_global_courant,
  488. gsb_data_account_get_current_balance (account_number));
  489. solde_global_pointe = gsb_real_add ( solde_global_pointe,
  490. gsb_data_account_get_marked_balance (account_number));
  491. }
  492. i++;
  493. list_tmp = list_tmp -> next;
  494. }
  495. /* affichage des soldes partiels s'ils existent */
  496. if ( new_comptes_passif > 0 )
  497. {
  498. list_tmp = gsb_data_partial_balance_get_list ( );
  499. if ( list_tmp )
  500. i += affiche_soldes_partiels ( pTable, i, new_comptes_passif, list_tmp,
  501. currency_number, GSB_TYPE_LIABILITIES );
  502. }
  503. /* Création et remplissage de la (nb_comptes + 3)ičme ligne du tableau :
  504. elle contient la somme des soldes de chaque compte */
  505. affiche_solde_des_comptes ( pTable, i, nb_comptes_passif, currency_number,
  506. solde_global_courant, solde_global_pointe );
  507. gtk_widget_show_all ( paddingbox );
  508. gtk_widget_show_all ( pTable );
  509. }
  510. /* Affichage des comptes d'actif */
  511. for ( devise = gsb_data_currency_get_currency_list (); devise ; devise = devise->next )
  512. {
  513. GSList *list_tmp;
  514. gint currency_number;
  515. gchar* tmpstr;
  516. currency_number = gsb_data_currency_get_no_currency (devise -> data);
  517. if ( !gsb_main_page_get_devise_is_used ( currency_number, GSB_TYPE_ASSET ) )
  518. continue;
  519. /* Creating the table which will store accounts with their balances */
  520. tmpstr = g_strdup_printf (_("Assets accounts balances in %s"),
  521. gsb_data_currency_get_name (currency_number));
  522. if ( conf.balances_with_scheduled == FALSE )
  523. tmpstr = g_strconcat ( tmpstr, _(" at "), gsb_date_today (), NULL );
  524. paddingbox = new_paddingbox_with_title ( vbox, FALSE, tmpstr );
  525. g_free ( tmpstr );
  526. pTable = gsb_main_page_get_table_for_accounts (
  527. nb_comptes_actif + 3 + new_comptes_passif + 2, 3 );
  528. gtk_box_pack_start ( GTK_BOX ( paddingbox ), pTable, FALSE, FALSE, 0 );
  529. /* Affichage des comptes et de leur solde */
  530. i = 1;
  531. solde_global_courant = null_real;
  532. solde_global_pointe = null_real;
  533. /* Pour chaque compte non cloturé (pour chaque ligne), */
  534. /* créer toutes les colonnes et les remplir */
  535. list_tmp = gsb_data_account_get_list_accounts ();
  536. while ( list_tmp )
  537. {
  538. gint account_number;
  539. account_number = gsb_data_account_get_no_account ( list_tmp -> data );
  540. if ( !gsb_data_account_get_closed_account (account_number) &&
  541. gsb_data_account_get_currency (account_number) == currency_number
  542. &&
  543. gsb_data_account_get_kind (account_number) == GSB_TYPE_ASSET )
  544. {
  545. /* on affiche la ligne du compte avec les soldes pointé et courant */
  546. gsb_main_page_affiche_ligne_du_compte ( pTable, account_number, i );
  547. /* ATTENTION : les sommes effectuées ici présupposent que
  548. TOUS les comptes sont dans la MĘME DEVISE !!!!! */
  549. solde_global_courant = gsb_real_add ( solde_global_courant,
  550. gsb_data_account_get_current_balance (account_number));
  551. solde_global_pointe = gsb_real_add ( solde_global_pointe,
  552. gsb_data_account_get_marked_balance (account_number));
  553. }
  554. i++;
  555. list_tmp = list_tmp -> next;
  556. }
  557. /* affichage des soldes partiels s'ils existent */
  558. if ( new_comptes_actif > 0 )
  559. {
  560. list_tmp = gsb_data_partial_balance_get_list ( );
  561. if ( list_tmp )
  562. i += affiche_soldes_partiels ( pTable, i, new_comptes_actif, list_tmp,
  563. currency_number, GSB_TYPE_ASSET );
  564. }
  565. /* Création et remplissage de la (nb_comptes + 3)ičme ligne du tableau :
  566. elle contient la somme des soldes de chaque compte */
  567. affiche_solde_des_comptes ( pTable, i, nb_comptes_actif, currency_number,
  568. solde_global_courant, solde_global_pointe );
  569. gtk_widget_show_all ( paddingbox );
  570. gtk_widget_show_all ( pTable );
  571. }
  572. /* Affichage des soldes mixtes */
  573. if ( soldes_mixtes > 0 )
  574. {
  575. if ( soldes_mixtes == 1 )
  576. tmpstr = g_strdup ( _("Additional balance") );
  577. else
  578. tmpstr = g_strdup ( _("Additional balances") );
  579. if ( conf.balances_with_scheduled == FALSE )
  580. tmpstr = g_strconcat ( tmpstr, _(" at "), gsb_date_today (), NULL );
  581. paddingbox = new_paddingbox_with_title ( vbox, FALSE, tmpstr );
  582. g_free ( tmpstr );
  583. pTable = gsb_main_page_get_table_for_accounts ( (3 * soldes_mixtes) , 3 );
  584. gtk_box_pack_start ( GTK_BOX ( paddingbox ), pTable, FALSE, FALSE, 0 );
  585. list_tmp = gsb_data_partial_balance_get_list ( );
  586. if ( list_tmp )
  587. i += affiche_soldes_additionnels ( pTable, i, list_tmp );
  588. }
  589. gtk_widget_show_all (vbox);
  590. }
  591. /**
  592. * teste si au moins 1 compte utilise la devise passée en paramčtre.
  593. *
  594. * \param currency_number
  595. *
  596. * \return TRUE si un compte utilise la devise FALSE sinon;
  597. * */
  598. gboolean gsb_main_page_get_devise_is_used ( gint currency_number, gint type_compte )
  599. {
  600. GSList *list_tmp;
  601. list_tmp = gsb_data_account_get_list_accounts ( );
  602. while ( list_tmp )
  603. {
  604. gint i;
  605. i = gsb_data_account_get_no_account ( list_tmp -> data );
  606. if ( gsb_data_account_get_currency ( i ) == currency_number
  607. &&
  608. !gsb_data_account_get_closed_account ( i )
  609. &&
  610. gsb_data_account_get_kind ( i ) == type_compte )
  611. return TRUE;
  612. list_tmp = list_tmp -> next;
  613. }
  614. return FALSE;
  615. }
  616. /**
  617. *
  618. *
  619. * \return style_label
  620. * */
  621. GtkStyle *gsb_main_page_get_default_label_style ( )
  622. {
  623. GtkWidget *label;
  624. GtkStyle * style_label;
  625. /* Création d'un label juste pour en récupérer le style */
  626. label = gtk_label_new (NULL);
  627. /* Initialisation du style Ť Nom du compte ť */
  628. style_label = gtk_style_copy ( gtk_widget_get_style ( label ) );
  629. style_label -> fg[GTK_STATE_NORMAL] = couleur_nom_compte_normal;
  630. style_label ->fg[GTK_STATE_PRELIGHT] = couleur_nom_compte_prelight;
  631. gtk_widget_destroy ( label );
  632. return style_label;
  633. }
  634. /**
  635. * Crée la table et sa premičre ligne
  636. *
  637. * \return table
  638. * */
  639. GtkWidget *gsb_main_page_get_table_for_accounts ( gint nb_lignes, gint nb_col )
  640. {
  641. GtkWidget *table, *label;
  642. table = gtk_table_new ( nb_lignes, nb_col, FALSE );
  643. /* Création et remplissage de la premičre ligne du tableau */
  644. label = gtk_label_new ( chaine_espace );
  645. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  646. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  647. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, 0, 1 );
  648. gtk_widget_show ( label );
  649. label = gtk_label_new (_("Reconciled balance"));
  650. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  651. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 1, 2, 0, 1 );
  652. gtk_widget_show ( label );
  653. label = gtk_label_new (_("Current balance"));
  654. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  655. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 2, 4, 0, 1 );
  656. gtk_widget_show ( label );
  657. return table;
  658. }
  659. /**
  660. * Affiche une ligne pour le compte donné en paramčtre
  661. *
  662. * \param table
  663. * \param account number
  664. * \param ligne dans la table
  665. *
  666. * \return FALSE
  667. * */
  668. void gsb_main_page_affiche_ligne_du_compte ( GtkWidget *pTable,
  669. gint account_number,
  670. gint i )
  671. {
  672. GtkWidget *pEventBox, *pLabel;
  673. GtkStyle *pStyleLabelNomCompte, *pStyleLabelSoldeCourant,
  674. *pStyleLabelSoldePointe;
  675. GSList *list = NULL;
  676. gchar* tmpstr;
  677. /* Initialisation du style Ť Nom du compte ť */
  678. pStyleLabelNomCompte = gsb_main_page_get_default_label_style ( );
  679. /* Premičre colonne : elle contient le nom du compte */
  680. tmpstr = g_strconcat ( gsb_data_account_get_name (account_number), " : ", NULL );
  681. pLabel = gtk_label_new ( tmpstr );
  682. g_free ( tmpstr );
  683. gtk_misc_set_alignment ( GTK_MISC ( pLabel ), MISC_LEFT, MISC_VERT_CENTER );
  684. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), pLabel );
  685. gtk_widget_set_style ( pLabel, pStyleLabelNomCompte );
  686. /* Création d'une boite ŕ évčnement qui sera rattachée au nom du compte */
  687. pEventBox = gtk_event_box_new ();
  688. list = g_slist_append ( list, pEventBox );
  689. g_signal_connect ( G_OBJECT ( pEventBox ),
  690. "enter-notify-event",
  691. G_CALLBACK ( met_en_prelight ),
  692. list );
  693. g_signal_connect ( G_OBJECT ( pEventBox ),
  694. "leave-notify-event",
  695. G_CALLBACK ( met_en_normal ),
  696. list );
  697. g_signal_connect_swapped ( G_OBJECT ( pEventBox ),
  698. "button-press-event",
  699. G_CALLBACK ( gsb_main_page_click_on_account ),
  700. GINT_TO_POINTER (account_number) );
  701. gtk_table_attach_defaults ( GTK_TABLE ( pTable ), pEventBox,
  702. 0, 1, i, i+1 );
  703. gtk_widget_show ( pEventBox );
  704. gtk_container_add ( GTK_CONTAINER ( pEventBox ), pLabel );
  705. gtk_widget_show ( pLabel );
  706. /* Deuxičme colonne : elle contient le solde pointé du compte */
  707. tmpstr = gsb_real_get_string_with_currency (
  708. gsb_data_account_get_marked_balance ( account_number ),
  709. gsb_data_account_get_currency (account_number), TRUE);
  710. pLabel = gtk_label_new ( tmpstr );
  711. g_free ( tmpstr );
  712. gtk_misc_set_alignment ( GTK_MISC ( pLabel ), MISC_RIGHT, MISC_VERT_CENTER );
  713. /* Mise en place du style du label en fonction du solde pointé */
  714. pStyleLabelSoldePointe = gtk_style_copy ( gtk_widget_get_style ( pLabel ));
  715. if ( gsb_real_cmp ( gsb_data_account_get_marked_balance (account_number),
  716. gsb_data_account_get_mini_balance_wanted (account_number)) != -1)
  717. {
  718. pStyleLabelSoldePointe->fg[GTK_STATE_NORMAL] = couleur_solde_alarme_verte_normal;
  719. pStyleLabelSoldePointe->fg[GTK_STATE_PRELIGHT] = couleur_solde_alarme_verte_prelight;
  720. }
  721. else
  722. {
  723. if ( gsb_real_cmp ( gsb_data_account_get_marked_balance (account_number),
  724. gsb_data_account_get_mini_balance_authorized (account_number)) != -1 )
  725. {
  726. pStyleLabelSoldePointe->fg[GTK_STATE_NORMAL] = couleur_solde_alarme_orange_normal;
  727. pStyleLabelSoldePointe->fg[GTK_STATE_PRELIGHT] = couleur_solde_alarme_orange_prelight;
  728. }
  729. else
  730. {
  731. pStyleLabelSoldePointe->fg[GTK_STATE_NORMAL] = couleur_solde_alarme_rouge_normal;
  732. pStyleLabelSoldePointe->fg[GTK_STATE_PRELIGHT] = couleur_solde_alarme_rouge_prelight;
  733. }
  734. }
  735. gtk_widget_set_style ( pLabel, pStyleLabelSoldePointe );
  736. /* Création d'une boite ŕ évčnement qui sera rattachée au solde pointé du compte */
  737. pEventBox = gtk_event_box_new ();
  738. list = g_slist_append ( list, pEventBox );
  739. g_signal_connect ( G_OBJECT ( pEventBox ),
  740. "enter-notify-event",
  741. G_CALLBACK ( met_en_prelight ),
  742. list );
  743. g_signal_connect ( G_OBJECT ( pEventBox ),
  744. "leave-notify-event",
  745. G_CALLBACK ( met_en_normal ),
  746. list );
  747. g_signal_connect_swapped ( G_OBJECT ( pEventBox ),
  748. "button-press-event",
  749. G_CALLBACK ( gsb_main_page_click_on_account ),
  750. GINT_TO_POINTER (account_number) );
  751. gtk_table_attach_defaults ( GTK_TABLE ( pTable ), pEventBox,
  752. 1, 2, i, i+1 );
  753. gtk_widget_show ( pEventBox );
  754. gtk_container_add ( GTK_CONTAINER ( pEventBox ), pLabel );
  755. gtk_widget_show ( pLabel );
  756. /* Troisičme colonne : elle contient le solde courant du compte */
  757. tmpstr = gsb_real_get_string_with_currency (
  758. gsb_data_account_get_current_balance (account_number),
  759. gsb_data_account_get_currency (account_number), TRUE);
  760. pLabel = gtk_label_new ( tmpstr );
  761. g_free ( tmpstr );
  762. gtk_misc_set_alignment ( GTK_MISC ( pLabel ), MISC_RIGHT, MISC_VERT_CENTER );
  763. /* Mise en place du style du label en fonction du solde courant */
  764. pStyleLabelSoldeCourant = gtk_style_copy ( gtk_widget_get_style ( pLabel ));
  765. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (account_number),
  766. gsb_data_account_get_mini_balance_wanted (account_number)) != -1)
  767. {
  768. pStyleLabelSoldeCourant->fg[GTK_STATE_NORMAL] = couleur_solde_alarme_verte_normal;
  769. pStyleLabelSoldeCourant->fg[GTK_STATE_PRELIGHT] = couleur_solde_alarme_verte_prelight;
  770. }
  771. else
  772. {
  773. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (account_number),
  774. gsb_data_account_get_mini_balance_authorized (account_number)) != -1 )
  775. {
  776. pStyleLabelSoldeCourant->fg[GTK_STATE_NORMAL] = couleur_solde_alarme_orange_normal;
  777. pStyleLabelSoldeCourant->fg[GTK_STATE_PRELIGHT] = couleur_solde_alarme_orange_prelight;
  778. }
  779. else
  780. {
  781. pStyleLabelSoldeCourant->fg[GTK_STATE_NORMAL] = couleur_solde_alarme_rouge_normal;
  782. pStyleLabelSoldeCourant->fg[GTK_STATE_PRELIGHT] = couleur_solde_alarme_rouge_prelight;
  783. }
  784. }
  785. gtk_widget_set_style ( pLabel, pStyleLabelSoldeCourant );
  786. /* Création d'une boite ŕ évčnement qui sera rattachée au solde courant du compte */
  787. pEventBox = gtk_event_box_new ();
  788. list = g_slist_append ( list, pEventBox );
  789. g_signal_connect ( G_OBJECT ( pEventBox ),
  790. "enter-notify-event",
  791. G_CALLBACK ( met_en_prelight ),
  792. list );
  793. g_signal_connect ( G_OBJECT ( pEventBox ),
  794. "leave-notify-event",
  795. G_CALLBACK ( met_en_normal ),
  796. list );
  797. g_signal_connect_swapped ( G_OBJECT ( pEventBox ),
  798. "button-press-event",
  799. G_CALLBACK (gsb_main_page_click_on_account),
  800. GINT_TO_POINTER (account_number) );
  801. gtk_table_attach_defaults ( GTK_TABLE ( pTable ), pEventBox,
  802. 2, 3, i, i+1 );
  803. gtk_widget_show ( pEventBox );
  804. gtk_container_add ( GTK_CONTAINER ( pEventBox ), pLabel );
  805. gtk_widget_show ( pLabel );
  806. }
  807. /**
  808. * Création de ou des lignes de solde partiels
  809. *
  810. * */
  811. gint affiche_soldes_partiels ( GtkWidget *table,
  812. gint i,
  813. gint nb_comptes,
  814. GSList *liste,
  815. gint currency_number,
  816. gint type_compte )
  817. {
  818. GtkWidget *label;
  819. gchar *tmpstr;
  820. gint nbre_lignes = 0;
  821. gboolean concerne = FALSE;
  822. while ( liste )
  823. {
  824. gint partial_number;
  825. kind_account kind;
  826. partial_number = gsb_data_partial_balance_get_number ( liste -> data );
  827. kind = gsb_data_partial_balance_get_kind ( partial_number );
  828. if ( ( kind == type_compte
  829. || ( kind < GSB_TYPE_LIABILITIES && type_compte < GSB_TYPE_LIABILITIES ) )
  830. &&
  831. gsb_data_partial_balance_get_currency ( partial_number ) == currency_number )
  832. {
  833. if ( concerne == FALSE )
  834. {
  835. /* on commence par une ligne vide */
  836. label = gtk_label_new ( chaine_espace );
  837. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  838. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  839. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  840. gtk_widget_show ( label );
  841. i ++;
  842. nbre_lignes ++;
  843. /* On met les titres du sous ensemble solde(s) partiel(s) */
  844. if ( nb_comptes == 1 )
  845. label = gtk_label_new ( _("Partial balance: ") );
  846. else
  847. label = gtk_label_new ( _("Partial balances: ") );
  848. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  849. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  850. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  851. gtk_widget_show ( label );
  852. label = gtk_label_new (_("Reconciled balance"));
  853. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  854. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 1, 2, i, i+1 );
  855. gtk_widget_show ( label );
  856. label = gtk_label_new (_("Current balance"));
  857. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  858. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 2, 4, i, i+1 );
  859. gtk_widget_show ( label );
  860. i ++;
  861. nbre_lignes ++;
  862. concerne = TRUE;
  863. }
  864. /* Premičre colonne : elle contient le nom du solde partiel */
  865. tmpstr = g_strconcat ( gsb_data_partial_balance_get_name ( partial_number ),
  866. " : ", NULL );
  867. label = gtk_label_new ( tmpstr );
  868. g_free ( tmpstr );
  869. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  870. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  871. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  872. gtk_widget_show ( label );
  873. /* Deuxičme colonne : elle contient le solde pointé du solde partiel */
  874. tmpstr = gsb_data_partial_balance_get_marked_balance ( partial_number );
  875. label = gtk_label_new ( tmpstr );
  876. gtk_label_set_markup ( GTK_LABEL ( label ), tmpstr );
  877. g_free ( tmpstr );
  878. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  879. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 1, 2, i, i+1 );
  880. gtk_widget_show ( label );
  881. /* Troisičme colonne : elle contient le solde courant du solde partiel */
  882. tmpstr = gsb_data_partial_balance_get_current_balance ( partial_number );
  883. label = gtk_label_new ( NULL );
  884. gtk_label_set_markup ( GTK_LABEL ( label ), tmpstr );
  885. g_free ( tmpstr );
  886. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  887. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 2, 3, i, i+1 );
  888. gtk_widget_show ( label );
  889. i++;
  890. nbre_lignes ++;
  891. }
  892. liste = liste -> next;
  893. }
  894. return nbre_lignes;
  895. }
  896. /**
  897. * Création de la ligne de solde des comptes
  898. *
  899. * */
  900. void affiche_solde_des_comptes ( GtkWidget *table,
  901. gint i,
  902. gint nb_comptes,
  903. gint currency_number,
  904. gsb_real solde_global_courant,
  905. gsb_real solde_global_pointe )
  906. {
  907. GtkWidget *label;
  908. gchar *tmpstr;
  909. /* on commence par une ligne vide */
  910. label = gtk_label_new ( chaine_espace );
  911. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  912. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  913. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  914. gtk_widget_show ( label );
  915. i ++;
  916. /* Premičre colonne */
  917. if ( nb_comptes == 1 )
  918. label = gtk_label_new ( _("Global balance: ") );
  919. else if ( conf.pluriel_final )
  920. label = gtk_label_new ( ("Soldes finaux: ") );
  921. else
  922. label = gtk_label_new ( _("Global balances: ") );
  923. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  924. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  925. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  926. gtk_widget_show ( label );
  927. /* Deuxičme colonne : elle contient le solde total pointé des comptes */
  928. tmpstr = gsb_real_get_string_with_currency (solde_global_pointe,
  929. currency_number, TRUE);
  930. label = gtk_label_new ( tmpstr );
  931. g_free ( tmpstr );
  932. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  933. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 1, 2, i, i+1 );
  934. gtk_widget_show ( label );
  935. /* Troisičme colonne : elle contient le solde total courant des comptes */
  936. tmpstr = gsb_real_get_string_with_currency (solde_global_courant, currency_number, TRUE);
  937. label = gtk_label_new ( tmpstr );
  938. g_free ( tmpstr );
  939. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  940. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 2, 3, i, i+1 );
  941. gtk_widget_show ( label );
  942. }
  943. /**
  944. * Création de ou des lignes de solde additionnel
  945. *
  946. * */
  947. gint affiche_soldes_additionnels ( GtkWidget *table, gint i, GSList *liste )
  948. {
  949. GtkWidget *label;
  950. gchar *tmpstr;
  951. gint nbre_lignes = 0;
  952. gint currency_number;
  953. /* on commence par une ligne vide */
  954. label = gtk_label_new ( chaine_espace );
  955. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  956. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  957. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  958. gtk_widget_show ( label );
  959. i ++;
  960. nbre_lignes ++;
  961. while ( liste )
  962. {
  963. gint partial_number;
  964. kind_account kind;
  965. partial_number = gsb_data_partial_balance_get_number ( liste -> data );
  966. kind = gsb_data_partial_balance_get_kind ( partial_number );
  967. if ( kind == - 1 )
  968. {
  969. /* Premičre colonne : elle contient le nom du solde partiel */
  970. currency_number = gsb_data_partial_balance_get_currency ( partial_number );
  971. tmpstr = g_strdup_printf (_(" in %s"), gsb_data_currency_get_name (
  972. currency_number ) );
  973. tmpstr = g_strconcat ( gsb_data_partial_balance_get_name ( partial_number ),
  974. tmpstr,
  975. " : ", NULL );
  976. label = gtk_label_new ( tmpstr );
  977. g_free ( tmpstr );
  978. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  979. gtk_size_group_add_widget ( GTK_SIZE_GROUP ( size_group_accueil ), label );
  980. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 0, 1, i, i+1 );
  981. gtk_widget_show ( label );
  982. /* Deuxičme colonne : elle contient le solde pointé du solde partiel */
  983. tmpstr = gsb_data_partial_balance_get_marked_balance ( partial_number );
  984. label = gtk_label_new ( tmpstr );
  985. gtk_label_set_markup ( GTK_LABEL ( label ), tmpstr );
  986. g_free ( tmpstr );
  987. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  988. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 1, 2, i, i+1 );
  989. gtk_widget_show ( label );
  990. /* Troisičme colonne : elle contient le solde courant du solde partiel */
  991. tmpstr = gsb_data_partial_balance_get_current_balance ( partial_number );
  992. label = gtk_label_new ( NULL );
  993. gtk_label_set_markup ( GTK_LABEL ( label ), tmpstr );
  994. g_free ( tmpstr );
  995. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  996. gtk_table_attach_defaults ( GTK_TABLE ( table ), label, 2, 3, i, i+1 );
  997. gtk_widget_show ( label );
  998. i++;
  999. nbre_lignes ++;
  1000. }
  1001. liste = liste -> next;
  1002. }
  1003. return nbre_lignes;
  1004. }
  1005. /**
  1006. * called by a click on an account name or balance of accounts on the main page
  1007. * it's just a mediator between the signal and gsb_navigation_show_account
  1008. *
  1009. * \param account_number a pointer wich is the number of account we want to switch
  1010. *
  1011. * \return FALSE
  1012. * */
  1013. gboolean gsb_main_page_click_on_account ( gint *account_number )
  1014. {
  1015. devel_debug_int (GPOINTER_TO_INT (account_number));
  1016. gsb_gui_navigation_set_selection ( GSB_ACCOUNT_PAGE,
  1017. GPOINTER_TO_INT (account_number),
  1018. NULL );
  1019. return FALSE;
  1020. }
  1021. /**
  1022. *
  1023. *
  1024. *
  1025. *
  1026. * */
  1027. void update_liste_echeances_manuelles_accueil ( gboolean force )
  1028. {
  1029. devel_debug_int (force);
  1030. /* need to set that in first because can change mise_a_jour_liste_echeances_manuelles_accueil */
  1031. gsb_scheduler_check_scheduled_transactions_time_limit ();
  1032. if ( !force
  1033. &&
  1034. !mise_a_jour_liste_echeances_manuelles_accueil )
  1035. return;
  1036. mise_a_jour_liste_echeances_manuelles_accueil = 0;
  1037. if ( scheduled_transactions_to_take )
  1038. {
  1039. GtkWidget *vbox;
  1040. GtkWidget *label;
  1041. GSList *pointeur_liste;
  1042. GtkWidget *event_box;
  1043. GtkWidget *hbox;
  1044. gint manual = 1;
  1045. /* s'il y avait déjŕ un fils dans la frame, le détruit */
  1046. gtk_notebook_remove_page ( GTK_NOTEBOOK(frame_etat_echeances_manuelles_accueil), 0 );
  1047. /* on affiche la seconde frame dans laquelle on place les
  1048. échéances ŕ saisir */
  1049. show_paddingbox ( frame_etat_echeances_manuelles_accueil );
  1050. /* on y place la liste des échéances */
  1051. vbox = gtk_vbox_new ( FALSE, 6 );
  1052. gtk_container_add ( GTK_CONTAINER(frame_etat_echeances_manuelles_accueil), vbox );
  1053. gtk_widget_show ( vbox );
  1054. /* on met une ligne vide pour faire joli */
  1055. label = gtk_label_new (NULL);
  1056. /* création du style normal -> bleu */
  1057. /* pointeur dessus -> jaune-rouge */
  1058. style_label = gtk_style_copy ( gtk_widget_get_style (label));
  1059. gtk_widget_destroy (label);
  1060. style_label->fg[GTK_STATE_PRELIGHT] = couleur_jaune;
  1061. style_label->fg[GTK_STATE_NORMAL] = couleur_bleue;
  1062. style_label->fg[GTK_STATE_INSENSITIVE] = couleur_bleue;
  1063. style_label->fg[GTK_STATE_SELECTED] = couleur_bleue;
  1064. style_label->fg[GTK_STATE_ACTIVE] = couleur_bleue;
  1065. pointeur_liste = g_slist_sort_with_data ( scheduled_transactions_to_take,
  1066. (GCompareDataFunc) classement_sliste_echeance_par_date,
  1067. GINT_TO_POINTER ( manual ) );
  1068. while ( pointeur_liste )
  1069. {
  1070. gint scheduled_number;
  1071. gint account_number;
  1072. gint currency_number;
  1073. gchar* tmpstr;
  1074. scheduled_number = GPOINTER_TO_INT (pointeur_liste -> data);
  1075. account_number = gsb_data_scheduled_get_account_number (scheduled_number);
  1076. currency_number = gsb_data_scheduled_get_currency_number (scheduled_number);
  1077. hbox = gtk_hbox_new ( TRUE, 5 );
  1078. gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
  1079. gtk_widget_show ( hbox );
  1080. /* bouton ŕ gauche */
  1081. event_box = gtk_event_box_new ();
  1082. g_signal_connect ( G_OBJECT ( event_box ),
  1083. "enter-notify-event",
  1084. G_CALLBACK ( met_en_prelight ),
  1085. NULL );
  1086. g_signal_connect ( G_OBJECT ( event_box ),
  1087. "leave-notify-event",
  1088. G_CALLBACK ( met_en_normal ),
  1089. NULL );
  1090. g_signal_connect ( G_OBJECT ( event_box ),
  1091. "button-press-event",
  1092. (GtkSignalFunc) saisie_echeance_accueil,
  1093. GINT_TO_POINTER (scheduled_number));
  1094. gtk_box_pack_start ( GTK_BOX ( hbox ), event_box, TRUE, TRUE, 5 );
  1095. gtk_widget_show ( event_box );
  1096. tmpstr = g_strconcat ( gsb_format_gdate (gsb_data_scheduled_get_date (scheduled_number)),
  1097. " : ",
  1098. gsb_data_payee_get_name (gsb_data_scheduled_get_party_number (scheduled_number),
  1099. FALSE ),
  1100. NULL );
  1101. label = gtk_label_new ( tmpstr );
  1102. g_free ( tmpstr );
  1103. gtk_widget_set_style ( label, style_label );
  1104. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  1105. gtk_container_add ( GTK_CONTAINER ( event_box ), label );
  1106. gtk_widget_show ( label );
  1107. /* label ŕ droite */
  1108. if ( gsb_data_scheduled_get_amount (scheduled_number).mantissa >= 0 )
  1109. {
  1110. gchar* tmpstr2 = gsb_real_get_string_with_currency (
  1111. gsb_data_scheduled_get_amount (scheduled_number), currency_number, TRUE);
  1112. gchar* tmpstr = g_strdup_printf ( _("%s credited on %s"), tmpstr2,
  1113. gsb_data_account_get_name (account_number));
  1114. g_free ( tmpstr2 );
  1115. label = gtk_label_new ( tmpstr );
  1116. g_free ( tmpstr );
  1117. }
  1118. else
  1119. {
  1120. gchar* tmpstr2 = gsb_real_get_string_with_currency (gsb_real_abs (
  1121. gsb_data_scheduled_get_amount (scheduled_number)), currency_number, TRUE);
  1122. gchar* tmpstr = g_strdup_printf ( _("%s debited on %s"), tmpstr2,
  1123. gsb_data_account_get_name (account_number));
  1124. g_free ( tmpstr2 );
  1125. label = gtk_label_new ( tmpstr );
  1126. g_free ( tmpstr );
  1127. }
  1128. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  1129. gtk_box_pack_start ( GTK_BOX ( hbox ), label, FALSE, TRUE, 0 );
  1130. gtk_widget_show ( label );
  1131. pointeur_liste = pointeur_liste -> next;
  1132. }
  1133. }
  1134. else
  1135. {
  1136. hide_paddingbox ( frame_etat_echeances_manuelles_accueil );
  1137. }
  1138. }
  1139. void update_liste_echeances_auto_accueil ( gboolean force )
  1140. {
  1141. if ( !force
  1142. &&
  1143. !mise_a_jour_liste_echeances_auto_accueil )
  1144. return;
  1145. devel_debug_int (force);
  1146. mise_a_jour_liste_echeances_auto_accueil = 0;
  1147. if ( scheduled_transactions_taken )
  1148. {
  1149. GtkWidget *vbox, *label, *event_box, *hbox;
  1150. GSList *pointeur_liste;
  1151. GtkStyle *style_selectable;
  1152. GdkColor gray_color;
  1153. gint manual = 0;
  1154. /* s'il y avait déjŕ un fils dans la frame, le détruit */
  1155. gtk_notebook_remove_page ( GTK_NOTEBOOK ( frame_etat_echeances_auto_accueil ), 0 );
  1156. /* on affiche la seconde frame dans laquelle on place les échéances ŕ saisir */
  1157. show_paddingbox ( frame_etat_echeances_auto_accueil );
  1158. gray_color.red = 0.61 * 65535 ;
  1159. gray_color.green = 0.61 * 65535 ;
  1160. gray_color.blue = 0.61 * 65535 ;
  1161. gray_color.pixel = 1;
  1162. style_selectable = gtk_style_copy ( gtk_widget_get_style ( frame_etat_echeances_auto_accueil ));
  1163. style_selectable->fg[GTK_STATE_PRELIGHT] = gray_color;
  1164. /* on y place la liste des échéances */
  1165. vbox = gtk_vbox_new ( FALSE, 5 );
  1166. gtk_container_add ( GTK_CONTAINER ( frame_etat_echeances_auto_accueil ), vbox);
  1167. gtk_widget_show ( vbox);
  1168. pointeur_liste = g_slist_sort_with_data ( scheduled_transactions_taken,
  1169. (GCompareDataFunc) classement_sliste_echeance_par_date,
  1170. GINT_TO_POINTER ( manual ) );
  1171. while ( pointeur_liste )
  1172. {
  1173. gint transaction_number;
  1174. gint account_number;
  1175. gint currency_number;
  1176. gchar* tmpstr;
  1177. transaction_number = GPOINTER_TO_INT ( pointeur_liste -> data );
  1178. account_number = gsb_data_transaction_get_account_number (transaction_number);
  1179. currency_number = gsb_data_transaction_get_currency_number (transaction_number);
  1180. hbox = gtk_hbox_new ( TRUE, 5 );
  1181. gtk_box_pack_start ( GTK_BOX ( vbox ), hbox, FALSE, FALSE, 0 );
  1182. gtk_widget_show ( hbox );
  1183. event_box = gtk_event_box_new ();
  1184. g_signal_connect ( G_OBJECT ( event_box ),
  1185. "enter-notify-event",
  1186. G_CALLBACK ( met_en_prelight ),
  1187. NULL );
  1188. g_signal_connect ( G_OBJECT ( event_box ),
  1189. "leave-notify-event",
  1190. G_CALLBACK ( met_en_normal ),
  1191. NULL );
  1192. g_signal_connect_swapped ( G_OBJECT ( event_box ),
  1193. "button-press-event",
  1194. G_CALLBACK (gsb_transactions_list_edit_transaction_by_pointer),
  1195. GINT_TO_POINTER (transaction_number));
  1196. gtk_widget_show ( event_box );
  1197. /* label ŕ gauche */
  1198. tmpstr = g_strconcat ( gsb_format_gdate ( gsb_data_transaction_get_date (transaction_number)),
  1199. " : ",
  1200. gsb_data_payee_get_name (gsb_data_transaction_get_party_number (transaction_number), FALSE),
  1201. NULL );
  1202. label = gtk_label_new ( tmpstr );
  1203. g_free ( tmpstr );
  1204. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  1205. gtk_widget_set_style ( label, style_selectable );
  1206. gtk_box_pack_start ( GTK_BOX ( hbox ), event_box, TRUE, TRUE, 5 );
  1207. gtk_container_add ( GTK_CONTAINER ( event_box ), label );
  1208. gtk_widget_show ( label );
  1209. /* label ŕ droite */
  1210. if ( gsb_data_transaction_get_amount (transaction_number).mantissa >= 0 )
  1211. {
  1212. gchar* tmpstr2 = gsb_real_get_string_with_currency (
  1213. gsb_data_transaction_get_amount (transaction_number), currency_number, TRUE);
  1214. gchar* tmpstr = g_strdup_printf ( _("%s credited on %s"), tmpstr2 ,
  1215. gsb_data_account_get_name (account_number));
  1216. g_free ( tmpstr2 );
  1217. label = gtk_label_new ( tmpstr );
  1218. g_free ( tmpstr );
  1219. }
  1220. else
  1221. {
  1222. gchar* tmpstr2 = gsb_real_get_string_with_currency (gsb_real_abs (
  1223. gsb_data_transaction_get_amount (transaction_number)), currency_number, TRUE);
  1224. gchar* tmpstr = g_strdup_printf ( _("%s debited on %s"),
  1225. tmpstr2, gsb_data_account_get_name (account_number));
  1226. g_free ( tmpstr2 );
  1227. label = gtk_label_new ( tmpstr );
  1228. g_free ( tmpstr );
  1229. }
  1230. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  1231. gtk_box_pack_start ( GTK_BOX ( hbox ), label, TRUE, TRUE, 5 );
  1232. gtk_widget_show ( label );
  1233. pointeur_liste = pointeur_liste -> next;
  1234. }
  1235. }
  1236. else
  1237. {
  1238. hide_paddingbox ( frame_etat_echeances_auto_accueil );
  1239. }
  1240. }
  1241. /**
  1242. * Fonction update_soldes_minimaux
  1243. * vérifie les soldes de tous les comptes, affiche un message d'alerte si nécessaire
  1244. *
  1245. *
  1246. *
  1247. *
  1248. * */
  1249. void update_soldes_minimaux ( gboolean force )
  1250. {
  1251. GtkWidget *vbox_1;
  1252. GtkWidget *vbox_2;
  1253. GtkWidget *label;
  1254. GSList *liste_autorise;
  1255. GSList *liste_voulu;
  1256. GSList *liste_autorise_et_voulu;
  1257. GSList *list_tmp;
  1258. if ( !force
  1259. &&
  1260. !mise_a_jour_soldes_minimaux )
  1261. return;
  1262. devel_debug ( "update_soldes_minimaux" );
  1263. mise_a_jour_soldes_minimaux = 0;
  1264. liste_autorise = NULL;
  1265. liste_voulu = NULL;
  1266. liste_autorise_et_voulu = NULL;
  1267. /* s'il y avait déjŕ un fils dans la frame, le détruit */
  1268. gtk_notebook_remove_page ( GTK_NOTEBOOK ( frame_etat_soldes_minimaux_autorises ), 0 );
  1269. gtk_notebook_remove_page ( GTK_NOTEBOOK ( frame_etat_soldes_minimaux_voulus ), 0 );
  1270. hide_paddingbox ( frame_etat_soldes_minimaux_autorises );
  1271. hide_paddingbox ( frame_etat_soldes_minimaux_voulus );
  1272. vbox_1 = NULL;
  1273. vbox_2 = NULL;
  1274. list_tmp = gsb_data_account_get_list_accounts ();
  1275. while ( list_tmp )
  1276. {
  1277. gint i;
  1278. i = gsb_data_account_get_no_account ( list_tmp -> data );
  1279. if ( gsb_data_account_get_closed_account ( i ) && !etat.show_closed_accounts )
  1280. {
  1281. list_tmp = list_tmp -> next;
  1282. continue;
  1283. }
  1284. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1285. gsb_data_account_get_mini_balance_authorized (i)) == -1
  1286. &&
  1287. gsb_data_account_get_kind (i) != GSB_TYPE_LIABILITIES )
  1288. {
  1289. if ( !vbox_1 )
  1290. {
  1291. vbox_1 = gtk_vbox_new ( TRUE, 5 );
  1292. gtk_container_add ( GTK_CONTAINER ( frame_etat_soldes_minimaux_autorises ), vbox_1 );
  1293. gtk_widget_show ( vbox_1 );
  1294. show_paddingbox ( frame_etat_soldes_minimaux_autorises );
  1295. }
  1296. label = gtk_label_new ( gsb_data_account_get_name (i) );
  1297. gtk_box_pack_start ( GTK_BOX ( vbox_1 ), label, FALSE, FALSE, 0 );
  1298. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_TOP );
  1299. gtk_widget_show ( label );
  1300. show_paddingbox ( frame_etat_soldes_minimaux_autorises );
  1301. }
  1302. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1303. gsb_data_account_get_mini_balance_wanted (i)) == -1
  1304. &&
  1305. gsb_data_account_get_kind (i) != GSB_TYPE_LIABILITIES
  1306. &&
  1307. gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1308. gsb_data_account_get_mini_balance_authorized (i)) == -1
  1309. &&
  1310. gsb_data_account_get_kind (i) != GSB_TYPE_LIABILITIES)
  1311. {
  1312. if ( !vbox_2 )
  1313. {
  1314. vbox_2 = gtk_vbox_new ( TRUE, 5 );
  1315. gtk_container_add ( GTK_CONTAINER ( frame_etat_soldes_minimaux_voulus ), vbox_2 );
  1316. gtk_widget_show ( vbox_2 );
  1317. show_paddingbox ( frame_etat_soldes_minimaux_voulus );
  1318. }
  1319. label = gtk_label_new ( gsb_data_account_get_name (i) );
  1320. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  1321. gtk_box_pack_start ( GTK_BOX ( vbox_2 ), label, FALSE, FALSE, 0 );
  1322. gtk_widget_show ( label );
  1323. show_paddingbox ( frame_etat_soldes_minimaux_voulus );
  1324. }
  1325. list_tmp = list_tmp -> next;
  1326. }
  1327. /* on affiche une boite d'avertissement si nécessaire */
  1328. affiche_dialogue_soldes_minimaux ();
  1329. mise_a_jour_liste_comptes_accueil = 1;
  1330. }
  1331. /* ************************************************************************* */
  1332. /* ************************************************************************* */
  1333. /* cette fonction vérifie les soldes minimaux et affiche une boite de dialogue */
  1334. /* avec les comptes en dessous des seuils si non désactivé */
  1335. /* ************************************************************************* */
  1336. void affiche_dialogue_soldes_minimaux ( void )
  1337. {
  1338. GSList *liste_autorise;
  1339. GSList *liste_voulu;
  1340. GSList *liste_autorise_et_voulu;
  1341. GSList *liste_tmp;
  1342. gchar *texte_affiche;
  1343. GSList *list_tmp;
  1344. if ( !mise_a_jour_soldes_minimaux )
  1345. return;
  1346. liste_autorise = NULL;
  1347. liste_voulu = NULL;
  1348. liste_autorise_et_voulu = NULL;
  1349. list_tmp = gsb_data_account_get_list_accounts ();
  1350. while ( list_tmp )
  1351. {
  1352. gint i;
  1353. i = gsb_data_account_get_no_account ( list_tmp -> data );
  1354. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1355. gsb_data_account_get_mini_balance_authorized (i)) == -1
  1356. &&
  1357. gsb_data_account_get_kind (i) != GSB_TYPE_LIABILITIES
  1358. &&
  1359. !gsb_data_account_get_mini_balance_authorized_message (i) )
  1360. {
  1361. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1362. gsb_data_account_get_mini_balance_wanted (i)) == -1 )
  1363. {
  1364. liste_autorise_et_voulu = g_slist_append ( liste_autorise_et_voulu,
  1365. gsb_data_account_get_name (i) );
  1366. gsb_data_account_set_mini_balance_wanted_message ( i,
  1367. 1 );
  1368. }
  1369. else
  1370. {
  1371. liste_autorise = g_slist_append ( liste_autorise,
  1372. gsb_data_account_get_name (i) );
  1373. }
  1374. gsb_data_account_set_mini_balance_authorized_message ( i,
  1375. 1 );
  1376. }
  1377. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1378. gsb_data_account_get_mini_balance_wanted (i)) == -1
  1379. &&
  1380. gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1381. gsb_data_account_get_mini_balance_authorized (i)) == 1
  1382. &&
  1383. gsb_data_account_get_kind (i) != GSB_TYPE_LIABILITIES
  1384. &&
  1385. !gsb_data_account_get_mini_balance_wanted_message (i) )
  1386. {
  1387. liste_voulu = g_slist_append ( liste_voulu,
  1388. gsb_data_account_get_name (i) );
  1389. gsb_data_account_set_mini_balance_wanted_message ( i,
  1390. 1 );
  1391. }
  1392. /* si on repasse au dessus des seuils, c'est comme si on n'avait rien affiché */
  1393. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1394. gsb_data_account_get_mini_balance_authorized (i)) == 1 )
  1395. gsb_data_account_set_mini_balance_authorized_message ( i,
  1396. 0 );
  1397. if ( gsb_real_cmp ( gsb_data_account_get_current_balance (i),
  1398. gsb_data_account_get_mini_balance_wanted (i)) == 1 )
  1399. gsb_data_account_set_mini_balance_wanted_message ( i,
  1400. 0 );
  1401. list_tmp = list_tmp -> next;
  1402. }
  1403. /* on crée le texte récapilutatif */
  1404. texte_affiche = g_strdup("");
  1405. if ( liste_autorise_et_voulu )
  1406. {
  1407. if ( g_slist_length ( liste_autorise_et_voulu ) == 1 )
  1408. texte_affiche = g_strdup_printf ( _("balance of account %s is under desired and authorised minima!"),
  1409. (gchar *) liste_autorise_et_voulu -> data );
  1410. else
  1411. {
  1412. texte_affiche = g_strdup(_("accounts with the balance under desired and authorised minimal :\n\n"));
  1413. liste_tmp = liste_autorise_et_voulu;
  1414. while ( liste_tmp )
  1415. {
  1416. gchar* oldstr = texte_affiche;
  1417. texte_affiche = g_strconcat ( oldstr,
  1418. liste_tmp -> data,
  1419. "\n",
  1420. NULL );
  1421. g_free ( oldstr );
  1422. liste_tmp = liste_tmp -> next;
  1423. }
  1424. }
  1425. }
  1426. if ( liste_autorise )
  1427. {
  1428. if ( strlen (texte_affiche))
  1429. {
  1430. gchar* oldstr = texte_affiche;
  1431. texte_affiche = g_strconcat ( oldstr,
  1432. "\n\n",
  1433. NULL );
  1434. g_free ( oldstr );
  1435. }
  1436. if ( g_slist_length ( liste_autorise ) == 1 )
  1437. {
  1438. gchar* oldstr = texte_affiche;
  1439. gchar* tmpstr = g_strdup_printf ( _("balance of account %s is under authorised minimum!"),
  1440. (gchar *) liste_autorise -> data );
  1441. texte_affiche = g_strconcat ( oldstr, tmpstr , NULL );
  1442. g_free ( oldstr );
  1443. g_free ( tmpstr );
  1444. }
  1445. else
  1446. {
  1447. gchar* oldstr = texte_affiche;
  1448. texte_affiche = g_strconcat ( oldstr,
  1449. _("accounts with the balance under authorised minimal :\n\n"),
  1450. NULL );
  1451. g_free ( oldstr );
  1452. liste_tmp = liste_autorise;
  1453. while ( liste_tmp )
  1454. {
  1455. gchar* oldstr = texte_affiche;
  1456. texte_affiche = g_strconcat ( oldstr,
  1457. liste_tmp -> data,
  1458. "\n",
  1459. NULL );
  1460. g_free ( oldstr );
  1461. liste_tmp = liste_tmp -> next;
  1462. }
  1463. }
  1464. }
  1465. if ( liste_voulu )
  1466. {
  1467. if ( strlen (texte_affiche))
  1468. {
  1469. gchar* oldstr = texte_affiche;
  1470. texte_affiche = g_strconcat ( oldstr,
  1471. "\n\n",
  1472. NULL );
  1473. g_free ( oldstr );
  1474. }
  1475. if ( g_slist_length ( liste_voulu ) == 1 )
  1476. {
  1477. gchar* oldstr = texte_affiche;
  1478. gchar* tmpstr = g_strdup_printf ( _("balance of account %s is under desired minimum!"),
  1479. (gchar *) liste_voulu -> data );
  1480. texte_affiche = g_strconcat ( texte_affiche, tmpstr , NULL );
  1481. g_free ( tmpstr );
  1482. g_free ( oldstr );
  1483. }
  1484. else
  1485. {
  1486. gchar* oldstr = texte_affiche;
  1487. texte_affiche = g_strconcat ( oldstr,
  1488. _("accounts with the balance under desired minimal :\n\n"),
  1489. NULL );
  1490. g_free ( oldstr );
  1491. liste_tmp = liste_voulu;
  1492. while ( liste_tmp )
  1493. {
  1494. gchar* oldstr = texte_affiche;
  1495. texte_affiche = g_strconcat ( oldstr,
  1496. liste_tmp -> data,
  1497. "\n",
  1498. NULL );
  1499. g_free ( oldstr );
  1500. liste_tmp = liste_tmp -> next;
  1501. }
  1502. }
  1503. }
  1504. if ( strlen ( texte_affiche ))
  1505. dialog_message ( "minimum-balance-alert", texte_affiche );
  1506. g_free ( texte_affiche );
  1507. }
  1508. /* ************************************************************************* */
  1509. void update_fin_comptes_passifs ( gboolean force )
  1510. {
  1511. GtkWidget *vbox;
  1512. GtkWidget *label;
  1513. GSList *liste_tmp;
  1514. GSList *pointeur;
  1515. GSList *list_tmp;
  1516. if ( !force
  1517. &&
  1518. !mise_a_jour_fin_comptes_passifs )
  1519. return;
  1520. devel_debug (NULL);
  1521. mise_a_jour_fin_comptes_passifs = 0;
  1522. gtk_notebook_remove_page ( GTK_NOTEBOOK(frame_etat_fin_compte_passif), 0 );
  1523. hide_paddingbox ( frame_etat_fin_compte_passif );
  1524. if ( !etat.show_closed_accounts )
  1525. return;
  1526. list_tmp = gsb_data_account_get_list_accounts ();
  1527. liste_tmp = NULL;
  1528. while ( list_tmp )
  1529. {
  1530. gint i;
  1531. i = gsb_data_account_get_no_account ( list_tmp -> data );
  1532. if ( gsb_data_account_get_kind (i) == GSB_TYPE_LIABILITIES
  1533. &&
  1534. gsb_data_account_get_current_balance (i).mantissa >= 0 )
  1535. liste_tmp = g_slist_append ( liste_tmp, gsb_data_account_get_name (i) );
  1536. list_tmp = list_tmp -> next;
  1537. }
  1538. if ( g_slist_length ( liste_tmp ) )
  1539. {
  1540. vbox = gtk_vbox_new ( FALSE, 0 );
  1541. gtk_container_add ( GTK_CONTAINER ( frame_etat_fin_compte_passif ), vbox );
  1542. gtk_widget_show ( vbox );
  1543. pointeur = liste_tmp;
  1544. while ( pointeur )
  1545. {
  1546. label = gtk_label_new (pointeur -> data );
  1547. gtk_box_pack_start ( GTK_BOX ( vbox ), label, FALSE, FALSE, 0 );
  1548. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  1549. gtk_widget_show ( label );
  1550. pointeur = pointeur -> next;
  1551. }
  1552. show_paddingbox ( frame_etat_fin_compte_passif );
  1553. }
  1554. }
  1555. /**
  1556. * update the finished scheduled transactions part in the main page
  1557. * the scheduled transaction in param is finished
  1558. *
  1559. * \param scheduled_number
  1560. *
  1561. * \return FALSE
  1562. * */
  1563. gboolean gsb_main_page_update_finished_scheduled_transactions ( gint scheduled_number )
  1564. {
  1565. GtkWidget * label, * hbox, * page;
  1566. gint account_number;
  1567. gint currency_number;
  1568. gchar* tmpstr;
  1569. account_number = gsb_data_scheduled_get_account_number (scheduled_number);
  1570. currency_number = gsb_data_scheduled_get_currency_number (scheduled_number);
  1571. /* check if the vbox is already made, and make it if necesssary */
  1572. page = gtk_notebook_get_nth_page (GTK_NOTEBOOK (main_page_finished_scheduled_transactions_part), 0);
  1573. if ( !page )
  1574. {
  1575. page = gtk_vbox_new ( FALSE,
  1576. 5 );
  1577. gtk_notebook_append_page (GTK_NOTEBOOK (main_page_finished_scheduled_transactions_part),
  1578. page, NULL );
  1579. gtk_widget_show ( page );
  1580. }
  1581. /* append in the page the finished scheduled transaction */
  1582. hbox = gtk_hbox_new ( TRUE, 0 );
  1583. gtk_widget_show ( hbox );
  1584. /* label ŕ gauche */
  1585. tmpstr = g_strconcat ( gsb_format_gdate ( gsb_data_scheduled_get_date (scheduled_number)),
  1586. " : ",
  1587. gsb_data_payee_get_name (gsb_data_scheduled_get_party_number (scheduled_number), FALSE),
  1588. NULL );
  1589. label = gtk_label_new ( tmpstr );
  1590. g_free ( tmpstr );
  1591. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_LEFT, MISC_VERT_CENTER );
  1592. gtk_box_pack_start ( GTK_BOX ( hbox ), label, TRUE, TRUE, 0 );
  1593. gtk_widget_show ( label );
  1594. /* label ŕ droite */
  1595. if ( gsb_data_scheduled_get_amount (scheduled_number).mantissa >= 0 )
  1596. {
  1597. gchar* tmpstr2 = gsb_real_get_string_with_currency ( gsb_data_scheduled_get_amount (
  1598. scheduled_number), currency_number, TRUE );
  1599. tmpstr = g_strdup_printf ( _("%s credited on %s"),
  1600. tmpstr2,
  1601. gsb_data_account_get_name (account_number));
  1602. g_free ( tmpstr2);
  1603. }
  1604. else
  1605. {
  1606. gchar* tmpstr2 = gsb_real_get_string_with_currency ( gsb_real_abs (
  1607. gsb_data_scheduled_get_amount (scheduled_number)), currency_number, TRUE );
  1608. tmpstr = g_strdup_printf ( _("%s debited on %s"),
  1609. tmpstr2,
  1610. gsb_data_account_get_name (account_number));
  1611. g_free ( tmpstr2 );
  1612. }
  1613. label = gtk_label_new ( tmpstr );
  1614. g_free ( tmpstr );
  1615. gtk_misc_set_alignment ( GTK_MISC ( label ), MISC_RIGHT, MISC_VERT_CENTER );
  1616. gtk_box_pack_end ( GTK_BOX (hbox), label, FALSE, TRUE, 0 );
  1617. gtk_widget_show ( label );
  1618. gtk_box_pack_start ( GTK_BOX (page),
  1619. hbox,
  1620. FALSE,
  1621. TRUE,
  1622. 0 );
  1623. gtk_widget_show ( label );
  1624. show_paddingbox (main_page_finished_scheduled_transactions_part);
  1625. return FALSE;
  1626. }
  1627. /* *******************************************************************************/
  1628. /* page de configuration pour la page d'accueil */
  1629. /* *******************************************************************************/
  1630. GtkWidget *onglet_accueil (void)
  1631. {
  1632. GtkWidget *vbox_pref, *vbox, *paddingbox, *button;
  1633. GtkWidget *hbox, *vbox2, *sw, *treeview;
  1634. GtkListStore *list_store;
  1635. GtkTreeViewColumn *column;
  1636. GtkCellRenderer *cell;
  1637. GtkTreeSelection *selection;
  1638. GtkTreeDragDestIface * dst_iface;
  1639. GtkTreeDragSourceIface * src_iface;
  1640. static GtkTargetEntry row_targets[] = {
  1641. { "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
  1642. };
  1643. vbox_pref = new_vbox_with_title_and_icon ( _("Configuration of the main page"),
  1644. "title.png" );
  1645. vbox = gtk_vbox_new ( FALSE, 12 );
  1646. gtk_box_pack_start ( GTK_BOX ( vbox_pref ), vbox, TRUE, TRUE, 0 );
  1647. gtk_container_set_border_width ( GTK_CONTAINER ( vbox ), 12 );
  1648. /* pour les francophones ;-) */
  1649. if ( g_strstr_len ( ( g_ascii_strup ( gdk_set_locale ( ), -1 ) ), -1, "FR" ) )
  1650. {
  1651. paddingbox = new_paddingbox_with_title (vbox, FALSE, "Pluriel de final" );
  1652. gtk_box_pack_start ( GTK_BOX ( paddingbox ),
  1653. gsb_automem_radiobutton_new ( "Soldes finals",
  1654. "Soldes finaux",
  1655. &conf.pluriel_final,
  1656. G_CALLBACK (gsb_gui_navigation_update_home_page), NULL ),
  1657. FALSE, FALSE, 0 );
  1658. }
  1659. /* Take into account the planned operations in the calculation of balances */
  1660. paddingbox = new_paddingbox_with_title ( vbox, FALSE, _("Calculation of balances") );
  1661. hbox = gtk_hbox_new ( FALSE, 0 );
  1662. gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, FALSE, FALSE, 0 );
  1663. button = gsb_automem_checkbutton_new (
  1664. _("Take into account the scheduled operations "
  1665. "in the calculation of balances"),
  1666. &conf.balances_with_scheduled,
  1667. G_CALLBACK ( gsb_config_scheduler_switch_balances_with_scheduled ),
  1668. NULL );
  1669. gtk_box_pack_start ( GTK_BOX ( hbox ), button, FALSE, FALSE, 0 );
  1670. /* Data partial balance settings */
  1671. paddingbox = new_paddingbox_with_title (vbox, FALSE,
  1672. _("Balances partials of the list of accounts") );
  1673. hbox = gtk_hbox_new ( FALSE, 5 );
  1674. gtk_box_pack_start ( GTK_BOX ( paddingbox ), hbox, TRUE, TRUE, 5);
  1675. sw = gtk_scrolled_window_new (NULL, NULL);
  1676. gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
  1677. GTK_SHADOW_ETCHED_IN);
  1678. gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
  1679. GTK_POLICY_AUTOMATIC,
  1680. GTK_POLICY_ALWAYS);
  1681. gtk_box_pack_start ( GTK_BOX (hbox), sw, TRUE,TRUE, 0 );
  1682. /* Create Add/Edit/Remove buttons */
  1683. vbox2 = gtk_vbox_new ( FALSE, 5 );
  1684. gtk_box_pack_start ( GTK_BOX ( hbox ), vbox2, FALSE, FALSE, 0 );
  1685. /* Button "Add" */
  1686. button = gtk_button_new_from_stock (GTK_STOCK_ADD);
  1687. g_signal_connect ( G_OBJECT ( button ),
  1688. "clicked",
  1689. G_CALLBACK ( gsb_partial_balance_add ),
  1690. vbox_pref );
  1691. gtk_box_pack_start ( GTK_BOX ( vbox2 ), button, FALSE, FALSE, 5 );
  1692. g_object_set_data ( G_OBJECT (vbox_pref), "add_button", button );
  1693. /* Button "Edit" */
  1694. button = gtk_button_new_from_stock (GTK_STOCK_EDIT);
  1695. g_signal_connect ( G_OBJECT ( button ),
  1696. "clicked",
  1697. G_CALLBACK ( gsb_partial_balance_edit ),
  1698. vbox_pref );
  1699. gtk_box_pack_start ( GTK_BOX ( vbox2 ), button, FALSE, FALSE, 5 );
  1700. gtk_widget_set_sensitive ( button, FALSE );
  1701. g_object_set_data ( G_OBJECT (vbox_pref), "edit_button", button );
  1702. /* Button "Remove" */
  1703. button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
  1704. g_signal_connect ( G_OBJECT ( button ),
  1705. "clicked",
  1706. G_CALLBACK ( gsb_partial_balance_delete ),
  1707. vbox_pref );
  1708. gtk_box_pack_start ( GTK_BOX ( vbox2 ), button, FALSE, FALSE, 5 );
  1709. gtk_widget_set_sensitive ( button, FALSE );
  1710. g_object_set_data ( G_OBJECT (vbox_pref), "remove_button", button );
  1711. /* create the model */
  1712. list_store = gsb_partial_balance_create_model ( );
  1713. /* populate the model if necessary */
  1714. if ( g_slist_length ( gsb_data_partial_balance_get_list ( ) ) > 0 )
  1715. gsb_partial_balance_fill_model ( list_store );
  1716. /* create the treeview */
  1717. treeview = gtk_tree_view_new_with_model (
  1718. GTK_TREE_MODEL (list_store) );
  1719. g_object_unref ( list_store );
  1720. gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (treeview), TRUE);
  1721. gtk_widget_set_size_request ( treeview, -1, 150 );
  1722. /* check the keys on the list */
  1723. g_signal_connect ( G_OBJECT ( treeview ),
  1724. "key_press_event",
  1725. G_CALLBACK ( gsb_partial_balance_key_press ),
  1726. NULL );
  1727. /* check the buttons on the list */
  1728. g_signal_connect ( G_OBJECT ( treeview ),
  1729. "button_press_event",
  1730. G_CALLBACK ( gsb_partial_balance_button_press ),
  1731. NULL );
  1732. /* Enable drag & drop */
  1733. gtk_tree_view_enable_model_drag_source ( GTK_TREE_VIEW (treeview),
  1734. GDK_BUTTON1_MASK, row_targets, 1,
  1735. GDK_ACTION_MOVE );
  1736. gtk_tree_view_enable_model_drag_dest ( GTK_TREE_VIEW (treeview), row_targets,
  1737. 1, GDK_ACTION_MOVE );
  1738. gtk_tree_view_set_reorderable ( GTK_TREE_VIEW (treeview), TRUE );
  1739. selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (treeview) );
  1740. gtk_tree_selection_set_select_function ( selection,
  1741. (GtkTreeSelectionFunc) gsb_partial_balance_select_func,
  1742. vbox_pref, NULL );
  1743. gtk_container_add (GTK_CONTAINER (sw), treeview);
  1744. gtk_container_set_resize_mode (GTK_CONTAINER (sw), GTK_RESIZE_PARENT);
  1745. g_object_set_data ( G_OBJECT (vbox_pref), "treeview", treeview );
  1746. /* Nom du solde partiel */
  1747. cell = gtk_cell_renderer_text_new ( );
  1748. column = gtk_tree_view_column_new_with_attributes ( _("Name"),
  1749. cell, "text", 0, NULL);
  1750. gtk_tree_view_column_set_expand ( column, TRUE );
  1751. gtk_tree_view_column_set_alignment ( column, 0.5 );
  1752. gtk_tree_view_column_set_sort_column_id (column, 0);
  1753. gtk_tree_view_append_column ( GTK_TREE_VIEW (treeview), column);
  1754. /* Liste des comptes */
  1755. cell = gtk_cell_renderer_text_new ( );
  1756. column = gtk_tree_view_column_new_with_attributes ( _("Accounts list"),
  1757. cell, "text", 1, NULL);
  1758. gtk_tree_view_column_set_expand ( column, TRUE );
  1759. gtk_tree_view_column_set_alignment ( column, 0.5 );
  1760. gtk_tree_view_column_set_sort_column_id (column, 1);
  1761. gtk_tree_view_append_column ( GTK_TREE_VIEW (treeview), column);
  1762. /* Colorize */
  1763. cell = gtk_cell_renderer_toggle_new ( );
  1764. g_signal_connect ( cell,
  1765. "toggled",
  1766. G_CALLBACK ( gsb_partial_balance_colorise_toggled ),
  1767. treeview );
  1768. gtk_cell_renderer_toggle_set_radio ( GTK_CELL_RENDERER_TOGGLE(cell), FALSE );
  1769. g_object_set (cell, "xalign", 0.5, NULL);
  1770. column = gtk_tree_view_column_new_with_attributes ( _("Colorize"),
  1771. cell,
  1772. "active", 5,
  1773. NULL);
  1774. gtk_tree_view_append_column ( GTK_TREE_VIEW(treeview), column);
  1775. /* Type de compte */
  1776. cell = gtk_cell_renderer_text_new ( );
  1777. column = gtk_tree_view_column_new_with_attributes ( _("Account kind"),
  1778. cell, "text", 2, NULL);
  1779. gtk_tree_view_column_set_expand ( column, TRUE );
  1780. gtk_tree_view_column_set_alignment ( column, 0.5 );
  1781. gtk_tree_view_column_set_sort_column_id (column, 2);
  1782. gtk_tree_view_append_column ( GTK_TREE_VIEW (treeview), column);
  1783. /* Devise */
  1784. cell = gtk_cell_renderer_text_new ( );
  1785. column = gtk_tree_view_column_new_with_attributes ( _("Currency"),
  1786. cell, "text", 3, NULL);
  1787. gtk_tree_view_column_set_expand ( column, TRUE );
  1788. gtk_tree_view_column_set_alignment ( column, 0.5 );
  1789. gtk_tree_view_column_set_sort_column_id (column, 3);
  1790. gtk_tree_view_append_column ( GTK_TREE_VIEW (treeview), column);
  1791. dst_iface = GTK_TREE_DRAG_DEST_GET_IFACE ( list_store );
  1792. if ( dst_iface )
  1793. dst_iface -> drag_data_received = &gsb_data_partial_balance_drag_data_received;
  1794. src_iface = GTK_TREE_DRAG_SOURCE_GET_IFACE ( list_store );
  1795. if ( src_iface )
  1796. {
  1797. gtk_selection_add_target ( treeview,
  1798. GDK_SELECTION_PRIMARY,
  1799. GDK_SELECTION_TYPE_ATOM,
  1800. 1 );
  1801. src_iface -> drag_data_get = &gsb_data_partial_balance_drag_data_get;
  1802. }
  1803. gtk_widget_show_all ( vbox_pref );
  1804. return ( vbox_pref );
  1805. }
  1806. /**
  1807. * update the title of the main page
  1808. *
  1809. * \param title
  1810. *
  1811. *
  1812. * */
  1813. void gsb_main_page_update_homepage_title ( const gchar *title )
  1814. {
  1815. gchar * tmp_str;
  1816. /* at the first use of grisbi,label_titre_fichier doesn't still exist */
  1817. if ( !label_titre_fichier || !GTK_IS_LABEL ( label_titre_fichier ) )
  1818. return;
  1819. tmp_str = g_markup_printf_escaped ("<span size=\"x-large\">%s</span>", title );
  1820. gtk_label_set_markup ( GTK_LABEL ( label_titre_fichier ), tmp_str );
  1821. g_free ( tmp_str );
  1822. }
  1823. gboolean gsb_config_scheduler_switch_balances_with_scheduled ( void )
  1824. {
  1825. GSList *list_tmp;
  1826. devel_debug ( NULL );
  1827. list_tmp = gsb_data_account_get_list_accounts ();
  1828. while ( list_tmp )
  1829. {
  1830. gint account_number;
  1831. account_number = gsb_data_account_get_no_account ( list_tmp -> data );
  1832. gsb_data_account_set_balances_are_dirty ( account_number );
  1833. /* MAJ HOME_PAGE */
  1834. gsb_gui_navigation_update_home_page ( );
  1835. list_tmp = list_tmp -> next;
  1836. }
  1837. return FALSE;
  1838. }
  1839. /* Local Variables: */
  1840. /* c-basic-offset: 4 */
  1841. /* End: */