Skip to content

Commit

Permalink
enforce code styling
Browse files Browse the repository at this point in the history
  • Loading branch information
alissonlauffer committed Mar 1, 2023
1 parent e52ba1b commit 80aa992
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.po diff=po
*.po diff=po
2 changes: 1 addition & 1 deletion .github/workflows/spot-quality.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: spot-quality

on:
push:
push:
pull_request:

jobs:
Expand Down
2 changes: 1 addition & 1 deletion ARTISTS
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Tobias Bernard
Noëlle
Noëlle
2 changes: 1 addition & 1 deletion AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ Warren Hu
bbb651
Julius Rüberg
janbrummer
Alisson Lauffer
Alisson Lauffer
2 changes: 1 addition & 1 deletion TRANSLATORS
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Amor Ali
Seioo Inoue
Dmitry
Julius Rüberg
Francesco Babetto
Francesco Babetto
2 changes: 1 addition & 1 deletion cargo-sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -4783,4 +4783,4 @@
"dest": "cargo",
"dest-filename": "config"
}
]
]
2 changes: 1 addition & 1 deletion data/dev.alextren.Spot.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,4 @@
</description>
</release>
</releases>
</component>
</component>
2 changes: 1 addition & 1 deletion data/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif
appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
test(
'Validate appstream appdata',
'Validate appstream appdata',
appstream_util,
args: ['validate-relax', meson.current_source_dir() / 'dev.alextren.Spot.appdata.xml']
)
Expand Down
2 changes: 1 addition & 1 deletion dev.alextren.Spot.development.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion dev.alextren.Spot.snapshots.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
]
}
]
}
}
2 changes: 1 addition & 1 deletion doc/.latexmkrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$pdf_mode = 1;
$pdf_previewer = '';
$pdflatex = 'lualatex -interaction=nonstopmode -synctex=1 -shell-escape %O %S';
$out_dir = 'target';
$out_dir = 'target';
2 changes: 1 addition & 1 deletion doc/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM atrendel/doxerlive:15-basic
RUN apk add gettext py3-pygments
ADD Makefile /var/doxerlive/
RUN make install
RUN make install
2 changes: 1 addition & 1 deletion doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ install:
tlmgr install $(DEPENDENCIES)

clean:
latexmk -C
latexmk -C
24 changes: 12 additions & 12 deletions doc/doc.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
\usetikzlibrary{shapes}
\usetikzlibrary{positioning}

\tikzstyle{box}=[fill=black, solid, line width=0mm, text=white, rounded corners=2mm, font={\bfseries}, inner sep=3mm]
\tikzstyle{box}=[fill=black, solid, line width=0mm, text=white, rounded corners=2mm, font={\bfseries}, inner sep=3mm]
\tikzstyle{sizedbox}=[box, text width=3cm, anchor=north, align=center]
\tikzstyle{link}=[->, >=latex, line width=.5mm, rounded corners, shorten >=1pt]
\tikzstyle{smalllink}=[->, >=latex, line width=.2mm, rounded corners, shorten >=1pt, dashed, gray]
Expand All @@ -31,12 +31,12 @@ \subsection{Overview}

\paragraph{Centralized.} That state is centralized and unique. This allows various parts of the application to access any part of it, and conversely makes it easy to perform state updates that affect various and sometimes unrelated parts of the application.

\paragraph{Controlled mutations.} There is only one way to modify the app state, and that is by dispatching \emph{actions} -- plain structs that represent a mutation to the state. Updates to the state produce \emph{events}, which \texttt{EventListeners} can use to update the UI.
\paragraph{Controlled mutations.} There is only one way to modify the app state, and that is by dispatching \emph{actions} -- plain structs that represent a mutation to the state. Updates to the state produce \emph{events}, which \texttt{EventListeners} can use to update the UI.

\begin{figure}[!h]

\centering

\begin{tikzpicture}

\node[box, fill=spotifygreen, minimum height=2cm] (model) at (0, 0) {\ttfamily AppModel};
Expand All @@ -57,7 +57,7 @@ \subsection{Overview}

This draws heavy inspiration from the Flux architecture\footnote{See https://facebook.github.io/flux/docs/in-depth-overview for instance}; the one big difference here is that there is no way to automatically find out which portion of the UI should be updated. Instead, listeners are responsible for figuring out the updates to apply based on the events.

It should be noted that the app state is only readable from the main thread for simplicity.
It should be noted that the app state is only readable from the main thread for simplicity.

\subsection{How actions are handled}

Expand All @@ -67,7 +67,7 @@ \subsection{How actions are handled}
let events = self.model.update_state(action);

for event in events.iter() {
for listener in self.listeners.iter_mut() {
for listener in self.listeners.iter_mut() {
listener.on_event(event);
}
}
Expand All @@ -81,18 +81,18 @@ \subsection{How actions are handled}

\subsection{A listener: the player subsystem}

Any element that wishes to update the state or react to changes from the state has to follow that same pattern. For instance, the ``player'' part of Spot receives \texttt{Commands} (mapped from events by a \texttt{PlayerNotifier}) to start playing music, and dispatches actions back the app through a \texttt{SpotifyPlayerDelegate} (see figure \ref{fig:player}).
Any element that wishes to update the state or react to changes from the state has to follow that same pattern. For instance, the ``player'' part of Spot receives \texttt{Commands} (mapped from events by a \texttt{PlayerNotifier}) to start playing music, and dispatches actions back the app through a \texttt{SpotifyPlayerDelegate} (see figure \ref{fig:player}).

These two extra elements add some indirection so that the player is not too strongly coupled to the rest of the app (it does not and should not care about most events, afterall!). Moreover, those commands are handled in a separate thread where the player lives.

\begin{figure}[!ht]
\centering

\begin{tikzpicture}

\node[box, fill=spotifygreen, minimum height=2cm] (model) at (0, 0) {\ttfamily AppModel};

\draw[smalllink] (-5, -3) node[sizedbox] (listeners) {Components}
\draw[smalllink] (-5, -3) node[sizedbox] (listeners) {Components}
-- +(0, -1.5) node[right] {update}
-- +(0, -2) node[sizedbox] (ui) {Gtk widgets};

Expand Down Expand Up @@ -131,7 +131,7 @@ \section{Components}

\subsection{Overview}

Components are thin wrappers around Gtk widgets, dedicated to binding them so that they produce the right actions, and updating them when specific events occur by conforming to \texttt{EventListener}.
Components are thin wrappers around Gtk widgets, dedicated to binding them so that they produce the right actions, and updating them when specific events occur by conforming to \texttt{EventListener}.

\subsection{Modeling interactions}

Expand All @@ -144,12 +144,12 @@ \subsection{Modeling interactions}
}
\end{minted}

What we need to make our button work is a way to know its current state (is a song playing?) and a way to change that state (toggling on activation). Note that it would be tempting to simply query the widget's state, which \emph{should} be in sync with the actual playback state, but what we should really do instead is query the app state, which is the one source of truth for anything state-related.
What we need to make our button work is a way to know its current state (is a song playing?) and a way to change that state (toggling on activation). Note that it would be tempting to simply query the widget's state, which \emph{should} be in sync with the actual playback state, but what we should really do instead is query the app state, which is the one source of truth for anything state-related.

Why do this? First, toggling the playback might fail (e.g. if no song is playing), but more importantly something else could alter the playback state (e.g. a DBUS query).

\begin{minted}{rust}
fn is_playing(&self) -> bool {
fn is_playing(&self) -> bool {
self.app_model.get_state().playback.is_playing()
}
\end{minted}
Expand Down Expand Up @@ -188,4 +188,4 @@ \subsection{Binding the widget}
}
\end{minted}

\end{document}
\end{document}
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
option('offline', type: 'boolean', value: true)
option('features', type: 'string', value: '')
option('features', type: 'string', value: '')
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#use_small_heuristics = "Max"
newline_style = "Unix"
use_field_init_shorthand = true
use_field_init_shorthand = true
2 changes: 1 addition & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

.playlist__title-entry--ro {
background: none;
}
}
2 changes: 1 addition & 1 deletion src/app/components/artist_details/artist_details.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ listview.artist__top-tracks row {

.artist__loaded {
opacity: 1;
}
}
2 changes: 1 addition & 1 deletion src/app/components/details/album_header.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ headerbar.details__headerbar windowtitle {

.details__headerbar.flat {
background-color: @view_bg_color;
}
}
20 changes: 10 additions & 10 deletions src/app/components/login/login.blp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ template LoginWindow : Adw.Window {
Adw.HeaderBar {
[title]
Label {}

styles ["flat"]
}

Expand All @@ -30,13 +30,13 @@ template LoginWindow : Adw.Window {
margin-start: 16;
margin-end: 16;
spacing: 24;

Image {
icon-name: "dev.alextren.Spot";
pixel-size: 128;
margin-bottom: 20;
}

Box{
hexpand: true;
orientation: vertical;
Expand All @@ -47,7 +47,7 @@ template LoginWindow : Adw.Window {
halign: center;
styles ["title-1"]
}

Label {
/* Translators: Login window title, must mention Premium (a premium account is required). */
label: _("Login with your Spotify Account. A Spotify Premium subscription is required to use Spot.");
Expand All @@ -57,20 +57,20 @@ template LoginWindow : Adw.Window {
styles ["body"]
}
}

ListBox {
styles ["boxed-list"]

Adw.EntryRow username {
/* Translators: Placeholder for the username field */
title: _("Username");
}

Adw.PasswordEntryRow password {
/* Translators: Placeholder for the password field */
title: _("Password");
}
}
}

Revealer auth_error_container {
vexpand: true;
Expand All @@ -86,7 +86,7 @@ template LoginWindow : Adw.Window {
styles ["error"]
}
}

Button login_button {
/* Translators: Log in button label */
label: _("Log in");
Expand All @@ -97,4 +97,4 @@ template LoginWindow : Adw.Window {
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/app/components/playlist_details/playlist_header.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ headerbar.playlist_details__headerbar windowtitle {

.playlist_details__headerbar.flat {
background-color: @view_bg_color;
}
}
2 changes: 1 addition & 1 deletion src/app/components/selection/selection_toolbar.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.selection_toolbar {
background: @theme_bg_color;
}
}
2 changes: 1 addition & 1 deletion src/app/components/settings/settings.blp
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ template SettingsWindow : Adw.PreferencesWindow {
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/spot.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@
<file compressed="true" preprocess="xml-stripblanks" alias="playlist2-symbolic.svg">app/components/selection/icons/playlist2-symbolic.svg</file>
<file compressed="true" preprocess="xml-stripblanks" alias="library-music-symbolic.svg">app/components/sidebar/icons/library-music-symbolic.svg</file>
</gresource>
</gresources>
</gresources>
2 changes: 1 addition & 1 deletion subprojects/blueprint-compiler.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ revision = v0.6.0
depth = 1

[provide]
program_names = blueprint-compiler
program_names = blueprint-compiler

0 comments on commit 80aa992

Please sign in to comment.