Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark theme not working #1746

Open
R4ygen opened this issue Feb 18, 2020 · 23 comments
Open

Dark theme not working #1746

R4ygen opened this issue Feb 18, 2020 · 23 comments

Comments

@R4ygen
Copy link

R4ygen commented Feb 18, 2020

Hello, i just installed the latest release of Xournal++ (1.0.17) on my Windows 10 Pro machine, as an alternative to OneNote.
So far so good apart for one thing: I can't make the dark theme working.

If i check the option under Preferences -> View -> Dark theme and reboot Xournalpp, nothing changes.
Immagine

So far i've been able to change the page color and the background, but i would like to change the toolbar, menu and window colors too.

I've found some config files in the directory \Program Files\Xournal++\ui but i couldn't figure out if there's some values i can manually change there to edit the theme colors.
I've already tried to reinstall the program (always through the release automated installer) and check for steps i could have skip in the installation instructions and FAQs, but nothing.

Thanks in advance

@R4ygen R4ygen added the bug label Feb 18, 2020
@Technius
Copy link
Member

Themes are controlled by GTK, so if you can somehow set the environment variable GTK_THEME=Adwaita:dark before launching Xournal++, it should show up dark. Unfortunately, this isn't something we can do within Xournal++ itself, but we might be able to change the Windows launcher application (xournalpp_launcher.exe) to make it easier.

Apparently the "Dark Theme" setting only changes the icons:

if (control->getSettings()->isDarkTheme()) {
string icon = gladePath->getFirstSearchPath() + "/iconsDark/";
gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), icon.c_str());
}

@R4ygen
Copy link
Author

R4ygen commented Feb 18, 2020

Oh i just got confused by the option name then, i though it as a whole dark theme.
Not a bug at least.

Well since it's a missing feature this could become a low priority enhancement request, yeah.
Sadly if it's more complex than editing a config file is still above my technical level. But i'll try to google a little about it.

@Technius
Copy link
Member

Oh i just got confused by the option name then, i though it as a whole dark theme.
Not a bug at least.

I would say it's a bug since it's misleading; it should really be renamed as "Use dark mode icons."

@Technius Technius added enhancement priority::low os::windows Operating System Microsoft Windows and removed os::windows Operating System Microsoft Windows labels Feb 19, 2020
@badshah400
Copy link
Contributor

This setting seems to be not working at all — even for toolbar icons — on my Linux installation. I have turned this setting on, and launched xournalpp (at commit 46a4dc8) with

GTK_THEME=Adwaita:dark xournalpp

Nonetheless, I see the same toolbar icons being used (i.e. not the icons from iconsDark). See, e.g., the icon for the Text tool or the brush sizes both of which should be white in colour if used from iconsDark.

image

@badshah400
Copy link
Contributor

It appears that the iconsDark dir was not the first in the list of dirs to search for icons even when the dark theme is set. Fixed by the following patch (I can make a PR if this looks ok):

From e3f54079c01f23f39de3817b912a34fa1c0cea36 Mon Sep 17 00:00:00 2001
From: Atri Bhattacharya <badshah400@gmail.com>
Date: Wed, 11 Mar 2020 13:00:31 +0100
Subject: [PATCH] Prepend iconsDark path after setting default path.

When the "dark theme" option is set, the iconsDark directory should be
the first dir where the icon theme should search for the icon. By
prepending this path after the default icons path has been set, we make
sure that this dir is the first in the list of dirs to look-up icons.

Fixes issue #1746.
---
 src/control/XournalMain.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/control/XournalMain.cpp b/src/control/XournalMain.cpp
index b996b5c0..9609db72 100644
--- a/src/control/XournalMain.cpp
+++ b/src/control/XournalMain.cpp
@@ -319,13 +319,14 @@ auto XournalMain::run(int argc, char* argv[]) -> int {
 
     auto* control = new Control(gladePath);
 
+    string icon = gladePath->getFirstSearchPath() + "/icons/";
+    gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), icon.c_str());
+
     if (control->getSettings()->isDarkTheme()) {
         string icon = gladePath->getFirstSearchPath() + "/iconsDark/";
         gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), icon.c_str());
-    }
 
-    string icon = gladePath->getFirstSearchPath() + "/icons/";
-    gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), icon.c_str());
+    }
 
     auto* win = new MainWindow(gladePath, control);
     control->initWindow(win);
-- 
2.25.1

@R4ygen R4ygen changed the title Dark theme not working on Windows Dark theme not working Mar 11, 2020
@Technius
Copy link
Member

Fixed by the following patch (I can make a PR if this looks ok):

Looks good to me, please do so!

@badshah400
Copy link
Contributor

I have a patch which actually makes the app use the dark theme variant of the GTK theme, if the theme has one. The patch itself is rather straightforward (see below). I use it for my daily activities and prefer this mode over the default one. Do you — the app developers — think this might be useful? I can send a PR if so.

diff --git a/src/control/XournalMain.cpp b/src/control/XournalMain.cpp
index fd746257..0121261c 100644
--- a/src/control/XournalMain.cpp
+++ b/src/control/XournalMain.cpp
@@ -323,6 +323,8 @@ auto XournalMain::run(int argc, char* argv[]) -> int {
     gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), icon.c_str());
 
     if (control->getSettings()->isDarkTheme()) {
+        g_object_set(gtk_settings_get_default(),
+                     "gtk-application-prefer-dark-theme", TRUE, NULL);
         string icon = gladePath->getFirstSearchPath() + "/iconsDark/";
         gtk_icon_theme_prepend_search_path(gtk_icon_theme_get_default(), icon.c_str());
     }
