yomonad/Main.hs
2025-01-31 04:31:04 +00:00

52 lines
1.6 KiB
Haskell

-- Copyright © 2025 Hashirama Senju
{-# LANGUAGE OverloadedStrings, OverloadedLabels, OverloadedLists, ImplicitParams #-}
module Main where
import Control.Monad (void)
import System.Environment (getArgs, getProgName)
import qualified GI.Gtk as Gtk
import GI.Gtk.Objects.Image (imageNewFromFile)
import Data.GI.Base
-- This function runs when the application is activated
activate :: Gtk.Application -> IO ()
activate app = do
-- todo: change to this:
-- https://git.ajattix.org/hashirama/xcdat-Cwrapper/src/commit/dd731c93e1612e4001b0b3d6dd1465ea06189ab8/haskell.hs#L80
image <- imageNewFromFile "/home/hashirama/image_test.jpg"
-- Set image to expand and fill available space
#setHalign image Gtk.AlignFill
#setValign image Gtk.AlignFill
#setHexpand image True
#setVexpand image True
-- Create a new application window and set the image as the child
window <- Gtk.new Gtk.ApplicationWindow
[ #application := app
, #title := "Yomonad"
, #child := image -- Set the image as the child of the window
, #resizable := True -- Ensure the window is resizable
]
-- Show the window
#show window
main :: IO ()
main = do
-- Create a new GTK application
app <- Gtk.new Gtk.Application [#applicationId := "wazajisho-test"]
-- Connect the activate signal to the activate function
-- The signal handler doesn't need arguments here
_ <- Gtk.on app #activate (activate app)
-- Get command line arguments and program name
args <- getArgs
progName <- getProgName
-- Run the application with arguments
void $ #run app (Just $ progName : args)