Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add scrollbar to sidebar and flowbox #35

Merged
merged 11 commits into from
Nov 2, 2023
1 change: 1 addition & 0 deletions src/components/wifi/wifiBox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use adw::glib::Object;
use adw::subclass::prelude::ObjectSubclassIsExt;
use dbus::blocking::Connection;
use dbus::Error;
use gtk::prelude::ButtonExt;

use crate::components::wifi::wifiBoxImpl;
use crate::components::wifi::wifiEntry::WifiEntry;
Expand Down
4 changes: 3 additions & 1 deletion src/components/wifi/wifiBoxImpl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cell::RefCell;
use gtk::{CompositeTemplate, glib, ListBox, ListBoxRow, Switch};
use gtk::{Button, CompositeTemplate, glib, ListBox, ListBoxRow, Revealer, Switch};
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use crate::components::wifi::wifiBox;
Expand All @@ -18,6 +18,8 @@ pub struct WifiBox {
pub resetWifiSwitch: TemplateChild<Switch>,
#[template_child]
pub resetWifiList: TemplateChild<ListBox>,
#[template_child]
pub resetWifiAdvanced: TemplateChild<Button>,
pub wifiEntries: RefCell<Vec<WifiEntry>>,
}

Expand Down
24 changes: 24 additions & 0 deletions src/components/window/handleSidebarClick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,27 @@ pub const HANDLE_MICROPHONE_CLICK: fn(FlowBox) = |resetMain: FlowBox| {
pub const HANDLE_HOME: fn(FlowBox) = |resetMain: FlowBox| {
resetMain.remove_all();
};

pub const HANDLE_PERIPHERALS_CLICK: fn(FlowBox) = |resetMain: FlowBox| {
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
};

pub const HANDLE_MONITOR_CLICK: fn(FlowBox) = |resetMain: FlowBox| {
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
};

pub const HANDLE_MOUSE_CLICK: fn(FlowBox) = |resetMain: FlowBox| {
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
};

pub const HANDLE_KEYBOARD_CLICK: fn(FlowBox) = |resetMain: FlowBox| {
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
};
1 change: 1 addition & 0 deletions src/components/window/sidebarEntryImpl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::components::window::sidebarEntry;
pub enum Categories {
Connectivity,
Audio,
Peripherals,
#[default]
Misc,
}
Expand Down
47 changes: 42 additions & 5 deletions src/components/window/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ use adw::BreakpointCondition;
use adw::glib::clone;
use adw::subclass::prelude::ObjectSubclassIsExt;
use glib::Object;
use gtk::{Application, gio, glib};
use gtk::{Application, gio, glib, ListBoxRow, Orientation};
use gtk::prelude::*;

use crate::components::window::handleSidebarClick::{
HANDLE_AUDIO_CLICK, HANDLE_BLUETOOTH_CLICK, HANDLE_CONNECTIVITY_CLICK, HANDLE_MICROPHONE_CLICK,
HANDLE_VOLUME_CLICK, HANDLE_VPN_CLICK, HANDLE_WIFI_CLICK,
};
use crate::components::window::handleSidebarClick::*;
use crate::components::window::sidebarEntry::SidebarEntry;
use crate::components::window::sidebarEntryImpl::Categories;
use crate::components::window::windowImpl;
Expand Down Expand Up @@ -171,11 +168,51 @@ impl Window {
audioList,
));

let peripheralsList = vec![
SidebarEntry::new(
"Displays",
"video-display-symbolic",
Categories::Peripherals,
true,
HANDLE_MONITOR_CLICK,
),
SidebarEntry::new(
"Mouse",
"input-mouse-symbolic",
Categories::Peripherals,
true,
HANDLE_MOUSE_CLICK,
),
SidebarEntry::new(
"Keyboard",
"input-keyboard-symbolic",
Categories::Peripherals,
true,
HANDLE_KEYBOARD_CLICK,
),
];

sidebarEntries.push((
SidebarEntry::new(
"Peripherals",
"preferences-system-devices-symbolic",
Categories::Peripherals,
false,
HANDLE_PERIPHERALS_CLICK,
),
peripheralsList,
));

for (mainEntry, subEntries) in sidebarEntries.iter() {
selfImp.resetSidebarList.append(mainEntry);
for subEntry in subEntries {
selfImp.resetSidebarList.append(subEntry);
}
let separator = ListBoxRow::new();
separator.set_child(Some(&gtk::Separator::new(Orientation::Horizontal)));
separator.set_selectable(false);
separator.set_activatable(false);
selfImp.resetSidebarList.append(&separator);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/resetBluetooth.ui
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@
<object class="GtkLabel">
<property name="halign">start</property>
<property name="justify">right</property>
<property name="label">Available device</property>
<property name="label">Available devices</property>
<property name="margin-start">5</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="min-content-height">100</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkViewport">
Expand Down Expand Up @@ -87,6 +88,7 @@
</child>
<child>
<object class="GtkScrolledWindow">
<property name="min-content-height">100</property>
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkViewport">
Expand Down
66 changes: 52 additions & 14 deletions src/resources/resetMainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,45 @@
</child>
<child>
<object class="GtkBox" id="resetPath">
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="hexpand-set">True</property>
<property name="valign">start</property>
<property name="valign">center</property>
<child>
<object class="GtkButton">
<property name="has-frame">False</property>
<property name="label">Home</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">&gt;</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="has-frame">False</property>
<property name="label">WiFi</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label">&gt;</property>
</object>
</child>
<child>
<object class="GtkButton">
<property name="has-frame">False</property>
<property name="label">Advanced</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuButton">
<property name="can-shrink">True</property>
<property name="halign">end</property>
<property name="has-frame">False</property>
<property name="hexpand-set">True</property>
<property name="icon-name">open-menu-symbolic</property>
<property name="popover">
Expand Down Expand Up @@ -88,6 +118,7 @@
<object class="GtkButton" id="resetClose">
<property name="css-classes">resetClose</property>
<property name="halign">start</property>
<property name="has-frame">False</property>
<property name="icon-name">window-close-symbolic</property>
<property name="margin-start">5</property>
</object>
Expand All @@ -97,14 +128,23 @@
</object>
</child>
<child>
<object class="GtkFlowBox" id="resetMain">
<property name="column-spacing">25</property>
<property name="hexpand">True</property>
<property name="hexpand-set">True</property>
<property name="margin-top">5</property>
<property name="row-spacing">25</property>
<property name="selection-mode">none</property>
<property name="valign">start</property>
<object class="GtkScrolledWindow">
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkViewport">
<child>
<object class="GtkFlowBox" id="resetMain">
<property name="column-spacing">25</property>
<property name="hexpand">True</property>
<property name="hexpand-set">True</property>
<property name="margin-top">5</property>
<property name="row-spacing">25</property>
<property name="selection-mode">none</property>
<property name="valign">start</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
Expand All @@ -129,12 +169,10 @@
</object>
</child>
<child>
<object class="GtkViewport">
<property name="margin-top">5</property>
<object class="GtkScrolledWindow">
<property name="propagate-natural-height">True</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="width-request">150</property>
<object class="GtkViewport">
<child>
<object class="GtkListBox" id="resetSidebarList">
<property name="css-name">resetList</property>
Expand Down
Loading
Loading