Closed refaelsh closed 1 year ago
I need more help please. The commit I've made should have compiled, but it does not, and I need help understanding the error. I've addapted the code from here: https://stackoverflow.com/questions/16386738/how-can-i-convert-from-a-netpbm-image-to-a-gtk-pixbuf-in-haskell.
In the meantime, I've asked this question on stackoverflow: https://stackoverflow.com/questions/76586787/how-to-create-a-pixbuf-from-bytestring-in-gtks-haskell-bindings.
@cdepillabout Please hold. There was a comment to the Stack Overflow question, and I think it might be the answer.
@cdepillabout The stackoverflow comment got me on the right track. I've made another commit, this time it compiles and runs. Don't look at the code, yet, it's very dirty now. I need more help please: I am using XMonad and I don't have all the visual window decorations like Gnome and/or KDE. I don't see where the icon should be. How can I test my new code works? How do you test it?
I've made another commit
Strange. I did a 'git push', but I don't see the commit here in this web interface of this PR. I don't know what to do.
I've made another commit
Strange. I did a 'git push', but I don't see the commit here in this web interface of this PR. I don't know what to do.
Also, please tell me what code formatter do you use? Is it Ormoulu or Fourmolu? I need to configure the same as you.
@refaelsh Thanks for continuing to work on this!
Let me answer some of your questions
I am using XMonad and I don't have all the visual window decorations like Gnome and/or KDE. I don't see where the icon should be. How can I test my new code works? How do you test it?
I actually have this same problem. I also use XMonad, and can't see the embedded icon.
Whenever I want to see the icon, I just spin up a VM and run Gnome or something. If you don't want to do this, that's fine, I can check it when I review the PR.
Strange. I did a 'git push', but I don't see the commit here in this web interface of this PR. I don't know what to do.
Yeah, that's really strange. I've never seen GitHub mess up like that before.
Maybe you could close this PR (or even just leave it open), create a new branch, and create a new PR? Hopefully then your second commit will show up.
I added your repo as a remote to my local termonad checkout with a command like git remote add refaelsh git@github.com:refaelsh/termonad.git
, and I am able to see your second commit. So you did push it correctly. I don't know what could be going on here.
please tell me what code formatter do you use? Is it Ormoulu or Fourmolu?
I don't actually use a code formatter. My personal style is somewhat similar to hindent
, although not exactly. I don't worry too much about code style for PRs (although sometimes I go in and fix stuff up when I'm playing around with the code).
We use fourmolu at work, so I'm fine with that too if you already have it setup.
Although I would ask that you try to make sure your PR doesn't change the formatting on lines that you're not editing! It is easiest to review when the diffs are minimal.
Although I would ask that you try to make sure your PR doesn't change the formatting on lines that you're not editing! It is easiest to review when the diffs are minimal.
Yes, off course. When I am done, I will make sure that no formatting noise is in the commits.
create a new branch, and create a new PR
I've opened a new PR: https://github.com/cdepillabout/termonad/pull/228. Leaving this one open as requested.
I am using XMonad and I don't have all the visual window decorations like Gnome and/or KDE. I don't see where the icon should be. How can I test my new code works? How do you test it?
Hmm, since I use Gnome, I was planning to test #228, but I am now realizing that even on master
, I don't see the custom icon:
On the left is the Gnome terminal, and it has a black icon which looks like a terminal. On the right is Termonad, whose icon is the default blue gears icon, not the fancy termonad-lambda.png
icon. I am not on NixOS and I do not see the termonad-lambda.png: No such file or directory
message on startup. I am starting termonad with stack exec termonad
. Should I open a new ticket or piggy-back on #165?
Should I open a new ticket or piggy-back on https://github.com/cdepillabout/termonad/issues/165?
I'm fine with either, although hopefully we can fix whatever the underlying problem is in https://github.com/cdepillabout/termonad/pull/228.
If you do stack build && stack exec termonad
, I wonder if the getDataFileName "img/termonad-lambda.png"
call is actually able to find the correct data file. I would assume that if you do something like stack install
, Stack will take care of setting up the data directory in a way so that the exe can find the data file, but if you just do stack build && stack exec
, I wonder if the data file can be found.
I would assume it works, since you're not getting the termonad-lambda.png: No such file or directory
message, but I was just wondering.
Also, I'm not super familiar with the Gnome/GTK ecosystem, but I know it has been going through some changes lately leading up to the release of GTK4 (while Termonad is currently on GTK3). I wonder if the recommended method of setting app icons has changed.
stack build && stack exec termonad
Thanks for reminding me to actually build the executable before running it! It's been a while since I've used stack, I forgot that there was a difference between run
and exec
. Unfortunately, the problem still occurs when I remember to build the executable.
I wonder if the
getDataFileName "img/termonad-lambda.png"
call is actually able to find the correct data file.
I tried to use a file which doesn't exist, getDataFileName "img/termonad-lambda2.png"
, and the error message revealed what stack is doing under the hood: termonad-linux-x86_64: Failed to open file “/.../.stack-work/.../termonad-4.3.0.0/img/termonad-lambda2.png”: No such file or directory
. I conclude that stack takes the files listed in termonad.cabal
's data-files
field, copies them somewhere inside the build folder, and then hardcodes that path inside the executable so that getDataFileName
can add the right prefix.
I would assume that if you do something like
stack install
, Stack will take care of setting up the data directory in a way so that the exe can find the data file
Nah, the same trick allows me to confirm that the installed executable still looks at this same path inside the build folder. Which makes sense, since stack install
simply copies the executable from the build folder to the ~/.local/bin
folder (unlike cabal install
, which does something much more complicated).
$ stack install && ~/.local/bin/termonad
Configuration '~/.config/termonad/termonad.hs' changed. Recompiling.
Error occurred while loading configuration file.
[...]
Could not find module ‘Termonad’
[...]
termonad: Failed to open file “/.../.stack-work/.../termonad-4.3.0.0/img/termonad-lambda2.png”: No such file or directory
Btw, when I use stack install
, termonad fails to recompile my configuration file because it can't find the Termonad
module. This is because stack exec
sets the GHC_PACKAGE_PATH
environment variable to point to the package-db where the termonad library is installed, whereas when running the installed executable, that variable is typically unset, so ghc only sees the global package-db (which only contains wired-in packages such as base
and transformers
) and the user package-db (which is typically empty now that stack and cabal both avoid installing libraries there).
In any case: if I use getDataFileName "img/termonad-lambda.png"
with the stack install
workflow, I still see the blue gears icon.
Also, I'm not super familiar with the Gnome/GTK ecosystem, but I know it has been going through some changes lately leading up to the release of GTK4 (while Termonad is currently on GTK3). I wonder if the recommended method of setting app icons has changed.
My investigation is inconclusive, but I still want to share my findings so far.
The GTK4 no longer supports Window::set_default_icon_from_file()
, only Window::set_default_icon_name()
. My understanding is that applications are now expected to point GTK4 to a folder containing a family of icons, e.g. a light mode icon and a dark mode icon in a variety of sizes, but I have not been able to find documentation on which convention the files in that folder are supposed to follow.
For this reason, I have tried to use a name such as printer
which is listed by IconTheme::get_icon_names()
and thus should already have a standard icon provided by Gnome. Unfortunately, neither calling Window::set_default_icon_name("printer")
nor Window::set_icon_name("printer")
changed the icon away from the blue gears.
In order to make sure I am using GTK4, I did not write my test program using Haskell's GTK bindings, I wrote a C++ program based on the Hello World example provided by the GTK4 documentation. I added the two set_icon calls to the default constructor of their HelloWorld
window class.
Since this didn't work, the next step in my investigation would be to look at the code of an existing Gnome application, such as Gnome Terminal. But I doubt I'll manage to find more time to look into this soon, so I hope someone else can pick up where I left!
More inconclusive results: I built Gnome Terminal from source, but when I ran it, it used the default blue gears icon.
This PR is for starting (or continuing) discussion on #165. Please, do not look at the code yet. I've made an initial dirty commit to start discussion.