Commit b49eb543 authored by Clement Lefebvre's avatar Clement Lefebvre
Browse files

First steps: Replace layout switcher with color chooser

parent 413d8cb1
......@@ -18,8 +18,6 @@ from locale import gettext as _
locale.bindtextdomain("mintwelcome", "/usr/share/linuxmint/locale")
locale.textdomain("mintwelcome")
LAYOUT_STYLE_LEGACY, LAYOUT_STYLE_NEW = range(2)
class SidebarRow(Gtk.ListBoxRow):
def __init__(self, page_widget, page_name, icon_name):
......@@ -86,14 +84,14 @@ class MintWelcome():
builder.get_object("button_timeshift").connect("clicked", self.pkexec, "timeshift-gtk")
builder.get_object("button_mintdrivers").connect("clicked", self.pkexec, "driver-manager")
builder.get_object("button_gufw").connect("clicked", self.launch, "gufw")
builder.get_object("button_layout_legacy").connect("clicked", self.on_button_layout_clicked, LAYOUT_STYLE_LEGACY)
builder.get_object("button_layout_new").connect("clicked", self.on_button_layout_clicked, LAYOUT_STYLE_NEW)
# Settings button depends on DE
de_is_cinnamon = False
self.theme = None
if os.getenv("XDG_CURRENT_DESKTOP") in ["Cinnamon", "X-Cinnamon"]:
builder.get_object("button_settings").connect("clicked", self.launch, "cinnamon-settings")
de_is_cinnamon = True
self.theme = Gio.Settings(schema="org.cinnamon.desktop.interface").get_string("gtk-theme")
elif os.getenv("XDG_CURRENT_DESKTOP") == "MATE":
builder.get_object("button_settings").connect("clicked", self.launch, "mate-control-center")
elif os.getenv("XDG_CURRENT_DESKTOP") == "XFCE":
......@@ -102,10 +100,6 @@ class MintWelcome():
# Hide settings
builder.get_object("box_first_steps").remove(builder.get_object("box_settings"))
# Hide Cinnamon layout settings in other DEs
if not de_is_cinnamon:
builder.get_object("box_first_steps").remove(builder.get_object("box_cinnamon"))
# Hide codecs box if they're already installed
add_codecs = False
cache = apt.Cache()
......@@ -161,17 +155,15 @@ class MintWelcome():
scale = window.get_scale_factor()
self.color = "green"
self.dark_mode = False
# Use HIDPI pictures if appropriate
if scale == 1:
surface = self.surface_for_path("/usr/share/linuxmint/mintwelcome/legacy.png", scale)
builder.get_object("img_legacy").set_from_surface(surface)
surface = self.surface_for_path("/usr/share/linuxmint/mintwelcome/modern.png", scale)
builder.get_object("img_modern").set_from_surface(surface)
else:
surface = self.surface_for_path("/usr/share/linuxmint/mintwelcome/legacy-hidpi.png", scale)
builder.get_object("img_legacy").set_from_surface(surface)
surface = self.surface_for_path("/usr/share/linuxmint/mintwelcome/modern-hidpi.png", scale)
builder.get_object("img_modern").set_from_surface(surface)
for color in ["green", "aqua", "blue", "brown", "grey", "orange", "pink", "purple", "red", "sand", "teal"]:
builder.get_object("img_" + color).set_from_surface(self.surface_for_path("/usr/share/linuxmint/mintwelcome/%s.png" % color, scale))
builder.get_object("button_" + color).connect("clicked", self.on_color_button_clicked, color)
builder.get_object("switch_dark").connect("state-set", self.on_dark_mode_changed)
window.set_default_size(800, 500)
window.show_all()
......@@ -192,68 +184,40 @@ class MintWelcome():
os.system("mkdir -p ~/.linuxmint/mintwelcome")
os.system("touch %s" % NORUN_FLAG)
def on_button_layout_clicked (self, button, style):
applets_legacy = ['panel1:left:0:menu@cinnamon.org',
'panel1:left:1:show-desktop@cinnamon.org',
'panel1:left:2:panel-launchers@cinnamon.org',
'panel1:left:3:window-list@cinnamon.org',
'panel1:right:0:systray@cinnamon.org',
'panel1:right:1:xapp-status@cinnamon.org',
'panel1:right:2:keyboard@cinnamon.org',
'panel1:right:3:notifications@cinnamon.org',
'panel1:right:4:printers@cinnamon.org',
'panel1:right:5:removable-drives@cinnamon.org',
'panel1:right:6:user@cinnamon.org',
'panel1:right:7:network@cinnamon.org',
'panel1:right:8:sound@cinnamon.org',
'panel1:right:9:power@cinnamon.org',
'panel1:right:10:calendar@cinnamon.org']
applets_new = ['panel1:left:0:menu@cinnamon.org',
'panel1:left:1:show-desktop@cinnamon.org',
'panel1:left:2:grouped-window-list@cinnamon.org',
'panel1:right:0:systray@cinnamon.org',
'panel1:right:1:xapp-status@cinnamon.org',
'panel1:right:2:notifications@cinnamon.org',
'panel1:right:3:printers@cinnamon.org',
'panel1:right:4:removable-drives@cinnamon.org',
'panel1:right:5:keyboard@cinnamon.org',
'panel1:right:6:network@cinnamon.org',
'panel1:right:7:sound@cinnamon.org',
'panel1:right:8:power@cinnamon.org',
'panel1:right:9:calendar@cinnamon.org']
settings = Gio.Settings("org.cinnamon")
settings.set_strv("panels-enabled", ['1:0:bottom'])
applets = applets_new
left_icon_size = 0
center_icon_size = 0
right_icon_size = 0
def on_dark_mode_changed(self, button, state):
self.dark_mode = state
self.change_color()
def on_color_button_clicked(self, button, color):
self.color = color
self.change_color()
def change_color(self):
theme = "Mint-Y"
wm_theme = "Mint-Y"
cinnamon_theme = "Mint-Y-Dark"
if style == LAYOUT_STYLE_LEGACY:
applets = applets_legacy
panel_size = 27
theme = "Mint-X"
cinnamon_theme = "Linux Mint"
menu_label = "Menu"
elif style == LAYOUT_STYLE_NEW:
panel_size = 40
right_icon_size = 24
menu_label = ""
settings.set_strv("panels-height", ['1:%s' % panel_size])
settings.set_strv("enabled-applets", applets)
settings.set_string("app-menu-label", menu_label)
settings.set_string("panel-zone-icon-sizes", "[{\"panelId\": 1, \"left\": %s, \"center\": %s, \"right\": %s}]" % (left_icon_size, center_icon_size, right_icon_size))
Gio.Settings('org.cinnamon.desktop.wm.preferences').set_string('theme', theme)
Gio.Settings('org.cinnamon.theme').set_string('name', cinnamon_theme)
Gio.Settings('org.cinnamon.desktop.interface').set_string('icon-theme', theme)
Gio.Settings('org.cinnamon.desktop.interface').set_string('gtk-theme', theme)
os.system("cinnamon --replace &")
if self.dark_mode:
theme = "%s-Dark" % theme
wm_theme = "Mint-Y-Dark"
if self.color != "green":
theme = "%s-%s" % (theme, self.color.title())
cinnamon_theme = "Mint-Y-Dark-%s" % self.color.title()
if os.getenv("XDG_CURRENT_DESKTOP") in ["Cinnamon", "X-Cinnamon"]:
settings = Gio.Settings(schema="org.cinnamon.desktop.interface")
settings.set_string("gtk-theme", theme)
settings.set_string("icon-theme", theme)
Gio.Settings(schema="org.cinnamon.desktop.wm.preferences").set_string("theme", wm_theme)
Gio.Settings(schema="org.cinnamon.theme").set_string("name", cinnamon_theme)
elif os.getenv("XDG_CURRENT_DESKTOP") == "MATE":
settings = Gio.Settings(schema="org.mate.interface")
settings.set_string("gtk-theme", theme)
settings.set_string("icon-theme", theme)
Gio.Settings(schema="org.mate.Marco.general").set_string("theme", wm_theme)
elif os.getenv("XDG_CURRENT_DESKTOP") == "XFCE":
subprocess.call(["xfconf-query", "-c", "xsettings", "-p", "/Net/ThemeName", "-s", theme])
subprocess.call(["xfconf-query", "-c", "xsettings", "-p", "/Net/IconThemeName", "-s", theme])
subprocess.call(["xfconf-query", "-c", "xfwm4", "-p", "/general/theme", "-s", theme])
def visit(self, button, url):
subprocess.Popen(["xdg-open", url])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment