#!/bin/sh
#
#    Copyright (C) 2021,2022  Ruben Rodriguez <ruben@trisquel.info>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

VERSION=12
. ./config

#correct gtk2 color syntax
sed '/gtk-color-scheme/d' -i light/gtk-2.0/gtkrc dark/gtk-2.0/gtkrc
sed '5agtk-color-scheme        = "bg_color:#D4D4D4\\nselected_bg_color:#6699CC\\nbase_color:#fcfcfc\\nfg_color:#3C3C3C\\nselected_fg_color:#ffffff\\ntext_color:#212121\\ntooltip_bg_color:#F5F5B5\\ntooltip_fg_color:#000000\\nlink_color:#35b9ab\\npanel_bg:#686868\\nfm_color:#F7F7F7\\nbg_color_dark:#686868\\ntext_color_dark:#FFF"' -i light/gtk-2.0/gtkrc
sed '5agtk-color-scheme        = "bg_color:#3b3b3b\\nselected_bg_color:#6699CC\\nbase_color:#2d2e30\\nfg_color:#eeeeec\\nselected_fg_color:#ffffff\\ntext_color:#ffffff\\ntooltip_bg_color:#F5F5B5\\ntooltip_fg_color:#000000\\nlink_color:#35b9ab\\npanel_bg:#686868\\nfm_color:#F7F7F7\\nbg_color_dark:#686868\\ntext_color_dark:#FFF"' -i dark/gtk-2.0/gtkrc

#highlight color
sed 's/#398ee7/#6699CC/g' -i light/gtk-3.0/_colors.scss

#custom mate-panel and other mate enhancements
cat $DATA/*.scss >> light/gtk-3.0/_others.scss
cat $DATA/*.scss >> dark/gtk-3.0/_others.scss
echo '$panelgradient_color: #555555;' >> light/gtk-3.0/_colors.scss
echo '@define-color content_view_bg #{"" + $panelgradient_color};' >> light/gtk-3.0/_colors_public.scss
echo '@define-color content_view_bg #{"" + $panelgradient_color};' >> dark/gtk-3.0/_colors_public.scss

#main background: trisquel grey, dark version desaturated
sed '/bg_color/s/#cecece, #3b3e3f/#D4D4D4, #3b3b3b/' -i light/gtk-3.0/_colors.scss

#increase contrast on gtk notebooks
sed 's/shade($bg_color, 1.05);/shade($bg_color, 1.13);/' -i light/gtk-3.0/_common.scss

#border contrast
sed '/^\$backdrop_borders_color/s/90%/50%/' -i light/gtk-3.0/_colors.scss

#thicker progress bars
sed '/progress.*min/s/8px/10px/' -i light/gtk-3.0/_common.scss
sed '/trough.*min/s/6px/8px/' -i light/gtk-3.0/_common.scss

#gradient on menu bar
sed '/Menus/,/^}/s/&:backdrop.*/background-image: linear-gradient(to bottom, $bg_color ,shade($bg_color, 0.95));/' -i light/gtk-3.0/_common.scss
sed '/headerbar_fill/,/}/s/linear-gradient(to bottom, $c/linear-gradient(to bottom, shade($c, 0.95)/' -i light/gtk-3.0/_drawing.scss
sed '/headerbar_fill/,/}/s/@if $variant.*//' -i light/gtk-3.0/_drawing.scss
sed 's/^$headerbar_color:.*/$headerbar_color: $bg_color;/' -i light/gtk-3.0/_colors.scss

#make buttons stand up more
sed '/normal button$/,/  }/s/1.02), 1.05/1.02), 1.1/; s/1.15), 0.97/1.02), 0.95/' -i light/gtk-3.0/_drawing.scss
sed '/normal button$/,/  }/s/$_button_edge/ inset 0 -1px 1px transparentize(black, 0.9)/' -i light/gtk-3.0/_drawing.scss

#more space on menus
sed '/  menuitem {/,/padding/s/min-height: 16px;/min-height: 18px;/'  -i light/gtk-3.0/_common.scss

#smaller menu arrows
sed '/submenu indicators/,/^$/s/16px/10px/' -i light/gtk-3.0/_common.scss

#grey menus
sed '/$menu_color/s/18/7/' -i light/gtk-3.0/_colors.scss

#border on side panel top, gtk file chooser
sed '/^placessidebar/,/^$/s/border-style: none;/border-width:1px 0px 0px 0px/' -i light/gtk-3.0/_common.scss

