Hello world of flowbox child activation.
This commit is contained in:
parent
910896cc08
commit
648ac9f63f
@ -6,6 +6,7 @@ workspace = "../"
|
||||
|
||||
[dependencies]
|
||||
gtk = { version = "0.2", features = ["v3_22"]}
|
||||
gdk = "0.6"
|
||||
glib = "0.3"
|
||||
gdk-pixbuf = "0.2"
|
||||
diesel = { version = "0.16", features = ["sqlite"] }
|
||||
|
||||
@ -55,13 +55,14 @@
|
||||
<child>
|
||||
<object class="GtkFlowBox" id="flowbox1">
|
||||
<property name="name">FlowBox1</property>
|
||||
<property name="width_request">200</property>
|
||||
<property name="height_request">200</property>
|
||||
<property name="width_request">600</property>
|
||||
<property name="height_request">600</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<property name="column_spacing">5</property>
|
||||
<property name="row_spacing">5</property>
|
||||
<property name="max_children_per_line">25</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
||||
@ -13,7 +13,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkEventBox">
|
||||
<object class="GtkEventBox" id="events">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// extern crate glib;
|
||||
extern crate diesel;
|
||||
extern crate gdk;
|
||||
extern crate gdk_pixbuf;
|
||||
extern crate gtk;
|
||||
extern crate hammond_data;
|
||||
@ -16,7 +17,7 @@ use gtk::TreeStore;
|
||||
use gtk::prelude::*;
|
||||
use gdk_pixbuf::Pixbuf;
|
||||
|
||||
fn create_flowbox_child(title: &str, image_uri: Option<&str>) -> gtk::Box {
|
||||
fn create_flowbox_child(title: &str, image_uri: Option<&str>) -> gtk::FlowBoxChild {
|
||||
let build_src = include_str!("../gtk/pd_fb_child.ui");
|
||||
let builder = gtk::Builder::new_from_string(build_src);
|
||||
|
||||
@ -25,6 +26,13 @@ fn create_flowbox_child(title: &str, image_uri: Option<&str>) -> gtk::Box {
|
||||
let pd_title: gtk::Label = builder.get_object("pd_title").unwrap();
|
||||
let pd_cover: gtk::Image = builder.get_object("pd_cover").unwrap();
|
||||
|
||||
let events: gtk::EventBox = builder.get_object("events").unwrap();
|
||||
|
||||
// GDK.TOUCH_MASK
|
||||
// https://developer.gnome.org/gdk3/stable/gdk3-Events.html#GDK-TOUCH-MASK:CAPS
|
||||
// http://gtk-rs.org/docs/gdk/constant.TOUCH_MASK.html
|
||||
events.add_events(4194304);
|
||||
|
||||
pd_title.set_text(&title);
|
||||
|
||||
let imgpath = hammond_downloader::downloader::cache_image(title, image_uri);
|
||||
@ -36,7 +44,11 @@ fn create_flowbox_child(title: &str, image_uri: Option<&str>) -> gtk::Box {
|
||||
}
|
||||
};
|
||||
|
||||
box_
|
||||
let fbc = gtk::FlowBoxChild::new();
|
||||
fbc.connect_activate(|_| println!("Hello World!, child activated"));
|
||||
|
||||
fbc.add(&box_);
|
||||
fbc
|
||||
}
|
||||
|
||||
fn create_and_fill_tree_store(connection: &SqliteConnection, builder: >k::Builder) -> TreeStore {
|
||||
@ -119,6 +131,7 @@ fn main() {
|
||||
|
||||
// Adapted copy of the way gnome-music does albumview
|
||||
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);
|
||||
|
||||
@ -128,9 +141,8 @@ fn main() {
|
||||
loop {
|
||||
let title = pd_model.get_value(&iter, 1).get::<String>().unwrap();
|
||||
let image_uri = pd_model.get_value(&iter, 5).get::<String>();
|
||||
info!("{:?}", title);
|
||||
let f = create_flowbox_child(&title, image_uri.as_ref().map(|s| s.as_str()));
|
||||
|
||||
let f = create_flowbox_child(&title, image_uri.as_ref().map(|s| s.as_str()));
|
||||
flowbox.add(&f);
|
||||
|
||||
if !pd_model.iter_next(&iter) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user