Extend TreeStore.
This commit is contained in:
parent
67a6d9ec65
commit
a4e2944622
@ -2,6 +2,28 @@
|
|||||||
<!-- Generated with glade 3.20.0 -->
|
<!-- Generated with glade 3.20.0 -->
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk+" version="3.20"/>
|
<requires lib="gtk+" version="3.20"/>
|
||||||
|
<object class="GtkTreeStore" id="FooStore">
|
||||||
|
<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 -->
|
||||||
|
<column type="GdkPixbuf"/>
|
||||||
|
<!-- column-name image_uri -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name uri -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name local_uri -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
<!-- column-name published_date -->
|
||||||
|
<column type="gchararray"/>
|
||||||
|
</columns>
|
||||||
|
</object>
|
||||||
<object class="GtkHeaderBar" id="headerbar1">
|
<object class="GtkHeaderBar" id="headerbar1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
@ -21,6 +43,21 @@
|
|||||||
<property name="position">3</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="refbutton">
|
||||||
|
<property name="label">gtk-refresh</property>
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="use_stock">True</property>
|
||||||
|
<property name="always_show_image">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="pack_type">end</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="addbutton">
|
<object class="GtkButton" id="addbutton">
|
||||||
<property name="label">gtk-add</property>
|
<property name="label">gtk-add</property>
|
||||||
@ -51,21 +88,6 @@
|
|||||||
<property name="position">2</property>
|
<property name="position">2</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="refbutton">
|
|
||||||
<property name="label">gtk-refresh</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
<property name="receives_default">True</property>
|
|
||||||
<property name="use_underline">True</property>
|
|
||||||
<property name="use_stock">True</property>
|
|
||||||
<property name="always_show_image">True</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkWindow" id="window1">
|
<object class="GtkWindow" id="window1">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
|||||||
@ -26,8 +26,10 @@ fn create_child(name: &str) -> gtk::Box {
|
|||||||
box_
|
box_
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_list_store(connection: &SqliteConnection) -> TreeStore {
|
fn create_tree_store(connection: &SqliteConnection, builder: >k::Builder) -> TreeStore {
|
||||||
let podcast_model = TreeStore::new(&[Type::String, Type::String, Type::String]);
|
// let podcast_model = TreeStore::new(&[Type::String, Type::String,
|
||||||
|
// Type::String]);
|
||||||
|
let podcast_model: TreeStore = builder.get_object("FooStore").unwrap();
|
||||||
|
|
||||||
let podcasts = dbqueries::get_podcasts(connection).unwrap();
|
let podcasts = dbqueries::get_podcasts(connection).unwrap();
|
||||||
|
|
||||||
@ -35,13 +37,27 @@ fn create_list_store(connection: &SqliteConnection) -> TreeStore {
|
|||||||
let iter = podcast_model.insert_with_values(
|
let iter = podcast_model.insert_with_values(
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
&[0, 1, 2],
|
&[0, 1, 2, 3, 5],
|
||||||
&[&pd.title(), &pd.description(), &pd.link()],
|
&[
|
||||||
|
&pd.id(),
|
||||||
|
&pd.title(),
|
||||||
|
&pd.description(),
|
||||||
|
&pd.link(),
|
||||||
|
&pd.image_uri().unwrap_or_default(),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
let episodes = dbqueries::get_pd_episodes(connection, &pd).unwrap();
|
let episodes = dbqueries::get_pd_episodes(connection, &pd).unwrap();
|
||||||
|
|
||||||
for ep in episodes {
|
for ep in episodes {
|
||||||
podcast_model.insert_with_values(Some(&iter), None, &[0], &[&ep.title().unwrap()]);
|
podcast_model.insert_with_values(
|
||||||
|
Some(&iter),
|
||||||
|
None,
|
||||||
|
&[0, 1, 2, 6, 7, 8],
|
||||||
|
&[
|
||||||
|
&ep.id(), &ep.title().unwrap(), &ep.description().unwrap_or_default(), &ep.uri(),
|
||||||
|
&ep.local_uri().unwrap_or_default(), &ep.published_date().unwrap_or_default(),
|
||||||
|
],
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,13 +76,6 @@ fn create_and_setup_view() -> TreeView {
|
|||||||
|
|
||||||
column.pack_start(&cell, true);
|
column.pack_start(&cell, true);
|
||||||
// Association of the view's column with the model's `id` column.
|
// Association of the view's column with the model's `id` column.
|
||||||
column.add_attribute(&cell, "text", 0);
|
|
||||||
tree.append_column(&column);
|
|
||||||
|
|
||||||
let column = TreeViewColumn::new();
|
|
||||||
let cell = CellRendererText::new();
|
|
||||||
|
|
||||||
column.pack_start(&cell, true);
|
|
||||||
column.add_attribute(&cell, "text", 1);
|
column.add_attribute(&cell, "text", 1);
|
||||||
tree.append_column(&column);
|
tree.append_column(&column);
|
||||||
|
|
||||||
@ -77,6 +86,13 @@ fn create_and_setup_view() -> TreeView {
|
|||||||
column.add_attribute(&cell, "text", 2);
|
column.add_attribute(&cell, "text", 2);
|
||||||
tree.append_column(&column);
|
tree.append_column(&column);
|
||||||
|
|
||||||
|
let column = TreeViewColumn::new();
|
||||||
|
let cell = CellRendererText::new();
|
||||||
|
|
||||||
|
column.pack_start(&cell, true);
|
||||||
|
column.add_attribute(&cell, "text", 3);
|
||||||
|
tree.append_column(&column);
|
||||||
|
|
||||||
tree
|
tree
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +134,7 @@ fn main() {
|
|||||||
|
|
||||||
// let flowbox: gtk::FlowBox = builder.get_object("flowbox1").unwrap();
|
// let flowbox: gtk::FlowBox = builder.get_object("flowbox1").unwrap();
|
||||||
let db = hammond_data::establish_connection();
|
let db = hammond_data::establish_connection();
|
||||||
let pd_model = create_list_store(&db);
|
let pd_model = create_tree_store(&db, &builder);
|
||||||
// let podcasts = dbqueries::get_podcasts(&db).unwrap();
|
// let podcasts = dbqueries::get_podcasts(&db).unwrap();
|
||||||
|
|
||||||
// for pd in &podcasts {
|
// for pd in &podcasts {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user