From 028e318bd3dba27d87efa99ef8dfd506f28f704d Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Fri, 10 May 2019 17:03:29 +0200 Subject: [PATCH] app: remove preferences dialog The dark theme option is broken with themes that don't ship a dark variant. The episode garbage collection doesn't seem useful being configurable at all. The gsettings are still there, this just removes the ui dialog since nothing useful made it into it ever. Also, less toggles the better. http://www.islinuxaboutchoice.com/ --- podcasts-gtk/resources/gtk/hamburger.ui | 5 - podcasts-gtk/resources/gtk/help-overlay.ui | 9 +- podcasts-gtk/resources/gtk/prefs.ui | 310 --------------------- podcasts-gtk/resources/resources.xml | 1 - podcasts-gtk/src/app.rs | 13 - podcasts-gtk/src/main.rs | 1 - podcasts-gtk/src/meson.build | 1 - podcasts-gtk/src/prefs.rs | 120 -------- 8 files changed, 1 insertion(+), 459 deletions(-) delete mode 100644 podcasts-gtk/resources/gtk/prefs.ui delete mode 100644 podcasts-gtk/src/prefs.rs diff --git a/podcasts-gtk/resources/gtk/hamburger.ui b/podcasts-gtk/resources/gtk/hamburger.ui index c1f90c5..5294c0f 100644 --- a/podcasts-gtk/resources/gtk/hamburger.ui +++ b/podcasts-gtk/resources/gtk/hamburger.ui @@ -18,11 +18,6 @@
- - _Preferences - win.preferences - <primary>e - _Keyboard Shortcuts win.show-help-overlay diff --git a/podcasts-gtk/resources/gtk/help-overlay.ui b/podcasts-gtk/resources/gtk/help-overlay.ui index 2ae4b56..33c2749 100644 --- a/podcasts-gtk/resources/gtk/help-overlay.ui +++ b/podcasts-gtk/resources/gtk/help-overlay.ui @@ -18,13 +18,6 @@ Check for new episodes - - - True - <primary>e - Preferences - - True @@ -37,4 +30,4 @@ - \ No newline at end of file + diff --git a/podcasts-gtk/resources/gtk/prefs.ui b/podcasts-gtk/resources/gtk/prefs.ui deleted file mode 100644 index 7918e9b..0000000 --- a/podcasts-gtk/resources/gtk/prefs.ui +++ /dev/null @@ -1,310 +0,0 @@ - - - - - - - - - - - 1 - 100 - 1 - 1 - 10 - - - False - Preferences - dialog - - - False - vertical - 2 - - - True - True - 480 - 200 - True - True - - - True - False - none - - - True - False - center - center - vertical - - - True - False - start - 10 - 5 - Appearance - - - False - True - 0 - - - - - 450 - True - False - 0 - in - - - True - False - - - True - False - none - False - - - 50 - True - True - False - False - - - True - False - 6 - 6 - 6 - 6 - - - True - False - Dark Theme - - - False - True - 0 - - - - - True - True - center - - - False - False - end - 1 - - - - - - - - - - - - - - - - False - True - 1 - - - - - True - False - start - 20 - 5 - Delete played episodes - - - False - True - 2 - - - - - 300 - True - False - 0 - in - - - True - False - - - True - False - none - False - - - 100 - 50 - True - True - False - False - - - True - False - 6 - 6 - 6 - 6 - - - True - False - After - - - False - True - 0 - - - - - True - False - - - True - True - digits - cleanup_value_adj - 1 - 1 - - - False - True - 0 - - - - - True - False - - - False - True - 1 - - - - - - False - True - end - 1 - - - - - - - - - - - - - - - - False - True - 3 - - - - - - - - - True - True - 1 - - - - - - - True - False - Preferences - True - - - - - - - - 1 - 100 - 1 - 1 - 10 - - diff --git a/podcasts-gtk/resources/resources.xml b/podcasts-gtk/resources/resources.xml index 0ba1f91..006d9a9 100644 --- a/podcasts-gtk/resources/resources.xml +++ b/podcasts-gtk/resources/resources.xml @@ -14,7 +14,6 @@ gtk/player_toolbar.ui icons/skip-back-symbolic.svg icons/skip-forward-symbolic.svg - gtk/prefs.ui gtk/style.css diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index d7caa98..96cb8c1 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -32,7 +32,6 @@ use fragile::Fragile; use podcasts_data::Show; use crate::headerbar::Header; -use crate::prefs::Prefs; use crate::settings::{self, WindowGeometry}; use crate::stacks::{Content, PopulatedState}; use crate::utils; @@ -268,18 +267,6 @@ impl App { }); self.instance.set_accels_for_action("win.quit", &["q"]); - let weak_settings = self.settings.downgrade(); - action(&self.window, "preferences", clone!(weak_win => move |_, _| { - let (win, settings) = match (weak_win.upgrade(), weak_settings.upgrade()) { - (Some(win), Some(settings)) => (win, settings), - _ => return, - }; - - let dialog = Prefs::new(&settings); - dialog.show(&win); - })); - self.instance.set_accels_for_action("win.preferences", &["e"]); - // Create the menu action let header = Rc::downgrade(&self.headerbar); action(&self.window, "menu", move |_, _| { diff --git a/podcasts-gtk/src/main.rs b/podcasts-gtk/src/main.rs index 9a00a29..628f112 100644 --- a/podcasts-gtk/src/main.rs +++ b/podcasts-gtk/src/main.rs @@ -85,7 +85,6 @@ mod widgets; mod app; mod config; mod headerbar; -mod prefs; mod manager; mod settings; diff --git a/podcasts-gtk/src/meson.build b/podcasts-gtk/src/meson.build index 4c02888..aa9386b 100644 --- a/podcasts-gtk/src/meson.build +++ b/podcasts-gtk/src/meson.build @@ -52,7 +52,6 @@ podcasts_sources = files( 'i18n.rs', 'main.rs', 'manager.rs', - 'prefs.rs', 'settings.rs', 'utils.rs' ) diff --git a/podcasts-gtk/src/prefs.rs b/podcasts-gtk/src/prefs.rs deleted file mode 100644 index 76e627f..0000000 --- a/podcasts-gtk/src/prefs.rs +++ /dev/null @@ -1,120 +0,0 @@ -// prefs.rs -// -// Copyright 2018 Measly Twerp -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// -// SPDX-License-Identifier: GPL-3.0-or-later - -use gio; -use gio::{Settings, SettingsExt}; -use gtk; -use gtk::prelude::*; - -use crate::i18n::i18n; - -#[derive(Debug, Clone)] -pub(crate) struct Prefs { - dialog: gtk::Window, - dark_toggle: gtk::Switch, - cleanup_value: gtk::SpinButton, - cleanup_type: gtk::ComboBox, -} - -impl Default for Prefs { - fn default() -> Prefs { - let builder = gtk::Builder::new_from_resource("/org/gnome/Podcasts/gtk/prefs.ui"); - - let dialog = builder.get_object("prefs").unwrap(); - let dark_toggle = builder.get_object("dark_toggle").unwrap(); - let cleanup_value = builder.get_object("cleanup_value").unwrap(); - let cleanup_type = builder.get_object("cleanup_type").unwrap(); - - Prefs { - dialog, - dark_toggle, - cleanup_value, - cleanup_type, - } - } -} - -// TODO: Refactor components into smaller state machines -impl Prefs { - pub(crate) fn new(settings: &Settings) -> Prefs { - let h = Prefs::default(); - h.init(settings); - h - } - - pub(crate) fn init(&self, settings: &Settings) { - settings.bind( - "dark-theme", - &self.dark_toggle, - "active", - gio::SettingsBindFlags::DEFAULT, - ); - settings.bind( - "cleanup-age-time", - &self.cleanup_value, - "value", - gio::SettingsBindFlags::DEFAULT, - ); - let cleanup_p = settings.get_string("cleanup-age-period").unwrap(); - let mut cleanup_pos = 0; - let store = gtk::ListStore::new(&[gtk::Type::String]); - for (i, item) in [ - i18n("Seconds"), - i18n("Minutes"), - i18n("Hours"), - i18n("Days"), - i18n("Weeks"), - ] - .iter() - .enumerate() - { - let row: &[&dyn ToValue] = &[item]; - if item.to_lowercase() == cleanup_p { - cleanup_pos = i as u32; - } - store.insert_with_values(None, &[0], &row); - } - self.cleanup_type.set_model(Some(&store)); - let renderer = gtk::CellRendererText::new(); - self.cleanup_type.pack_start(&renderer, true); - self.cleanup_type.add_attribute(&renderer, "text", 0); - self.cleanup_type.set_active(cleanup_pos); - - let weak_settings = settings.downgrade(); - let weak_store = store.downgrade(); - // Totally the prettiest stairway you ever saw - self.cleanup_type.connect_changed(move |combo| { - if let Some(ref treeiter) = combo.get_active_iter() { - if let Some(store) = weak_store.upgrade() { - if let Some(s) = store.get_value(treeiter, 0).get::<&str>() { - if let Some(settings) = weak_settings.upgrade() { - settings.set_string("cleanup-age-period", &s.to_lowercase()); - } - } - } - }; - }); - } - - pub(crate) fn show(&self, parent: >k::ApplicationWindow) { - self.dialog.set_transient_for(Some(parent)); - self.dialog.set_modal(true); - self.dialog.show_all(); - } -}