Commit 696206ee authored by Meade's avatar Meade

Now at version 2.0.0. Tons of code improvements. Did away with the regex crate...

Now at version 2.0.0. Tons of code improvements. Did away with the regex crate dependency. Added the IBU calculator. Added link-time optimisation to Cargo.toml for the release build.
parent 824ba20d
This diff is collapsed.
[package]
name = "BrewStillery"
version = "1.1.0"
version = "2.0.0"
authors = ["Emily And Meade <thedarkula2049@gmail.com>"]
description = "BrewStillery is a brewer's, vintner's, and distiller's calculator. It has a multitude of great functions, such as calculating ABV, determining carbonation, and total sparge water needed."
# documentation to come
......@@ -17,7 +17,6 @@ exclude = ["media/screenshots/*", "Arch/*"]
maintenance = { status = "actively-developed" }
[dependencies]
regex = "0.2.2"
[dependencies.gtk]
version = "0.2.0"
......@@ -28,4 +27,5 @@ codegen-units = 4
[profile.release]
opt-level = 3
codegen-units = 4
\ No newline at end of file
codegen-units = 4
lto = true
\ No newline at end of file
......@@ -4,17 +4,21 @@ It has a multitude of great functions, such as calculating ABV, determining carb
Written in Rust, using GTK3
## New In 2.0.0
Added the IBU calculator to the beer tab.
## Screenshots:
![General Tab Screenshot](media/screenshots/BrewStilleryGeneralTab.png)
![Beer Tab Screenshot](media/screenshots/BrewStilleryBeerTab.png)
![Beer Tab IBU Screenshot](media/screenshots/BrewStilleryBeerIBU.png)
![Champagne Tab Screenshot](media/screenshots/BrewStilleryChampagneTab.png)
## To Do:
* IBU
* Grain
......@@ -36,4 +40,5 @@ Written in Rust, using GTK3
## Sources:
* ["Brew By Numbers - Add Up What's In Your Beer"](https://www.homebrewersassociation.org/attachments/0000/2497/Math_in_Mash_SummerZym95.pdf) - Michael L. Hall. PH.D., Zymurgy (Summer) 1995
* ["Kraeusening"](http://www.braukaiser.com/wiki/index.php?title=Kraeusening) - Braukaiser.com, Modified: January 2, 2010
\ No newline at end of file
* ["Kraeusening"](http://www.braukaiser.com/wiki/index.php?title=Kraeusening) - Braukaiser.com, Modified: January 2, 2010
* ["Glenn Tinseth's Hop Page"](http://realbeer.com/hops/) - Glenn Tinseth, 1995-1999
\ No newline at end of file
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use regex::Regex;
use functions::commonFunctions::*;
pub fn champagneCarbonationPrep(ref champagneCarbonationBuilderClone: &gtk::Builder) {
let champagneCarbonationInput: &gtk::Entry = &champagneCarbonationBuilderClone.get_object("champagneCarbonationInput").unwrap();
let champagneCarbonationInputBuffer = champagneCarbonationInput.get_text().expect("No input");
let champagneVolume = validInput(&champagneCarbonationInputBuffer);
let champagneCarbonationOutput = String::from("champagneCarbonationOutput");
let isNumerical = Regex::new(r"^\d+\.\d+|\d+$").unwrap();
let isCharacter = Regex::new(r"^\D$").unwrap();
let isMismatched = Regex::new(r"^\d+\D+|\d+\D+\d+$").unwrap();
if champagneCarbonationInputBuffer == "" || isNumerical.is_match(&champagneCarbonationInputBuffer) == false || isCharacter.is_match(&champagneCarbonationInputBuffer) == true || isMismatched.is_match(&champagneCarbonationInputBuffer) == true {
if champagneVolume == 0.0 {
let output: gtk::Entry = champagneCarbonationBuilderClone.get_object(&champagneCarbonationOutput).unwrap();
output.set_text("Enter a number");
} else {
let champagneCarbonationInputBufferFloat: f32 = champagneCarbonationInputBuffer.parse().unwrap();
if champagneCarbonationInputBufferFloat <= 0.0 {
if champagneVolume <= 0.0 {
let output: gtk::Entry = champagneCarbonationBuilderClone.get_object(&champagneCarbonationOutput).unwrap();
output.set_text("Enter a positive number");
} else {
onChampagneActivate(champagneCarbonationInputBuffer, &champagneCarbonationBuilderClone);
onChampagneActivate(champagneVolume, &champagneCarbonationBuilderClone);
}
}
}
pub fn onChampagneActivate(champagneCarbonationInputBuffer: String, ref champagneCarbonationBuilderClone: &gtk::Builder) {
pub fn onChampagneActivate(champagneVolume: f32, ref champagneCarbonationBuilderClone: &gtk::Builder) {
let ref champagneCarbonationSwitch: &gtk::Switch = &champagneCarbonationBuilderClone.get_object("champagneCarbonationSwitch").unwrap();
let champagneVolume: f32 = champagneCarbonationInputBuffer.parse().unwrap();
if champagneCarbonationSwitch.get_active() == true {
let imperialOrMetric = String::from("metric");
champagneCarbonationMaths(champagneVolume, imperialOrMetric, &champagneCarbonationBuilderClone);
......
#![allow(non_snake_case)]
use std::f32::consts::E;
pub fn brixToGravity(brix: f32) -> f32 {
(brix / (258.6 - ((brix / 258.2) * 227.1))) + 1.0
}
pub fn gravityToPlato(gravity: f32) -> f32 {
135.997 * gravity.powi(3) - 630.272 * gravity.powi(2) + 1111.14 * gravity - 616.868
}
pub fn gramsToOunces(grams: f32) -> f32 {
0.03527396_f32 * grams
}
pub fn litresToGallons(litres: f32) -> f32 {
0.2641729_f32 * litres
}
pub fn validInput(stringToCheck: &String) -> f32 {
let isANumber = stringToCheck.parse::<f32>().is_ok();
if isANumber == true {
stringToCheck.parse().unwrap()
} else {
0.0
}
}
pub fn realIBU(brix: f32, wortVolume: f32, boilTime: f32, alphaAcid: f32, hopAmount: f32) -> f32 {
(1.65 * 0.000125_f32.powf(brixToGravity(brix) - 1.0)) * ((1.0 - E.powf(-0.04 * boilTime)) / 4.15) * (( (alphaAcid / 100.0) * hopAmount * 7490.0 ) / wortVolume)
}
\ No newline at end of file
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use regex::Regex;
use functions::commonFunctions::*;
pub fn guestimatePrep(ref guestimatorBuilderClone: &gtk::Builder) {
let guestimatorInput: &gtk::Entry = &guestimatorBuilderClone.get_object("guestimatorInput").unwrap();
let buffer = guestimatorInput.get_text().expect("No input");
let guestimatorInput = guestimatorInput.get_text().expect("No input");
let startingBrix = validInput(&guestimatorInput);
let guestimatorOutput = String::from("guestimatorOutput");
let isNumerical = Regex::new(r"^\d+\.\d+|\d+$").unwrap();
let isCharacter = Regex::new(r"^\D$").unwrap();
let isMismatched = Regex::new(r"^\d+\D+|\d+\D+\d+$").unwrap();
if buffer == "" || isNumerical.is_match(&buffer) == false || isCharacter.is_match(&buffer) == true || isMismatched.is_match(&buffer) == true {
if startingBrix == 0.0 {
let output: gtk::Entry = guestimatorBuilderClone.get_object(&guestimatorOutput).unwrap();
output.set_text("Enter a number");
} else {
let bufferFloat: f32 = buffer.parse().unwrap();
if bufferFloat < 3.83 {
if startingBrix < 3.83 {
let output: gtk::Entry = guestimatorBuilderClone.get_object(&guestimatorOutput).unwrap();
output.set_text("Enter a number greater than 3.83");
} else if bufferFloat > 49.48 {
} else if startingBrix > 49.48 {
let output: gtk::Entry = guestimatorBuilderClone.get_object(&guestimatorOutput).unwrap();
output.set_text("Enter a number less than 49.48");
} else {
guestiMaths(buffer, guestimatorOutput, &guestimatorBuilderClone);
guestiMaths(startingBrix, guestimatorOutput, &guestimatorBuilderClone);
}
}
}
pub fn guestiMaths(buffer: String, guestimatorOutput: String, ref guestimatorBuilderClone: &gtk::Builder) {
let startingBrix: f32 = buffer.parse().unwrap();
pub fn guestiMaths(startingBrix: f32, guestimatorOutput: String, ref guestimatorBuilderClone: &gtk::Builder) {
let originalGravity = brixToGravity(startingBrix);
let finalGravity: f32 = 1.015;
// since finalGravity is unknown, this constant is ideal
......
This diff is collapsed.
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use regex::Regex;
use functions::commonFunctions::*;
pub fn gyleCarbonationPrep(ref gyleBuilderClone: &gtk::Builder) {
let gyleBrixInput: &gtk::Entry = &gyleBuilderClone.get_object("gyleBrixInput").unwrap();
let gyleBrixInputBuffer = gyleBrixInput.get_text().expect("No input");
let startingBrix = validInput(&gyleBrixInputBuffer);
let gyleCO2Input: &gtk::Entry = &gyleBuilderClone.get_object("gyleCO2Input").unwrap();
let gyleCO2InputBuffer = gyleCO2Input.get_text().expect("No input");
let desiredCO2Level = validInput(&gyleCO2InputBuffer);
let gyleWortVolumeInput: &gtk::Entry = &gyleBuilderClone.get_object("gyleWortVolumeInput").unwrap();
let gyleWortVolumeInputBuffer = gyleWortVolumeInput.get_text().expect("No input");
let finalVolume = validInput(&gyleWortVolumeInputBuffer);
let gyleOutput = String::from("gyleOutput");
let spargeMashWaterOutput = String::from("spargeMashWaterOutput");
let isNumerical = Regex::new(r"^\d+\.\d+|\d+$").unwrap();
let isCharacter = Regex::new(r"^\D$").unwrap();
let isMismatched = Regex::new(r"^\d+\D+|\d+\D+\d+$").unwrap();
if gyleBrixInputBuffer == "" || isNumerical.is_match(&gyleBrixInputBuffer) == false || isCharacter.is_match(&gyleBrixInputBuffer) == true || isMismatched.is_match(&gyleBrixInputBuffer) == true {
let output: gtk::Entry = gyleBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
if startingBrix == 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&gyleOutput).unwrap();
output.set_text("Enter a number");
} else if gyleCO2InputBuffer == "" || isNumerical.is_match(&gyleCO2InputBuffer) == false || isCharacter.is_match(&gyleCO2InputBuffer) == true || isMismatched.is_match(&gyleCO2InputBuffer) == true {
let output: gtk::Entry = gyleBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
} else if desiredCO2Level == 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&gyleOutput).unwrap();
output.set_text("Enter a number");
} else if gyleWortVolumeInputBuffer == "" || isNumerical.is_match(&gyleWortVolumeInputBuffer) == false || isCharacter.is_match(&gyleWortVolumeInputBuffer) == true || isMismatched.is_match(&gyleWortVolumeInputBuffer) == true {
let output: gtk::Entry = gyleBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
} else if finalVolume == 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&gyleOutput).unwrap();
output.set_text("Enter a number");
} else {
let gyleBrixInputBufferFloat: f32 = gyleBrixInputBuffer.parse().unwrap();
let gyleCO2InputBufferFloat: f32 = gyleCO2InputBuffer.parse().unwrap();
let gyleWortVolumeInputBufferFloat: f32 = gyleWortVolumeInputBuffer.parse().unwrap();
if gyleBrixInputBufferFloat <= 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
if startingBrix <= 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&gyleOutput).unwrap();
output.set_text("Enter a positive number");
} else if gyleCO2InputBufferFloat <= 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
} else if desiredCO2Level <= 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&gyleOutput).unwrap();
output.set_text("Enter a positive number");
} else if gyleWortVolumeInputBufferFloat <= 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
} else if finalVolume <= 0.0 {
let output: gtk::Entry = gyleBuilderClone.get_object(&gyleOutput).unwrap();
output.set_text("Enter a positive number");
} else {
onGyleActivate(gyleBrixInputBuffer, gyleCO2InputBuffer, gyleWortVolumeInputBuffer, &gyleBuilderClone);
onGyleActivate(startingBrix, desiredCO2Level, finalVolume, &gyleBuilderClone);
}
}
}
pub fn onGyleActivate(startingBrixBuffer: String, desiredCO2LevelBuffer: String, finalVolumeBuffer: String, ref gyleBuilderClone: &gtk::Builder) {
pub fn onGyleActivate(startingBrix: f32, desiredCO2Level: f32, finalVolume: f32, ref gyleBuilderClone: &gtk::Builder) {
let ref gyleCarbonationSwitch: &gtk::Switch = &gyleBuilderClone.get_object("gyleCarbonationSwitch").unwrap();
let startingBrix: f32 = startingBrixBuffer.parse().unwrap();
let desiredCO2Level: f32 = desiredCO2LevelBuffer.parse().unwrap();
let finalVolume: f32 = finalVolumeBuffer.parse().unwrap();
if gyleCarbonationSwitch.get_active() == true {
let imperialOrMetric = String::from("metric");
gyleMaths(startingBrix, desiredCO2Level, finalVolume, imperialOrMetric, &gyleBuilderClone);
......
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use regex::Regex;
use functions::commonFunctions::*;
pub fn increaseABVPrep(ref increaseABVBuilderClone: &gtk::Builder) {
let increaseABVBrixInput: &gtk::Entry = &increaseABVBuilderClone.get_object("increaseABVBrixInput").unwrap();
let increaseABVBrixInputBuffer = increaseABVBrixInput.get_text().expect("No input");
let startingBrix = validInput(&increaseABVBrixInputBuffer);
let increaseABVABVInput: &gtk::Entry = &increaseABVBuilderClone.get_object("increaseABVABVInput").unwrap();
let increaseABVABVInputBuffer = increaseABVABVInput.get_text().expect("No input");
let desiredABV = validInput(&increaseABVABVInputBuffer);
let increaseABVVolumeInput: &gtk::Entry = &increaseABVBuilderClone.get_object("increaseABVVolumeInput").unwrap();
let increaseABVVolumeInputBuffer = increaseABVVolumeInput.get_text().expect("No input");
let desiredWortVolume = validInput(&increaseABVVolumeInputBuffer);
let increaseABVNewBrixOutput = String::from("increaseABVNewBrixOutput");
let isNumerical = Regex::new(r"^\d+\.\d+|\d+$").unwrap();
let isCharacter = Regex::new(r"^\D$").unwrap();
let isMismatched = Regex::new(r"^\d+\D+|\d+\D+\d+$").unwrap();
if increaseABVBrixInputBuffer == "" || isNumerical.is_match(&increaseABVBrixInputBuffer) == false || isCharacter.is_match(&increaseABVBrixInputBuffer) == true || isMismatched.is_match(&increaseABVBrixInputBuffer) == true {
if startingBrix == 0.0 {
let output: gtk::Entry = increaseABVBuilderClone.get_object(&increaseABVNewBrixOutput).unwrap();
output.set_text("Enter a number");
} else if increaseABVABVInputBuffer == "" || isNumerical.is_match(&increaseABVABVInputBuffer) == false || isCharacter.is_match(&increaseABVABVInputBuffer) == true || isMismatched.is_match(&increaseABVABVInputBuffer) == true {
} else if desiredABV == 0.0 {
let output: gtk::Entry = increaseABVBuilderClone.get_object(&increaseABVNewBrixOutput).unwrap();
output.set_text("Enter a number");
} else if increaseABVVolumeInputBuffer == "" || isNumerical.is_match(&increaseABVVolumeInputBuffer) == false || isCharacter.is_match(&increaseABVVolumeInputBuffer) == true || isMismatched.is_match(&increaseABVVolumeInputBuffer) == true {
} else if desiredWortVolume == 0.0 {
let output: gtk::Entry = increaseABVBuilderClone.get_object(&increaseABVNewBrixOutput).unwrap();
output.set_text("Enter a number");
} else {
let increaseABVBrixInputBufferFloat: f32 = increaseABVBrixInputBuffer.parse().unwrap();
let increaseABVABVInputBufferFloat: f32 = increaseABVABVInputBuffer.parse().unwrap();
let increaseABVVolumeInputBufferFloat: f32 = increaseABVVolumeInputBuffer.parse().unwrap();
if increaseABVBrixInputBufferFloat <= 0.0 {
if startingBrix <= 0.0 {
let output: gtk::Entry = increaseABVBuilderClone.get_object(&increaseABVNewBrixOutput).unwrap();
output.set_text("Enter a positive number");
} else if increaseABVABVInputBufferFloat <= 0.0 {
} else if desiredABV <= 0.0 {
let output: gtk::Entry = increaseABVBuilderClone.get_object(&increaseABVNewBrixOutput).unwrap();
output.set_text("Enter a positive number");
} else if increaseABVVolumeInputBufferFloat <= 0.0 {
} else if desiredWortVolume <= 0.0 {
let output: gtk::Entry = increaseABVBuilderClone.get_object(&increaseABVNewBrixOutput).unwrap();
output.set_text("Enter a positive number");
} else {
onIncreaseActivate(increaseABVBrixInputBuffer, increaseABVABVInputBuffer, increaseABVVolumeInputBuffer, &increaseABVBuilderClone);
onIncreaseActivate(startingBrix, desiredABV, desiredWortVolume, &increaseABVBuilderClone);
}
}
}
pub fn onIncreaseActivate(increaseABVBrixInputBuffer: String, increaseABVABVInputBuffer: String, increaseABVVolumeInputBuffer: String, ref increaseABVBuilderClone: &gtk::Builder) {
pub fn onIncreaseActivate(startingBrix: f32, desiredABV: f32, desiredWortVolume: f32, ref increaseABVBuilderClone: &gtk::Builder) {
let ref increaseABVSwitch: &gtk::Switch = &increaseABVBuilderClone.get_object("increaseABVSwitch").unwrap();
let startingBrix: f32 = increaseABVBrixInputBuffer.parse().unwrap();
let desiredABV: f32 = increaseABVABVInputBuffer.parse().unwrap();
let desiredWortVolume: f32 = increaseABVVolumeInputBuffer.parse().unwrap();
if increaseABVSwitch.get_active() == true {
let imperialOrMetric = String::from("metric");
differenceBrixMaths(startingBrix, desiredABV, desiredWortVolume, imperialOrMetric, &increaseABVBuilderClone);
......
......@@ -3,5 +3,6 @@ pub mod increaseABV;
pub mod realABV;
pub mod waterSparge;
pub mod gyleCarbonation;
pub mod guestimateIBU;
pub mod champagneCarbonation;
pub mod commonFunctions;
\ No newline at end of file
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use regex::Regex;
use functions::commonFunctions::*;
pub fn realABVPrep(ref realABVBuilderClone: &gtk::Builder) {
let realABVStartingBrixInput: &gtk::Entry = &realABVBuilderClone.get_object("realABVStartingBrixInput").unwrap();
let realABVStartingBrixInputBuffer = realABVStartingBrixInput.get_text().expect("No input");
let startingBrix = validInput(&realABVStartingBrixInputBuffer);
let realABVFinalBrixInput: &gtk::Entry = &realABVBuilderClone.get_object("realABVFinalBrixInput").unwrap();
let realABVFinalBrixInputBuffer = realABVFinalBrixInput.get_text().expect("No input");
let finalBrix = validInput(&realABVFinalBrixInputBuffer);
let realABVRealAttenuationOutput = String::from("realABVRealAttenuationOutput");
let isNumerical = Regex::new(r"^\d+\.\d+|\d+$").unwrap();
let isCharacter = Regex::new(r"^\D$").unwrap();
let isMismatched = Regex::new(r"^\d+\D+|\d+\D+\d+$").unwrap();
if realABVStartingBrixInputBuffer == "" || isNumerical.is_match(&realABVStartingBrixInputBuffer) == false || isCharacter.is_match(&realABVStartingBrixInputBuffer) == true || isMismatched.is_match(&realABVStartingBrixInputBuffer) == true {
if startingBrix == 0.0 {
let output: gtk::Entry = realABVBuilderClone.get_object(&realABVRealAttenuationOutput).unwrap();
output.set_text("Enter a number");
} else if realABVFinalBrixInputBuffer == "" || isNumerical.is_match(&realABVFinalBrixInputBuffer) == false || isCharacter.is_match(&realABVFinalBrixInputBuffer) == true || isMismatched.is_match(&realABVFinalBrixInputBuffer) == true {
} else if finalBrix == 0.0 {
let output: gtk::Entry = realABVBuilderClone.get_object(&realABVRealAttenuationOutput).unwrap();
output.set_text("Enter a number");
} else {
let realABVStartingBrixInputBufferFloat: f32 = realABVStartingBrixInputBuffer.parse().unwrap();
let realABVFinalBrixInputBufferFloat: f32 = realABVFinalBrixInputBuffer.parse().unwrap();
if realABVStartingBrixInputBufferFloat <= 0.0 {
if startingBrix <= 0.0 {
let output: gtk::Entry = realABVBuilderClone.get_object(&realABVRealAttenuationOutput).unwrap();
output.set_text("Enter a positive number");
} else if realABVFinalBrixInputBufferFloat <= 0.0 {
} else if finalBrix <= 0.0 {
let output: gtk::Entry = realABVBuilderClone.get_object(&realABVRealAttenuationOutput).unwrap();
output.set_text("Enter a positive number");
} else if realABVStartingBrixInputBufferFloat < realABVFinalBrixInputBufferFloat {
} else if startingBrix < finalBrix {
let output: gtk::Entry = realABVBuilderClone.get_object(&realABVRealAttenuationOutput).unwrap();
output.set_text("Starting brix must be greater than final brix");
} else {
realABVMaths(realABVStartingBrixInputBuffer, realABVFinalBrixInputBuffer, &realABVBuilderClone);
realABVMaths(startingBrix, finalBrix, &realABVBuilderClone);
}
}
}
pub fn realABVMaths(realABVStartingBrixInputBuffer: String, realABVFinalBrixInputBuffer: String, ref realABVBuilderClone: &gtk::Builder) {
pub fn realABVMaths(startingBrix: f32, finalBrix: f32, ref realABVBuilderClone: &gtk::Builder) {
let ref realABVRealAttenuationOutput: &gtk::Entry = &realABVBuilderClone.get_object("realABVRealAttenuationOutput").unwrap();
let ref realABVFinalABVOutput: &gtk::Entry = &realABVBuilderClone.get_object("realABVFinalABVOutput").unwrap();
let startingBrix: f32 = realABVStartingBrixInputBuffer.parse().unwrap();
let finalBrix: f32 = realABVFinalBrixInputBuffer.parse().unwrap();
let originalGravity = (startingBrix / (258.6 - ((startingBrix / 258.2) * 227.1))) + 1.0;
let finalGravity = (finalBrix / (258.6 - ((finalBrix / 258.2) * 227.1))) + 1.0;
let originalExtract = (-668.962) + (1262.45 * originalGravity) - (776.43 * originalGravity.powi(2)) + (182.94 * originalGravity.powi(3));
......
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use regex::Regex;
use functions::commonFunctions::*;
pub fn waterSpargePrep(ref waterSpargeBuilderClone: &gtk::Builder) {
let spargePreFermentVolumeInput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargePreFermentVolumeInput").unwrap();
let spargePreFermentVolumeInputBuffer = spargePreFermentVolumeInput.get_text().expect("No input");
let preFermentVolume = validInput(&spargePreFermentVolumeInputBuffer);
let spargeTotalGrainInput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeTotalGrainInput").unwrap();
let spargeTotalGrainInputBuffer = spargeTotalGrainInput.get_text().expect("No input");
let totalGrain = validInput(&spargeTotalGrainInputBuffer);
let spargeBoilTimeInput: &gtk::Entry = &waterSpargeBuilderClone.get_object("spargeBoilTimeInput").unwrap();
let spargeBoilTimeInputBuffer = spargeBoilTimeInput.get_text().expect("No input");
let boilTemp = validInput(&spargeBoilTimeInputBuffer);
let spargeMashWaterOutput = String::from("spargeMashWaterOutput");
let isNumerical = Regex::new(r"^\d+\.\d+|\d+$").unwrap();
let isCharacter = Regex::new(r"^\D$").unwrap();
let isMismatched = Regex::new(r"^\d+\D+|\d+\D+\d+$").unwrap();
if spargePreFermentVolumeInputBuffer == "" || isNumerical.is_match(&spargePreFermentVolumeInputBuffer) == false || isCharacter.is_match(&spargePreFermentVolumeInputBuffer) == true || isMismatched.is_match(&spargePreFermentVolumeInputBuffer) == true {
if preFermentVolume == 0.0 {
let output: gtk::Entry = waterSpargeBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
output.set_text("Enter a number");
} else if spargeTotalGrainInputBuffer == "" || isNumerical.is_match(&spargeTotalGrainInputBuffer) == false || isCharacter.is_match(&spargeTotalGrainInputBuffer) == true || isMismatched.is_match(&spargeTotalGrainInputBuffer) == true {
} else if totalGrain == 0.0 {
let output: gtk::Entry = waterSpargeBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
output.set_text("Enter a number");
} else if spargeBoilTimeInputBuffer == "" || isNumerical.is_match(&spargeBoilTimeInputBuffer) == false || isCharacter.is_match(&spargeBoilTimeInputBuffer) == true || isMismatched.is_match(&spargeBoilTimeInputBuffer) == true {
} else if boilTemp == 0.0 {
let output: gtk::Entry = waterSpargeBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
output.set_text("Enter a number");
} else {
......@@ -42,17 +42,14 @@ pub fn waterSpargePrep(ref waterSpargeBuilderClone: &gtk::Builder) {
let output: gtk::Entry = waterSpargeBuilderClone.get_object(&spargeMashWaterOutput).unwrap();
output.set_text("Enter a positive number");
} else {
onSpargeActivate(spargePreFermentVolumeInputBuffer, spargeTotalGrainInputBuffer, spargeBoilTimeInputBuffer, &waterSpargeBuilderClone);
onSpargeActivate(preFermentVolume, totalGrain, boilTemp, &waterSpargeBuilderClone);
}
}
}
pub fn onSpargeActivate(spargePreFermentVolumeInputBuffer: String, spargeTotalGrainInputBuffer: String, spargeBoilTimeInputBuffer: String, ref waterSpargeBuilderClone: &gtk::Builder) {
pub fn onSpargeActivate(preFermentVolume: f32, totalGrain: f32, boilTemp: f32, ref waterSpargeBuilderClone: &gtk::Builder) {
let ref waterSpargeSwitch: &gtk::Switch = &waterSpargeBuilderClone.get_object("waterSpargeSwitch").unwrap();
let preFermentVolume: f32 = spargePreFermentVolumeInputBuffer.parse().unwrap();
let totalGrain: f32 = spargeTotalGrainInputBuffer.parse().unwrap();
let boilTemp: f32 = spargeBoilTimeInputBuffer.parse().unwrap();
let boilTime: f32 = boilTemp / 60.0;
if waterSpargeSwitch.get_active() == true {
......
This diff is collapsed.
#![allow(non_snake_case)]
use gtk::{self};
use gtk;
use gtk::prelude::*;
use functions::guestimateABV::*;
......@@ -8,6 +8,7 @@ use functions::increaseABV::*;
use functions::realABV::*;
use functions::waterSparge::*;
use functions::gyleCarbonation::*;
use functions::guestimateIBU::*;
use functions::champagneCarbonation::*;
pub fn startGTK() {
......@@ -143,6 +144,117 @@ pub fn startGTK() {
});
// guestimateIBU Section
let totalIBUButton: gtk::Button = builder.get_object("totalIBUButton").unwrap();
let totalIBUButtonClone = builder.clone();
totalIBUButton.connect_clicked(move |_| {
guestimateIBUPrep(&totalIBUButtonClone);
});
let totalIBUPreBoilBrixInput: gtk::Entry = builder.get_object("totalIBUPreBoilBrixInput").unwrap();
let totalIBUPreBoilBrixInputBuilderClone = builder.clone();
totalIBUPreBoilBrixInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUPreBoilBrixInputBuilderClone);
});
let totalIBUWortVolumeInput: gtk::Entry = builder.get_object("totalIBUWortVolumeInput").unwrap();
let totalIBUWortVolumeInputBuilderClone = builder.clone();
totalIBUWortVolumeInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUWortVolumeInputBuilderClone);
});
let totalIBUBoilTimeInput: gtk::Entry = builder.get_object("totalIBUBoilTimeInput").unwrap();
let totalIBUBoilTimeInputBuilderClone = builder.clone();
totalIBUBoilTimeInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUBoilTimeInputBuilderClone);
});
let totalIBUFirstHopAlphaInput: gtk::Entry = builder.get_object("totalIBUFirstHopAlphaInput").unwrap();
let totalIBUFirstHopAlphaInputBuilderClone = builder.clone();
totalIBUFirstHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUFirstHopAlphaInputBuilderClone);
});
let totalIBUFirstHopAmountInput: gtk::Entry = builder.get_object("totalIBUFirstHopAmountInput").unwrap();
let totalIBUFirstHopAmountInputBuilderClone = builder.clone();
totalIBUFirstHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUFirstHopAmountInputBuilderClone);
});
let totalIBUSecondHopAlphaInput: gtk::Entry = builder.get_object("totalIBUSecondHopAlphaInput").unwrap();
let totalIBUSecondHopAlphaInputBuilderClone = builder.clone();
totalIBUSecondHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUSecondHopAlphaInputBuilderClone);
});
let totalIBUSecondHopAmountInput: gtk::Entry = builder.get_object("totalIBUSecondHopAmountInput").unwrap();
let totalIBUSecondHopAmountInputBuilderClone = builder.clone();
totalIBUSecondHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUSecondHopAmountInputBuilderClone);
});
let totalIBUThirdHopAlphaInput: gtk::Entry = builder.get_object("totalIBUThirdHopAlphaInput").unwrap();
let totalIBUThirdHopAlphaInputBuilderClone = builder.clone();
totalIBUThirdHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUThirdHopAlphaInputBuilderClone);
});
let totalIBUThirdHopAmountInput: gtk::Entry = builder.get_object("totalIBUThirdHopAmountInput").unwrap();
let totalIBUThirdHopAmountInputBuilderClone = builder.clone();
totalIBUThirdHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUThirdHopAmountInputBuilderClone);
});
let totalIBUFourthHopAlphaInput: gtk::Entry = builder.get_object("totalIBUFourthHopAlphaInput").unwrap();
let totalIBUFourthHopAlphaInputBuilderClone = builder.clone();
totalIBUFourthHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUFourthHopAlphaInputBuilderClone);
});
let totalIBUFourthHopAmountInput: gtk::Entry = builder.get_object("totalIBUFourthHopAmountInput").unwrap();
let totalIBUFourthHopAmountInputBuilderClone = builder.clone();
totalIBUFourthHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUFourthHopAmountInputBuilderClone);
});
let totalIBUFifthHopAlphaInput: gtk::Entry = builder.get_object("totalIBUFifthHopAlphaInput").unwrap();
let totalIBUFifthHopAlphaInputBuilderClone = builder.clone();
totalIBUFifthHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUFifthHopAlphaInputBuilderClone);
});
let totalIBUFifthHopAmountInput: gtk::Entry = builder.get_object("totalIBUFifthHopAmountInput").unwrap();
let totalIBUFifthHopAmountInputBuilderClone = builder.clone();
totalIBUFifthHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUFifthHopAmountInputBuilderClone);
});
let totalIBUSixthHopAlphaInput: gtk::Entry = builder.get_object("totalIBUSixthHopAlphaInput").unwrap();
let totalIBUSixthHopAlphaInputBuilderClone = builder.clone();
totalIBUSixthHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUSixthHopAlphaInputBuilderClone);
});
let totalIBUSixthHopAmountInput: gtk::Entry = builder.get_object("totalIBUSixthHopAmountInput").unwrap();
let totalIBUSixthHopAmountInputBuilderClone = builder.clone();
totalIBUSixthHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUSixthHopAmountInputBuilderClone);
});
let totalIBUSeventhHopAlphaInput: gtk::Entry = builder.get_object("totalIBUSeventhHopAlphaInput").unwrap();
let totalIBUSeventhHopAlphaInputBuilderClone = builder.clone();
totalIBUSeventhHopAlphaInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUSeventhHopAlphaInputBuilderClone);
});
let totalIBUSeventhHopAmountInput: gtk::Entry = builder.get_object("totalIBUSeventhHopAmountInput").unwrap();
let totalIBUSeventhHopAmountInputBuilderClone = builder.clone();
totalIBUSeventhHopAmountInput.connect_activate(move |_| {
guestimateIBUPrep(&totalIBUSeventhHopAmountInputBuilderClone);
});
// champagneCarbonation Section
let champagneCarbonationButton: gtk::Button = builder.get_object("champagneCarbonationButton").unwrap();
......
#![allow(non_snake_case)]
extern crate gtk;
extern crate regex;
mod gui;
mod functions;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment