Skip to content

Commit

Permalink
Better kvantum handling
Browse files Browse the repository at this point in the history
Be aware of modified themes
Use modified theme configs using our widget settings
e.g. whether buttons have icons etc.
  • Loading branch information
ALEX11BR committed May 23, 2022
1 parent 08392d5 commit 795cd31
Show file tree
Hide file tree
Showing 6 changed files with 412 additions and 16 deletions.
23 changes: 21 additions & 2 deletions src/applythemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BaseApplyThemes:
"""
The base theme applying mechanism: write themes and settings to config files
"""
def applyThemes(self, props, gtk2Theme, gtk4Theme, kvantumTheme, cssText):
def applyThemes(self, props, gtk2Theme, gtk4Theme, kvantumTheme, kvantumThemeFilePath, cssText):
gtkKeyFile = GLib.KeyFile()

gtkKeyFile.set_string("Settings", "gtk-theme-name", gtk4Theme)
Expand Down Expand Up @@ -58,8 +58,27 @@ def applyThemes(self, props, gtk2Theme, gtk4Theme, kvantumTheme, cssText):
iconKeyFile.save_to_file(os.path.join(GLib.get_home_dir(), ".icons", "default", "index.theme"))

if kvantumTheme:
kvantumThemeKeyFile = GLib.KeyFile()
if kvantumThemeFilePath[:2] != "//":
kvantumThemeKeyFile.load_from_file(kvantumThemeFilePath, GLib.KeyFileFlags.NONE)
else:
kvantumThemeKeyFile.load_from_bytes(
Gio.resources_lookup_data(
"/com/github/alex11br/themechanger/default.kvconfig",
Gio.ResourceLookupFlags.NONE
),
GLib.KeyFileFlags.NONE
)
kvantumThemeKeyFile.set_boolean("Hacks", "iconless_pushbutton", not props.gtk_button_images)
kvantumThemeKeyFile.set_boolean("Hacks", "iconless_menu", not props.gtk_menu_images)
kvantumThemeKeyFile.set_boolean("%General", "transient_scrollbar", props.gtk_overlay_scrolling)

kvantumThemeDir = os.path.join(GLib.get_user_config_dir(), "Kvantum", kvantumTheme+"#")
os.makedirs(kvantumThemeDir, exist_ok=True)
kvantumThemeKeyFile.save_to_file(os.path.join(kvantumThemeDir, kvantumTheme+"#.kvconfig"))

kvantumKeyFile = GLib.KeyFile()
kvantumKeyFile.set_string("General", "theme", kvantumTheme)
kvantumKeyFile.set_string("General", "theme", kvantumTheme+"#")
kvantumKeyFile.save_to_file(os.path.join(GLib.get_user_config_dir(), "Kvantum", "kvantum.kvconfig"))

with open(os.path.join(GLib.get_home_dir(), ".gtkrc-2.0"), "w") as gtk2File:
Expand Down
355 changes: 355 additions & 0 deletions src/default.kvconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,355 @@
[%General]
author=Tsu Jan
comment=A theme inspired by Enlightenment
comment[eo]=Etoso inspirita de Enlightenment
respect_DE=true
x11drag=true
alt_mnemonic=true
left_tabs=false
joined_inactive_tabs=true
attach_active_tab=false
group_toolbar_buttons=false
composite=true
menu_shadow_depth=6
tooltip_shadow_depth=6
splitter_width=7
scroll_width=12
slider_width=8
slider_handle_width=16
slider_handle_length=16
opaque=kaffeine,kmplayer,subtitlecomposer,kdenlive,vlc,smplayer,smplayer2,avidemux,avidemux2_qt4,avidemux3_qt4,avidemux3_qt5,kamoso,QtCreator,VirtualBox,VirtualBoxVM,trojita,dragon,digikam,lyx

[GeneralColors]
window.color=#3D3D3E
base.color=#2E2E2E
alt.base.color=#383838
button.color=#494949
light.color=#626262
mid.light.color=#555555
dark.color=#171717
mid.color=#3C3C3C
highlight.color=#737373
inactive.highlight.color=#4A4A4A
tooltip.base.color=black
text.color=white
window.text.color=white
button.text.color=white
disabled.text.color=#A0A0A0
tooltip.text.color=white
highlight.text.color=white
link.color=#2EB8E6
link.visited.color=#FF6666

[Hacks]
respect_darkness=true

[PanelButtonCommand]
frame=true
frame.element=button
frame.top=3
frame.bottom=3
frame.left=3
frame.right=3
interior=true
interior.element=button
indicator.size=9
text.normal.color=white
text.focus.color=#80C0FF
text.press.color=white
text.toggle.color=white
text.shadow=false
text.margin=1
text.iconspacing=4
indicator.element=arrow
text.margin.top=3
text.margin.bottom=3
text.margin.left=4
text.margin.right=4
text.shadow.xshift=1
text.shadow.yshift=1
text.shadow.color=#000000
text.shadow.alpha=255
text.shadow.depth=1

[PanelButtonTool]
inherits=PanelButtonCommand

[Dock]
inherits=PanelButtonCommand
frame=false
interior=false

[DockTitle]
inherits=PanelButtonCommand
frame=false
interior=true
interior.element=dock
text.focus.color=white
text.bold=true
text.margin.top=2
text.margin.bottom=2
text.margin.left=3
text.margin.right=3

[IndicatorSpinBox]
inherits=PanelButtonCommand
indicator.element=arrow
frame.element=spin
interior.element=spin
frame.top=3
frame.bottom=3
frame.left=3
frame.right=3
indicator.size=9

[RadioButton]
inherits=PanelButtonCommand
interior.element=radio
text.margin.top=2
text.margin.bottom=2
text.margin.left=3
text.margin.right=3

[CheckBox]
inherits=PanelButtonCommand
interior.element=checkbox
text.margin.top=2
text.margin.bottom=2
text.margin.left=3
text.margin.right=3

[Focus]
inherits=PanelButtonCommand
interior=false
frame=true
frame.element=focus
frame.top=1
frame.bottom=1
frame.left=1
frame.right=1
frame.patternsize=20

[GenericFrame]
inherits=PanelButtonCommand
frame=true
interior=false
frame.element=common
interior.element=common

[LineEdit]
inherits=PanelButtonCommand
frame.element=lineedit
interior.element=lineedit

[DropDownButton]
inherits=PanelButtonCommand
indicator.element=arrow-down

[IndicatorArrow]
indicator.element=arrow
indicator.size=9

[ToolboxTab]
inherits=PanelButtonCommand

[Tab]
inherits=PanelButtonCommand
interior.element=tab
text.margin.left=8
text.margin.right=8
frame.element=tab
indicator.element=tab
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2

[TabFrame]
inherits=PanelButtonCommand
frame.element=tabframe
interior.element=common

[TreeExpander]
inherits=PanelButtonCommand
frame=false
interior=false
indicator.size=7

[HeaderSection]
inherits=PanelButtonCommand

[SizeGrip]
indicator.element=sizegrip

[Toolbar]
inherits=PanelButtonCommand
indicator.element=toolbar
indicator.size=5
frame.element=toolbar
interior.element=toolbar

[Slider]
inherits=PanelButtonCommand
frame.element=slider
interior.element=slider
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2

[SliderCursor]
inherits=PanelButtonCommand
frame=false
interior.element=slidercursor

[Progressbar]
inherits=PanelButtonCommand
frame.element=progress
interior.element=progress
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2
text.focus.color=white
text.bold=true

[ProgressbarContents]
inherits=PanelButtonCommand
frame=false
interior.element=progress-pattern

[ItemView]
inherits=PanelButtonCommand
text.margin=0
frame.element=itemview
interior.element=itemview
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2

[Splitter]
inherits=PanelButtonCommand
interior.element=splitter
frame.element=splitter
frame.top=0
frame.bottom=0
frame.left=1
frame.right=1
indicator.element=splitter-grip
indicator.size=16

[Scrollbar]
inherits=PanelButtonCommand
indicator.size=8

[ScrollbarSlider]
inherits=PanelButtonCommand
frame.element=scrollbarslider
interior.element=scrollbarslider
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2
indicator.element=grip
indicator.size=13

[ScrollbarGroove]
inherits=PanelButtonCommand
interior.element=slider
frame.element=slider
frame.top=0
frame.bottom=0
frame.left=4
frame.right=4

[MenuItem]
inherits=PanelButtonCommand
frame=false
interior.element=menuitem
indicator.element=menuitem
min_height=22
text.focus.color=#4DA6FF
text.margin.top=2
text.margin.bottom=2
text.margin.left=3
text.margin.right=3

[MenuBarItem]
inherits=PanelButtonCommand
interior.element=menubaritem
frame.element=menubaritem
frame.top=2
frame.bottom=2
frame.left=2
frame.right=2
text.margin.top=2
text.margin.bottom=2

[MenuBar]
inherits=PanelButtonCommand
frame.top=0
frame.bottom=0
frame.left=2
frame.right=2
frame.element=menuitem
interior.element=menuitem

[TitleBar]
inherits=PanelButtonCommand
frame=false
interior.element=titlebar
indicator.size=12
indicator.element=mdi
text.normal.color=black
text.focus.color=white
text.margin.top=2
text.margin.bottom=2
text.margin.left=3
text.margin.right=3

[ComboBox]
inherits=PanelButtonCommand

[Menu]
inherits=PanelButtonCommand
frame.top=3
frame.bottom=3
frame.left=3
frame.right=3
frame.element=menu
interior.element=menu

[GroupBox]
inherits=GenericFrame
frame=true
frame.element=group
interior=true
interior.element=group
text.shadow=false
text.margin=0
frame.top=3
frame.bottom=3
frame.left=3
frame.right=3

[TabBarFrame]
inherits=GenericFrame
frame=false
interior=false
text.shadow=false

[ToolTip]
inherits=GenericFrame
frame.top=3
frame.bottom=3
frame.left=3
frame.right=3
interior=true
text.shadow=false
text.margin=0
interior.element=tooltip
frame.element=tooltip

[Window]
interior=false
Loading

0 comments on commit 795cd31

Please sign in to comment.