[meld] bin/meld: Add support for a dark theme, following the GtkSetting
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] bin/meld: Add support for a dark theme, following the GtkSetting
- Date: Thu, 2 Oct 2014 20:37:59 +0000 (UTC)
commit f84e165dcebd2239d4c5ed0ca1847ac02b884e2d
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Aug 10 09:06:19 2014 +1000
bin/meld: Add support for a dark theme, following the GtkSetting
This commit just loads the dark CSS if it's present; there still isn't
any there. Since we're doing this, we also handle CSS files not being
found and complain appropriately.
bin/meld | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 257e38c..4fe5c56 100755
--- a/bin/meld
+++ b/bin/meld
@@ -174,15 +174,23 @@ def check_requirements():
def setup_resources():
from gi.repository import GObject
+ from gi.repository import GLib
from gi.repository import Gtk
from gi.repository import Gdk
GObject.threads_init()
icon_dir = os.path.join(meld.conf.DATADIR, "icons")
Gtk.IconTheme.get_default().append_search_path(icon_dir)
- css_file = os.path.join(meld.conf.DATADIR, "meld.css")
+
+ gtk_settings = Gtk.Settings.get_default()
+ dark_theme = gtk_settings.get_property('gtk-application-prefer-dark-theme')
+ css_name = "meld-dark" if dark_theme else "meld"
+ css_file = os.path.join(meld.conf.DATADIR, css_name + ".css")
provider = Gtk.CssProvider()
- provider.load_from_path(css_file)
+ try:
+ provider.load_from_path(css_file)
+ except GLib.GError as err:
+ print(_("Couldn't load Meld-specific CSS (%s)\n%s") % (css_file, err))
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]