Skip to content

Commit

Permalink
Add initial storage location selection page
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 2, 2024
1 parent 05a5979 commit daa9576
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 4 deletions.
8 changes: 8 additions & 0 deletions cozy/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ def last_launched_version(self) -> str:
def last_launched_version(self, new_value: str):
self._settings.set_string("last-launched-version", new_value)

@property
def first_launch(self) -> bool:
return self._settings.get_boolean("first-launch")

@first_launch.setter
def first_launch(self, new_value: bool):
self._settings.set_boolean("first-launch", new_value)

@property
def rewind_duration(self) -> int:
return self._settings.get_int("rewind-duration")
Expand Down
4 changes: 2 additions & 2 deletions cozy/ui/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def __init_window(self):
self.drop_revealer: Gtk.Revealer = self.window_builder.get_object("drop_revealer")

self.navigation_view.add(BookDetailView())

WelcomeDialog().present(self.window)
if self.application_settings.first_launch:
WelcomeDialog().present(self.window)

self.window.present()

Expand Down
15 changes: 13 additions & 2 deletions cozy/ui/widgets/welcome_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from cozy.ui.widgets.error_reporting import ErrorReporting

Check failure on line 5 in cozy/ui/widgets/welcome_dialog.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

cozy/ui/widgets/welcome_dialog.py:5:45: F401 `cozy.ui.widgets.error_reporting.ErrorReporting` imported but unused
from cozy.settings import ApplicationSettings

from cozy.ui.widgets.storages import ask_storage_location


@Gtk.Template.from_resource('/com/github/geigi/cozy/ui/welcome_dialog.ui')
class WelcomeDialog(Adw.Dialog):
Expand All @@ -15,19 +17,28 @@ class WelcomeDialog(Adw.Dialog):
carousel: Adw.Carousel = Gtk.Template.Child()
welcome_page: Adw.StatusPage = Gtk.Template.Child()
reporting_page: Gtk.Box = Gtk.Template.Child()
locations_page: Adw.StatusPage = Gtk.Template.Child()

def __init__(self):
super().__init__()
self.order = [self.welcome_page, self.reporting_page, self.welcome_page]
self.order = [self.welcome_page, self.reporting_page, self.locations_page]

@Gtk.Template.Callback()
def deny_reporting(self, _):
self.app_settings.report_level = 0
self.advance()
self.app_settings.report_level = 0

@Gtk.Template.Callback()
def accept_reporting(self, _):
self.advance()

@Gtk.Template.Callback()
def done(self, _):
self.close()

@Gtk.Template.Callback()
def choose_directory(self, _):
ask_storage_location(inject.instance("MainWindow")._set_audiobook_path, None)

def advance(self):
self.carousel.scroll_to(self.order[int(self.carousel.get_position()) + 1], True)
5 changes: 5 additions & 0 deletions data/com.github.geigi.cozy.gschema.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema path="/com/github/geigi/cozy/" id="com.github.geigi.cozy" gettext-domain="cozy">
<key type="b" name="first-launch">
<default>true</default>
<summary>Whether to show the welcome dialog</summary>
<description></description>
</key>
<key type="b" name="symlinks">
<default>false</default>
<summary>Follow symlinks</summary>
Expand Down
41 changes: 41 additions & 0 deletions data/ui/welcome_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,46 @@ template $WelcomeDialog: Adw.Dialog {
}
}
}
Adw.StatusPage locations_page {
title: _("Add Audiobooks");
margin-start: 12;
margin-end: 12;

child: Box {
orientation: vertical;
spacing: 18;

Adw.PreferencesGroup {
Adw.SwitchRow {
title: _("Create Default Audiobooks Directory");
subtitle: _("This will create a dedicated directory for audiobooks in your home directory");
}

Adw.ActionRow {
selectable: false;
activatable: true;
title: _("Audiobooks Directory");
subtitle: _("You can add more locations in the settings");

activated => $choose_directory();

[suffix]
Button {
icon-name: "folder-open-symbolic";
valign: center;
}
}
}

Button {
label: _("Done");
halign: center;

styles ["pill", "suggested-action"]

clicked => $done();
}
};
}
}
}

0 comments on commit daa9576

Please sign in to comment.