Skip to content

touero/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GTK Calculator

A lightweight desktop calculator built in C with GTK+ 3. The app supports expression input through on-screen buttons, high-precision arithmetic via bc -l, and a built-in calculation history panel.

Screenshot

Calculator screenshot

Features

  • GTK+ 3 desktop UI with a compact keypad layout
  • Expression evaluation through bc -l for floating-point math
  • Calculation history view with separate history clear (CH)
  • Input controls: clear (C), backspace (), parentheses, decimal support
  • Error handling for invalid expressions (shows Error in display and history)

Tech Stack

  • Language: C
  • UI Toolkit: GTK+ 3
  • Evaluator: bc
  • Build System: GNU Make + pkg-config

Requirements

Install the following before building:

  • gcc
  • make
  • pkg-config
  • GTK+ 3 development packages (gtk+-3.0)
  • bc

Example (Debian/Ubuntu):

sudo apt update
sudo apt install -y build-essential pkg-config libgtk-3-dev bc

Build and Run

From the project root:

make
./calculator

Available Make Targets

make           # build
make clean     # remove object files and binary
make install   # install binary to /usr/local/bin (sudo required)
make uninstall # remove binary from /usr/local/bin (sudo required)

Controls

  • Digits: 0-9
  • Operators: +, -, *, /
  • Grouping: (, )
  • Decimal point: .
  • =: evaluate current expression
  • C: clear current input
  • : delete last character (UTF-8 safe)
  • CH: clear history panel

Project Structure

calculator/
├── main.c      # GTK UI, button actions, expression evaluation, history handling
├── Makefile    # build/install/uninstall targets
├── preview.png # application screenshot
└── .gitignore

Notes

  • Expression results come from bc -l, so behavior follows bc arithmetic rules.
  • The entry widget is intentionally read-only; inputs are driven by button clicks.

About

Simple Calculator GUI App in C and GTK.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors