ShowWidget: Initial implementation of a menu popup.

Re implement mark_all_episodes_as_watched functionality too.
This commit is contained in:
Jordan Petridis 2018-03-05 20:14:06 +02:00
parent bb467b7aba
commit 10db4f7210
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 37 additions and 1 deletions

View File

@ -266,4 +266,29 @@ Tobias Bernard
</packing>
</child>
</object>
<object class="GtkPopover" id="show_menu">
<property name="can_focus">False</property>
<property name="position">bottom</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkModelButton" id="mark_all_watched">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="text" translatable="yes">Mark all epiodes as Watched</property>
<property name="centered">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -62,6 +62,8 @@ impl ShowWidget {
}
pub fn init(&self, pd: Arc<Podcast>, sender: Sender<Action>) {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/show_widget.ui");
// Hacky workaround so the pd.id() can be retrieved from the `ShowStack`.
WidgetExt::set_name(&self.container, &pd.id().to_string());
@ -88,6 +90,16 @@ impl ShowWidget {
error!("Error: {}", err);
}
});
let show_menu: gtk::Popover = builder.get_object("show_menu").unwrap();
let mark_all: gtk::ModelButton = builder.get_object("mark_all_watched").unwrap();
mark_all.connect_clicked(clone!(pd, sender => move |_| {
if let Err(err) = on_played_button_clicked(&pd, sender.clone()) {
error!("Failed to mark all episodes as watched: {}", err);
}
}));
self.settings.set_popover(&show_menu);
}
/// Populate the listbox with the shows episodes.
@ -142,7 +154,6 @@ fn on_unsub_button_clicked(
Ok(())
}
#[allow(dead_code)]
fn on_played_button_clicked(pd: &Podcast, sender: Sender<Action>) -> Result<(), Error> {
dbqueries::update_none_to_played_now(pd)?;
sender.send(Action::RefreshWidget)?;