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

Respect $GTK2_RC_FILES when writing themes #12416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,11 @@ def on_overlay_scrollbars_changed(self, settings, key, data=None):

class Gtk2ScrollbarSizeEditor:
def __init__(self, ui_scale):
self._path = os.path.join(GLib.get_home_dir(), ".gtkrc-2.0")
rcpath = GLib.getenv("GTK2_RC_FILES")
if rcpath:
self._path = rcpath.split(":")[0]
else:
self._path = os.path.join(GLib.get_home_dir(), ".gtkrc-2.0")
self._file = Gio.File.new_for_path(self._path)
self._settings = Gio.Settings(schema_id="org.cinnamon.theme")
self.ui_scale = ui_scale
Expand All @@ -425,7 +429,7 @@ def __init__(self, ui_scale):
if e.code == Gio.IOErrorEnum.NOT_FOUND:
pass
else:
print("Could not load ~/.gtkrc-2.0 file: %s" % e.message)
print("Could not load .gtkrc-2.0 file: %s" % e.message)

self.parse_contents()

Expand All @@ -450,6 +454,9 @@ def on_set_size_timeout(self, size):
# print("saving changed: ", final_contents)

try:
# If a path is specified through GTK2_RC_FILES, ensure it exists
if not self._file.get_parent().query_exists():
self._file.get_parent().make_directory_with_parents()
self._file.replace_contents(final_contents.encode("utf-8"),
None,
False,
Expand Down