implement tour

main
Mirko Brombin 2 years ago
parent 30a7d18141
commit 9d9fed76c6

@ -2,24 +2,27 @@
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0" />
<template class="VanillaProgress" parent="AdwBin">
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<template class="VanillaProgress" parent="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="AdwStatusPage" id="status_page">
<property name="title">Please Wait…</property>
<property name="description">The changes are being applied.</property>
<object class="AdwCarousel" id="carousel_tour">
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="GtkSpinner" id="spinner">
<property name="valign">center</property>
<property name="halign">center</property>
<property name="spinning">true</property>
</object>
</child>
<property name="vexpand">true</property>
<property name="allow_scroll_wheel">False</property>
<property name="allow_mouse_drag">False</property>
<property name="allow_long_swipes">False</property>
</object>
</child>
<child>
<object class="GtkProgressBar" id="progressbar">
<property name="text">The changes are being applied. Please Wait…</property>
<property name="show-text">true</property>
<property name="margin-top">20</property>
<property name="margin-start">20</property>
<property name="margin-bottom">20</property>
<property name="margin-end">20</property>
</object>
</child>
</template>

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<requires lib="libadwaita" version="1.0" />
<template class="VanillaTour" parent="AdwBin">
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="AdwStatusPage" id="status_page">
<property name="halign">fill</property>
<property name="valign">fill</property>
<property name="hexpand">true</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="vexpand">True</property>
<property name="hexpand">True</property>
<property name="valign">center</property>
<child>
<object class="GtkBox">
<property name="valign">center</property>
<property name="spacing">10</property>
<property name="halign">center</property>
<child>
<object class="GtkButton" id="btn_read_more">
<property name="label">Read More</property>
<property name="halign">center</property>
<style>
<class name="pill" />
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

@ -5,6 +5,7 @@
<file>gtk/done.ui</file>
<file>gtk/progress.ui</file>
<file>gtk/dialog.ui</file>
<file>gtk/tour.ui</file>
<file>gtk/default-theme.ui</file>
<file>gtk/default-welcome.ui</file>

@ -5,6 +5,7 @@ sources = [
'__init__.py',
'done.py',
'progress.py',
'tour.py',
]
install_data(sources, install_dir: viewsdir)

@ -14,13 +14,47 @@
# 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 gi.repository import Gtk, Adw
import time
from gi.repository import Gtk, GLib, Adw
from vanilla_first_setup.utils.run_async import RunAsync
from vanilla_first_setup.views.tour import VanillaTour
@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/progress.ui')
class VanillaProgress(Adw.Bin):
class VanillaProgress(Gtk.Box):
__gtype_name__ = 'VanillaProgress'
def __init__(self, window, **kwargs):
carousel_tour = Gtk.Template.Child()
progressbar = Gtk.Template.Child()
def __init__(self, window, tour: dict, **kwargs):
super().__init__(**kwargs)
self.__window = window
self.__tour = tour
self.__build_ui()
def __build_ui(self):
for _, tour in self.__tour.items():
self.carousel_tour.append(VanillaTour(self.__window, tour))
self.__start_tour()
def __switch_tour(self, *args):
cur_index = self.carousel_tour.get_position()
page = self.carousel_tour.get_nth_page(cur_index + 1)
if page is None:
page = self.carousel_tour.get_nth_page(0)
self.carousel_tour.scroll_to(page, True)
def __start_tour(self):
def run_async():
while True:
GLib.idle_add(self.progressbar.pulse)
GLib.idle_add(self.__switch_tour)
time.sleep(5)
RunAsync(run_async, "tour_loop")

@ -0,0 +1,45 @@
# tour.py
#
# Copyright 2022 mirkobrombin
#
# 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 Foundationat version 3 of the License.
#
# 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, see <http://www.gnu.org/licenses/>.
import webbrowser
from gi.repository import Gtk, Adw
@Gtk.Template(resource_path='/io/github/vanilla-os/FirstSetup/gtk/tour.ui')
class VanillaTour(Adw.Bin):
__gtype_name__ = 'VanillaTour'
status_page = Gtk.Template.Child()
btn_read_more = Gtk.Template.Child()
def __init__(self, window, tour, **kwargs):
super().__init__(**kwargs)
self.__window = window
self.__tour = tour
self.__build_ui()
# signals
self.btn_read_more.connect("clicked", self.__on_read_more)
def __build_ui(self):
self.status_page.set_icon_name(self.__tour["icon"])
self.status_page.set_title(self.__tour["title"])
self.status_page.set_description(self.__tour["description"])
self.btn_read_more.set_visible(bool("read_more_link" in self.__tour))
def __on_read_more(self, e):
webbrowser.open_new_tab(self.__tour["read_more_link"])

@ -42,7 +42,7 @@ class VanillaWindow(Adw.ApplicationWindow):
self.recipe = self.__builder.recipe
# system views
self.__view_progress = VanillaProgress(self)
self.__view_progress = VanillaProgress(self, self.recipe.get("tour", {}))
self.__view_done = VanillaDone(self)
# this builds the UI with the widgets generated by the builder

Loading…
Cancel
Save