Refactor a bit and add backlight brightness keys handling
This will only work if the video driver supports the xrandr backlight property. It's possible only Intel does this...
This commit is contained in:
@ -11,6 +11,7 @@ struct Widgets {
|
||||
blank_before_locking: gtk::SpinButton,
|
||||
new_login_command_combo: gtk::ComboBoxText,
|
||||
custom_new_login_command_entry: gtk::Entry,
|
||||
handle_brightness_keys_checkbox: gtk::CheckButton,
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
@ -190,11 +191,31 @@ fn show_ui(app: >k::Application, config: &Configuration) {
|
||||
custom_new_login_command_hbox.set_sensitive(sensitive);
|
||||
}));
|
||||
|
||||
let hbox = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.spacing(8)
|
||||
.build();
|
||||
topvbox.pack_start(&hbox, false, false, 0);
|
||||
|
||||
let spacer = gtk::Box::builder()
|
||||
.orientation(gtk::Orientation::Horizontal)
|
||||
.spacing(0)
|
||||
.build();
|
||||
label_sg.add_widget(&spacer);
|
||||
hbox.pack_start(&spacer, false, false, 0);
|
||||
|
||||
let handle_brightness_keys_checkbox = gtk::CheckButton::builder()
|
||||
.label("Handle brightness keys")
|
||||
.active(config.handle_brightness_keys)
|
||||
.build();
|
||||
hbox.pack_start(&handle_brightness_keys_checkbox, false, false, 0);
|
||||
|
||||
let widgets = Widgets {
|
||||
lock_timeout: lock_timeout_spinbutton.clone(),
|
||||
blank_before_locking: blank_before_locking_spinbutton.clone(),
|
||||
new_login_command_combo: new_login_command_combo.clone(),
|
||||
custom_new_login_command_entry: custom_new_login_command_entry.clone(),
|
||||
handle_brightness_keys_checkbox: handle_brightness_keys_checkbox.clone(),
|
||||
};
|
||||
mainwin.connect_delete_event(clone!(@strong config, @strong widgets, @strong app, @strong mainwin => move |_,_| {
|
||||
Inhibit(!confirm_cancel(&config, &widgets, &mainwin))
|
||||
@ -315,6 +336,8 @@ fn build_new_configuration(old_config: &Configuration, widgets: &Widgets) -> (Co
|
||||
},
|
||||
};
|
||||
|
||||
new_config.handle_brightness_keys = widgets.handle_brightness_keys_checkbox.is_active();
|
||||
|
||||
let changed = old_config != &new_config;
|
||||
(new_config, changed)
|
||||
}
|
||||
|
Reference in New Issue
Block a user