Skip to content

Commit 015f904

Browse files
committed
with #1186 gtk4 seemed to no longer set a min_height on the bluetoothbox, this adds a method to allow the box to grow until a limit of height is reached.
1 parent cc88560 commit 015f904

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

docs/modules/Bluetooth.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Clicking on the widget opens a popout displaying list of available devices and c
1818
| `format.connected` | `string` | ` {device_alias}` | Format string to use for the widget button when bluetooth adapter is enabled and a device is connected. |
1919
| `format.connected_battery` | `string` | ` {device_alias} • {device_battery_percent}%` | Format string to use for the widget button when bluetooth adapter is enabled, a device is connected and `{device_battery_percent}` is available. |
2020
| `popup.scrollable` | `boolean` | `true` | If true makes the popup scrollable, if false stretchable to show all of its content. |
21+
| `popup.grow_height_until` | `i32` | `250` | Grows the Height of the Popup automatically based on the content up to this limit. Usefull when scrolling is enabled. |
2122
| `popup.header` | `string` | ` Enable Bluetooth` | Format string to use for the header of popup window. |
2223
| `popup.disabled` | `string` | `{adapter_status}` | Format string to use for the message that is displayed when the adapter is not found or disabled. |
2324
| `popup.device.header` | `string` | `{device_alias}` | Format string to use for the header of device box. |

src/modules/bluetooth/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ pub struct PopupConfig {
9595
/// **Default**: `true`
9696
pub scrollable: bool,
9797

98+
/// Grow the size of the popup dynamically up till the provided maximum
99+
///
100+
/// **Default**: `250`
101+
pub grow_height_until: i32,
102+
98103
/// Format string to use for the header of popup window.
99104
///
100105
/// **Default**: `" Enable Bluetooth"`
@@ -113,6 +118,7 @@ impl Default for PopupConfig {
113118
fn default() -> Self {
114119
Self {
115120
scrollable: true,
121+
grow_height_until: 250,
116122
header: " Enable Bluetooth".to_string(),
117123
disabled: "{adapter_status}".to_string(),
118124
device: PopupDeviceConfig::default(),

src/modules/bluetooth/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ impl Module<Button> for BluetoothModule {
336336
let icon_size = self.icon_size;
337337

338338
let popup_header = self.popup.header;
339+
let popup_grow_height_until = self.popup.grow_height_until;
339340
let popup_disabled = self.popup.disabled;
340341
let device_strings = self.popup.device;
341342
let device_status = self.device_status;
@@ -353,6 +354,8 @@ impl Module<Button> for BluetoothModule {
353354
}
354355

355356
devices.set_visible(state.is_enabled());
357+
//ensure the content is at least some basic height to see at least 2 devices, everything else can be done per css: min-height
358+
devices.set_min_content_height(devices_box.height().min(popup_grow_height_until));
356359

357360
disabled.set_visible(!state.is_enabled());
358361
disabled_spinner.set_visible(

0 commit comments

Comments
 (0)