-- 
2.25.1

Screenshot from 2020-03-25 21-29-08

@Technius
Copy link
Member

@badshah400 That would be useful for Windows users, but I think we should make that a separate option (e.g. Force Dark Theme). Also, what do you think about #1735?

@Technius
Copy link
Member

@R4ygen I figured out a way to enable dark theme on Windows. Find where Xournal++ is installed or located (the folder containing bin); there should be the following folders:

bin
lib
share
ui

Create two nested folders, etc\gtk-3.0. Inside of the gtk-3.0 folder, create a file called settings.ini with the following contents:

[Settings]
gtk-application-prefer-dark-theme=1

If you did everything correctly, you should now see the program in dark theme.

@ericschdt
Copy link

ericschdt commented Apr 14, 2020

This setting seems to be not working at all — even for toolbar icons — on my Linux installation. I have turned this setting on, and launched xournalpp (at commit 46a4dc8) with

GTK_THEME=Adwaita:dark xournalpp

Nonetheless, I see the same toolbar icons being used (i.e. not the icons from iconsDark). See, e.g., the icon for the Text tool or the brush sizes both of which should be white in colour if used from iconsDark.

image

I have the same issue on Manjaro KDE with a Breeze Dark and the Adwaita Dark theme for GTK. I hope this can be fixed soon, as trying to identify the hardly visible icons makes me become a headache. ;)

It doesn't seem that I can explicitly use a light theme only for Xournal as a workaround until the issue is fixed. :-(

@badshah400
Copy link
Contributor

@ericschdt This was fixed by commit 7e1b862. If you are installing from a package in Manjaro, you will need to patch the sources with this commit and rebuild the package.

@R4ygen
Copy link
Author

R4ygen commented Apr 14, 2020

@R4ygen I figured out a way to enable dark theme on Windows. Find where Xournal++ is installed or located (the folder containing bin); there should be the following folders:

bin
lib
share
ui

Create two nested folders, etc\gtk-3.0. Inside of the gtk-3.0 folder, create a file called settings.ini with the following contents:

[Settings]
gtk-application-prefer-dark-theme=1

If you did everything correctly, you should now see the program in dark theme.

That worked out perfectly!
I'll try to rebuild it myself to also include the commit 7e1b862 then, so i can try it out with dark icons too

@benwinding
Copy link

For anyone on Ubuntu, you might need to remove the apt package, and use the snap package instead.

sudo apt remove xournal
sudo snap install xournalpp

@samuele555
Copy link

So the dark theme for now does not provide page color and primary pen (black) to switch color automatically like in onenote?

@Technius
Copy link
Member

No, the dark theme only affects the color of the application buttons/background.

@samuele555
Copy link

No, the dark theme only affects the color of the application buttons/background.

Is there any planning to implement such feature described above?

@Technius
Copy link
Member

No, the dark theme only affects the color of the application buttons/background.

Is there any planning to implement such feature described above?

This has been requested before (#1781) but no one has tried implementing it.

@thillRobot
Copy link

One solution is to set the page color manually. I used #31343A so looks like a chalkboard.

@rafisics
Copy link

rafisics commented Feb 10, 2021

I am using Xournalpp (version 1.0.20) both in Windows and Ubuntu. In Ubuntu 20.04 LTS, the dark theme is working okay. But in Windows 10, it's still not functioning properly. It seems the dark theme is occurring only on the tools icons, but not on the background window color. What is the most effective solution to switch to the dark theme in Windows 10?
I wish its dark theme functioned as the theme switching features of OneNote for Windows 10.

@daholzfeind
Copy link
Contributor

daholzfeind commented Apr 13, 2021

I use Xournal (nightly) and the dark theme isn't working. Neither the Repo nor the Flatpak. This is really sad, because you can hardly spot the dark icons on dark background. Is there any way to fix this?
Bildschirmfoto vom 2021-04-13 19-26-40

And yes, using Dark Theme is enabled in the setting menu for both, Flatpak and nightly.

Edit: Fixed by installing a dark theme icon set, see also: #3034 (comment). I left this here, if someone have the same issue.

@arixank
Copy link

arixank commented May 23, 2021

Dark Mode has no effect on my Ubuntu system..!

Any help..?

image

I have tried changing this value, but in vain..!

image

@trydercal
Copy link

I use Xournal (nightly) and the dark theme isn't working. Neither the Repo nor the Flatpak. This is really sad, because you can hardly spot the dark icons on dark background. Is there any way to fix this?
Bildschirmfoto vom 2021-04-13 19-26-40

And yes, using Dark Theme is enabled in the setting menu for both, Flatpak and nightly.

Edit: Fixed by installing a dark theme icon set, see also: #3034 (comment). I left this here, if someone have the same issue.

How do you install this dark theme icon set?

@daholzfeind
Copy link
Contributor

daholzfeind commented Jun 23, 2021

How do you install this dark theme icon set?

@trydercal As far as I remember, for the native App you have to enable dark variants of your system icons, i.e. Mint-Y-Darker.
If u use the Flatpak version you have to check if the chosen Icon Set, i.e. Mint-Y-Darker or whatever, is installed. It must be identical to the Icon set you use on your system, otherwise it won't work.
See here for installing additional GTK or Qt Themes in Flatpak: https://docs.flatpak.org/en/latest/desktop-integration.html#instructions-for-gtk

Maybe there is a hint in the Xournal++ Documentary, if not we may add this to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests