Skip to content

Commit

Permalink
Finish up welcome dialog, correct some strings
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 3, 2024
1 parent fa75c7a commit 7215575
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 17 deletions.
26 changes: 17 additions & 9 deletions cozy/ui/widgets/welcome_dialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path
import inject
import os.path
from gi.repository import Adw, Gtk

from cozy.view_model.playback_speed_view_model import PlaybackSpeedViewModel

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

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

cozy/ui/widgets/welcome_dialog.py:6:55: F401 `cozy.view_model.playback_speed_view_model.PlaybackSpeedViewModel` imported but unused
Expand All @@ -22,24 +23,38 @@ class WelcomeDialog(Adw.Dialog):
reporting_page: Gtk.Box = Gtk.Template.Child()
locations_page: Adw.StatusPage = Gtk.Template.Child()
create_directory_switch: Adw.SwitchRow = Gtk.Template.Child()
chooser_button_label: Adw.ButtonContent = Gtk.Template.Child()

def __init__(self):
super().__init__()
self._path = None
self._order = [self.welcome_page, self.reporting_page, self.locations_page]

@Gtk.Template.Callback()
def advance(self, *_):
self.carousel.scroll_to(self._order[int(self.carousel.get_position()) + 1], True)

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

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

@Gtk.Template.Callback()
def done(self, _):
def choose_directory(self, _):
ask_storage_location(self._ask_storage_location_callback, None)

def _ask_storage_location_callback(self, path):
self._path = path
self.chooser_button_label.set_label(os.path.basename(path))

@Gtk.Template.Callback()
def done(self, __chooser_button_label):
self.close()
self.app_settings.first_launch = False

if self.create_directory_switch.props.active:
audiobooks_dir = Path.home() / _("Audiobooks")
Expand All @@ -49,10 +64,3 @@ def done(self, _):
inject.instance("MainWindow")._set_audiobook_path(self._path, default=False)
else:
inject.instance("MainWindow")._set_audiobook_path(self._path)

@Gtk.Template.Callback()
def choose_directory(self, _):
ask_storage_location(lambda path: setattr(self, "_path", path), None)

def advance(self):
self.carousel.scroll_to(self._order[int(self.carousel.get_position()) + 1], True)
4 changes: 2 additions & 2 deletions data/ui/error_reporting.blp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Adw 1;

template $ErrorReporting: Box {
orientation: vertical;
spacing: 12;
spacing: 8;

Label {
halign: fill;
Expand Down Expand Up @@ -41,7 +41,7 @@ template $ErrorReporting: Box {
selection-mode: none;

Adw.ComboRow detail_combo {
title: "Detail Level";
title: _("Detail Level");
}

Adw.ActionRow description {}
Expand Down
4 changes: 2 additions & 2 deletions data/ui/main_window.blp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Adw.ApplicationWindow app_window {

child: Adw.StatusPage {
icon-name: 'library-symbolic';
title: _("No Recent Books yet");
title: _("No Recent Books Yet");
description: _("Explore your library by switching to the Author or Reader view");
};
}
Expand Down Expand Up @@ -237,7 +237,7 @@ Adw.ApplicationWindow app_window {

content: Adw.StatusPage welcome_status_page {
icon-name: 'com.github.geigi.cozy';
title: _("Let's Get Cozy");
title: _("Let's Get Cozy!");
description: _("Select a folder, or drop audiobooks here to add them to your library");
child: Button first_import_button {
halign: center;
Expand Down
26 changes: 22 additions & 4 deletions data/ui/welcome_dialog.blp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@ template $WelcomeDialog: Adw.Dialog {
content-height: 600;

Adw.Carousel carousel {
interactive: false;

Adw.StatusPage welcome_page {
icon-name: 'com.github.geigi.cozy';
title: "Let's Get Cozy!";
hexpand: true;

Button {
halign: center;
label: _("Start!");

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

clicked => $advance();
}
}

Box reporting_page{
orientation: vertical;
spacing: 18;
spacing: 12;

Adw.StatusPage {
valign: start;
Expand All @@ -35,13 +46,15 @@ template $WelcomeDialog: Adw.Dialog {
[center]
Box {
spacing: 12;
margin-bottom: 18;
margin-bottom: 12;
homogeneous: true;

Button {
label: "I Don't Want This";
clicked => $deny_reporting();
}
Button {
label: "It's Fine With Me";
label: "It's Fine by Me";
clicked => $accept_reporting();
}
}
Expand Down Expand Up @@ -73,8 +86,13 @@ template $WelcomeDialog: Adw.Dialog {

[suffix]
Button {
icon-name: "folder-open-symbolic";
valign: center;
clicked => $choose_directory();

Adw.ButtonContent chooser_button_label {
icon-name: "folder-open-symbolic";
can-shrink: true;
}
}
}
}
Expand Down

0 comments on commit 7215575

Please sign in to comment.