implement color-scheme option

main
mirkobrombin 2 years ago
parent f2aa57a25b
commit 8b20b7d754

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="vanilla-first-setup">
<schema id="io.github.vanilla-os.FirstSetup" path="/pm/mirko/FirstSetup/">
<schema id="io.github.vanilla-os.FirstSetup" path="/io/github/vanilla-os/FirstSetup/">
</schema>
</schemalist>

@ -1,24 +1,24 @@
3f84a85bd8dcb22475ca07a2d69063ac usr/bin/vanilla-first-setup
e53214a91cfee2c537138e64d0d2357e usr/bin/vanilla-first-setup-processor
f62ae2de8dd39b794fa94951db288612 usr/share/appdata/pm.mirko.FirstSetup.appdata.xml
572c7ac7342d5e999af8cf5fc99fc7ba usr/share/applications/pm.mirko.FirstSetup.desktop
f62ae2de8dd39b794fa94951db288612 usr/share/appdata/io.github.vanilla-os.FirstSetup.appdata.xml
572c7ac7342d5e999af8cf5fc99fc7ba usr/share/applications/io.github.vanilla-os.FirstSetup.desktop
632c1335ca45192e9b887308023c156c usr/share/doc/vanilla-first-setup/changelog.gz
62ed186d7529beecf72bcf7c48b53a76 usr/share/doc/vanilla-first-setup/copyright
3ff815595db45e9dcd137d06f9d8718c usr/share/glib-2.0/schemas/pm.mirko.FirstSetup.gschema.xml
a3cd0585c74138a988a7225dd57fc171 usr/share/icons/hicolor/scalable/apps/pm.mirko.FirstSetup.svg
a3cd0585c74138a988a7225dd57fc171 usr/share/icons/hicolor/symbolic/apps/pm.mirko.FirstSetup-symbolic.svg
75fdbd9173045311c140056e34292035 usr/share/pm.mirko.FirstSetup/vanilla-first-setup.gresource
d41d8cd98f00b204e9800998ecf8427e usr/share/pm.mirko.FirstSetup/vanilla_first_setup/__init__.py
cacabd792fe13148f625e90b1d63e343 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/main.py
d41d8cd98f00b204e9800998ecf8427e usr/share/pm.mirko.FirstSetup/vanilla_first_setup/models/__init__.py
655cc3575fd9547bcc28605a40adecb4 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/models/config.py
19a9c8ef77a0b94b9bd9da204bf619be usr/share/pm.mirko.FirstSetup/vanilla_first_setup/models/preset.py
d41d8cd98f00b204e9800998ecf8427e usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/__init__.py
24bb5bd4e6d6262c1b454b3656ab24e0 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/apt.py
4d805e042731d213eb5139530d8aa638 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/checks.py
7823cbc7898533c975d6a44bc5805480 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/configurator.py
d757da1b73916417336840cc67295681 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/flatpak.py
f2595187532f527875795277675234a5 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/processor.py
0ebff648510796f3d38e84739469f97e usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/run_async.py
ebbd22d7a8847f604900387b8c9d86a2 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/utils/snap.py
f07c8b3e157f197d2cefd0a89862b3c1 usr/share/pm.mirko.FirstSetup/vanilla_first_setup/window.py
3ff815595db45e9dcd137d06f9d8718c usr/share/glib-2.0/schemas/io.github.vanilla-os.FirstSetup.gschema.xml
a3cd0585c74138a988a7225dd57fc171 usr/share/icons/hicolor/scalable/apps/io.github.vanilla-os.FirstSetup.svg
a3cd0585c74138a988a7225dd57fc171 usr/share/icons/hicolor/symbolic/apps/io.github.vanilla-os.FirstSetup-symbolic.svg
75fdbd9173045311c140056e34292035 usr/share/io.github.vanilla-os.FirstSetup/vanilla-first-setup.gresource
d41d8cd98f00b204e9800998ecf8427e usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/__init__.py
cacabd792fe13148f625e90b1d63e343 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/main.py
d41d8cd98f00b204e9800998ecf8427e usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/models/__init__.py
655cc3575fd9547bcc28605a40adecb4 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/models/config.py
19a9c8ef77a0b94b9bd9da204bf619be usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/models/preset.py
d41d8cd98f00b204e9800998ecf8427e usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/__init__.py
24bb5bd4e6d6262c1b454b3656ab24e0 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/apt.py
4d805e042731d213eb5139530d8aa638 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/checks.py
7823cbc7898533c975d6a44bc5805480 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/configurator.py
d757da1b73916417336840cc67295681 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/flatpak.py
f2595187532f527875795277675234a5 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/processor.py
0ebff648510796f3d38e84739469f97e usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/run_async.py
ebbd22d7a8847f604900387b8c9d86a2 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/utils/snap.py
f07c8b3e157f197d2cefd0a89862b3c1 usr/share/io.github.vanilla-os.FirstSetup/vanilla_first_setup/window.py

