Skip to content

Commit 276a6e0

Browse files
committed
feat(client-icon): move disabling it to style under none (#84)
really no point in having a separate switch for this. It includes a migration codepath to the new key Reviewed-on: https://codeberg.org/GeopJr/Turntable/pulls/84
1 parent 9e1d564 commit 276a6e0

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

data/dev.geopjr.Turntable.gschema.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,17 @@
3737
<key name="cover-scaling" type="s">
3838
<default>'linear'</default>
3939
</key>
40+
<!-- Deprecated: use client-icon-style -->
4041
<key name="client-icon-style-symbolic" type="b">
4142
<default>true</default>
4243
</key>
44+
<!-- Deprecated: use client-icon-style -->
4345
<key name="component-client-icon" type="b">
4446
<default>true</default>
4547
</key>
48+
<key name="client-icon-style" type="s">
49+
<default>'unset'</default>
50+
</key>
4651
<key name="component-cover-fit" type="b">
4752
<default>true</default>
4853
</key>

src/Utils/Settings.vala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ public class Turntable.Utils.Settings : GLib.Settings {
55
public bool component_progressbin { get; set; }
66
public bool component_extract_colors { get; set; }
77
public string window_style { get; set; }
8-
public bool client_icon_style_symbolic { get; set; }
9-
public bool component_client_icon { get; set; }
108
public bool component_cover_fit { get; set; }
119
public bool component_tonearm { get; set; }
1210
public bool component_center_text { get; set; }
@@ -18,6 +16,7 @@ public class Turntable.Utils.Settings : GLib.Settings {
1816
public string cover_size { get; set; }
1917
public string text_size { get; set; }
2018
public string cover_scaling { get; set; }
19+
public string client_icon_style { get; set; }
2120
public string[] scrobbler_allowlist { get; set; default = {}; }
2221

2322
private const string[] KEYS_TO_INIT = {
@@ -27,8 +26,6 @@ public class Turntable.Utils.Settings : GLib.Settings {
2726
"component-progressbin",
2827
"component-extract-colors",
2928
"window-style",
30-
"client-icon-style-symbolic",
31-
"component-client-icon",
3229
"component-cover-fit",
3330
"scrobbler-allowlist",
3431
"meta-dim",
@@ -40,6 +37,7 @@ public class Turntable.Utils.Settings : GLib.Settings {
4037
"component-center-text",
4138
"now-playing",
4239
"component-more-controls",
40+
"client-icon-style",
4341
"offline-scrobbling"
4442
};
4543

src/Views/Window.vala

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
55
GLib.SimpleAction component_progressbin_action;
66
GLib.SimpleAction component_extract_colors_action;
77
GLib.SimpleAction window_style_action;
8-
GLib.SimpleAction client_icon_style_symbolic_action;
9-
GLib.SimpleAction component_client_icon_action;
8+
GLib.SimpleAction client_icon_style_action;
109
GLib.SimpleAction component_cover_fit_action;
1110
GLib.SimpleAction meta_dim_action;
1211
GLib.SimpleAction text_size_action;
@@ -511,13 +510,9 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
511510
window_style_action.change_state.connect (on_change_window_style);
512511
this.add_action (window_style_action);
513512

514-
client_icon_style_symbolic_action = new GLib.SimpleAction.stateful ("client-icon-style-symbolic", GLib.VariantType.BOOLEAN, settings.client_icon_style_symbolic);
515-
client_icon_style_symbolic_action.change_state.connect (on_change_client_icon_style);
516-
this.add_action (client_icon_style_symbolic_action);
517-
518-
component_client_icon_action = new GLib.SimpleAction.stateful ("component-client-icon", null, settings.component_client_icon);
519-
component_client_icon_action.change_state.connect (on_change_component_client_icon);
520-
this.add_action (component_client_icon_action);
513+
client_icon_style_action = new GLib.SimpleAction.stateful ("client-icon-style", GLib.VariantType.STRING, settings.client_icon_style);
514+
client_icon_style_action.change_state.connect (on_change_client_icon_style);
515+
this.add_action (client_icon_style_action);
521516

522517
component_tonearm_action = new GLib.SimpleAction.stateful ("component-tonearm", null, settings.component_tonearm);
523518
component_tonearm_action.change_state.connect (on_change_component_tonearm);
@@ -551,8 +546,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
551546
settings.notify["component-progressbin"].connect (update_progressbin_from_settings);
552547
settings.notify["component-extract-colors"].connect (update_extract_colors_from_settings);
553548
settings.notify["window-style"].connect (update_window_from_settings);
554-
settings.notify["client-icon-style-symbolic"].connect (update_client_icon_from_settings);
555-
settings.notify["component-client-icon"].connect (update_component_client_icon_from_settings);
549+
settings.notify["client-icon-style"].connect (update_client_icon_style_from_settings);
556550
settings.notify["component-tonearm"].connect (update_component_tonearm_from_settings);
557551
settings.notify["component-center-text"].connect (update_component_center_text_from_settings);
558552
settings.notify["component-more-controls"].connect (update_component_more_controls_from_settings);
@@ -652,8 +646,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
652646
update_progressbin_from_settings ();
653647
update_extract_colors_from_settings ();
654648
update_window_from_settings ();
655-
update_client_icon_from_settings ();
656-
update_component_client_icon_from_settings ();
649+
update_client_icon_style_from_settings ();
657650
update_component_tonearm_from_settings ();
658651
update_component_cover_fit_from_settings ();
659652
update_meta_dim_from_settings ();
@@ -695,11 +688,6 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
695688
window_style_action.set_state (this.window_style.to_string ());
696689
}
697690

698-
private void update_client_icon_from_settings () {
699-
this.prog.client_icon_style = settings.client_icon_style_symbolic ? Widgets.ProgressBin.ClientIconStyle.SYMBOLIC : Widgets.ProgressBin.ClientIconStyle.FULL_COLOR;
700-
client_icon_style_symbolic_action.set_state (settings.client_icon_style_symbolic);
701-
}
702-
703691
private void update_meta_dim_from_settings () {
704692
if (settings.meta_dim) {
705693
if (!artist_label.has_css_class ("dim-label")) artist_label.add_css_class ("dim-label");
@@ -727,9 +715,23 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
727715
toggle_orientation_action.set_state (settings.orientation_horizontal);
728716
}
729717

730-
private void update_component_client_icon_from_settings () {
731-
this.prog.client_icon_enabled = settings.component_client_icon;
732-
component_client_icon_action.set_state (settings.component_client_icon);
718+
private void update_client_icon_style_from_settings () {
719+
// TODO: deprecated, remove in next major
720+
Widgets.ProgressBin.ClientIconStyle cis;
721+
if (settings.client_icon_style == "unset") {
722+
if (settings.get_boolean ("component-client-icon")) {
723+
cis = settings.get_boolean ("client-icon-style-symbolic") ? Widgets.ProgressBin.ClientIconStyle.SYMBOLIC : Widgets.ProgressBin.ClientIconStyle.FULL_COLOR;
724+
} else {
725+
cis = NONE;
726+
}
727+
728+
settings.client_icon_style = cis.to_string ();
729+
} else {
730+
cis = Widgets.ProgressBin.ClientIconStyle.from_string (settings.client_icon_style);
731+
}
732+
733+
this.prog.client_icon_style = cis;
734+
client_icon_style_action.set_state (cis.to_string ());
733735
}
734736

735737
private void update_component_tonearm_from_settings () {
@@ -904,13 +906,7 @@ public class Turntable.Views.Window : Adw.ApplicationWindow {
904906

905907
private void on_change_client_icon_style (GLib.SimpleAction action, GLib.Variant? value) {
906908
if (value == null) return;
907-
settings.client_icon_style_symbolic = value.get_boolean ();
908-
settings.component_client_icon = true;
909-
}
910-
911-
private void on_change_component_client_icon (GLib.SimpleAction action, GLib.Variant? value) {
912-
if (value == null) return;
913-
settings.component_client_icon = value.get_boolean ();
909+
settings.client_icon_style = value.get_string ();
914910
}
915911

916912
private void on_change_component_tonearm (GLib.SimpleAction action, GLib.Variant? value) {

src/Widgets/ControlsOverlay.vala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,6 @@ public class Turntable.Widgets.ControlsOverlay : Adw.Bin {
137137
component_submenu_model.append (_("Background Progress"), "win.component-progressbin");
138138
// translators: whether to show center the title, album and artist labels
139139
component_submenu_model.append (_("Center Text"), "win.component-center-text");
140-
// translators: whether to show a client icon in the bottom right; client = music playing app
141-
component_submenu_model.append (_("Client Icon"), "win.component-client-icon");
142140
// translators: whether to make the artist and album labels slightly transparent / less prominent
143141
component_submenu_model.append (_("Dim Metadata Labels"), "win.meta-dim");
144142
// translators: whether to fit the cover art in the cover; this will stretch or crop art that is not square
@@ -196,10 +194,11 @@ public class Turntable.Widgets.ControlsOverlay : Adw.Bin {
196194

197195
var style_submenu_model = new GLib.Menu ();
198196
var client_style_submenu_model = new GLib.Menu ();
197+
client_style_submenu_model.append (_("None"), "win.client-icon-style('none')");
199198
// translators: cover icon style; symbolic = the monochrome simplified version
200-
client_style_submenu_model.append (_("Symbolic"), "win.client-icon-style-symbolic(true)");
199+
client_style_submenu_model.append (_("Symbolic"), "win.client-icon-style('symbolic')");
201200
// translators: cover icon style
202-
client_style_submenu_model.append (_("Full Color"), "win.client-icon-style-symbolic(false)");
201+
client_style_submenu_model.append (_("Full Color"), "win.client-icon-style('full-color')");
203202
// translators: menu entry that opens a submenu; client = music playing app
204203
style_submenu_model.append_submenu (_("Client Icon"), client_style_submenu_model);
205204

src/Widgets/ProgressBin.vala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,44 @@ public class Turntable.Widgets.ProgressBin : Adw.Bin {
1010
}
1111

1212
public enum ClientIconStyle {
13+
NONE,
1314
SYMBOLIC,
1415
FULL_COLOR;
1516

1617
public string to_string () {
1718
switch (this) {
19+
case NONE: return "none";
1820
case FULL_COLOR: return "full-color";
1921
default: return "symbolic";
2022
}
2123
}
2224

2325
public static ClientIconStyle from_string (string string_style) {
2426
switch (string_style) {
27+
case "none": return NONE;
2528
case "full-color": return FULL_COLOR;
2629
default: return SYMBOLIC;
2730
}
2831
}
2932
}
3033

31-
public bool client_icon_enabled {
32-
set {
33-
client_icon_widget.visible = value;
34-
}
35-
}
36-
3734
private void update_client_icon () {
3835
string name = this.client_icon;
3936

4037
switch (this.client_icon_style) {
38+
case NONE:
39+
client_icon_widget.visible = false;
40+
break;
4141
case FULL_COLOR:
42+
client_icon_widget.visible = true;
4243
if (name.down ().has_suffix ("-symbolic")) {
4344
name = name.substring (0, name.length - 9);
4445
}
4546
if (client_icon_widget.has_css_class ("dim-label")) client_icon_widget.remove_css_class ("dim-label");
4647
break;
4748
case SYMBOLIC:
49+
client_icon_widget.visible = true;
50+
4851
if (!name.down ().has_suffix ("-symbolic")) {
4952
name = @"$name-symbolic";
5053
}

0 commit comments

Comments
 (0)