diff --git a/FyneApp.toml b/FyneApp.toml new file mode 100644 index 0000000..49a204a --- /dev/null +++ b/FyneApp.toml @@ -0,0 +1,8 @@ +Website = "https://www.kirsle.net/errorgen" + +[Details] + Icon = "icons/radiation.png" + Name = "ErrorGen" + ID = "net.kirsle.ErrorGen" + Version = "2.0.0" + Build = 17 diff --git a/Makefile b/Makefile index befd841..21a8c88 100644 --- a/Makefile +++ b/Makefile @@ -54,4 +54,30 @@ run: # `make clean` to cleanup the repo. .PHONY: clean clean: - rm errorgen \ No newline at end of file + rm -rf errorgen fyne-cross + +# `make release` uses fyne-cross to produce builds for Linux and Windows. +.PHONY: release +release: clean + fyne-cross windows -arch=* + fyne-cross linux -arch=* + +# `make release-sudo` uses sudo commands for release in case of permission errors. +.PHONY: release-sudo +release-sudo: clean + sudo $(shell which fyne-cross) windows -arch=\* + sudo $(shell which fyne-cross) linux -arch=\* + sudo chown -R $(shell whoami) fyne-cross + +# `make package` creates nice ZIP files for release after `make release` +.PHONY: package +package: + cp -r README.md README.html *.png icons fyne-cross/bin/windows-386/ + cp -r README.md README.html *.png icons fyne-cross/bin/windows-amd64/ + cp -r README.md README.html *.png icons fyne-cross/bin/linux-386/ + cp -r README.md README.html *.png icons fyne-cross/bin/linux-amd64/ + +# `make pandoc` converts README.md into HTML for distribution. +.PHONY: pandoc +pandoc: + pandoc -o README.html README.md \ No newline at end of file diff --git a/README.html b/README.html new file mode 100644 index 0000000..a31def6 --- /dev/null +++ b/README.html @@ -0,0 +1,559 @@ +

Error Message Generator 2.0

+

This is a modern remake of my “Error Message Generator” that was originally written using Perl/Tk around 2006. This one is written in Go in 2023 using the Fyne UI and aims to match and surpass the features of the original Perl version.

+
+Screenshot +
+

The original inspiration for this back in 2006 was an online web tool called “Atom Smasher’s Error Message Generator” which generated images of error messages. My Perl ErrorGen program included all of the Atom Smasher icons. Atom Smasher’s page seems offline recently, so interest has skyrocketed for my Perl ErrorGen program, so I decided to dust it off, redo it in Go and make it better than ever before.

+

Features

+

This program has two operating modes:

+ +

The current features include:

+ +

The roadmap of future features include:

+ +

Command Line Interface

+

You can call this program from batch files or shell scripts to prompt the user with a graphical dialog box and read the button they chose from this program’s standard output.

+

For example, from a bash script:

+
#!/bin/bash
+answer=`./errorgen --alert --title "Disk Failure" \
+    --text "Failure to read from drive Z:/" \
+    --icon defrag --button Abort --button Retry --button Fail \
+    --default 1 --cancel Fail`
+echo "You have chosen: $answer"
+
+Screenshot from the above command +
+

The full documentation is included below. Running errorgen --help from a text terminal will have the program print its documentation to you, but this won’t work on the Windows version since a program must decide if it’s a graphical or a command line app and can’t be both.

+

Built-in Icons

+

