Wired add button, Fixed db refresh and changed the index API.

This commit is contained in:
Jordan Petridis
2017-10-18 05:53:52 +03:00
parent eb0ee994fe
commit 0e8ea41ca7
6 changed files with 37 additions and 26 deletions
+3 -1
View File
@@ -44,7 +44,7 @@
<property name="lines">3</property>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
@@ -78,6 +78,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
@@ -100,6 +101,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
+1 -2
View File
@@ -52,13 +52,12 @@
<child>
<object class="GtkStack" id="add-button-stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="can_focus">True</property>
<property name="interpolate_size">True</property>
<child>
<object class="GtkButton" id="add-button">
<property name="label" translatable="yes">Add</property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<style>
-1
View File
@@ -74,7 +74,6 @@
<property name="use_markup">True</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="selectable">True</property>
<property name="ellipsize">end</property>
<property name="max_width_chars">30</property>
<property name="lines">5</property>
+20 -7
View File
@@ -16,6 +16,7 @@ extern crate open;
use log::LogLevel;
use diesel::prelude::*;
use hammond_data::dbqueries;
use hammond_data::index_feed;
use hammond_data::models::Episode;
use hammond_downloader::downloader;
@@ -231,14 +232,26 @@ fn build_ui() {
let add_popover: gtk::Popover = header_build.get_object("add-popover").unwrap();
let new_url: gtk::Entry = header_build.get_object("new-url").unwrap();
let add_button: gtk::Button = header_build.get_object("add-button").unwrap();
// TODO: check if url exists in the db and lock the button
new_url.connect_changed(move |url| {
println!("{:?}", url.get_text());
});
// FIXME: Button is not clickable for some reason
add_button.connect_clicked(move |f| {
println!("{:?} feed added", f);
let add_popover_clone = add_popover.clone();
let db_clone = db.clone();
add_button.connect_clicked(move |_| {
let tempdb = db_clone.lock().unwrap();
let url = new_url.get_text().unwrap();
let _ = index_feed::insert_return_source(&tempdb, &url);
drop(tempdb);
println!("{:?} feed added", url);
// update the db
// TODO: refactor the update and spin a thread.
index_feed::index_loop(db_clone.clone(), false).unwrap();
// TODO: lock the button instead of hiding and add notification of feed added.
add_popover_clone.hide();
});
// add_button.clicked();
add_popover.hide();
add_toggle_button.set_popover(&add_popover);
@@ -255,10 +268,10 @@ fn build_ui() {
// FIXME: There appears to be a memmory leak here.
let db_clone = db.clone();
refresh_button.connect_clicked(move |_| {
let _db_clone = db_clone.clone();
// fsdaa, The things I do for the borrow checker.
let db_clone = db_clone.clone();
thread::spawn(move || {
// let tempdb = db_clone.lock().unwrap();
// hammond_data::index_feed::index_loop(*tempdb, false).unwrap();
hammond_data::index_feed::index_loop(db_clone.clone(), false).unwrap();
});
});