From 52f2fa87918be28aeb6af2ceb84c04f35191b3b4 Mon Sep 17 00:00:00 2001 From: Jordan Petridis Date: Wed, 18 Oct 2017 18:32:39 +0300 Subject: [PATCH] More modulation of the gtk client. --- hammond-gtk/gtk/foo.ui | 40 +------------------ hammond-gtk/gtk/podcast_widget.ui | 16 ++++++++ hammond-gtk/src/main.rs | 8 ++-- hammond-gtk/src/views/mod.rs | 1 + hammond-gtk/src/views/podcasts_view.rs | 1 + .../{episode_widget.rs => widgets/episode.rs} | 2 +- hammond-gtk/src/widgets/mod.rs | 2 + .../{podcast_widget.rs => widgets/podcast.rs} | 12 +++--- 8 files changed, 33 insertions(+), 49 deletions(-) create mode 100644 hammond-gtk/src/views/mod.rs create mode 100644 hammond-gtk/src/views/podcasts_view.rs rename hammond-gtk/src/{episode_widget.rs => widgets/episode.rs} (97%) create mode 100644 hammond-gtk/src/widgets/mod.rs rename hammond-gtk/src/{podcast_widget.rs => widgets/podcast.rs} (84%) diff --git a/hammond-gtk/gtk/foo.ui b/hammond-gtk/gtk/foo.ui index d92bc04..23d2e19 100644 --- a/hammond-gtk/gtk/foo.ui +++ b/hammond-gtk/gtk/foo.ui @@ -2,44 +2,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - False 1000 @@ -104,7 +66,7 @@ - + diff --git a/hammond-gtk/gtk/podcast_widget.ui b/hammond-gtk/gtk/podcast_widget.ui index 44e8a04..4be262e 100644 --- a/hammond-gtk/gtk/podcast_widget.ui +++ b/hammond-gtk/gtk/podcast_widget.ui @@ -2,6 +2,22 @@ + + + + + + + + + + + + + + + + True False diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs index 0438005..3b7742e 100644 --- a/hammond-gtk/src/main.rs +++ b/hammond-gtk/src/main.rs @@ -25,10 +25,10 @@ use gtk::prelude::*; use gio::ApplicationExt; use gdk_pixbuf::Pixbuf; -pub mod podcast_widget; -pub mod episode_widget; +pub mod views; +pub mod widgets; -use podcast_widget::{create_flowbox_child, podcast_liststore, podcast_widget}; +use widgets::podcast::{create_flowbox_child, podcast_liststore, podcast_widget}; /* THIS IS STILL A PROTOTYPE. @@ -120,7 +120,7 @@ fn build_ui() { }); let tempdb = db.lock().unwrap(); - let pd_model = podcast_liststore(&tempdb, &builder); + let pd_model = podcast_liststore(&tempdb); drop(tempdb); // Get a ListStore iterator at the first element. diff --git a/hammond-gtk/src/views/mod.rs b/hammond-gtk/src/views/mod.rs new file mode 100644 index 0000000..69e01ee --- /dev/null +++ b/hammond-gtk/src/views/mod.rs @@ -0,0 +1 @@ +pub mod podcasts_view; diff --git a/hammond-gtk/src/views/podcasts_view.rs b/hammond-gtk/src/views/podcasts_view.rs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/hammond-gtk/src/views/podcasts_view.rs @@ -0,0 +1 @@ + diff --git a/hammond-gtk/src/episode_widget.rs b/hammond-gtk/src/widgets/episode.rs similarity index 97% rename from hammond-gtk/src/episode_widget.rs rename to hammond-gtk/src/widgets/episode.rs index 5189c0d..a0a61ae 100644 --- a/hammond-gtk/src/episode_widget.rs +++ b/hammond-gtk/src/widgets/episode.rs @@ -16,7 +16,7 @@ fn epidose_widget( pd_title: &str, ) -> gtk::Box { // This is just a prototype and will be reworked probably. - let builder = include_str!("../gtk/episode_widget.ui"); + let builder = include_str!("../../gtk/episode_widget.ui"); let builder = gtk::Builder::new_from_string(builder); let ep: gtk::Box = builder.get_object("episode_box").unwrap(); diff --git a/hammond-gtk/src/widgets/mod.rs b/hammond-gtk/src/widgets/mod.rs new file mode 100644 index 0000000..5752aa3 --- /dev/null +++ b/hammond-gtk/src/widgets/mod.rs @@ -0,0 +1,2 @@ +pub mod podcast; +pub mod episode; diff --git a/hammond-gtk/src/podcast_widget.rs b/hammond-gtk/src/widgets/podcast.rs similarity index 84% rename from hammond-gtk/src/podcast_widget.rs rename to hammond-gtk/src/widgets/podcast.rs index eda2051..38c6dbc 100644 --- a/hammond-gtk/src/podcast_widget.rs +++ b/hammond-gtk/src/widgets/podcast.rs @@ -7,7 +7,7 @@ use hammond_data::dbqueries; use std::sync::{Arc, Mutex}; -use episode_widget::episodes_listbox; +use widgets::episode::episodes_listbox; pub fn podcast_widget( connection: Arc>, @@ -16,7 +16,7 @@ pub fn podcast_widget( image: Option, ) -> gtk::Box { // Adapted from gnome-music AlbumWidget - let pd_widget_source = include_str!("../gtk/podcast_widget.ui"); + let pd_widget_source = include_str!("../../gtk/podcast_widget.ui"); let pd_widget_buidler = gtk::Builder::new_from_string(pd_widget_source); let pd_widget: gtk::Box = pd_widget_buidler.get_object("podcast_widget").unwrap(); @@ -44,7 +44,7 @@ pub fn podcast_widget( } pub fn create_flowbox_child(title: &str, cover: Option) -> gtk::FlowBoxChild { - let build_src = include_str!("../gtk/pd_fb_child.ui"); + let build_src = include_str!("../../gtk/pd_fb_child.ui"); let builder = gtk::Builder::new_from_string(build_src); // Copy of gnome-music AlbumWidget @@ -70,8 +70,10 @@ pub fn create_flowbox_child(title: &str, cover: Option) -> gtk::FlowBoxC fbc } -pub fn podcast_liststore(connection: &SqliteConnection, builder: >k::Builder) -> gtk::ListStore { - let podcast_model: gtk::ListStore = builder.get_object("PdListStore").unwrap(); +pub fn podcast_liststore(connection: &SqliteConnection) -> gtk::ListStore { + let builder = include_str!("../../gtk/podcast_widget.ui"); + let builder = gtk::Builder::new_from_string(builder); + let podcast_model: gtk::ListStore = builder.get_object("pd_store").unwrap(); let podcasts = dbqueries::get_podcasts(connection).unwrap();