Changeset View
Changeset View
Standalone View
Standalone View
src/appearancegtk2.cpp
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | 111 | { | |||
---|---|---|---|---|---|
113 | modifyGtkrcProperty("gtk-theme-name", m_settings["theme"], fileContents); | 113 | modifyGtkrcProperty("gtk-theme-name", m_settings["theme"], fileContents); | ||
114 | modifyGtkrcProperty("gtk-icon-theme-name", m_settings["icon"], fileContents); | 114 | modifyGtkrcProperty("gtk-icon-theme-name", m_settings["icon"], fileContents); | ||
115 | modifyGtkrcProperty("gtk-fallback-icon-theme", m_settings["icon_fallback"], fileContents); | 115 | modifyGtkrcProperty("gtk-fallback-icon-theme", m_settings["icon_fallback"], fileContents); | ||
116 | modifyGtkrcProperty("gtk-cursor-theme-name", m_settings["cursor"], fileContents); | 116 | modifyGtkrcProperty("gtk-cursor-theme-name", m_settings["cursor"], fileContents); | ||
117 | modifyGtkrcProperty("gtk-toolbar-style", m_settings["toolbar_style"], fileContents); | 117 | modifyGtkrcProperty("gtk-toolbar-style", m_settings["toolbar_style"], fileContents); | ||
118 | modifyGtkrcProperty("gtk-menu-images", m_settings["show_icons_menus"], fileContents); | 118 | modifyGtkrcProperty("gtk-menu-images", m_settings["show_icons_menus"], fileContents); | ||
119 | modifyGtkrcProperty("gtk-button-images", m_settings["show_icons_buttons"], fileContents); | 119 | modifyGtkrcProperty("gtk-button-images", m_settings["show_icons_buttons"], fileContents); | ||
120 | modifyGtkrcProperty("gtk-primary-button-warps-slider", m_settings["primary_button_warps_slider"], fileContents); | 120 | modifyGtkrcProperty("gtk-primary-button-warps-slider", m_settings["primary_button_warps_slider"], fileContents); | ||
121 | removeGtkrcLegacyContents(fileContents); | ||||
121 | } | 122 | } | ||
122 | 123 | | |||
123 | void AppearanceGTK2::modifyGtkrcProperty(const QString& propertyName, const QString& newValue, QString& fileContents) const | 124 | void AppearanceGTK2::modifyGtkrcProperty(const QString& propertyName, const QString& newValue, QString& fileContents) const | ||
124 | { | 125 | { | ||
125 | const QRegularExpression regExp{propertyName + "=[^\n]*($|\n)"}; | 126 | const QRegularExpression regExp{propertyName + "=[^\n]*($|\n)"}; | ||
126 | 127 | | |||
127 | static const QStringList nonStringProperties{ | 128 | static const QStringList nonStringProperties{ | ||
128 | "gtk-toolbar-style", | 129 | "gtk-toolbar-style", | ||
Show All 11 Lines | |||||
140 | 141 | | |||
141 | if (fileContents.contains(regExp)) { | 142 | if (fileContents.contains(regExp)) { | ||
142 | fileContents.replace(regExp, newConfigString); | 143 | fileContents.replace(regExp, newConfigString); | ||
143 | } else { | 144 | } else { | ||
144 | fileContents = newConfigString + "\n" + fileContents; | 145 | fileContents = newConfigString + "\n" + fileContents; | ||
145 | } | 146 | } | ||
146 | } | 147 | } | ||
147 | 148 | | |||
149 | void AppearanceGTK2::removeGtkrcLegacyContents(QString &fileContents) const | ||||
150 | { | ||||
151 | // Remove "include" lines | ||||
152 | // Example: | ||||
153 | // include "/usr/share/themes/Adwaita-dark/gtk-2.0/gtkrc" | ||||
154 | | ||||
155 | static const QRegularExpression includeRegExp(QStringLiteral("include .*\n")); | ||||
156 | fileContents.remove(includeRegExp); | ||||
157 | | ||||
158 | // Remove redundant font config lines | ||||
159 | // Example: | ||||
160 | // style "user-font" | ||||
161 | // { | ||||
162 | // font_name="Noto Sans Regular" | ||||
163 | // } | ||||
164 | // widget_class "*" style "user-font" | ||||
165 | | ||||
166 | static const QRegularExpression userFontStyleRegexp(QStringLiteral("style(.|\n)*{(.|\n)*}\nwidget_class.*\"user-font\"")); | ||||
167 | fileContents.remove(userFontStyleRegexp); | ||||
168 | } | ||||
169 | | ||||
148 | void AppearanceGTK2::reset() | 170 | void AppearanceGTK2::reset() | ||
149 | { | 171 | { | ||
150 | m_settings = QMap<QString, QString> { | 172 | m_settings = QMap<QString, QString> { | ||
151 | {"toolbar_style", "GTK_TOOLBAR_ICONS"}, | 173 | {"toolbar_style", "GTK_TOOLBAR_ICONS"}, | ||
152 | {"show_icons_buttons", "0"}, | 174 | {"show_icons_buttons", "0"}, | ||
153 | {"show_icons_menus", "0"}, | 175 | {"show_icons_menus", "0"}, | ||
154 | {"primary_button_warps_slider", "false"} | 176 | {"primary_button_warps_slider", "false"} | ||
155 | }; | 177 | }; | ||
▲ Show 20 Lines • Show All 56 Lines • Show Last 20 Lines |