@ -23,7 +23,7 @@ import locale
import gettext
VERSION = '0.0.1'
pkgdatadir = '/usr/share/pm.mirko.FirstSetup'
pkgdatadir = '/usr/share/io.github.vanilla-os.FirstSetup'
localedir = '/usr/share/locale'
sys.path.insert(1, pkgdatadir)

@ -24,7 +24,7 @@ import gettext
import argparse
VERSION = '0.0.1'
pkgdatadir = '/usr/share/pm.mirko.FirstSetup'
pkgdatadir = '/usr/share/io.github.vanilla-os.FirstSetup'
localedir = '/usr/share/locale'
sys.path.insert(1, pkgdatadir)

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>pm.mirko.FirstSetup.desktop</id>
<id>io.github.vanilla-os.FirstSetup.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-3.0-only</project_license>
<name translatable="no">Vanilla OS First Setup</name>
@ -10,7 +10,7 @@
<p>No description</p>
</description>
<screenshots/>
<translation type="gettext">pm.mirko.FirstSetup</translation>
<translation type="gettext">io.github.vanilla-os.FirstSetup</translation>
<content_rating type="oars-1.1"/>
<recommends>
<control>pointing</control>

@ -1,7 +1,7 @@
[Desktop Entry]
Name=Vanilla OS First Setup
Exec=vanilla-first-setup
Icon=pm.mirko.FirstSetup
Icon=io.github.vanilla-os.FirstSetup
Terminal=false
Type=Application
Categories=GTK;

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="vanilla-first-setup">
<schema id="pm.mirko.FirstSetup" path="/pm/mirko/FirstSetup/">
<schema id="io.github.vanilla-os.FirstSetup" path="/io/github/vanilla-os/FirstSetup/">
</schema>
</schemalist>

