adds comments

This commit is contained in:
2019-06-06 21:52:38 +02:00
parent 40b079c8e1
commit 664c10359d

View File

@@ -36,13 +36,11 @@ impl CellWidget {
fn new(pos: CellPosition, header_text: &str) -> Self {
let cell_src = include_str!("../res/cell.glade");
let builder = gtk::Builder::new_from_string(cell_src);
// Set up reactivity on buttons
// Retrieve children
let eventbox: gtk::EventBox =
builder
.get_object("cell")
.unwrap();
let header: gtk::Label =
builder
.get_object("header")
@@ -53,34 +51,35 @@ impl CellWidget {
.get_object("position")
.unwrap();
position.set_text(&format!("{}x{}", pos.0, pos.1));
// Drag-and-drop capacity
let desc_btn: gtk::Button =
builder
.get_object("desc_btn")
.unwrap();
desc_btn.set_visible(false);
// The data to be send
let targets = vec![
gtk::TargetEntry::new("text/plain", gtk::TargetFlags::SAME_APP, 0)
];
eventbox.drag_source_set(
gdk::ModifierType::MODIFIER_MASK,
&targets,
gdk::DragAction::MOVE,
);
let cell = CellWidget {
eventbox,
position,
header,
desc_btn
desc_btn,
};
// Drag-and-drop capacity
// The data to be sent
let targets = vec![
gtk::TargetEntry::new("text/plain", gtk::TargetFlags::SAME_APP, 0)
];
// Acting as source
cell.eventbox.drag_source_set(
gdk::ModifierType::MODIFIER_MASK,
&targets,
gdk::DragAction::MOVE,
);
let h = cell.header.clone();
// Send data to the drop site
cell.eventbox.connect_drag_data_get(
move |_,_,data,info,time| {
println!("Send...");
// TODO: Refactoring, this is the inverse of 'placing',
// building a PawnData instead of destructuring it.
if let Some(to_send) = h.get_text() {
data.set_text(&to_send);
}
@@ -94,7 +93,7 @@ impl CellWidget {
Self::set_content(&c, None);
}
);
// Acting as destination
cell.eventbox.drag_dest_set(
gtk::DestDefaults::ALL,
&targets,