/** * Signal triggered when user configure display grisbi title * * \param button Radio button that triggered event. * * \return FALSE */ gboolean change_grisbi_title_type ( GtkRadioButton *button, GtkWidget *entry ) { if ( gtk_toggle_button_get_active ( GTK_TOGGLE_BUTTON ( button ) ) ) { conf.display_grisbi_title = GPOINTER_TO_INT ( g_object_get_data ( G_OBJECT ( button ), "display" ) ); } switch ( conf.display_grisbi_title ) { case GSB_ACCOUNTS_TITLE: gtk_widget_set_sensitive ( entry, TRUE ); if ( titre_fichier && strlen ( titre_fichier ) ) gtk_entry_set_text ( GTK_ENTRY ( entry ), titre_fichier ); else { gtk_entry_set_text ( GTK_ENTRY ( entry ), "" ); titre_fichier = NULL; } break; case GSB_ACCOUNT_HOLDER: gtk_widget_set_sensitive ( entry, FALSE); break; case GSB_ACCOUNTS_FILE: gtk_widget_set_sensitive ( entry, FALSE); break; } /* set Grisbi title */ gsb_main_set_grisbi_title ( gsb_gui_navigation_get_current_account ( ) ); return FALSE; }
/** * Update the label that contain main title in homepage. * * \param entry Widget that triggered this handled. Not used. * \param value Not used handler parameter. * \param length Not used handler parameter. * \param position Not used handler parameter. */ gboolean update_homepage_title (GtkEntry *entry, gchar *value, gint length, gint * position) { if ( titre_fichier && strlen ( titre_fichier ) ) g_free ( titre_fichier ); titre_fichier = my_strdup ( gtk_entry_get_text ( GTK_ENTRY ( entry ) ) ); /* set Grisbi title */ gsb_main_set_grisbi_title ( -1 ); /* Mark file as modified */ gsb_file_set_modified ( TRUE ); return FALSE; }
/** * close the file * if no file loaded or no change, directly return TRUE * * \param * * \return FALSE if problem, TRUE if ok * */ gboolean gsb_file_close ( void ) { gint result; devel_debug (NULL); if ( !assert_account_loaded () ) return ( TRUE ); /* ask for saving */ result = gsb_file_dialog_save(); switch ( result ) { case GTK_RESPONSE_OK: /* try to save */ if ( !gsb_file_save_file (-1) ) return ( FALSE ); case GTK_RESPONSE_NO : /* remove the lock */ if ( !etat.fichier_deja_ouvert && gsb_data_account_get_accounts_amount () && nom_fichier_comptes ) gsb_file_util_modify_lock ( FALSE ); gsb_gui_init_general_vbox ( ); /* free all the variables */ init_variables (); gsb_account_property_clear_config ( ); gsb_main_set_grisbi_title ( -1 ); /* unsensitive the necessaries menus */ gsb_menu_set_menus_with_file_sensitive ( FALSE ); table_etat = NULL; return ( TRUE ); default : return FALSE; } }
/** * save the file * * \param origine 0 from gsb_file_save (menu), -1 from gsb_file_close, -2 from gsb_file_save_as * * \return TRUE if ok, FALSE if problem * */ gboolean gsb_file_save_file ( gint origine ) { gint etat_force, result; gchar *nouveau_nom_enregistrement; devel_debug_int (origine); etat_force = 0; if ( ( !gsb_file_get_modified ( ) && origine != -2 ) || !gsb_data_account_get_accounts_amount () ) { notice_debug ( "nothing done in gsb_file_save_file" ); return ( TRUE ); } /* si le fichier de comptes n'a pas de nom ou si on enregistre sous un nouveau nom */ /* c'est ici */ if ( !nom_fichier_comptes || origine == -2 ) nouveau_nom_enregistrement = gsb_file_dialog_ask_name (); else nouveau_nom_enregistrement = nom_fichier_comptes; if ( !nouveau_nom_enregistrement ) return FALSE; /* on vérifie que le fichier n'est pas locké */ if ( etat.fichier_deja_ouvert && !conf.force_enregistrement && origine != -2 ) { gchar* tmpstr1 = g_strdup_printf( _("Grisbi was unable to save this file because it is locked. Please save it with another name or activate the \"%s\" option in preferences."), _("Force saving of locked files" ) ); gchar* tmpstr2 = g_strdup_printf( _("Can not save file \"%s\""), nom_fichier_comptes ); dialogue_error_hint ( tmpstr1, tmpstr2 ); g_free ( tmpstr1 ); g_free ( tmpstr2 ); return ( FALSE ); } /* Si le fichier est un d'une version précédente de grisbi on demande si on l'efface */ if ( copy_old_filename && strlen ( copy_old_filename ) > 0 ) { gsb_file_save_remove_old_file ( copy_old_filename ); g_free ( copy_old_filename ); copy_old_filename = NULL; } /* make backup before saving if asked */ if (conf.make_backup) gsb_file_save_backup(); /* on a maintenant un nom de fichier */ /* et on sait qu'on peut sauvegarder */ gsb_status_message ( _("Saving file") ); result = gsb_file_save_save_file ( nouveau_nom_enregistrement, conf.compress_file, FALSE ); if ( result ) { /* saving was right, so unlock the last name */ gsb_file_util_modify_lock ( FALSE ); nom_fichier_comptes = nouveau_nom_enregistrement; /* and lock the new name */ gsb_file_util_modify_lock ( TRUE ); /* update variables */ etat.fichier_deja_ouvert = 0; gsb_file_set_modified ( FALSE ); gsb_main_set_grisbi_title ( gsb_gui_navigation_get_current_account ( ) ); gsb_file_append_name_to_opened_list ( nom_fichier_comptes ); } gsb_status_message ( _("Done") ); return ( result ); }
/** * open a new grisbi file, don't check anything about another opened file that must * have been done before * * \para filename the name of the file * * \return TRUE ok, FALSE problem * */ gboolean gsb_file_open_file ( gchar *filename ) { GSList *list_tmp; devel_debug (filename); if ( !filename || !strlen (filename)) return FALSE; gsb_status_wait ( TRUE ); gsb_status_message ( _("Loading accounts") ); /* try to load the file */ /* FIXME:BUG under Windows: for unknwon reason yet filename is cleared * when returning from gsb_file_load_open_file! * making application crashes! */ if ( gsb_file_load_open_file (filename)) { /* the file has been opened succesfully */ /* we make a backup if necessary */ if ( conf.sauvegarde_demarrage ) { gsb_file_save_backup (); gsb_file_set_modified ( FALSE ); } } else { /* Loading failed. */ gsb_status_message ( _("Failed to load accounts") ); if ( conf.sauvegarde_demarrage || conf.make_backup || conf.make_backup_every_minutes ) { gchar *tmpstr = g_strdup_printf ( _("Error loading file '%s'"), filename); gchar *tmpstr2 = g_strdup_printf ( _("Grisbi was unable to load file. You should find the last " "backups in '%s', they are saved with date and time into " "their name so you should find easily the last backup " "saved.\n" "Please contact the Grisbi's team on [email protected] " "to find what happened to you current file."), gsb_file_get_backup_path ()); dialogue_error_hint ( tmpstr2, tmpstr ); g_free ( tmpstr ); g_free ( tmpstr2 ); gsb_status_stop_wait ( TRUE ); return FALSE; } else { gchar *tmpstr = g_strdup_printf ( _("Error loading file '%s'"), filename); gchar *tmpstr2; if (gsb_file_get_backup_path ()) tmpstr2 = g_strdup_printf ( _("Grisbi was unable to load file and the backups seem not to " "be activated... This is a bad thing.\nYour backup path is '%s', " "try to find if earlier you had some backups in there ?\n" "Please contact the Grisbi's team on [email protected] " "to find what happened to you current file."), gsb_file_get_backup_path ()); else tmpstr2 = my_strdup ( _("Grisbi was unable to load file and the backups seem not " "to be activated... This is a bad thing.\n" "Please contact the Grisbi's team on " "[email protected] to find what happened to you " "current file.")); dialogue_error_hint ( tmpstr2, tmpstr ); g_free ( tmpstr ); g_free ( tmpstr2 ); gsb_status_stop_wait ( TRUE ); return FALSE; } } /* ok, here the file or backup is loaded */ gsb_status_message ( _("Checking schedulers")); /* the the name in the last opened files */ gsb_file_append_name_to_opened_list ( filename ); /* create the archives store data, ie the transaction wich will replace the archive in * the list of transactions */ gsb_data_archive_store_create_list (); /* create all the gui */ gsb_file_new_gui (); /* check the amounts of all the accounts */ gsb_status_message ( _("Checking amounts")); list_tmp = gsb_data_account_get_list_accounts (); while ( list_tmp ) { gint account_number; volatile gint value; account_number = gsb_data_account_get_no_account ( list_tmp -> data ); /* set the minimum balances to be shown or not */ value = gsb_real_cmp ( gsb_data_account_get_current_balance (account_number), gsb_data_account_get_mini_balance_authorized (account_number) ) == -1; gsb_data_account_set_mini_balance_authorized_message ( account_number, value); value = gsb_real_cmp ( gsb_data_account_get_current_balance (account_number), gsb_data_account_get_mini_balance_wanted (account_number) ) == -1; gsb_data_account_set_mini_balance_wanted_message ( account_number, value); list_tmp = list_tmp -> next; } /* set Grisbi title */ gsb_main_set_grisbi_title ( -1 ); /* update the main page */ mise_a_jour_accueil (TRUE); /* for now, the flag for modification of the file is ok, but the menu couldn't be set * as sensitive/unsensitive so do it now */ gsb_file_set_modified ( gsb_file_get_modified ( ) ); gsb_status_message ( _("Done") ); gsb_status_stop_wait ( TRUE ); /* go to the home page */ gsb_gui_navigation_set_selection ( GSB_HOME_PAGE, -1, NULL ); /* set the focus to the selection tree at left */ gtk_widget_grab_focus ( gsb_gui_navigation_get_tree_view ( ) ); return TRUE; }