Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions anyrun/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,30 @@ impl Component for App {
}
}
},
#[local]
plugins -> gtk::Box {
set_orientation: gtk::Orientation::Vertical,

// Scrollable results
#[name = "results"]
gtk::ScrolledWindow {
set_can_focus: false,
set_css_classes: &["matches"],
set_hscrollbar_policy: gtk::PolicyType::Never,
set_vscrollbar_policy: if config.scroll {
gtk::PolicyType::Automatic
} else {
gtk::PolicyType::Never
},

set_min_content_height: config.min_results_height,
set_max_content_height: config.max_results_height,
set_css_classes: &["results"],
set_hexpand: true,

#[local]
plugins -> gtk::Box {
set_orientation: gtk::Orientation::Vertical,
set_can_focus: false,
set_css_classes: &["matches"],
set_hexpand: true,
}
}
}
}
Expand Down Expand Up @@ -459,7 +477,22 @@ impl Component for App {
}
self.plugins.broadcast(PluginBoxInput::MaybeHide);
}

// Workaround for max_content_height not taking effect
// (the full height is set by min_content_height)
let min_height = widgets.results.min_content_height();
let max_height = widgets.results.max_content_height();
let (_, natural_height, _, _) = self.plugins.widget().measure(gtk::Orientation::Vertical, -1);

let height = if max_height > 0 {
natural_height.clamp(min_height, max_height)
} else {
natural_height.max(min_height)
};

widgets.results.set_height_request(height);
}

// Handle clicked selections
AppMsg::PluginOutput(PluginBoxOutput::RowSelected(index)) => {
for (i, plugin) in self.plugins.iter().enumerate() {
Expand Down
22 changes: 22 additions & 0 deletions anyrun/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ pub struct Config {
pub width: RelativeNum,
#[serde(default = "Config::default_height")]
pub height: RelativeNum,

#[serde(default = "Config::default_min_results_height")]
pub min_results_height: i32,
#[serde(default = "Config::default_max_results_height")]
pub max_results_height: i32,

#[serde(default = "Config::default_scroll")]
pub scroll: bool,

#[serde(default = "Config::default_plugins")]
pub plugins: Vec<PathBuf>,
Expand Down Expand Up @@ -62,6 +70,17 @@ impl Config {
RelativeNum::Absolute(1)
}

fn default_min_results_height() -> i32 {
0
}
fn default_max_results_height() -> i32 {
400
}

fn default_scroll() -> bool {
false
}

fn default_plugins() -> Vec<PathBuf> {
vec![
"libapplications.so".into(),
Expand Down Expand Up @@ -137,6 +156,9 @@ impl Default for Config {
y: Self::default_y(),
width: Self::default_width(),
height: Self::default_height(),
min_results_height: Self::default_min_results_height(),
max_results_height: Self::default_max_results_height(),
scroll: Self::default_scroll(),
plugins: Self::default_plugins(),
provider: Self::default_provider(),
hide_icons: false,
Expand Down