Skip to content

Commit

Permalink
feat[close #5]: Support actions in tour
Browse files Browse the repository at this point in the history
* fix: Support actions in tour #5:

-  refactor slide to make use of `AdwSttausPage` and hidden `GtkButton`
- fix gresource for png asset

* use `startswith()`
  • Loading branch information
Muqtxdir authored Jan 8, 2024
1 parent f3e4be5 commit d8b1fd7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 25 deletions.
5 changes: 0 additions & 5 deletions vanilla_tour/assets/tour.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"resource": "/org/vanillaos/Tour/assets/solid.svg",
"title": "Solid. Secure. Maintenance-free.",
"description": "Vanilla OS is developed with security in mind. Updates are automatic and run in the background, they won't get in your way.",
"hasAction": true,
"action": {
"title": "Configure Updates",
"callback": "cmd://vanilla-updates-utility"
Expand All @@ -18,7 +17,6 @@
"resource": "/org/vanillaos/Tour/assets/favorite-apps.svg",
"title": "Your Favorite Apps, Right Here",
"description": "From your favorite music player, to your trusted web browser. They are all available, install them from the store.",
"hasAction": true,
"action": {
"title": "Open the Store",
"callback": "cmd://gnome-software"
Expand All @@ -43,7 +41,6 @@
"resource": "/org/vanillaos/Tour/assets/configure.svg",
"title": "Configure Your Device",
"description": "From Bluetooth devices to that wallpaper you love so much. The settings panel allows you to configure it as you like.",
"hasAction": true,
"action": {
"title": "Open the Settings",
"callback": "cmd://gnome-control-center"
Expand All @@ -53,7 +50,6 @@
"resource": "/org/vanillaos/Tour/assets/connect.svg",
"title": "Connect Your Online Accounts",
"description": "Do you have a Gmail, Outlook, Nextcloud or other account? Connect them to your Vanilla OS device to integrate email, calendars.. everything.",
"hasAction": true,
"action": {
"title": "Connect an Account",
"callback": "cmd://gnome-control-center online-accounts"
Expand All @@ -63,7 +59,6 @@
"resource": "/org/vanillaos/Tour/assets/end.svg",
"title": "There is More",
"description": "Find out more about all the Orchid news and features on our blog.",
"hasAction": true,
"action": {
"title": "Visit the Blog",
"callback": "url://https://vanillaos.org/blog"
Expand Down
30 changes: 17 additions & 13 deletions vanilla_tour/blp/slide.blp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ template $Slide: Adw.Bin {
spacing: 24;
halign: center;
valign: center;
hexpand: true;


Adw.Clamp {
hexpand: true;
maximum-size: 600;
tightening-threshold: 500;

Expand All @@ -24,19 +25,22 @@ template $Slide: Adw.Bin {
}
}

Label title {
margin-top: 24;
wrap: true;
justify: center;
Adw.StatusPage status_page {
Box {
halign: center;
valign: center;

styles [
"title-1",
]
}
Button btn_action {
visible: false;

Label description {
wrap: true;
justify: center;
styles [
"suggested-action",
"pill",
]
}
}
}

}
}

}
25 changes: 19 additions & 6 deletions vanilla_tour/slide.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,36 @@
#
# SPDX-License-Identifier: GPL-3.0-or-later

from gi.repository import Adw, Gtk

from gi.repository import Adw, Gtk, GLib
import webbrowser

@Gtk.Template(resource_path="/org/vanillaos/Tour/blp/slide.ui")
class Slide(Adw.Bin):
__gtype_name__ = "Slide"

title = Gtk.Template.Child()
description = Gtk.Template.Child()
status_page = Gtk.Template.Child()
assets_svg = Gtk.Template.Child()
btn_action = Gtk.Template.Child()

def __init__(self, slide, **kwargs):
super().__init__(**kwargs)
self.__slide = slide
self.__build_ui()

self.btn_action.connect("clicked", self.__on_btn_action_clicked)

def __build_ui(self):
self.assets_svg.set_resource(self.__slide["resource"])
self.title.set_label(self.__slide["title"])
self.description.set_label(self.__slide["description"])
self.status_page.set_title(self.__slide["title"])
self.status_page.set_description(self.__slide["description"])

if "action" in self.__slide:
self.btn_action.set_visible(True)
self.btn_action.set_label(self.__slide["action"]["title"])

def __on_btn_action_clicked(self, widget):
if self.__slide["action"]["callback"].startswith("url://"):
webbrowser.open(self.__slide["action"]["callback"].split("url://")[1])

elif self.__slide["action"]["callback"].startswith("cmd://"):
GLib.spawn_command_line_async(self.__slide["action"]["callback"].split("cmd://")[1])
2 changes: 1 addition & 1 deletion vanilla_tour/vanilla-tour.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<file preprocess="xml-stripblanks">assets/favorite-apps.svg</file>
<file preprocess="xml-stripblanks">assets/overview.svg</file>
<file preprocess="xml-stripblanks">assets/solid.svg</file>
<file preprocess="xml-stripblanks">assets/welcome.png</file>
<file>assets/welcome.png</file>
<file>assets/tour.json</file>
</gresource>
</gresources>

0 comments on commit d8b1fd7

Please # to comment.