@ -31,7 +31,7 @@ class FirstSetupApplication(Adw.Application):
"""The main application singleton class."""
def __init__(self):
super().__init__(application_id='pm.mirko.FirstSetup',
super().__init__(application_id='io.github.vanilla-os.FirstSetup',
flags=Gio.ApplicationFlags.FLAGS_NONE)
self.create_action('quit', self.close, ['<primary>q'])

@ -22,7 +22,7 @@ from vanilla_first_setup.utils.processor import Processor
from vanilla_first_setup.utils.run_async import RunAsync
@Gtk.Template(resource_path='/pm/mirko/FirstSetup/gtk/window.ui')
@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/window.ui')
class FirstSetupWindow(Adw.ApplicationWindow):
__gtype_name__ = 'FirstSetupWindow'

@ -17,7 +17,7 @@
from gi.repository import Gtk, Adw
@Gtk.Template(resource_path='/pm/mirko/FirstSetup/gtk/dialog-prop-nvidia.ui')
@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/dialog-prop-nvidia.ui')
class ProprietaryDriverDialog(Adw.Window):
__gtype_name__ = 'ProprietaryDriverDialog'

@ -17,7 +17,7 @@
from gi.repository import Gtk, Adw
@Gtk.Template(resource_path='/pm/mirko/FirstSetup/gtk/dialog-subsystem.ui')
@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/dialog-subsystem.ui')
class SubSystemDialog(Adw.Window):
__gtype_name__ = 'SubSystemDialog'

@ -40,7 +40,7 @@
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="GtkButton" id="btn_start">
<object class="GtkButton" id="btn_go_theme">
<property name="label">Let's Start</property>
<property name="halign">center</property>
<style>
@ -52,6 +52,65 @@
</object>
</child>
<!-- Light/Dark -->
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="halign">fill</property>
<property name="valign">center</property>
<property name="hexpand">true</property>
<child>
<object class="GtkBox">
<property name="valign">center</property>
<property name="spacing">10</property>
<property name="halign">center</property>
<child>
<object class="GtkCheckButton" id="btn_light">
<property name="tooltip-text">Light</property>
<property name="halign">center</property>
<property name="active">True</property>
<style>
<class name="theme-selector" />
<class name="light" />
<class name="card" />
</style>
</object>
</child>
<child>
<object class="GtkCheckButton" id="btn_dark">
<property name="tooltip-text">Dark</property>
<property name="halign">center</property>
<style>
<class name="theme-selector" />
<class name="dark" />
<class name="card" />
</style>
</object>
</child>
</object>
</child>
<child>
<object class="AdwStatusPage">
<property name="title">Light or Dark?</property>
<property name="description">Choose your preferred theme.</property>
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="GtkButton" id="btn_go_package">
<property name="label">Next</property>
<property name="halign">center</property>
<style>
<class name="pill" />
<class name="suggested-action" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<!-- Package Manager -->
<child>
<object class="AdwStatusPage">
@ -112,7 +171,7 @@
</object>
</child>
<child>
<object class="GtkButton" id="btn_next">
<object class="GtkButton" id="btn_go_subsystem">
<property name="label">Next</property>
<property name="halign">center</property>
<style>

@ -14,15 +14,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from vanilla_first_setup.window import FirstSetupWindow
from gi.repository import Gtk, Gio, Adw
import sys
import gi
import sys
import logging
gi.require_version('Gtk', '4.0')
gi.require_version('Adw', '1')
from gi.repository import Gtk, Gdk, Gio, Adw
from vanilla_first_setup.window import FirstSetupWindow
logging.basicConfig(level=logging.INFO)
@ -36,11 +37,65 @@ class FirstSetupApplication(Adw.Application):
self.create_action('quit', self.close, ['<primary>q'])
def do_activate(self):
"""Called when the application is activated.
"""
Called when the application is activated.
We raise the application's main window, creating it if
necessary.
--
CSS inspired by: Sonny Piers <https://github.com/sonnyp>
"""
css = """
.theme-selector {
border-radius: 100px;
margin: 8px;
border: 1px solid rgba(145, 145, 145, 0.1);
padding: 30px;
}
.theme-selector radio {
-gtk-icon-source: none;
border: none;
background: none;
box-shadow: none;
min-width: 12px;
min-height: 12px;
transform: translate(34px, 20px);
padding: 2px;
border-radius: 100px;
}
.theme-selector radio:checked {
-gtk-icon-source: -gtk-icontheme("object-select-symbolic");
background-color: @theme_selected_bg_color;
color: @theme_selected_fg_color;
}
.theme-selector:checked {
border-color: @theme_selected_bg_color;
border-width: 2px;
background-color: @theme_selected_bg_color;
}
.theme-selector.light {
background-color: #ffffff;
}
.theme-selector.dark {
background-color: #202020;
}
.theme-selector.light:checked {
background-color: #eeeeee;
}
.theme-selector.dark:checked {
background-color: #303030;
}
"""
provider = Gtk.CssProvider()
provider.load_from_data(css.encode())
Gtk.StyleContext.add_provider_for_display(
display=Gdk.Display.get_default(),
provider=provider,
priority=Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
win = self.props.active_window
if not win:
win = FirstSetupWindow(application=self)

@ -13,7 +13,7 @@ class Config:
appimage: bool,
apport: bool,
distrobox: bool,
nvidia: bool
nvidia: bool,
):
self.snap = snap
self.flatpak = flatpak
@ -27,7 +27,7 @@ class Config:
"snap", "flatpak", "appimage", "apport", "distrobox", "nvidia"
]
vals = [
self.snap, self.flatpak, self.appimage, self.apport, self.distrobox, self.nvidia
self.snap, self.flatpak, self.appimage, self.apport, self.distrobox, self.nvidia, self.theme
]
return "|".join([f"{key}::{val}" for key, val in zip(keys, vals)])
@ -69,5 +69,5 @@ class Config:
appimage=get_bool(appimage),
apport=get_bool(apport),
distrobox=get_bool(distrobox),
nvidia=get_bool(nvidia)
nvidia=get_bool(nvidia),
)

@ -3,6 +3,8 @@ import time
import logging
import subprocess
from gi.repository import Gio
from vanilla_first_setup.utils import checks
from vanilla_first_setup.utils.apt import Apt
from vanilla_first_setup.utils.flatpak import Flatpak
@ -111,7 +113,7 @@ class Configurator:
if self.fake:
return self.__fake("Fake: Nvidia enabled")
proc.subprocess.run(['sudo', 'ubuntu-drivers', 'install', '--recommended'])
subprocess.run(['sudo', 'ubuntu-drivers', 'install', '--recommended'])
def __disable_on_startup(self):
if self.fake:

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/pm/mirko/FirstSetup">
<gresource prefix="/io/github/vanilla-os/FirstSetup">
<file>gtk/window.ui</file>
<file>gtk/dialog-subsystem.ui</file>
<file>gtk/dialog-prop-nvidia.ui</file>
</gresource>
<gresource prefix="/pm/mirko/FirstSetup/icons/scalable/actions/">
<gresource prefix="/io/github/vanilla-os/FirstSetup/icons/scalable/actions/">
<file preprocess="xml-stripblanks">../data/icons/hicolor/symbolic/actions/vanilla-package-symbolic.svg</file>
<file preprocess="xml-stripblanks">../data/icons/hicolor/symbolic/actions/vanilla-container-terminal-symbolic.svg</file>
<file preprocess="xml-stripblanks">../data/icons/hicolor/symbolic/actions/vanilla-puzzle-piece-symbolic.svg</file>

@ -28,13 +28,16 @@ from vanilla_first_setup.dialogs.subsystem import SubSystemDialog
from vanilla_first_setup.dialogs.prop_drivers import ProprietaryDriverDialog
@Gtk.Template(resource_path='/pm/mirko/FirstSetup/gtk/window.ui')
@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/window.ui')
class FirstSetupWindow(Adw.ApplicationWindow):
__gtype_name__ = 'FirstSetupWindow'
carousel = Gtk.Template.Child()
btn_start = Gtk.Template.Child()
btn_next = Gtk.Template.Child()
btn_go_theme = Gtk.Template.Child()
btn_light = Gtk.Template.Child()
btn_dark = Gtk.Template.Child()
btn_go_package = Gtk.Template.Child()
btn_go_subsystem = Gtk.Template.Child()
btn_save = Gtk.Template.Child()
btn_reboot = Gtk.Template.Child()
btn_no_subsystem = Gtk.Template.Child()
@ -50,13 +53,15 @@ class FirstSetupWindow(Adw.ApplicationWindow):
spinner = Gtk.Template.Child()
status_welcome = Gtk.Template.Child()
status_nvidia = Gtk.Template.Child()
page_welcome = -1
page_configuration = 0
page_subsystem = 1
page_nvidia_drivers = 2
page_extras = 3
page_progress = 4
page_done = 5
page_theme = 0
page_configuration = 1
page_subsystem = 2
page_nvidia_drivers = 3
page_extras = 4
page_progress = 5
page_done = 6
def __init__(self, **kwargs):
super().__init__(**kwargs)
@ -82,12 +87,19 @@ class FirstSetupWindow(Adw.ApplicationWindow):
self.switch_appimage.set_active(Preset.appimage)
self.switch_apport.set_active(Preset.apport)
self.btn_dark.set_group(self.btn_light)
def __connect_signals(self):
self.btn_start.connect('clicked', self.__on_btn_start_clicked)
self.btn_next.connect('clicked', self.__on_btn_next_clicked)
self.btn_go_theme.connect('clicked', self.__show_page, self.page_theme)
self.btn_go_package.connect('clicked', self.__show_page, self.page_configuration)
self.btn_go_subsystem.connect('clicked', self.__show_page, self.page_subsystem)
self.btn_save.connect('clicked', self.on_btn_save_clicked)
self.btn_reboot.connect('clicked', self.on_btn_reboot_clicked)
self.btn_light.connect('toggled', self.__set_theme, "light")
self.btn_dark.connect('toggled', self.__set_theme, "dark")
self.btn_no_subsystem.connect('clicked', self.on_btn_subsystem_clicked, False)
self.btn_use_subsystem.connect('clicked', self.on_btn_subsystem_clicked, True)
self.btn_info_subsystem.connect('clicked', self.__on_btn_info_subsystem_clicked)
@ -102,26 +114,27 @@ class FirstSetupWindow(Adw.ApplicationWindow):
self.switch_apport.connect(
'state-set', self.__on_switch_apport_state_set)
def __show_page(self, page: int):
def __show_page(self, widget=None, page: int=-1):
_page = self.carousel.get_nth_page(page + 1)
self.carousel.scroll_to(_page, True)
def __on_btn_start_clicked(self, widget):
self.__show_page(self.page_configuration)
def __on_btn_next_clicked(self, widget):
self.__show_page(self.page_subsystem)
def on_btn_save_clicked(self, widget):
def on_done(result, error=None):
self.spinner.stop()
self.__show_page(self.page_done)
self.__show_page(page=self.page_done)
self.__show_page(self.page_progress)
self.__show_page(page=self.page_progress)
self.spinner.start()
RunAsync(Processor(self.__config).run, on_done)
def __set_theme(self, widget, theme: str):
self.__config.set_val('theme', theme)
pref = "prefer-dark" if theme == "dark" else "default"
gtk = "Adwaita-dark" if theme == "dark" else "Adwaita"
Gio.Settings.new("org.gnome.desktop.interface").set_string("color-scheme", pref)
Gio.Settings.new("org.gnome.desktop.interface").set_string("gtk-theme", gtk)
def __on_switch_snap_state_set(self, widget, state):
self.__config.set_val('snap', state)
@ -139,14 +152,14 @@ class FirstSetupWindow(Adw.ApplicationWindow):
def on_btn_subsystem_clicked(self, widget, state):
self.__config.set_val('distrobox', state)
self.__show_page(self.page_nvidia_drivers if self.__has_nvidia else self.page_extras)
self.__show_page(page=self.page_nvidia_drivers if self.__has_nvidia else self.page_extras)
def __on_btn_info_subsystem_clicked(self, widget):
SubSystemDialog(self).show()
def on_btn_prop_nvidia_clicked(self, widget, state):
self.__config.set_val('nvidia', state)
self.__show_page(self.page_extras)
self.__show_page(page=self.page_extras)
def __on_btn_info_prop_nvidia_clicked(self, widget):
ProprietaryDriverDialog(self).show()

Loading…
Cancel
Save