These are all the icons that currently come with ErrorGen:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ImageName
aim_guyaim_guy
aol_iconaol_icon
attentionattention
bombbomb
bomb_dynamitebomb_dynamite
bomb_grenadebomb_grenade
bubble_ibubble_i
bubble_qbubble_q
bulbbulb
butterflybutterfly
cakecake
circularsawcircularsaw
control_panelcontrol_panel
cowcow
defragdefrag
disk_bludisk_blu
disk_blu_lbldisk_blu_lbl
disk_orgdisk_org
disk_reddisk_red
disk_red_lbldisk_red_lbl
disk_skulldisk_skull
disk_yeldisk_yel
dosdos
e_orbite_orbit
errorerror
error2error2
error3error3
error4error4
file_cabinetfile_cabinet
findfind
fortunecookiefortunecookie
garbage_emptygarbage_empty
garbage_fullgarbage_full
gungun
hammerhammer
heartheart
helphelp
hubhub
hwinfohwinfo
ic_aic_a
keyskeys
keys2keys2
keys3keys3
labteclabtec
macmac
mailmail
mail_deletedmail_deleted
mailboxmailbox
mouthmouth
mycomputermycomputer
mycomputer2mycomputer2
mycomputer3mycomputer3
newspapernewspaper
peripheralperipheral
plant_leafplant_leaf
radiationradiation
ramram
recyclerecycle
recycle2recycle2
scannerscanner
screwscrew
screw2screw2
setupsetup
sknifesknife
skullskull
skull2skull2
skull3skull3
tuxtux
tux_configtux_config
upsups
zipdiskzipdisk
zipdiskszipdisks
+

Command Line Usage

+

The result of errorgen --help:

+
NAME:
+   errorgen - make fun and custom error messages.
+
+USAGE:
+   errorgen [global options] command [command options] [arguments...]
+
+AUTHOR:
+   Noah Petherbridge, https://www.kirsle.net
+
+COMMANDS:
+   help, h  Shows a list of commands or help for one command
+
+GLOBAL OPTIONS:
+   --version, -v  Show program version and build information and exit. (default: false)
+   --error, -e    Make the dialog box be of type 'error' by default.
+
+      An info box has these default attributes unless overridden by
+      other options:
+
+      Title: Error
+      Text: An error has occurred.
+      Icon: error
+      Buttons: Ok (default: false)
+   --alert, -a  Make the dialog box be of type 'alert' by default.
+
+      An alert box has these default attributes unless overridden by
+    other options:
+
+      Title: Warning
+      Text: Are you sure you want to proceed?
+      Icon: attention
+      Buttons: Ok (default: false)
+   --info, -i  Make the dialog box be of type 'info' by default.
+
+      An info box has these default attributes unless overridden by
+    other options:
+
+      Title: Information
+      Text: All updates are complete.
+      Icon: info
+      Buttons: Ok (default: false)
+   --question, -q  Make the dialog box be of type 'question' by default.
+
+      A question box has these default attributes unless overridden by
+    other options:
+
+      Title: Question
+      Text: Are you sure you want to proceed?
+      Icon: question
+      Buttons: Ok, Cancel (default: false)
+   --title value, -n value  Set the title for the dialog box.
+
+      If no title is set, a default is used based on the type of dialog
+      box requested (which is --info by default; see also --error,
+      --info, --question)
+   --text value, -t value  The text displayed inside the dialog box.
+
+      Use \n where you want line breaks.
+
+      Important: the text does NOT have automatic word wrapping applied.
+      Insert your own line breaks or else the dialog can be VERY wide for
+      longer messages!
+   --button value, -b value  Add a button to the dialog.
+
+      Use this option as many times as you want to add multiple buttons.
+      The one the user chooses will be printed to standard output. If no
+      buttons, default is an Ok button.  (accepts multiple inputs)
+   --default value, -m value             Set the default button by its label.
+
+      The matching --button will be made the default/primary button.
+   --cancel value, -c value  Set the 'cancel button'.
+
+      This value should match one of your --buttons and will be the
+      value 'selected' if the user closes the window or hits the
+      Escape key.
+   --disabled value, -d value, -g value  Mark buttons (by index) disabled
+
+      Specify a --button number (from 0 to n) that should be disabled,
+      or greyed out. The user can not click on this button.  (accepts multiple inputs)
+   --icon value, -o value                                    Set the icon to be displayed in the dialog box.
+
+      Use either a built-in icon by name (e.g. "aim_guy") or name your
+      own custom PNG image from disk.
+
+      Built-in icon names include the following:
+
+          aim_guy
+          aol_icon
+          attention
+          bomb
+          bomb_dynamite
+          bomb_grenade
+          bubble_i
+          bubble_q
+          bulb
+          butterfly
+          cake
+          circularsaw
+          control_panel
+          cow
+          defrag
+          disk_blu
+          disk_blu_lbl
+          disk_org
+          disk_red
+          disk_red_lbl
+          disk_skull
+          disk_yel
+          dos
+          e_orbit
+          error
+          error2
+          error3
+          error4
+          file_cabinet
+          find
+          fortunecookie
+          garbage_empty
+          garbage_full
+          gun
+          hammer
+          heart
+          help
+          hub
+          hwinfo
+          ic_a
+          keys
+          keys2
+          keys3
+          labtec
+          mac
+          mail
+          mail_deleted
+          mailbox
+          mouth
+          mycomputer
+          mycomputer2
+          mycomputer3
+          newspaper
+          peripheral
+          plant_leaf
+          radiation
+          ram
+          recycle
+          recycle2
+          scanner
+          screw
+          screw2
+          setup
+          sknife
+          skull
+          skull2
+          skull3
+          tux
+          tux_config
+          ups
+          zipdisk
+          zipdisks
+   --help, -h  show help (default: false)
+

