From 9e7a6f5ecd73fe786b930b6ac36dcc07405ee9b4 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Tue, 10 Oct 2017 01:26:16 +0300 Subject: [PATCH] IT DISPLAYS STUFF!! --- .gitignore | 1 + hammond-gtk/Cargo.toml | 3 ++- hammond-gtk/gtk/foo.ui | 2 +- hammond-gtk/src/main.rs | 17 +++++++++++++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 360b42d..94aee47 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ **/*.rs.bk Cargo.lock .vscode +*.ui~ diff --git a/hammond-gtk/Cargo.toml b/hammond-gtk/Cargo.toml index d2e7325..7d0674a 100644 --- a/hammond-gtk/Cargo.toml +++ b/hammond-gtk/Cargo.toml @@ -6,4 +6,5 @@ authors = ["Jordan Petridis "] [dependencies] gtk = { version = "0.2.0", features = ["v3_22"]} glib = "0.3.0" -gdk-pixbuf = "0.2.0" \ No newline at end of file +gdk-pixbuf = "0.2.0" +hammond-data = {path = "../hammond-data"} \ No newline at end of file diff --git a/hammond-gtk/gtk/foo.ui b/hammond-gtk/gtk/foo.ui index e9b9afc..667b011 100644 --- a/hammond-gtk/gtk/foo.ui +++ b/hammond-gtk/gtk/foo.ui @@ -9,7 +9,7 @@ World! True - + gtk-refresh True True diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs index 3ba4d60..d24441d 100644 --- a/hammond-gtk/src/main.rs +++ b/hammond-gtk/src/main.rs @@ -1,18 +1,23 @@ // extern crate glib; extern crate gtk; // extern crate gdk_pixbuf; +extern crate hammond_data; use gtk::prelude::*; use gtk::Orientation; use gtk::IconSize; // use gtk::{CellRendererText, TreeStore, TreeView, TreeViewColumn}; +use hammond_data::dbqueries; + use gtk::prelude::*; +// TODO: setup a img downloader, caching system, and then display them. fn create_child(name: &str) -> gtk::Box { let box_ = gtk::Box::new(Orientation::Vertical, 5); let img = gtk::Image::new_from_icon_name("gtk-missing-image", IconSize::Menu.into()); let label = gtk::Label::new(name); + box_.set_size_request(200, 200); box_.pack_start(&img, true, true, 0); box_.pack_start(&label, false, false, 0); box_ @@ -24,7 +29,7 @@ fn main() { return; } - // Direct copy of the way gnome-music does albumview + // Adapted copy of the way gnome-music does albumview let glade_src = include_str!("../gtk/foo.ui"); let builder = gtk::Builder::new_from_string(glade_src); @@ -41,12 +46,16 @@ fn main() { }); let flowbox: gtk::FlowBox = builder.get_object("flowbox1").unwrap(); - for _ in 0..10 { - let f = create_child("placeholder"); + + // TODO: This should be in a TreeStore. + let db = hammond_data::establish_connection(); + let podcasts = dbqueries::get_podcasts(&db).unwrap(); + + for pd in &podcasts { + let f = create_child(pd.title()); flowbox.add(&f); } - window.show_all(); gtk::main(); }