Switched back to a ListStore for now.
The dream would be to use One TStroe for all/many views, but that seem to be expensive and not pleasant to work with. Might also completly drop all stores, or at least some, since I could construct the views using just Diesel models.
This commit is contained in:
parent
970b151353
commit
a8084e1bdf
@ -24,6 +24,22 @@
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkListStore" id="PdListStore">
|
||||
<columns>
|
||||
<!-- column-name id -->
|
||||
<column type="guint"/>
|
||||
<!-- column-name title -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name description -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name link -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name image_uri -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name img -->
|
||||
<column type="GdkPixbuf"/>
|
||||
</columns>
|
||||
</object>
|
||||
<object class="GtkWindow" id="window1">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="default_width">1000</property>
|
||||
|
||||
@ -89,6 +89,31 @@ fn create_and_fill_tree_store(connection: &SqliteConnection, builder: >k::Buil
|
||||
podcast_model
|
||||
}
|
||||
|
||||
fn create_and_fill_list_store(
|
||||
connection: &SqliteConnection,
|
||||
builder: >k::Builder,
|
||||
) -> gtk::ListStore {
|
||||
let podcast_model: gtk::ListStore = builder.get_object("PdListStore").unwrap();
|
||||
|
||||
let podcasts = dbqueries::get_podcasts(connection).unwrap();
|
||||
|
||||
for pd in &podcasts {
|
||||
podcast_model.insert_with_values(
|
||||
None,
|
||||
&[0, 1, 2, 3, 4],
|
||||
&[
|
||||
&pd.id(),
|
||||
&pd.title(),
|
||||
&pd.description(),
|
||||
&pd.link(),
|
||||
&pd.image_uri().unwrap_or_default(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
podcast_model
|
||||
}
|
||||
|
||||
fn main() {
|
||||
loggerv::init_with_level(LogLevel::Info).unwrap();
|
||||
|
||||
@ -138,14 +163,15 @@ fn main() {
|
||||
let flowbox: gtk::FlowBox = builder.get_object("flowbox1").unwrap();
|
||||
|
||||
let db = hammond_data::establish_connection();
|
||||
let pd_model = create_and_fill_tree_store(&db, &builder);
|
||||
// let pd_model = create_and_fill_tree_store(&db, &builder);
|
||||
let pd_model = create_and_fill_list_store(&db, &builder);
|
||||
|
||||
let iter = pd_model.get_iter_first().unwrap();
|
||||
// this will iterate over the episodes.
|
||||
// let iter = pd_model.iter_children(&iter).unwrap();
|
||||
loop {
|
||||
let title = pd_model.get_value(&iter, 1).get::<String>().unwrap();
|
||||
let image_uri = pd_model.get_value(&iter, 5).get::<String>();
|
||||
let image_uri = pd_model.get_value(&iter, 4).get::<String>();
|
||||
|
||||
let f = create_flowbox_child(&title, image_uri.as_ref().map(|s| s.as_str()));
|
||||
let stack_clone = stack.clone();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user