Commit 0bf4d3ad authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

Add a "Clear" button

parent fe941ece
......@@ -58,6 +58,19 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="clear_button">
<property name="label" translatable="yes">Clear</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<child>
......
......@@ -56,6 +56,23 @@ pub fn new_window(
grid_da.set_from_file(path);
}));
let grid_da: gtk::Image = builder.get_object("grid_da").expect("grid_da not found");
let btn_clear: gtk::Button = builder
.get_object("clear_button")
.expect("clear_button not found");
btn_clear.connect_clicked(clone!(cmd_chan, update_chan => move |_| {
cmd_chan.read().unwrap().send(BackendCommand::Clear).unwrap();
let mut path = String::new();
match update_chan.read().unwrap().recv().unwrap() {
BackendUpdate::NewState(p) => path = p,
BackendUpdate::Err(msg) => println!("Error: {}", msg),
}
grid_da.set_from_file(path);
}));
let mnu_about: gtk::MenuItem = builder
.get_object("about_menu")
.expect("about_menu not found");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment