From 02b218fddd79a353281bfc9472ee212fbd058d3d Mon Sep 17 00:00:00 2001 From: "Sebastian H. Gabrielli" Date: Sun, 19 Jun 2022 00:11:16 +0200 Subject: [PATCH] Color picker added, does not function yet --- .vscode/launch.json | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 18 +++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..4d36162 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,45 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug executable 'keyboard_control_software'", + "cargo": { + "args": [ + "build", + "--bin=keyboard_control_software", + "--package=keyboard_control_software" + ], + "filter": { + "name": "keyboard_control_software", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + }, + { + "type": "lldb", + "request": "launch", + "name": "Debug unit tests in executable 'keyboard_control_software'", + "cargo": { + "args": [ + "test", + "--no-run", + "--bin=keyboard_control_software", + "--package=keyboard_control_software" + ], + "filter": { + "name": "keyboard_control_software", + "kind": "bin" + } + }, + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index f62dfd9..b305b0c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ extern crate json; use colored::Colorize; use std::path::Path; -use gtk::prelude::*; +use gtk::{prelude::*, Window}; use gtk::{Application, ApplicationWindow, Button, ListBox}; #[derive(Debug)] @@ -159,6 +159,22 @@ fn build_ui(app: &Application) { .build(); button.connect_clicked(move |button| { + let color = gtk::ColorChooserDialog::builder() + .default_width(400) + .default_height(200) + .name("Color picker") + .visible(true) + .use_alpha(true) + .use_header_bar(1) + .hide_on_close(true) + .build(); + + color.display(); + + color.connect_color_activated(move |color, rgba| { + println!("The selected color is: {}", rgba); + }); + println!("The label of the button is {}", button.label().unwrap()); });