Skip to content

Commit

Permalink
feat(preferences): remove options
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr committed Sep 28, 2024
1 parent 58b3123 commit 8893542
Show file tree
Hide file tree
Showing 12 changed files with 6 additions and 214 deletions.
15 changes: 0 additions & 15 deletions data/dev.geopjr.Tuba.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@
<key name="active-account" type="s">
<default>''</default>
</key>
<key name="color-scheme" enum="dev.geopjr.Tuba.ColorScheme">
<default>'system'</default>
</key>
<key name="work-in-background" type="b">
<default>false</default>
</key>
Expand All @@ -46,18 +43,12 @@
<key name="show-spoilers" type="b">
<default>false</default>
</key>
<key name="show-preview-cards" type="b">
<default>true</default>
</key>
<key name="larger-font-size" type="b">
<default>false</default>
</key>
<key name="larger-line-height" type="b">
<default>false</default>
</key>
<key name="scale-emoji-hover" type="b">
<default>false</default>
</key>
<key name="aggressive-resolving" type="b">
<default>false</default>
</key>
Expand All @@ -67,15 +58,9 @@
<key name="letterbox-media" type="b">
<default>false</default>
</key>
<key name="media-viewer-expand-pictures" type="b">
<default>true</default>
</key>
<key name="enlarge-custom-emojis" type="b">
<default>false</default>
</key>
<key name="use-blurhash" type="b">
<default>true</default>
</key>
<key name="group-push-notifications" type="b">
<default>false</default>
</key>
Expand Down
4 changes: 2 additions & 2 deletions data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,11 @@ video > overlay > revealer > controls, .audio-controls {
.theme-autism.about .app-version{background:linear-gradient(to bottom,#e5304355,#e5304355 16.66%,#f6834755 16.66%,#f6834755 33.33%,#fac85755 33.33%,#fac85755 66.67%,#99d67155 66.67%,#99d67155 83.33%,#21ae7555 83.33%,#21ae7555);}
.theme-autism.about .app-version:hover{background:linear-gradient(to bottom,#e53043,#e53043 16.66%,#f68347 16.66%,#f68347 33.33%,#fac857 33.33%,#fac857 66.67%,#99d671 66.67%,#99d671 83.33%,#21ae75 83.33%,#21ae75);}

.lww-scale-emoji-hover .lww-emoji {
.lww-emoji {
transition-duration: 150ms;
}

.lww-scale-emoji-hover .lww-emoji:hover {
.lww-emoji:hover {
transform: scale(2);
}

Expand Down
39 changes: 0 additions & 39 deletions data/ui/dialogs/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,6 @@
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Appearance</property>
<child>
<object class="AdwComboRow" id="scheme_combo_row">
<property name="title" translatable="yes">Color Scheme</property>
<signal name="notify::selected-item" handler="on_scheme_changed" swapped="no" />

<property name="model">
<object class="TubaColorSchemeListModel" />
</property>

<property name="expression">
<lookup type="TubaColorSchemeListItem" name="name" />
</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="larger_font_size">
<property name="title" translatable="yes">Large Text</property>
Expand All @@ -52,12 +38,6 @@
<property name="title" translatable="yes">Large Custom Emojis</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="scale_emoji_hover">
<property name="title" translatable="yes">Scale Custom Emojis on Hover</property>
<property name="subtitle" translatable="yes">Slightly increases the size of custom emojis when you hover over them</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="letterbox_media">
<!-- translators: if unsure, you can find the translation on glitch-soc https://github.com/glitch-soc/mastodon/tree/main/app/javascript/flavours/glitch/locales under the key "settings.media_letterbox" -->
Expand All @@ -66,30 +46,11 @@
<property name="subtitle" translatable="yes">Scale down and letterbox media to fill the image containers instead of stretching and cropping them</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="media_viewer_expand_pictures">
<!-- translators: expand as in enlarge -->
<property name="title" translatable="yes">Expand Pictures in Media Viewer</property>
<!-- translators: expand as in enlarge -->
<property name="subtitle" translatable="yes">Expand pictures to fill the media viewer by default</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="use_blurhash">
<property name="title" translatable="no">BlurHash</property>
<property name="subtitle" translatable="yes">Show a blurred version of the media until they fully load</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="show_spoilers">
<property name="title" translatable="yes">Reveal Spoilers by Default</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="show_preview_cards">
<property name="title" translatable="yes">Show Link Preview Cards</property>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="darken_images_on_dark_mode">
<property name="title" translatable="yes">Darken Images on Dark Mode</property>
Expand Down
4 changes: 0 additions & 4 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,6 @@ namespace Tuba {
error (msg);
}

var style_manager = Adw.StyleManager.get_default ();
ColorScheme color_scheme = (ColorScheme) settings.get_enum ("color-scheme");
style_manager.color_scheme = color_scheme.to_adwaita_scheme ();

#if DEV_MODE
set_accels_for_action ("app.dev-only-window", {"F2"});
#endif
Expand Down
69 changes: 0 additions & 69 deletions src/Dialogs/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
public string event;
}

[GtkChild] unowned Adw.ComboRow scheme_combo_row;
[GtkChild] unowned Adw.ComboRow post_visibility_combo_row;
[GtkChild] unowned Adw.ComboRow default_language_combo_row;
[GtkChild] unowned Adw.ComboRow default_content_type_combo_row;
Expand All @@ -116,15 +115,11 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
[GtkChild] unowned Adw.SwitchRow live_updates;
[GtkChild] unowned Adw.SwitchRow public_live_updates;
[GtkChild] unowned Adw.SwitchRow show_spoilers;
[GtkChild] unowned Adw.SwitchRow show_preview_cards;
[GtkChild] unowned Adw.SwitchRow larger_font_size;
[GtkChild] unowned Adw.SwitchRow larger_line_height;
[GtkChild] unowned Adw.SwitchRow scale_emoji_hover;
[GtkChild] unowned Adw.SwitchRow strip_tracking;
[GtkChild] unowned Adw.SwitchRow letterbox_media;
[GtkChild] unowned Adw.SwitchRow media_viewer_expand_pictures;
[GtkChild] unowned Adw.SwitchRow enlarge_custom_emojis;
[GtkChild] unowned Adw.SwitchRow use_blurhash;
[GtkChild] unowned Adw.SwitchRow group_push_notifications;
[GtkChild] unowned Adw.SwitchRow advanced_boost_dialog;
[GtkChild] unowned Adw.SwitchRow darken_images_on_dark_mode;
Expand Down Expand Up @@ -170,17 +165,10 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
private bool lang_changed { get; set; default=false; }
private bool privacy_changed { get; set; default=false; }

static construct {
typeof (ColorSchemeListModel).ensure ();
}

construct {
proxy_entry.text = settings.proxy;
post_visibility_combo_row.model = accounts.active.visibility_list;

// Setup scheme combo row
scheme_combo_row.selected = settings.get_enum ("color-scheme");

uint default_visibility_index;
if (
accounts.active.visibility.has_key (settings.default_post_visibility)
Expand Down Expand Up @@ -285,15 +273,11 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
settings.bind ("live-updates", live_updates, "active", SettingsBindFlags.DEFAULT);
settings.bind ("public-live-updates", public_live_updates, "active", SettingsBindFlags.DEFAULT);
settings.bind ("show-spoilers", show_spoilers, "active", SettingsBindFlags.DEFAULT);
settings.bind ("show-preview-cards", show_preview_cards, "active", SettingsBindFlags.DEFAULT);
settings.bind ("larger-font-size", larger_font_size, "active", SettingsBindFlags.DEFAULT);
settings.bind ("larger-line-height", larger_line_height, "active", SettingsBindFlags.DEFAULT);
settings.bind ("scale-emoji-hover", scale_emoji_hover, "active", SettingsBindFlags.DEFAULT);
settings.bind ("strip-tracking", strip_tracking, "active", SettingsBindFlags.DEFAULT);
settings.bind ("letterbox-media", letterbox_media, "active", SettingsBindFlags.DEFAULT);
settings.bind ("media-viewer-expand-pictures", media_viewer_expand_pictures, "active", SettingsBindFlags.DEFAULT);
settings.bind ("enlarge-custom-emojis", enlarge_custom_emojis, "active", SettingsBindFlags.DEFAULT);
settings.bind ("use-blurhash", use_blurhash, "active", SettingsBindFlags.DEFAULT);
settings.bind ("group-push-notifications", group_push_notifications, "active", SettingsBindFlags.DEFAULT);
settings.bind ("advanced-boost-dialog", advanced_boost_dialog, "active", SettingsBindFlags.DEFAULT);
settings.bind ("darken-images-on-dark-mode", darken_images_on_dark_mode, "active", SettingsBindFlags.DEFAULT);
Expand All @@ -309,15 +293,6 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
default_language_combo_row.disconnect (dlcr_id);
}

[GtkCallback]
private void on_scheme_changed () {
var selected_item = (ColorSchemeListItem) scheme_combo_row.selected_item;
var style_manager = Adw.StyleManager.get_default ();

style_manager.color_scheme = selected_item.adwaita_scheme;
settings.color_scheme = selected_item.color_scheme;
}

[GtkCallback]
private void add_keyword_row () {
var dlg = new Dialogs.FilterEdit (this);
Expand Down Expand Up @@ -455,47 +430,3 @@ public class Tuba.Dialogs.Preferences : Adw.PreferencesDialog {
}
}
}

public class Tuba.ColorSchemeListModel : Object, ListModel {
private Gee.ArrayList<ColorSchemeListItem> array = new Gee.ArrayList<ColorSchemeListItem> ();

construct {
array.add (new ColorSchemeListItem (SYSTEM));
array.add (new ColorSchemeListItem (LIGHT));
array.add (new ColorSchemeListItem (DARK));
}

public Object? get_item (uint position) requires (position < array.size) {
return array.get ((int) position);
}

public Type get_item_type () {
return typeof (ColorSchemeListItem);
}

public uint get_n_items () {
return array.size;
}

public Object? get_object (uint position) {
return get_item (position);
}
}

public class Tuba.ColorSchemeListItem : Object {
public ColorScheme color_scheme { get; construct; }
public string name {
owned get {
return color_scheme.to_string ();
}
}
public Adw.ColorScheme adwaita_scheme {
get {
return color_scheme.to_adwaita_scheme ();
}
}

public ColorSchemeListItem (ColorScheme color_scheme) {
Object (color_scheme: color_scheme);
}
}
45 changes: 0 additions & 45 deletions src/Services/Settings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,17 @@ public class Tuba.Settings : GLib.Settings {
}
}

public ColorScheme color_scheme { get; set; }
public bool work_in_background { get; set; }
public int timeline_page_size { get; set; }
public bool live_updates { get; set; }
public bool public_live_updates { get; set; }
public bool show_spoilers { get; set; }
public bool show_preview_cards { get; set; }
public bool larger_font_size { get; set; }
public bool larger_line_height { get; set; }
public bool scale_emoji_hover { get; set; }
public bool aggressive_resolving { get; set; }
public bool strip_tracking { get; set; }
public bool letterbox_media { get; set; }
public bool media_viewer_expand_pictures { get; set; }
public bool enlarge_custom_emojis { get; set; }
public bool use_blurhash { get; set; }
public bool group_push_notifications { get; set; }
public bool advanced_boost_dialog { get; set; }
public bool reply_to_old_post_reminder { get; set; }
Expand All @@ -131,21 +126,16 @@ public class Tuba.Settings : GLib.Settings {

private static string[] keys_to_init = {
"active-account",
"color-scheme",
"timeline-page-size",
"live-updates",
"public-live-updates",
"show-spoilers",
"show-preview-cards",
"larger-font-size",
"larger-line-height",
"aggressive-resolving",
"strip-tracking",
"scale-emoji-hover",
"letterbox-media",
"media-viewer-expand-pictures",
"enlarge-custom-emojis",
"use-blurhash",
"group-push-notifications",
"advanced-boost-dialog",
"reply-to-old-post-reminder",
Expand Down Expand Up @@ -187,38 +177,3 @@ public class Tuba.Settings : GLib.Settings {
this.apply ();
}
}

public enum Tuba.ColorScheme {
SYSTEM,
LIGHT,
DARK;

public string to_string () {
switch (this) {
case SYSTEM:
// translators: Follow System's dark mode preference
return _("Follow System");
case LIGHT:
// translators: Light mode theme
return _("Light");
case DARK:
// translators: Dark mode theme
return _("Dark");
default:
assert_not_reached ();
}
}

public Adw.ColorScheme to_adwaita_scheme () {
switch (this) {
case SYSTEM:
return DEFAULT;
case LIGHT:
return FORCE_LIGHT;
case DARK:
return FORCE_DARK;
default:
assert_not_reached ();
}
}
}
15 changes: 3 additions & 12 deletions src/Views/MediaViewer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,13 @@ public class Tuba.Views.MediaViewer : Gtk.Widget, Gtk.Buildable, Adw.Swipeable {
public void zoom (double zoom_level, int? old_width = null, int? old_height = null) {
// Don't zoom on video
if (is_video || is_audio) return;
if ((zoom_level > 1.0 && !can_zoom_in) || (zoom_level < 1.0 && !can_zoom_out && settings.media_viewer_expand_pictures) || zoom_level == 1.0) return;
if ((zoom_level > 1.0 && !can_zoom_in) || (zoom_level < 1.0 && !can_zoom_out) || zoom_level == 1.0) return;

var new_width = (old_width ?? child_width) * zoom_level;
var new_height = (old_height ?? child_height) * zoom_level;

if (settings.media_viewer_expand_pictures) {
if (new_width < scroller.hadjustment.page_size) new_width = scroller.hadjustment.page_size;
if (new_height < scroller.vadjustment.page_size) new_height = scroller.vadjustment.page_size;
} else {
if (new_width < 0) new_width = -1;
if (new_height < 0) new_height = -1;
}
if (new_width < scroller.hadjustment.page_size) new_width = scroller.hadjustment.page_size;
if (new_height < scroller.vadjustment.page_size) new_height = scroller.vadjustment.page_size;

child_widget.set_size_request ((int) new_width, (int) new_height);

Expand Down Expand Up @@ -1069,10 +1064,6 @@ public class Tuba.Views.MediaViewer : Gtk.Widget, Gtk.Buildable, Adw.Swipeable {
} else {
var picture = new Gtk.Picture ();

if (!settings.media_viewer_expand_pictures) {
picture.valign = picture.halign = Gtk.Align.CENTER;
}

item = new Item (picture, final_friendly_url, final_preview);
item.zoom_changed.connect (on_zoom_change);

Expand Down
1 change: 0 additions & 1 deletion src/Views/Timeline.vala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public class Tuba.Views.Timeline : AccountHolder, Streamable, Views.ContentBase
}

settings.notify["show-spoilers"].connect (on_refresh);
settings.notify["show-preview-cards"].connect (on_refresh);
settings.notify["enlarge-custom-emojis"].connect (on_refresh);

#if !USE_LISTVIEW
Expand Down
Loading

0 comments on commit 8893542

Please sign in to comment.