Skip to content

Commit

Permalink
Set panel attributes on a per theme basis #173
Browse files Browse the repository at this point in the history
  • Loading branch information
fossfreedom committed Mar 21, 2018
1 parent 1e797ae commit 2ee4511
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 81 deletions.
94 changes: 14 additions & 80 deletions budgie-welcome
Original file line number Diff line number Diff line change
Expand Up @@ -415,42 +415,19 @@ class AppView(WebKit2.WebView):
code = uri[6:]
panelstyle = os.path.expanduser('~') + "/.config/gtk-3.0/gtk.css"

if code == "undo":
theme = localdir + '/style-backup.json'
else:
theme = app._data_path + "/config/" + code + "-style.json"
theme = app._data_path + "/config/" + code + "-style.json"

def applyStyle():
with open(theme) as file:
config = json.load(file)

# Create backup file if it does not exist
backup = localdir + '/style-backup.json'
if code != "undo" and not os.path.isfile(backup):
data = []
for item in config:
schema = item["SCHEMA"]
values = item["VALUES"]

gsettings = Gio.Settings.new(schema)

coll = {}
vals = {}

for key in values:
vals[key] = gsettings.get_value(key).unpack()

coll["SCHEMA"] = schema
coll["VALUES"] = vals
data.append(coll)

with open(backup, "w") as file:
file.write(json.dumps(data))

if os.path.isfile(panelstyle):
shutil.move(panelstyle, localdir + '/gtk.css')

attrib = None

for item in config:
if "panel-attrib" in item:
attrib = item["panel-attrib"]
continue

schema = item["SCHEMA"]
values = item["VALUES"]

Expand All @@ -462,58 +439,15 @@ class AppView(WebKit2.WebView):
else:
gsettings.set_string(key, value)

if code == "undo":
# Delete backup file
if os.path.isfile(localdir + '/gtk.css'):
shutil.move(localdir + '/gtk.css', panelstyle)

os.remove(theme)

if code == "material":
self._set_panel_key('enable-shadow', False)
self._set_panel_key('size', 37)

if code == "vertex":
self._set_panel_key('enable-shadow', False)
self._set_panel_key('size', 51)

if code == "ceti-2":
self._set_panel_key('enable-shadow', False)
self._set_panel_key('size', 40)

if code == 'material-flat-plat':
self._set_panel_key('size', 47)

if code == 'evopop':
self._set_panel_key('enable-shadow', False)
self._set_panel_key('size', 39)

def removepanelstyle():
# Don't allow theme over writing
try:
os.remove(panelstyle)
except:
pass

if code == "material-vimix":
self._set_panel_key('enable-shadow', False)
self._set_panel_key('size', 37)

removepanelstyle()

if code in ["arc", "pocillo"]:
if attrib:
self._set_panel_key('enable-shadow', attrib['enable-shadow'])
self._set_panel_key('size', attrib['size'])
self._set_panel_key('transparency', attrib['transparency'])
else:
# sane defaults
self._set_panel_key('enable-shadow', True)
self._set_panel_key('size', 39)

removepanelstyle()

if code == "pop":
self._set_panel_key('enable-shadow', False)
self._set_panel_key('size', 37)

if code == "ant":
self._set_panel_key('enable-shadow', True)
self._set_panel_key('size', 39)
self._set_panel_key('transparency', None)

subprocess.Popen(['budgie-panel', '--replace', '&'])

Expand Down
7 changes: 7 additions & 0 deletions data/config/ant-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 39,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
7 changes: 7 additions & 0 deletions data/config/arc-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 39,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
14 changes: 14 additions & 0 deletions data/config/ceti-2-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 39,
"transparency": "none"
}
},
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 40,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
7 changes: 7 additions & 0 deletions data/config/evopop-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": false,
"size" : 39,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
14 changes: 14 additions & 0 deletions data/config/material-materia-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
[
{
"panel-attrib" : {
"enable-shadow": false,
"size" : 47,
"transparency": "none"
}
},
{
"panel-attrib" : {
"enable-shadow": false,
"size" : 37,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
7 changes: 7 additions & 0 deletions data/config/material-materia2-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": false,
"size" : 37,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
7 changes: 7 additions & 0 deletions data/config/material-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": false,
"size" : 37,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
9 changes: 8 additions & 1 deletion data/config/material-vimix-style.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 39,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
"cursor-theme": "Paper",
"gtk-theme": "VimixDark",
"gtk-theme": "Vimix",
"icon-theme": "Paper",
"monospace-font-name": "Noto Mono 11",
"font-name": "Noto Sans UI 11",
Expand Down
7 changes: 7 additions & 0 deletions data/config/pocillo-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 39,
"transparency": "dynamic"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
7 changes: 7 additions & 0 deletions data/config/pop-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 39,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down
7 changes: 7 additions & 0 deletions data/config/vertex-style.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
[
{
"panel-attrib" : {
"enable-shadow": true,
"size" : 51,
"transparency": "none"
}
},
{
"SCHEMA": "org.gnome.desktop.interface",
"VALUES": {
Expand Down

0 comments on commit 2ee4511

Please sign in to comment.