From 778a75ee9ba19abf9b38a127269b2bca5671cec4 Mon Sep 17 00:00:00 2001 From: Jordan Josephs Date: Sat, 4 Jul 2026 23:19:21 -0400 Subject: [PATCH] Creating the scaffold for my calculator app! --- .gitignore | 6 ++++++ main.vala | 39 +++++++++++++++++++++++++++++++++++++++ meson.build | 9 +++++++++ 3 files changed, 54 insertions(+) create mode 100644 .gitignore create mode 100644 main.vala create mode 100644 meson.build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8008de7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.DS_Store +.idea +*.log +tmp/ + +build/ diff --git a/main.vala b/main.vala new file mode 100644 index 0000000..ea3d89a --- /dev/null +++ b/main.vala @@ -0,0 +1,39 @@ +public class Main : Gtk.Application { + public Main() { + Object (application_id: "com.example.App"); + } + + public override void activate () { + var win = new Gtk.ApplicationWindow (this); + win.set_title("Calculator"); + + var display = new Gtk.Label("Display"); + display.xalign = 1.0f; + var grid = new Gtk.Grid(); + + grid.attach(display, 0, 0, 3); + // Procedurlly generating numbered buttons 1-9 + for (int col = 0; col < 3; col++) { + for (int row = 0; row < 3; row++){ + // This math is need to orient the buttons in the correct order + // starting from bottom left to top right + var number = (3 - row - 1)*3 + col + 1; + var btn = new Gtk.Button.with_label("%d".printf(number)); + grid.attach(btn, col, row+1); + } + } + + var zero = new Gtk.Button.with_label("0"); + var equal = new Gtk.Button.with_label("="); + grid.attach(zero, 0, 4); + grid.attach(equal, 1, 4); + + win.child = grid; + win.present (); + } + + public static int main (string[] args) { + var app = new Main(); + return app.run (args); + } +} diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..b1c043b --- /dev/null +++ b/meson.build @@ -0,0 +1,9 @@ +project('calculator', 'vala') + +dependencies = [ + dependency('gtk4') + ] + +sources = files('main.vala') + +executable('calculator', sources, dependencies: dependencies)