Checkboxes (#119)
* Add -c / --config argument to eww daemon * Fix for requested changes * removed comment * Added checkbox * cargo fmt
This commit is contained in:
parent
2120e76a5c
commit
6251a2bc1d
3 changed files with 30 additions and 3 deletions
|
@ -16,7 +16,9 @@ pub mod app;
|
|||
pub mod application_lifecycle;
|
||||
pub mod client;
|
||||
pub mod config;
|
||||
pub mod display_backend;
|
||||
pub mod eww_state;
|
||||
pub mod geometry;
|
||||
pub mod ipc_server;
|
||||
pub mod opts;
|
||||
pub mod script_var_handler;
|
||||
|
@ -24,8 +26,6 @@ pub mod server;
|
|||
pub mod util;
|
||||
pub mod value;
|
||||
pub mod widgets;
|
||||
pub mod geometry;
|
||||
pub mod display_backend;
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref IPC_SOCKET_PATH: std::path::PathBuf = std::env::var("XDG_RUNTIME_DIR")
|
||||
|
|
|
@ -54,7 +54,8 @@ macro_rules! loop_select {
|
|||
/// then parse it into css.
|
||||
pub fn parse_scss_from_file(path: &Path) -> Result<String> {
|
||||
let config_dir = path.parent().context("Given SCSS file has no parent directory?!")?;
|
||||
let scss_file_content = std::fs::read_to_string(path).with_context(|| { format!("Given SCSS File Doesnt Exist! {}", path.display()) })?;
|
||||
let scss_file_content =
|
||||
std::fs::read_to_string(path).with_context(|| format!("Given SCSS File Doesnt Exist! {}", path.display()))?;
|
||||
let file_content = replace_env_var_references(scss_file_content);
|
||||
let grass_config = grass::Options::default().load_path(config_dir);
|
||||
grass::from_string(file_content, &grass_config).map_err(|err| anyhow!("Encountered SCSS parsing error: {:?}", err))
|
||||
|
|
|
@ -24,6 +24,8 @@ pub(super) fn widget_to_gtk_widget(bargs: &mut BuilderArgs) -> Result<Option<gtk
|
|||
"expander" => build_gtk_expander(bargs)?.upcast(),
|
||||
"color-chooser" => build_gtk_color_chooser(bargs)?.upcast(),
|
||||
"combo-box-text" => build_gtk_combo_box_text(bargs)?.upcast(),
|
||||
"checkbox" => build_gtk_checkbox(bargs)?.upcast(),
|
||||
|
||||
_ => return Ok(None),
|
||||
};
|
||||
Ok(Some(gtk_widget))
|
||||
|
@ -197,6 +199,30 @@ fn build_gtk_expander(bargs: &mut BuilderArgs) -> Result<gtk::Expander> {
|
|||
Ok(gtk_widget)
|
||||
}
|
||||
|
||||
/// @widget a checkbox
|
||||
/// @desc A checkbox that can trigger events on checked / unchecked.
|
||||
fn build_gtk_checkbox(bargs: &mut BuilderArgs) -> Result<gtk::CheckButton> {
|
||||
let gtk_widget = gtk::CheckButton::new();
|
||||
let on_change_handler_id: Rc<RefCell<Option<glib::SignalHandlerId>>> = Rc::new(RefCell::new(None));
|
||||
resolve_block!(bargs, gtk_widget, {
|
||||
// @prop onchecked - action (command) to be executed when checked by the user
|
||||
// @prop onunchecked - similar to onchecked but when the widget is unchecked
|
||||
prop(onchecked: as_string = "", onunchecked: as_string = "") {
|
||||
let old_id = on_change_handler_id.replace(Some(
|
||||
gtk_widget.connect_toggled(move |gtk_widget| {
|
||||
if gtk_widget.get_active() {
|
||||
run_command(&onchecked, "");
|
||||
} else {
|
||||
run_command(&onunchecked, "");
|
||||
}
|
||||
})
|
||||
));
|
||||
old_id.map(|id| gtk_widget.disconnect(id));
|
||||
}
|
||||
});
|
||||
Ok(gtk_widget)
|
||||
}
|
||||
|
||||
/// @widget color-button
|
||||
/// @desc A button opening a color chooser window
|
||||
fn build_gtk_color_button(bargs: &mut BuilderArgs) -> Result<gtk::ColorButton> {
|
||||
|
|
Loading…
Add table
Reference in a new issue