#square scrollbars
sed '/\/\/ slider$/,/^$/s/min-width: 7px/min-width: 12px/g' -i light/gtk-3.0/_common.scss
sed '/\/\/ slider$/,/^$/s/min-height: 7px/min-height: 12px/g' -i light/gtk-3.0/_common.scss
sed '/\/\/ slider$/,/^$/s/margin: 3px/margin: 0px/g' -i light/gtk-3.0/_common.scss
sed '/\/\/ slider$/,/^$/s/border-radius: 10px/border-radius: 0px/g' -i light/gtk-3.0/_common.scss

sed '/GtkScrollbar/s/::trough-border.*/::trough-border = 0/' -i light/gtk-2.0/gtkrc dark/gtk-2.0/gtkrc
sed '/GtkScrollbar/s/::slider-width.*/::slider-width = 12/' -i light/gtk-2.0/gtkrc dark/gtk-2.0/gtkrc
sed '/^style "scrollbar"/,/^}$/s/roundness.*/roundness = 0/' -i light/gtk-2.0/gtkrc dark/gtk-2.0/gtkrc

#bigger buttons
sed '/^button {/,/transition/s/min-height: 24px/min-height: 26px/' -i light/gtk-3.0/_common.scss
sed '/^button {/,/transition/s/padding: 1px 2px/padding: 1px 4px/' -i light/gtk-3.0/_common.scss

#tooltips
sed '/^tooltip {$/,/^}$/s/background-color: transparentize.*/background-color: #F5F5B5;/' -i light/gtk-3.0/_common.scss
sed '/^tooltip {$/,/^}$/s/color: white/color: black/' -i light/gtk-3.0/_common.scss
sed '/^tooltip {$/,/^}$/s/border-radius: 5px/border-radius: 0px/' -i light/gtk-3.0/_common.scss
sed '/^tooltip {$/,/^}$/s/padding: 1px/padding: 3px/' -i light/gtk-3.0/_common.scss
sed '/^tooltip {$/,/^}$/s/text-shadow.*/text-shadow: none;/' -i light/gtk-3.0/_common.scss
#Leave tooltip text as default.
#sed '/tooltip/s/#000000/#F5F5B5/; s/#E1E1E1/#000000/' -i light/gtk-2.0/gtkrc dark/gtk-2.0/gtkrc

#wider paned separators
sed '/Paned/,/^$/s/min-width: 1px/min-width: 4px/' -i light/gtk-3.0/_common.scss
sed '/Paned/,/^$/s/min-height: 1px/min-height: 4px/' -i light/gtk-3.0/_common.scss
sed '/Paned/,/^$/s/transparent.*/$bg_color;/' -i light/gtk-3.0/_common.scss
sed '/Paned/,/^$/s/background-image.*//' -i light/gtk-3.0/_common.scss
sed '/Paned/,/^$/s/background-size.*//' -i light/gtk-3.0/_common.scss
sed '/Paned/,/^}$/s/image($backdrop_borders_color)/image($bg_color)/' -i light/gtk-3.0/_common.scss

# fix panel toggles too wide
sed '/min-width: 44px/d' -i light/gtk-3.0/_others.scss dark/gtk-3.0/_others.scss

#fix invisible alt-tab transparent selector under white brackground.
cat << EOF >> dark/gtk-3.0/_others.scss
.osd image:selected {
  background: #363636;
}
EOF

# lxde panel
cat << EOF >> dark/gtk-2.0/apps/xfce-panel.rc

# For lxpanel
style "darkpanel"
{
        fg[NORMAL]              = "#ffffff"
        fg[PRELIGHT]            = "#ffffff"
        fg[SELECTED]            = "#ffffff"
        fg[ACTIVE]              = "#ffffff"
        fg[INSENSITIVE]         = "#ffffff"
}
widget "*Panel*" style "darkpanel"
EOF

# fix background non-selected pane - GitLab PH#152
## light
cat << EOF >> light/gtk-3.0/_others.scss

treeview.view:selected:not(:focused) {
        color: #ffffff;
        background-image: linear-gradient(to bottom, shade(#6699CC, 0.87), shade(#6699CC, 0.95) 100%);
}
EOF
## dark
cat << EOF >> dark/gtk-3.0/_others.scss

treeview.view:selected:not(:focused) {
        color: #ffffff;
        background-image: linear-gradient(to bottom, shade(#6699CC, 0.87), shade(#6699CC, 0.95) 100%);
}
EOF

changelog "Customized for Trisquel"

package

