From aa982bbeac619afbb0bd34121f1b8502b912b57f Mon Sep 17 00:00:00 2001 From: "Sebastian H. Gabrielli" Date: Mon, 20 Jun 2022 00:09:38 +0200 Subject: [PATCH] Can close the dialogue now --- src/main.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index b305b0c..73549a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,6 @@ extern crate libusb; extern crate colored; extern crate json; -use colored::Colorize; use std::path::Path; use gtk::{prelude::*, Window}; @@ -31,6 +30,15 @@ struct KeyboardConfig { lighting: KeyboardLighting } +#[derive(Debug)] +struct LightingMessage { + row: u16, + col: u16, + red: u8, + green: u8, + blue: u8 +} + fn parse_config(config_path: &Path) -> KeyboardConfig{ let mut parsed_json = json::parse(&std::fs::read_to_string(config_path).unwrap()).unwrap(); @@ -171,8 +179,16 @@ fn build_ui(app: &Application) { color.display(); - color.connect_color_activated(move |color, rgba| { - println!("The selected color is: {}", rgba); + color.connect_close(move |color| { + println!("The user requested to close the window with a keybind"); + println!("{}", color.rgba()); + }); + + println!("My button label is {:?}", button.label()); + color.connect_response(move |color, response| { + println!("The user responded to the window with response type {}", response); + println!("{}", color.rgba()); + color.destroy(); }); println!("The label of the button is {}", button.label().unwrap());