Skip to content

Commit

Permalink
chore: rename libadwaita package to adw
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriele Musco committed Dec 2, 2023
1 parent 35fa139 commit da66937
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 55 deletions.
4 changes: 2 additions & 2 deletions lact-gui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = "2021"
[features]
default = ["gtk-tests"]
gtk-tests = []
libadwaita = ["dep:libadwaita"]
libadwaita = ["dep:adw"]

[dependencies]
lact-client = { path = "../lact-client" }
Expand All @@ -16,7 +16,7 @@ gtk = { version = "0.7", package = "gtk4", features = ["v4_6", "blueprint"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
anyhow = "1.0"
libadwaita = { version = "0.5.3", features = ["v1_4"], optional = true }
adw = { package = "libadwaita", version = "0.5.3", features = ["v1_4"], optional = true }

[dev-dependencies]
pretty_assertions = "1.4.0"
4 changes: 2 additions & 2 deletions lact-gui/src/app/dialogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use gtk::prelude::*;
use tracing::warn;

#[cfg(feature = "libadwaita")]
use libadwaita::prelude::MessageDialogExt;
use adw::prelude::MessageDialogExt;

#[cfg(feature = "libadwaita")]
#[macro_export]
macro_rules! info_dialog {
($parent:expr, $heading:expr, $body:expr, $response_id:expr, $response_txt:expr) => {{
let diag = libadwaita::MessageDialog::builder()
let diag = adw::MessageDialog::builder()
.heading($heading)
.body($body)
.modal(true)
Expand Down
4 changes: 2 additions & 2 deletions lact-gui/src/app/headerbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::{apply_box::ApplyBox, gpu_selector::GpuSelector};
#[derive(Debug, Clone)]
pub struct Headerbar {
#[cfg(feature = "libadwaita")]
pub container: libadwaita::HeaderBar,
pub container: adw::HeaderBar,

#[cfg(not(feature = "libadwaita"))]
pub container: gtk::HeaderBar,
Expand All @@ -15,7 +15,7 @@ pub struct Headerbar {
impl Headerbar {
pub fn new() -> Self {
#[cfg(feature = "libadwaita")]
let container = libadwaita::HeaderBar::builder().show_title(false).build();
let container = adw::HeaderBar::builder().show_title(false).build();

#[cfg(not(feature = "libadwaita"))]
let container = gtk::HeaderBar::builder()
Expand Down
26 changes: 13 additions & 13 deletions lact-gui/src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ use std::time::Duration;
use tracing::{debug, error, trace, warn};

#[cfg(feature = "libadwaita")]
use libadwaita::prelude::{AdwApplicationWindowExt, MessageDialogExt};
use adw::prelude::{AdwApplicationWindowExt, MessageDialogExt};

// In ms
const STATS_POLL_INTERVAL: u64 = 250;

#[derive(Clone)]
pub struct App {
#[cfg(feature = "libadwaita")]
application: libadwaita::Application,
application: adw::Application,
#[cfg(feature = "libadwaita")]
pub window: libadwaita::ApplicationWindow,
pub window: adw::ApplicationWindow,

#[cfg(not(feature = "libadwaita"))]
application: Application,
Expand All @@ -53,13 +53,13 @@ pub struct App {
impl App {
pub fn new(daemon_client: DaemonClient) -> Self {
#[cfg(feature = "libadwaita")]
let application = libadwaita::Application::new(Some(APP_ID), ApplicationFlags::default());
let application = adw::Application::new(Some(APP_ID), ApplicationFlags::default());

#[cfg(not(feature = "libadwaita"))]
let application = Application::new(Some(APP_ID), ApplicationFlags::default());

#[cfg(feature = "libadwaita")]
let window = libadwaita::ApplicationWindow::builder()
let window = adw::ApplicationWindow::builder()
.title("LACT")
.default_width(820)
.default_height(750)
Expand Down Expand Up @@ -94,10 +94,10 @@ impl App {

#[cfg(feature = "libadwaita")]
{
let root_view = libadwaita::ToolbarView::new();
let root_view = adw::ToolbarView::new();
root_view.add_top_bar(&headerbar.container);
root_view.add_bottom_bar(
&libadwaita::ViewSwitcherBar::builder()
&adw::ViewSwitcherBar::builder()
.reveal(true)
.stack(&root_stack.container)
.build(),
Expand Down Expand Up @@ -528,7 +528,7 @@ impl App {
#[cfg(feature = "libadwaita")]
fn enable_overclocking(&self) {
let text = format!("This will enable the overdrive feature of the amdgpu driver by creating a file at <b>{MODULE_CONF_PATH}</b>");
let dialog = libadwaita::MessageDialog::builder()
let dialog = adw::MessageDialog::builder()
.heading("Enable Overclocking")
.body_use_markup(true)
.body(text)
Expand All @@ -541,8 +541,8 @@ impl App {

dialog.add_response(res_cancel, "_Cancel");
dialog.add_response(res_ok, "_Ok");
dialog.set_response_appearance(res_cancel, libadwaita::ResponseAppearance::Destructive);
dialog.set_response_appearance(res_ok, libadwaita::ResponseAppearance::Suggested);
dialog.set_response_appearance(res_cancel, adw::ResponseAppearance::Destructive);
dialog.set_response_appearance(res_ok, adw::ResponseAppearance::Suggested);

dialog.connect_response(
None,
Expand Down Expand Up @@ -608,7 +608,7 @@ impl App {
#[cfg(feature = "libadwaita")]
fn ask_confirmation(&self, gpu_id: String, mut delay: u64) {
let text = confirmation_text(delay);
let dialog = libadwaita::MessageDialog::builder()
let dialog = adw::MessageDialog::builder()
.heading("Confirm settings")
.body(text)
.modal(true)
Expand All @@ -620,8 +620,8 @@ impl App {

dialog.add_response(res_no, "_No");
dialog.add_response(res_yes, "_Yes");
dialog.set_response_appearance(res_no, libadwaita::ResponseAppearance::Destructive);
dialog.set_response_appearance(res_yes, libadwaita::ResponseAppearance::Suggested);
dialog.set_response_appearance(res_no, adw::ResponseAppearance::Destructive);
dialog.set_response_appearance(res_yes, adw::ResponseAppearance::Suggested);
let confirmed = Rc::new(AtomicBool::new(false));

glib::source::timeout_add_local(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use gtk::{gio, glib};
#[cfg(feature = "libadwaita")]
glib::wrapper! {
pub struct VulkanFeaturesWindow(ObjectSubclass<imp::VulkanFeaturesWindow>)
@extends gtk::Box, gtk::Widget, gtk::Window, libadwaita::Window,
@extends gtk::Box, gtk::Widget, gtk::Window, adw::Window,
@implements gtk::Orientable, gtk::Accessible, gtk::Buildable;
}

Expand Down Expand Up @@ -44,12 +44,18 @@ mod imp {
use std::cell::RefCell;

#[cfg(feature = "libadwaita")]
use libadwaita::subclass::window::AdwWindowImpl;
use adw::subclass::window::AdwWindowImpl;

#[derive(CompositeTemplate, Properties, Default)]
#[properties(wrapper_type = super::VulkanFeaturesWindow)]
#[cfg_attr(feature = "libadwaita", template(file = "ui/vulkan_features_window.blp"))]
#[cfg_attr(not(feature = "libadwaita"), template(file = "ui/vulkan_features_window_gtk.blp"))]
#[cfg_attr(
feature = "libadwaita",
template(file = "ui/vulkan_features_window.blp")
)]
#[cfg_attr(
not(feature = "libadwaita"),
template(file = "ui/vulkan_features_window_gtk.blp")
)]
pub struct VulkanFeaturesWindow {
#[property(get, set)]
model: RefCell<Option<gio::ListModel>>,
Expand All @@ -71,7 +77,7 @@ mod imp {
type Type = super::VulkanFeaturesWindow;

#[cfg(feature = "libadwaita")]
type ParentType = libadwaita::Window;
type ParentType = adw::Window;

#[cfg(not(feature = "libadwaita"))]
type ParentType = gtk::Window;
Expand Down
6 changes: 3 additions & 3 deletions lact-gui/src/app/root_stack/info_page/vulkan_info/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use lact_client::schema::VulkanInfo;
use tracing::trace;

#[cfg(feature = "libadwaita")]
use libadwaita::prelude::ActionRowExt;
use adw::prelude::ActionRowExt;

#[derive(Debug, Clone)]
pub struct VulkanInfoFrame {
Expand Down Expand Up @@ -45,7 +45,7 @@ impl VulkanInfoFrame {

#[cfg(feature = "libadwaita")]
{
let features_row = libadwaita::ActionRow::builder()
let features_row = adw::ActionRow::builder()
.activatable(true)
.title("Features")
.build();
Expand All @@ -55,7 +55,7 @@ impl VulkanInfoFrame {
}));
container.append(&features_row);

let extensions_row = libadwaita::ActionRow::builder()
let extensions_row = adw::ActionRow::builder()
.activatable(true)
.title("Extensions")
.build();
Expand Down
21 changes: 12 additions & 9 deletions lact-gui/src/app/root_stack/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ use traits::BoxExt;
use traits::WidgetExt;

#[cfg(feature = "libadwaita")]
use libadwaita::prelude::ActionRowExt;
use adw::prelude::ActionRowExt;

#[derive(Debug, Clone)]
pub struct RootStack {
#[cfg(feature = "libadwaita")]
pub container: libadwaita::ViewStack,
pub container: adw::ViewStack,
#[cfg(not(feature = "libadwaita"))]
pub container: Stack,

Expand All @@ -34,7 +34,7 @@ impl RootStack {
embedded_daemon: bool,
) -> Self {
#[cfg(feature = "libadwaita")]
let container = libadwaita::ViewStack::builder()
let container = adw::ViewStack::builder()
.vexpand(true)
.hexpand(true)
.build();
Expand Down Expand Up @@ -94,7 +94,7 @@ impl RootStack {
#[derive(Debug, Clone)]
pub struct LabelRow {
#[cfg(feature = "libadwaita")]
pub container: libadwaita::ActionRow,
pub container: adw::ActionRow,

#[cfg(not(feature = "libadwaita"))]
pub container: ListBoxRow,
Expand Down Expand Up @@ -132,8 +132,8 @@ impl LabelRow {
}

#[cfg(feature = "libadwaita")]
pub fn list_clamp(child: &impl IsA<Widget>) -> libadwaita::Clamp {
libadwaita::Clamp::builder()
pub fn list_clamp(child: &impl IsA<Widget>) -> adw::Clamp {
adw::Clamp::builder()
.maximum_size(600)
.margin_top(24)
.margin_bottom(24)
Expand Down Expand Up @@ -165,8 +165,8 @@ pub fn action_row(
subtitle: Option<&str>,
suffixes: &[&impl IsA<Widget>],
css_classes: Option<&[&str]>,
) -> libadwaita::ActionRow {
let ar = libadwaita::ActionRow::builder()
) -> adw::ActionRow {
let ar = adw::ActionRow::builder()
.subtitle_lines(0)
.title(title)
.build();
Expand Down Expand Up @@ -232,5 +232,8 @@ pub fn action_row(
inner.append(*suf);
});

ListBoxRow::builder().activatable(false).child(&inner).build()
ListBoxRow::builder()
.activatable(false)
.child(&inner)
.build()
}
9 changes: 3 additions & 6 deletions lact-gui/src/app/root_stack/oc_page/clocks_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use tracing::debug;

#[cfg(feature = "libadwaita")]
use libadwaita::prelude::ActionRowExt;

const VOLTAGE_OFFSET_RANGE: f64 = 250.0;

// The AtomicBool stores if the value was changed
Expand All @@ -22,7 +19,7 @@ pub struct ClocksFrame {
heading_listbox: ListBox,

#[cfg(feature = "libadwaita")]
advanced_switch_row: libadwaita::SwitchRow,
advanced_switch_row: adw::SwitchRow,

#[cfg(not(feature = "libadwaita"))]
advanced_switch_row: Switch,
Expand Down Expand Up @@ -58,7 +55,7 @@ impl ClocksFrame {

#[cfg(feature = "libadwaita")]
let advanced_switch_row = {
let row = libadwaita::SwitchRow::builder()
let row = adw::SwitchRow::builder()
.title("Advanced mode")
.active(false)
.build();
Expand Down Expand Up @@ -394,7 +391,7 @@ fn oc_adjustment(title: &'static str, listbox: &ListBox) -> (Adjustment, Rc<Atom
let adjustment = Adjustment::new(0.0, 0.0, 0.0, 1.0, 10.0, 0.0);

#[cfg(feature = "libadwaita")]
let value_selector = libadwaita::SpinRow::builder()
let value_selector = adw::SpinRow::builder()
.title(title)
.adjustment(&adjustment)
.build();
Expand Down
10 changes: 8 additions & 2 deletions lact-gui/src/app/root_stack/oc_page/gpu_stats_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ mod imp {

#[derive(CompositeTemplate, Default, Properties)]
#[properties(wrapper_type = super::GpuStatsSection)]
#[cfg_attr(feature = "libadwaita", template(file = "ui/oc_page/gpu_stats_section.blp"))]
#[cfg_attr(not(feature = "libadwaita"), template(file = "ui/oc_page/gpu_stats_section_gtk.blp"))]
#[cfg_attr(
feature = "libadwaita",
template(file = "ui/oc_page/gpu_stats_section.blp")
)]
#[cfg_attr(
not(feature = "libadwaita"),
template(file = "ui/oc_page/gpu_stats_section_gtk.blp")
)]
pub struct GpuStatsSection {
#[property(get, set)]
core_clock: RefCell<String>,
Expand Down
2 changes: 1 addition & 1 deletion lact-gui/src/app/root_stack/oc_page/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl OcPage {

#[cfg(feature = "libadwaita")]
vbox.append(
&libadwaita::Bin::builder()
&adw::Bin::builder()
.css_classes(["card"])
.child(&warning_frame)
.build(),
Expand Down
10 changes: 5 additions & 5 deletions lact-gui/src/app/root_stack/oc_page/performance_frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ use lact_client::schema::amdgpu_sysfs::gpu_handle::{
use std::{cell::RefCell, rc::Rc, str::FromStr};

#[cfg(feature = "libadwaita")]
use libadwaita::prelude::{ActionRowExt, ComboRowExt};
use adw::prelude::{ActionRowExt, ComboRowExt};

#[derive(Debug, Clone)]
pub struct PerformanceFrame {
pub container: PageSection,

#[cfg(feature = "libadwaita")]
level_row: libadwaita::ComboRow,
level_row: adw::ComboRow,
#[cfg(feature = "libadwaita")]
mode_row: libadwaita::ComboRow,
mode_row: adw::ComboRow,

#[cfg(not(feature = "libadwaita"))]
level_row: DropDown,
Expand All @@ -44,7 +44,7 @@ impl PerformanceFrame {

#[cfg(feature = "libadwaita")]
let level_row = {
let row = libadwaita::ComboRow::builder()
let row = adw::ComboRow::builder()
.model(&levels_model)
.title("Performance level")
.subtitle("")
Expand Down Expand Up @@ -84,7 +84,7 @@ impl PerformanceFrame {

#[cfg(feature = "libadwaita")]
let mode_row = {
let row = libadwaita::ComboRow::builder()
let row = adw::ComboRow::builder()
.model(&filler_model)
.title("Power level mode")
.subtitle("Set \"Performance level\" to \"Manual\" to use power states and modes")
Expand Down
10 changes: 8 additions & 2 deletions lact-gui/src/app/root_stack/oc_page/power_cap_section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,14 @@ mod imp {

#[derive(CompositeTemplate, Default, Properties)]
#[properties(wrapper_type = super::PowerCapSection)]
#[cfg_attr(feature = "libadwaita", template(file = "ui/oc_page/power_cap_section.blp"))]
#[cfg_attr(not(feature = "libadwaita"), template(file = "ui/oc_page/power_cap_section_gtk.blp"))]
#[cfg_attr(
feature = "libadwaita",
template(file = "ui/oc_page/power_cap_section.blp")
)]
#[cfg_attr(
not(feature = "libadwaita"),
template(file = "ui/oc_page/power_cap_section_gtk.blp")
)]
pub struct PowerCapSection {
#[property(get, set)]
pub current_value: RefCell<f64>,
Expand Down

0 comments on commit da66937

Please sign in to comment.