add support for markup

solves #25
This commit is contained in:
Alexander Mohr 2025-05-03 15:19:19 +02:00
parent 56bc6aeb20
commit 649fa3b6dc
2 changed files with 19 additions and 6 deletions

View file

@ -188,8 +188,9 @@ pub struct Config {
#[clap(short = 'I', long = "allow-images")] #[clap(short = 'I', long = "allow-images")]
allow_images: Option<bool>, allow_images: Option<bool>,
/// If `true` pango markup is parsed
#[clap(short = 'm', long = "allow-markup")] #[clap(short = 'm', long = "allow-markup")]
allow_markup: Option<bool>, // todo support this allow_markup: Option<bool>,
#[clap(short = 'k', long = "cache-file")] #[clap(short = 'k', long = "cache-file")]
cache_file: Option<String>, // todo support this cache_file: Option<String>, // todo support this
@ -223,8 +224,11 @@ pub struct Config {
#[clap(short = 'M', long = "matching")] #[clap(short = 'M', long = "matching")]
matching: Option<MatchMethod>, matching: Option<MatchMethod>,
/// Control if search is case insenstive or not.
/// Defaults to false
#[clap(short = 'i', long = "insensitive")] #[clap(short = 'i', long = "insensitive")]
insensitive: Option<bool>, #[serde(default = "default_true")]
insensitive: bool,
#[clap(short = 'q', long = "parse-search")] #[clap(short = 'q', long = "parse-search")]
parse_search: Option<bool>, // todo support this parse_search: Option<bool>, // todo support this
@ -249,7 +253,7 @@ pub struct Config {
sort_order: Option<String>, sort_order: Option<String>,
#[clap(short = 'Q', long = "search")] #[clap(short = 'Q', long = "search")]
search: Option<String>, // todo support this search: Option<String>,
#[clap(short = 'o', long = "monitor")] #[clap(short = 'o', long = "monitor")]
monitor: Option<String>, // todo support this monitor: Option<String>, // todo support this
@ -477,24 +481,33 @@ impl Config {
#[must_use] #[must_use]
pub fn insensitive(&self) -> bool { pub fn insensitive(&self) -> bool {
self.insensitive.unwrap_or(true) self.insensitive
} }
#[must_use] #[must_use]
pub fn hide_search(&self) -> bool { pub fn hide_search(&self) -> bool {
self.hide_search.unwrap_or(false) self.hide_search.unwrap_or(false)
} }
#[must_use] #[must_use]
pub fn search(&self) -> Option<String> { pub fn search(&self) -> Option<String> {
self.search.clone() self.search.clone()
} }
#[must_use]
pub fn allow_markup(&self) -> bool {
self.allow_markup.unwrap_or(false)
}
} }
fn default_false() -> bool { fn default_false() -> bool {
false false
} }
fn default_true() -> bool {
true
}
// //
// // TODO // // TODO
// // GtkOrientation orientation = config_get_mnemonic(config, "orientation", "vertical", 2, "vertical", "horizontal"); // // GtkOrientation orientation = config_get_mnemonic(config, "orientation", "vertical", 2, "vertical", "horizontal");
@ -508,7 +521,6 @@ fn default_false() -> bool {
// // GtkAlign valign = config_get_mnemonic(config, "valign", default_valign, 4, "fill", "start", "end", "center"); // // GtkAlign valign = config_get_mnemonic(config, "valign", default_valign, 4, "fill", "start", "end", "center");
// // char* prompt = config_get(config, "prompt", mode); // // char* prompt = config_get(config, "prompt", mode);
// // uint64_t filter_rate = strtol(config_get(config, "filter_rate", "100"), NULL, 10); // // uint64_t filter_rate = strtol(config_get(config, "filter_rate", "100"), NULL, 10);
// // allow_images = strcmp(config_get(config, "allow_images", "false"), "true") == 0;
// // allow_markup = strcmp(config_get(config, "allow_markup", "false"), "true") == 0; // // allow_markup = strcmp(config_get(config, "allow_markup", "false"), "true") == 0;
// // image_size = strtol(config_get(config, "image_size", "32"), NULL, 10); // // image_size = strtol(config_get(config, "image_size", "32"), NULL, 10);
// // cache_file = map_get(config, "cache_file"); // // cache_file = map_get(config, "cache_file");

View file

@ -801,6 +801,7 @@ fn create_menu_row<T: Clone + 'static>(
} }
let label = Label::new(Some(element_to_add.label.as_str())); let label = Label::new(Some(element_to_add.label.as_str()));
label.set_use_markup(meta.config.allow_markup());
label.set_natural_wrap_mode(meta.config.line_wrap().into()); label.set_natural_wrap_mode(meta.config.line_wrap().into());
label.set_hexpand(true); label.set_hexpand(true);