Building

+

Requirements:

+ +

Fedora: sudo dnf install golang gcc libXcursor-devel libXrandr-devel mesa-libGL-devel libXi-devel libXinerama-devel libXxf86vm-devel

+

Ubuntu/Debian: sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev

+

There is a GNU Makefile to make build commands easier to remember.

+ +

Cross compiling: install Docker and fyne-cross and run make release to produce the build. To install fyne-cross:

+
go install github.com/fyne-io/fyne-cross
+

In case of permission errors (Docker often needs run as root) you can try sudo running fyne-cross directly, e.g. to produce Windows amd64 and i386 builds a command like:

+
# which fyne-cross to use your locally installed Go binary for the current user,
+# so that root doesn't need to also install fyne-cross and have a $PATH set up.
+sudo $(which fyne-cross) windows -arch=\*
+

License & Author

+

Icons from the Atom Smasher Error Message Generator.

+

Developed by Noah Petherbridge, https://www.kirsle.net/

+

See my web page about this at https://www.kirsle.net/errorgen

+
Error Message Generator
+Copyright (C) 2023  Noah Petherbridge
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation, either version 3 of the License, or (at your
+option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/README.md b/README.md index 1094c78..de610ac 100644 --- a/README.md +++ b/README.md @@ -305,13 +305,50 @@ GLOBAL OPTIONS: --help, -h show help (default: false) ``` +# Building + +Requirements: + +* Go: https://golang.org +* Fyne dependencies: https://developer.fyne.io/started/ + +Fedora: `sudo dnf install golang gcc libXcursor-devel libXrandr-devel mesa-libGL-devel libXi-devel libXinerama-devel libXxf86vm-devel` + +Ubuntu/Debian: `sudo apt-get install golang gcc libgl1-mesa-dev xorg-dev` + +There is a GNU Makefile to make build commands easier to remember. + +* `make setup` installs Go dependencies for this project. +* `make` or `make build` will produce the ./errorgen binary. +* `make run` runs the Go app locally for development and testing.] +* `make clean` removes the built binary. + +Cross compiling: install Docker and fyne-cross and run `make release` to produce the build. To install fyne-cross: + +```bash +go install github.com/fyne-io/fyne-cross +``` + +In case of permission errors (Docker often needs run as root) you can try sudo running fyne-cross directly, e.g. +to produce Windows amd64 and i386 builds a command like: + +```bash +# which fyne-cross to use your locally installed Go binary for the current user, +# so that root doesn't need to also install fyne-cross and have a $PATH set up. +sudo $(which fyne-cross) windows -arch=\* +sudo $(which fyne-cross) linux -arch=\* + +# Fix ownership permissions on the output folder +sudo chown -R user:user fyne-cross +``` + # License & Author Icons from the Atom Smasher Error Message Generator. -Developed by Noah Petherbridge, https://www.kirsle.net/ +Developed by Noah Petherbridge, -See my web page about this at https://www.kirsle.net/errorgen +See my web page about this at Error Message Generator Copyright (C) 2023 Noah Petherbridge diff --git a/dialog.go b/dialog.go index 9bfc5d3..e90c0e8 100644 --- a/dialog.go +++ b/dialog.go @@ -90,6 +90,7 @@ func (d Dialog) Show(app fyne.App) { } w.SetIcon(d.Icon) + w.CenterOnScreen() // Icon + Message row. icon := canvas.NewImageFromResource(d.Icon) diff --git a/go.mod b/go.mod index 601eddd..5203a76 100644 --- a/go.mod +++ b/go.mod @@ -10,11 +10,14 @@ require ( require ( fyne.io/systray v1.10.1-0.20221115204952-d16a6177e6f1 // indirect + github.com/BurntSushi/toml v1.1.0 // indirect + github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9 // indirect github.com/benoitkugler/textlayout v0.3.0 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fredbi/uri v0.1.0 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/fyne-io/fyne-cross v1.3.0 // indirect github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe // indirect github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect diff --git a/go.sum b/go.sum index 09903b1..3784d98 100644 --- a/go.sum +++ b/go.sum @@ -42,8 +42,12 @@ fyne.io/fyne/v2 v2.3.0/go.mod h1:odfJmbFnODiKn1MXdL44JR6CK+0v8lrmgdPlrUF6w0M= fyne.io/systray v1.10.1-0.20221115204952-d16a6177e6f1 h1:OiHw+bZAGEaSreHsA8dDkBOVJmSFzsNTOc/htpM+fOc= fyne.io/systray v1.10.1-0.20221115204952-d16a6177e6f1/go.mod h1:oM2AQqGJ1AMo4nNqZFYU8xYygSBZkW2hmdJ7n4yjedE= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I= github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9 h1:1ltqoej5GtaWF8jaiA49HwsZD459jqm9YFz9ZtMFpQA= +github.com/Kodeworks/golang-image-ico v0.0.0-20141118225523-73f0f4cfade9/go.mod h1:7uhhqiBaR4CpN0k9rMjOtjpcfGd6DG2m04zQxKnWQ0I= github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= @@ -86,6 +90,8 @@ github.com/fredbi/uri v0.1.0/go.mod h1:1xC40RnIOGCaQzswaOvrzvG/3M3F0hyDVb3aO/1iG github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fyne-io/fyne-cross v1.3.0 h1:pU8+B0J1+xYQJ27TNRjXiV9qsGHuHFXTDlqp0zfEyWo= +github.com/fyne-io/fyne-cross v1.3.0/go.mod h1:Kp7K91rS+2lmoa9g2kYolExO2I3BB/80no1wplc6mIw= github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe h1:A/wiwvQ0CAjPkuJytaD+SsXkPU0asQ+guQEIg1BJGX4= github.com/fyne-io/gl-js v0.0.0-20220119005834-d2da28d9ccfe/go.mod h1:d4clgH0/GrRwWjRzJJQXxT/h1TyuNSfF/X64zb/3Ggg= github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 h1:+31CdF/okdokeFNoy9L/2PccG3JFidQT3ev64/r4pYU= @@ -470,6 +476,7 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= diff --git a/main_window.go b/main_window.go index f9cc3cb..e4da763 100644 --- a/main_window.go +++ b/main_window.go @@ -22,6 +22,7 @@ func RunGUI() { w.SetOnClosed(func() { a.Quit() }) + w.CenterOnScreen() // Create a Dialog template that the UI components will modify. var d = Dialog{