Merge branch 'alatiera/nuke-preferences' into 'master'
app: remove preferences dialog Closes #67 See merge request World/podcasts!104
This commit is contained in:
commit
a5be789745
@ -18,11 +18,6 @@
|
||||
</item>
|
||||
</section>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Preferences</attribute>
|
||||
<attribute name="action">win.preferences</attribute>
|
||||
<attribute name="accel"><primary>e</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes">_Keyboard Shortcuts</attribute>
|
||||
<attribute name="action">win.show-help-overlay</attribute>
|
||||
|
||||
@ -18,13 +18,6 @@
|
||||
<property name="title" translatable="yes" context="shortcut window">Check for new episodes</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">True</property>
|
||||
<property name="accelerator"><primary>e</property>
|
||||
<property name="title" translatable="yes" context="shortcut window">Preferences</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkShortcutsShortcut">
|
||||
<property name="visible">True</property>
|
||||
@ -37,4 +30,4 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
</interface>
|
||||
|
||||
@ -1,310 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.0
|
||||
|
||||
Copyright (C) 2017 - 2018
|
||||
|
||||
This file is part of GNOME Podcasts.
|
||||
|
||||
GNOME Podcasts 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.
|
||||
|
||||
GNOME Podcasts 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 GNOME Podcasts. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Authors:
|
||||
Jordan Petridis
|
||||
Tobias Bernard
|
||||
|
||||
-->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<!-- interface-license-type gplv3 -->
|
||||
<!-- interface-name GNOME Podcasts -->
|
||||
<!-- interface-description A podcast client for the GNOME Desktop -->
|
||||
<!-- interface-copyright 2017 - 2018 -->
|
||||
<!-- interface-authors Jordan Petridis\nTobias Bernard -->
|
||||
<object class="GtkAdjustment" id="cleanup_value_adj">
|
||||
<property name="lower">1</property>
|
||||
<property name="upper">100</property>
|
||||
<property name="value">1</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="prefs">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Preferences</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="min_content_width">480</property>
|
||||
<property name="min_content_height">200</property>
|
||||
<property name="propagate_natural_width">True</property>
|
||||
<property name="propagate_natural_height">True</property>
|
||||
<child>
|
||||
<object class="GtkViewport">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="shadow_type">none</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_top">10</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="label" translatable="yes">Appearance</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="width_request">450</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<property name="activate_on_single_click">False</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="height_request">50</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="activatable">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_start">6</property>
|
||||
<property name="margin_end">6</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Dark Theme</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSwitch" id="dark_toggle">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="valign">center</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="margin_top">20</property>
|
||||
<property name="margin_bottom">5</property>
|
||||
<property name="label" translatable="yes">Delete played episodes</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="width_request">300</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label_xalign">0</property>
|
||||
<property name="shadow_type">in</property>
|
||||
<child>
|
||||
<object class="GtkAlignment">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkListBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="selection_mode">none</property>
|
||||
<property name="activate_on_single_click">False</property>
|
||||
<child>
|
||||
<object class="GtkListBoxRow">
|
||||
<property name="width_request">100</property>
|
||||
<property name="height_request">50</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="activatable">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_start">6</property>
|
||||
<property name="margin_end">6</property>
|
||||
<property name="margin_top">6</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">After</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkSpinButton" id="cleanup_value">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="input_purpose">digits</property>
|
||||
<property name="adjustment">cleanup_value_adj</property>
|
||||
<property name="climb_rate">1</property>
|
||||
<property name="value">1</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkComboBox" id="cleanup_type">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="label_item">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="titlebar">
|
||||
<object class="GtkHeaderBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Preferences</property>
|
||||
<property name="show_close_button">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkAdjustment" id="refresh_value_adj">
|
||||
<property name="lower">1</property>
|
||||
<property name="upper">100</property>
|
||||
<property name="value">1</property>
|
||||
<property name="step_increment">1</property>
|
||||
<property name="page_increment">10</property>
|
||||
</object>
|
||||
</interface>
|
||||
@ -14,7 +14,6 @@
|
||||
<file compressed="true" preprocess="xml-stripblanks">gtk/player_toolbar.ui</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">icons/skip-back-symbolic.svg</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">icons/skip-forward-symbolic.svg</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks">gtk/prefs.ui</file>
|
||||
<file compressed="true">gtk/style.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
@ -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 |_, _| {
|
||||
|
||||
@ -85,7 +85,6 @@ mod widgets;
|
||||
mod app;
|
||||
mod config;
|
||||
mod headerbar;
|
||||
mod prefs;
|
||||
|
||||
mod manager;
|
||||
mod settings;
|
||||
|
||||
@ -52,7 +52,6 @@ podcasts_sources = files(
|
||||
'i18n.rs',
|
||||
'main.rs',
|
||||
'manager.rs',
|
||||
'prefs.rs',
|
||||
'settings.rs',
|
||||
'utils.rs'
|
||||
)
|
||||
|
||||
@ -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: >k::ApplicationWindow) {
|
||||
self.dialog.set_transient_for(Some(parent));
|
||||
self.dialog.set_modal(true);
|
||||
self.dialog.show_all();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user