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/
This commit is contained in:
Jordan Petridis
2019-05-10 17:08:35 +02:00
parent b2b0b0f2c8
commit 028e318bd3
8 changed files with 1 additions and 459 deletions
-13
View File
@@ -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", &["<primary>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", &["<primary>e"]);
// Create the menu action
let header = Rc::downgrade(&self.headerbar);
action(&self.window, "menu", move |_, _| {
-1
View File
@@ -85,7 +85,6 @@ mod widgets;
mod app;
mod config;
mod headerbar;
mod prefs;
mod manager;
mod settings;
-1
View File
@@ -52,7 +52,6 @@ podcasts_sources = files(
'i18n.rs',
'main.rs',
'manager.rs',
'prefs.rs',
'settings.rs',
'utils.rs'
)
-120
View File
@@ -1,120 +0,0 @@
// prefs.rs
//
// Copyright 2018 Measly Twerp <measlytwerp@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
//
// 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: &gtk::ApplicationWindow) {
self.dialog.set_transient_for(Some(parent));
self.dialog.set_modal(true);
self.dialog.show_all();
}
}