chore: rename gtk4 to gtk and libadwaita to adw

This commit is contained in:
Gabriele Musco 2024-08-06 11:41:33 +02:00
commit 4c9ee56044
6 changed files with 49 additions and 50 deletions

View file

@ -9,9 +9,9 @@ edition = "2021"
anyhow = "1.0.86" anyhow = "1.0.86"
gettext-rs = { version = "0.7.0", features = ["gettext-system"] } gettext-rs = { version = "0.7.0", features = ["gettext-system"] }
git2 = "0.19.0" git2 = "0.19.0"
gtk4 = { version = "0.9.0", features = ["v4_10"] } gtk = { package = "gtk4", version = "0.9.0", features = ["v4_10"] }
lazy_static = "1.5.0" lazy_static = "1.5.0"
libadwaita = { version = "0.7.0", features = ["v1_5"] } adw = { package = "libadwaita", version = "0.7.0", features = ["v1_5"] }
libmonado-rs = { git = "https://github.com/technobaboo/libmonado-rs", rev = "a495f6d162fce47ae5aafeb7ec38e774cb731c29" } libmonado-rs = { git = "https://github.com/technobaboo/libmonado-rs", rev = "a495f6d162fce47ae5aafeb7ec38e774cb731c29" }
rusb = "0.9.4" rusb = "0.9.4"
nix = { version = "0.29.0", features = ["fs", "signal"] } nix = { version = "0.29.0", features = ["fs", "signal"] }

View file

@ -1,5 +1,5 @@
use crate::config::Config; use crate::config::Config;
use gtk4::{ use gtk::{
gio::{ gio::{
prelude::{ApplicationCommandLineExt, ApplicationExt}, prelude::{ApplicationCommandLineExt, ApplicationExt},
Application, ApplicationCommandLine, Application, ApplicationCommandLine,

View file

@ -497,7 +497,7 @@ impl SimpleComponent for LibsurviveSetupWindow {
calibration_done_page: None, calibration_done_page: None,
calibration_cancelled_page: None, calibration_cancelled_page: None,
steam_lighthouse_path: NO_FILE_MSG.into(), steam_lighthouse_path: NO_FILE_MSG.into(),
filefilter_listmodel: gtk4::gio::ListStore::builder() filefilter_listmodel: gtk::gio::ListStore::builder()
.item_type(gtk::FileFilter::static_type()) .item_type(gtk::FileFilter::static_type())
.build(), .build(),
profile: None, profile: None,

View file

@ -1,5 +1,4 @@
use gtk4::{gdk, glib::clone, prelude::*}; use gtk::{gdk, glib::clone, prelude::*};
use relm4::adw;
use vte4::{prelude::*, Terminal}; use vte4::{prelude::*, Terminal};
use super::util::copy_text; use super::util::copy_text;
@ -8,9 +7,9 @@ const MAX_SCROLLBACK: u32 = 2000;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct TermWidget { pub struct TermWidget {
pub container: gtk4::Box, pub container: gtk::Box,
pub term: Terminal, pub term: Terminal,
popover_menu: gtk4::PopoverMenu, popover_menu: gtk::PopoverMenu,
} }
const ADW_LIGHT_FG: &str = "#000000"; const ADW_LIGHT_FG: &str = "#000000";
@ -31,9 +30,9 @@ impl TermWidget {
.build(); .build();
term.set_clear_background(false); term.set_clear_background(false);
term.search_set_wrap_around(true); term.search_set_wrap_around(true);
let container = gtk4::Box::builder().hexpand(true).vexpand(true).build(); let container = gtk::Box::builder().hexpand(true).vexpand(true).build();
let sw = gtk4::ScrolledWindow::builder() let sw = gtk::ScrolledWindow::builder()
.hexpand(true) .hexpand(true)
.vexpand(true) .vexpand(true)
.child(&term) .child(&term)
@ -41,8 +40,8 @@ impl TermWidget {
container.append(&sw); container.append(&sw);
let action_grp = gtk4::gio::SimpleActionGroup::new(); let action_grp = gtk::gio::SimpleActionGroup::new();
let selectall_action = gtk4::gio::SimpleAction::new("selectall", None); let selectall_action = gtk::gio::SimpleAction::new("selectall", None);
selectall_action.connect_activate(clone!( selectall_action.connect_activate(clone!(
#[strong] #[strong]
term, term,
@ -51,7 +50,7 @@ impl TermWidget {
} }
)); ));
action_grp.add_action(&selectall_action); action_grp.add_action(&selectall_action);
let copy_action = gtk4::gio::SimpleAction::new("copy", None); let copy_action = gtk::gio::SimpleAction::new("copy", None);
copy_action.connect_activate(clone!( copy_action.connect_activate(clone!(
#[strong] #[strong]
term, term,
@ -63,11 +62,11 @@ impl TermWidget {
container.insert_action_group("term", Some(&action_grp)); container.insert_action_group("term", Some(&action_grp));
let menu = gtk4::gio::Menu::new(); let menu = gtk::gio::Menu::new();
menu.append(Some("Select all"), Some("term.selectall")); menu.append(Some("Select all"), Some("term.selectall"));
menu.append(Some("Copy"), Some("term.copy")); menu.append(Some("Copy"), Some("term.copy"));
let popover_menu = gtk4::PopoverMenu::builder() let popover_menu = gtk::PopoverMenu::builder()
.pointing_to(&term.allocation()) .pointing_to(&term.allocation())
.autohide(true) .autohide(true)
.menu_model(&menu) .menu_model(&menu)
@ -88,15 +87,15 @@ impl TermWidget {
} }
fn setup_rightclick_gesture(&self) { fn setup_rightclick_gesture(&self) {
let gesture = gtk4::GestureClick::builder() let gesture = gtk::GestureClick::builder()
.button(gtk4::gdk::BUTTON_SECONDARY) .button(gtk::gdk::BUTTON_SECONDARY)
.build(); .build();
gesture.connect_pressed(clone!( gesture.connect_pressed(clone!(
#[strong(rename_to=popover)] #[strong(rename_to=popover)]
self.popover_menu, self.popover_menu,
move |gesture, _, x, y| { move |gesture, _, x, y| {
gesture.set_state(gtk4::EventSequenceState::Claimed); gesture.set_state(gtk::EventSequenceState::Claimed);
popover.set_pointing_to(Some(&gtk4::gdk::Rectangle::new(x as i32, y as i32, 1, 1))); popover.set_pointing_to(Some(&gtk::gdk::Rectangle::new(x as i32, y as i32, 1, 1)));
popover.popup(); popover.popup();
} }
)); ));
@ -110,18 +109,18 @@ impl TermWidget {
} }
fn setup_shortcuts(&self) { fn setup_shortcuts(&self) {
let sc = gtk4::ShortcutController::new(); let sc = gtk::ShortcutController::new();
["<Control>c", "<Shift><Control>c"] ["<Control>c", "<Shift><Control>c"]
.iter() .iter()
.for_each(|combo| { .for_each(|combo| {
sc.add_shortcut(gtk4::Shortcut::new( sc.add_shortcut(gtk::Shortcut::new(
gtk4::ShortcutTrigger::parse_string(combo), gtk::ShortcutTrigger::parse_string(combo),
Some(gtk4::CallbackAction::new(clone!( Some(gtk::CallbackAction::new(clone!(
#[strong(rename_to = term)] #[strong(rename_to = term)]
self.term, self.term,
move |_, _| { move |_, _| {
Self::copy_selected(&term); Self::copy_selected(&term);
gtk4::glib::Propagation::Proceed gtk::glib::Propagation::Proceed
} }
))), ))),
)); ));
@ -129,14 +128,14 @@ impl TermWidget {
["<Control>a", "<Shift><Control>a"] ["<Control>a", "<Shift><Control>a"]
.iter() .iter()
.for_each(|combo| { .for_each(|combo| {
sc.add_shortcut(gtk4::Shortcut::new( sc.add_shortcut(gtk::Shortcut::new(
gtk4::ShortcutTrigger::parse_string(combo), gtk::ShortcutTrigger::parse_string(combo),
Some(gtk4::CallbackAction::new(clone!( Some(gtk::CallbackAction::new(clone!(
#[strong(rename_to = term)] #[strong(rename_to = term)]
self.term, self.term,
move |_, _| { move |_, _| {
term.select_all(); term.select_all();
gtk4::glib::Propagation::Proceed gtk::glib::Propagation::Proceed
} }
))), ))),
)); ));

View file

@ -1,6 +1,6 @@
use gtk4::{gdk, gio, glib::clone, prelude::*}; use gtk::{gdk, gio, glib::clone, prelude::*};
pub fn limit_dropdown_width(dd: &gtk4::DropDown) { pub fn limit_dropdown_width(dd: &gtk::DropDown) {
let mut dd_child = dd let mut dd_child = dd
.first_child() .first_child()
.unwrap() .unwrap()
@ -13,29 +13,29 @@ pub fn limit_dropdown_width(dd: &gtk4::DropDown) {
if dd_child.is_none() { if dd_child.is_none() {
break; break;
} }
if let Ok(label) = dd_child.clone().unwrap().downcast::<gtk4::Label>() { if let Ok(label) = dd_child.clone().unwrap().downcast::<gtk::Label>() {
label.set_ellipsize(gtk4::pango::EllipsizeMode::End); label.set_ellipsize(gtk::pango::EllipsizeMode::End);
} }
let nc = dd_child.unwrap().first_child().clone(); let nc = dd_child.unwrap().first_child().clone();
dd_child = nc; dd_child = nc;
} }
} }
pub fn warning_heading() -> gtk4::Box { pub fn warning_heading() -> gtk::Box {
let b = gtk4::Box::builder() let b = gtk::Box::builder()
.orientation(gtk4::Orientation::Horizontal) .orientation(gtk::Orientation::Horizontal)
.spacing(12) .spacing(12)
.hexpand(true) .hexpand(true)
.build(); .build();
b.append( b.append(
&gtk4::Image::builder() &gtk::Image::builder()
.css_classes(["warning"]) .css_classes(["warning"])
.icon_name("dialog-warning-symbolic") .icon_name("dialog-warning-symbolic")
.build(), .build(),
); );
b.append( b.append(
&gtk4::Label::builder() &gtk::Label::builder()
.css_classes(["warning", "heading"]) .css_classes(["warning", "heading"])
.label("Warning") .label("Warning")
.build(), .build(),
@ -69,19 +69,19 @@ pub fn bits_from_mbits(mbits: u32) -> Option<u32> {
mbits.checked_mul(1000000) mbits.checked_mul(1000000)
} }
pub fn copiable_code_snippet(code: &str) -> gtk4::Widget { pub fn copiable_code_snippet(code: &str) -> gtk::Widget {
let container = gtk4::Box::builder() let container = gtk::Box::builder()
.orientation(gtk4::Orientation::Horizontal) .orientation(gtk::Orientation::Horizontal)
.spacing(6) .spacing(6)
.build(); .build();
let btn = gtk4::Button::builder() let btn = gtk::Button::builder()
.css_classes(["flat", "circular"]) .css_classes(["flat", "circular"])
.tooltip_text("Copy") .tooltip_text("Copy")
.icon_name("edit-copy-symbolic") .icon_name("edit-copy-symbolic")
.vexpand(false) .vexpand(false)
.hexpand(false) .hexpand(false)
.valign(gtk4::Align::Center) .valign(gtk::Align::Center)
.halign(gtk4::Align::Center) .halign(gtk::Align::Center)
.build(); .build();
btn.connect_clicked(clone!( btn.connect_clicked(clone!(
#[to_owned] #[to_owned]
@ -89,13 +89,13 @@ pub fn copiable_code_snippet(code: &str) -> gtk4::Widget {
move |_| copy_text(&code) move |_| copy_text(&code)
)); ));
container.append( container.append(
&gtk4::ScrolledWindow::builder() &gtk::ScrolledWindow::builder()
.vscrollbar_policy(gtk4::PolicyType::Never) .vscrollbar_policy(gtk::PolicyType::Never)
.hscrollbar_policy(gtk4::PolicyType::Automatic) .hscrollbar_policy(gtk::PolicyType::Automatic)
.css_classes(["card"]) .css_classes(["card"])
.overflow(gtk4::Overflow::Hidden) .overflow(gtk::Overflow::Hidden)
.child( .child(
&gtk4::TextView::builder() &gtk::TextView::builder()
.hexpand(true) .hexpand(true)
.vexpand(false) .vexpand(false)
.monospace(true) .monospace(true)
@ -105,7 +105,7 @@ pub fn copiable_code_snippet(code: &str) -> gtk4::Widget {
.top_margin(6) .top_margin(6)
.bottom_margin(18) .bottom_margin(18)
.buffer( .buffer(
&gtk4::TextBuffer::builder() &gtk::TextBuffer::builder()
.text(code) .text(code)
.enable_undo(false) .enable_undo(false)
.build(), .build(),

View file

@ -19,7 +19,7 @@ use crate::{
}, },
}; };
use adw::prelude::*; use adw::prelude::*;
use gtk4::glib::clone; use gtk::glib::clone;
use relm4::{factory::AsyncFactoryVecDeque, prelude::*}; use relm4::{factory::AsyncFactoryVecDeque, prelude::*};
#[tracker::track] #[tracker::track]