style: apply nightly rustfmt import grouping across the workspace

rustfmt.toml sets group_imports, imports_granularity and imports_layout,
which are nightly-only; agents formatted with stable rustfmt, which
ignored them. This is a formatting-only pass with `cargo +nightly fmt`.

Test Plan:
- cargo clippy --workspace --all-targets -- -D warnings
- cargo test --workspace
This commit is contained in:
ddidderr committed 2026-10-12 05:03:37 +02:00
1 parent 3fd4ea6ae9
commit 126da77a37
259 files changed
+2495 -1547

No files matched your search

+6 -5
View File
@@ -7,14 +7,15 @@
//! app.terminate();
//! ```
use std::rc::Rc;
use std::sync::Arc;
use std::{rc::Rc, sync::Arc};
use ghostty_apprt::action::{Action, Target};
use ghostty_apprt::ipc;
use ghostty_apprt::{
action::{Action, Target},
ipc,
runtime_api::{CoreApp, SurfaceId, Waker},
};
use crate::class::application::{Application, RunError};
use ghostty_apprt::runtime_api::{CoreApp, SurfaceId, Waker};
/// This is detected by the Renderer, in which case it sends a
/// `redraw_surface` message so that we can call `drawFrame` ourselves from
+1 -3
View File
@@ -1,8 +1,6 @@
//! Transient systemd scope creation over D-Bus (port of `apprt/gtk/cgroup.zig`).
use gtk::gio;
use gtk::glib;
use gtk::prelude::*;
use gtk::{gio, glib, prelude::*};
/// Properties for the transient scope.
#[derive(Debug, Clone, Copy, Default)]
@@ -18,32 +18,41 @@
clippy::should_implement_trait
)]
use std::cell::{Cell, OnceCell, Ref, RefCell, RefMut};
use std::rc::Rc;
use std::sync::Arc;
use std::{
cell::{Cell, OnceCell, Ref, RefCell, RefMut},
rc::Rc,
sync::Arc,
};
use adw::prelude::*;
use adw::subclass::prelude::*;
use ghostty_apprt::action::{self, Action, Target};
use ghostty_apprt::structs::ColorScheme;
use ghostty_config::cli_args::ConfigField;
use ghostty_config::command::Command;
use ghostty_config::config::Config as CoreConfig;
use ghostty_config::types_b::{GtkSingleInstance, WindowTheme};
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::{
action::{self, Action, Target},
runtime_api::{AppMessage, CoreApp, RtApp, SurfaceId},
structs::ColorScheme,
};
use ghostty_config::{
cli_args::ConfigField,
command::Command,
config::Config as CoreConfig,
types_b::{GtkSingleInstance, WindowTheme},
};
use ghostty_input::binding::Action as BindingAction;
use gtk::{gdk, gio, glib};
use crate::class::close_confirmation_dialog::{self, CloseConfirmationDialog};
use crate::class::config::Config;
use crate::class::config_errors_dialog::ConfigErrorsDialog;
use crate::class::global_shortcuts::GlobalShortcuts;
use crate::class::split_tree::SplitTree;
use crate::class::surface::{Size, Surface};
use crate::class::tab::Tab;
use crate::class::window::{SelectTab, TabOverrides, Window};
use crate::css::CssProviders;
use crate::winproto;
use ghostty_apprt::runtime_api::{AppMessage, CoreApp, RtApp, SurfaceId};
use crate::{
class::{
close_confirmation_dialog::{self, CloseConfirmationDialog},
config::Config,
config_errors_dialog::ConfigErrorsDialog,
global_shortcuts::GlobalShortcuts,
split_tree::SplitTree,
surface::{Size, Surface},
tab::Tab,
window::{SelectTab, TabOverrides, Window},
},
css::CssProviders,
winproto,
};
/// Errors from [`Application::run_loop`].
#[derive(Debug, thiserror::Error)]
@@ -268,14 +277,26 @@ impl RtApp for AppRt {
}
mod imp {
use super::{
AppMessage, Cell, Config, ConfigErrorsDialog, CoreApp, CssProviders, GlobalShortcuts,
OnceCell, QuitTimer, Rc, RefCell, RtApp, glib, winproto,
};
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use gtk::gio;
use super::{
AppMessage,
Cell,
Config,
ConfigErrorsDialog,
CoreApp,
CssProviders,
GlobalShortcuts,
OnceCell,
QuitTimer,
Rc,
RefCell,
RtApp,
glib,
winproto,
};
#[derive(Default)]
pub struct Application {
/// The libghostty App instance.
@@ -826,7 +847,10 @@ impl Application {
fn sync_action_accelerators(&self) {
use ghostty_input::binding::action::{
CloseTabMode, CopyToClipboard, InspectorMode, SplitDirection,
CloseTabMode,
CopyToClipboard,
InspectorMode,
SplitDirection,
};
let a = |name: &str, action: BindingAction| self.sync_action_accelerator(name, &action);
a("app.quit", BindingAction::Quit);
@@ -5,14 +5,15 @@
//! `clipboard-contents` (GtkTextBuffer), `blur`. Signals `confirm(bool)` and
//! `deny(bool)` (bool = "remember choice").
use adw::prelude::*;
use adw::subclass::prelude::*;
use std::{
cell::{Cell, RefCell},
sync::OnceLock,
};
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::structs::ClipboardRequest;
use ghostty_os::i18n::tr;
use gtk::glib;
use gtk::glib::subclass::Signal;
use std::cell::{Cell, RefCell};
use std::sync::OnceLock;
use gtk::{glib, glib::subclass::Signal};
use super::dialog::{Dialog, DialogImpl};
@@ -22,13 +23,25 @@ use super::dialog::{Dialog, DialogImpl};
pub struct ClipboardRequestBoxed(pub ClipboardRequest);
mod imp {
use super::{
AdwAlertDialogImpl, AdwDialogImpl, Cell, ClipboardRequest, ClipboardRequestBoxed, Dialog,
DialogImpl, ObjectImpl, ObjectSubclass, OnceLock, RefCell, Signal, WidgetImpl, tr,
};
use adw::prelude::*;
use gtk::glib;
use gtk::subclass::prelude::*;
use gtk::{glib, subclass::prelude::*};
use super::{
AdwAlertDialogImpl,
AdwDialogImpl,
Cell,
ClipboardRequest,
ClipboardRequestBoxed,
Dialog,
DialogImpl,
ObjectImpl,
ObjectSubclass,
OnceLock,
RefCell,
Signal,
WidgetImpl,
tr,
};
#[derive(Default, glib::Properties, gtk::CompositeTemplate)]
#[properties(wrapper_type = super::ClipboardConfirmationDialog)]
@@ -2,13 +2,11 @@
//! (`GhosttyCloseConfirmationDialog`). Property `target`; signals
//! `close-request` and `cancel`.
use adw::prelude::*;
use adw::subclass::prelude::*;
use std::{cell::Cell, sync::OnceLock};
use adw::{prelude::*, subclass::prelude::*};
use ghostty_os::i18n::tr;
use gtk::glib;
use gtk::glib::subclass::Signal;
use std::cell::Cell;
use std::sync::OnceLock;
use gtk::{glib, glib::subclass::Signal};
use super::dialog::{Dialog, DialogImpl};
@@ -47,13 +45,21 @@ impl Target {
}
mod imp {
use gtk::{glib, glib::prelude::*, subclass::prelude::*};
use super::{
AdwAlertDialogImpl, AdwDialogImpl, Cell, Dialog, DialogImpl, ObjectImpl, ObjectSubclass,
OnceLock, Signal, Target, WidgetImpl,
AdwAlertDialogImpl,
AdwDialogImpl,
Cell,
Dialog,
DialogImpl,
ObjectImpl,
ObjectSubclass,
OnceLock,
Signal,
Target,
WidgetImpl,
};
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::subclass::prelude::*;
#[derive(Default, glib::Properties, gtk::CompositeTemplate)]
#[properties(wrapper_type = super::CloseConfirmationDialog)]
@@ -5,22 +5,13 @@
//! keeps itself alive (a self-reference) from `new()` until its dialog is
//! closed, like the Zig `refSink`/`unref` dance.
use std::cell::RefCell;
use std::cmp::Ordering;
use std::sync::OnceLock;
use std::{cell::RefCell, cmp::Ordering, sync::OnceLock};
use adw::prelude::*;
use adw::subclass::prelude::*;
use ghostty_input::binding::Action as BindingAction;
use ghostty_input::command::Command as InputCommand;
use gtk::glib;
use gtk::glib::subclass::Signal;
use gtk::{CompositeTemplate, TemplateChild, gio};
use adw::{prelude::*, subclass::prelude::*};
use ghostty_input::{binding::Action as BindingAction, command::Command as InputCommand};
use gtk::{CompositeTemplate, TemplateChild, gio, glib, glib::subclass::Signal};
use super::application::Application;
use super::config::Config;
use super::surface::Surface;
use super::window::Window;
use super::{application::Application, config::Config, surface::Surface, window::Window};
/// Boxed wrapper so a binding action can travel through the `trigger`
/// signal (Zig passes `*const input.Binding.Action`).
@@ -32,12 +23,19 @@ pub struct BoxedAction(pub BindingAction);
// Command (list item)
mod command_imp {
use super::{
BindingAction, Config, InputCommand, RefCell, Surface, ghostty_command_title_for_jump, glib,
};
use adw::prelude::*;
use gtk::glib::subclass::prelude::*;
use super::{
BindingAction,
Config,
InputCommand,
RefCell,
Surface,
ghostty_command_title_for_jump,
glib,
};
pub enum CommandData {
Regular {
command: InputCommand,
@@ -276,14 +274,23 @@ fn is_action_supported_on_gtk(action: &BindingAction) -> bool {
// CommandPalette
mod imp {
use adw::{prelude::*, subclass::prelude::*};
use gtk::{gio, glib};
use super::{
Application, BoxedAction, Command, CompositeTemplate, Config, OnceLock, Ordering, RefCell,
Signal, TemplateChild, compare_commands, is_action_supported_on_gtk,
Application,
BoxedAction,
Command,
CompositeTemplate,
Config,
OnceLock,
Ordering,
RefCell,
Signal,
TemplateChild,
compare_commands,
is_action_supported_on_gtk,
};
use adw::prelude::*;
use adw::subclass::prelude::*;
use gtk::gio;
use gtk::glib;
#[derive(Default, glib::Properties, CompositeTemplate)]
#[properties(wrapper_type = super::CommandPalette)]
+8 -8
View File
@@ -3,19 +3,19 @@
//! Wraps a core config in a GObject so it can be reference counted and bound
//! from blueprints (`diagnostics-buffer`, `has-diagnostics`).
use std::cell::RefCell;
use std::sync::Arc;
use std::{cell::RefCell, sync::Arc};
use ghostty_config::config::Config as CoreConfig;
use gtk::glib;
use gtk::glib::subclass::prelude::*;
use gtk::{glib, glib::subclass::prelude::*};
mod imp {
use gtk::{
glib,
glib::{prelude::*, subclass::prelude::*},
prelude::TextBufferExt,
};
use super::{Arc, CoreConfig, RefCell};
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::glib::subclass::prelude::*;
use gtk::prelude::TextBufferExt;
#[derive(glib::Properties)]
#[properties(wrapper_type = super::Config)]
@@ -2,25 +2,33 @@
//!
//! Property `config` (GhosttyConfig); signal `reload-config`.
use std::cell::RefCell;
use std::{cell::RefCell, sync::OnceLock};
use adw::prelude::*;
use adw::subclass::prelude::*;
use gtk::glib;
use gtk::glib::subclass::Signal;
use std::sync::OnceLock;
use adw::{prelude::*, subclass::prelude::*};
use gtk::{glib, glib::subclass::Signal};
use super::config::Config;
use super::dialog::{Dialog, DialogImpl};
use super::{
config::Config,
dialog::{Dialog, DialogImpl},
};
mod imp {
use gtk::{glib, glib::prelude::*, subclass::prelude::*};
use super::{
AdwAlertDialogImpl, AdwDialogImpl, Config, Dialog, DialogImpl, ObjectImpl, ObjectSubclass,
ObjectSubclassExt, OnceLock, RefCell, Signal, WidgetImpl,
AdwAlertDialogImpl,
AdwDialogImpl,
Config,
Dialog,
DialogImpl,
ObjectImpl,
ObjectSubclass,
ObjectSubclassExt,
OnceLock,
RefCell,
Signal,
WidgetImpl,
};
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::subclass::prelude::*;
#[derive(Default, glib::Properties, gtk::CompositeTemplate)]
#[properties(wrapper_type = super::ConfigErrorsDialog)]
@@ -4,8 +4,7 @@
use gtk::glib;
mod imp {
use gtk::glib;
use gtk::subclass::prelude::*;
use gtk::{glib, subclass::prelude::*};
#[derive(Default, gtk::CompositeTemplate)]
#[template(resource = "/com/mitchellh/ghostty/ui/1.3/debug-warning.ui")]
+1 -2
View File
@@ -4,8 +4,7 @@
//! `adw::MessageDialog` fallback is not needed). Subclasses implement
//! [`DialogImpl`] and may override `response` via `AlertDialogImpl`.
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib;
mod imp {
@@ -8,21 +8,28 @@
#![allow(deprecated)] // gio D-Bus signal_subscribe: replacement API is awkward for portal use
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::sync::OnceLock;
use std::{
cell::{Cell, RefCell},
collections::HashMap,
sync::OnceLock,
};
use ghostty_input::binding::Action as BindingAction;
use ghostty_input::binding::set::Value as BindingValue;
use gtk::gio::{self, prelude::*};
use gtk::glib::{self, subclass::Signal, subclass::prelude::*, variant::ObjectPath};
use ghostty_input::binding::{Action as BindingAction, set::Value as BindingValue};
use gtk::{
gio::{self, prelude::*},
glib::{
self,
subclass::{Signal, prelude::*},
variant::ObjectPath,
},
};
use crate::class::config::Config;
mod imp {
use glib::{prelude::*, subclass::prelude::*};
use super::{BindingAction, Cell, Config, OnceLock, RefCell, Signal, gio, glib};
use glib::prelude::*;
use glib::subclass::prelude::*;
#[derive(glib::Properties, Default)]
#[properties(wrapper_type = super::GlobalShortcuts)]
@@ -9,15 +9,15 @@
//! cheaply in gtk-rs without a lot of class struct boilerplate, so subclasses
//! install the two hooks with [`ImguiWidget::set_hooks`] instead.
use std::cell::{Cell, RefCell};
use std::time::{Duration, Instant};
use std::{
cell::{Cell, RefCell},
time::{Duration, Instant},
};
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use dear_imgui_glow::GlowRenderer;
use ghostty_inspector::imgui::{Context, MouseButton, Ui};
use gtk::glib::translate::IntoGlib;
use gtk::{gdk, glib};
use gtk::{gdk, glib, glib::translate::IntoGlib};
use crate::key;
@@ -4,16 +4,16 @@
//! property activates the inspector on that surface's core surface and
//! clearing it deactivates it again.
use std::cell::RefCell;
use std::rc::Rc;
use std::{cell::RefCell, rc::Rc};
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::runtime_api::CoreSurface;
use gtk::glib;
use super::imgui_widget::{ImguiWidget, ImguiWidgetImpl};
use super::surface::Surface;
use super::{
imgui_widget::{ImguiWidget, ImguiWidgetImpl},
surface::Surface,
};
glib::wrapper! {
pub struct InspectorWidget(ObjectSubclass<imp::InspectorWidget>)
@@ -2,13 +2,10 @@
//!
//! Window for displaying the Ghostty inspector.
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib;
use super::debug_warning::DebugWarning;
use super::inspector_widget::InspectorWidget;
use super::surface::Surface;
use super::{debug_warning::DebugWarning, inspector_widget::InspectorWidget, surface::Surface};
glib::wrapper! {
pub struct InspectorWindow(ObjectSubclass<imp::InspectorWindow>)
@@ -7,8 +7,7 @@
//! Deviation: Zig's `ext.StringList` boxed type is replaced by `GStrv`
//! (`Vec<String>`) for the `tables` and `sequence` properties.
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib;
glib::wrapper! {
@@ -10,8 +10,7 @@
//! 2. Set the label with `set_label`
//! 3. Schedule to show it with `schedule`
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib;
glib::wrapper! {
@@ -5,10 +5,8 @@
use std::sync::OnceLock;
use adw::prelude::*;
use adw::subclass::prelude::*;
use gtk::glib::subclass::Signal;
use gtk::{gdk, glib};
use adw::{prelude::*, subclass::prelude::*};
use gtk::{gdk, glib, glib::subclass::Signal};
glib::wrapper! {
pub struct SearchOverlay(ObjectSubclass<imp::SearchOverlay>)
@@ -10,19 +10,29 @@
use std::cell::{Cell, RefCell};
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use ghostty_datastruct::split_tree::{
Direction, Goto, Handle, Layout, Node, SplitError, SplitTree as DsSplitTree, SplitTreeView,
Direction,
Goto,
Handle,
Layout,
Node,
SplitError,
SplitTree as DsSplitTree,
SplitTreeView,
};
use gtk::{
gio,
glib::{self, clone, subclass::Signal},
};
use gtk::gio;
use gtk::glib::{self, clone, subclass::Signal};
use half::f16;
use super::application::Application;
use super::close_confirmation_dialog::{CloseConfirmationDialog, Target as CloseTarget};
use super::surface::{Surface, SurfaceOverrides};
use super::surface_scrolled_window::SurfaceScrolledWindow;
use super::{
application::Application,
close_confirmation_dialog::{CloseConfirmationDialog, Target as CloseTarget},
surface::{Surface, SurfaceOverrides},
surface_scrolled_window::SurfaceScrolledWindow,
};
/// The split tree of surfaces (Zig: `Surface.Tree`).
pub type Tree = DsSplitTree<Surface>;
+71 -41
View File
@@ -8,47 +8,71 @@
//! into) is [`RtSurfaceHandle`], which implements [`ghostty_apprt::runtime_api::RtSurface`]
//! and holds only a weak reference to the widget.
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::io::Write as _;
use std::rc::Rc;
use std::sync::OnceLock;
use adw::prelude::*;
use adw::subclass::prelude::*;
use ghostty_apprt::action::{CommandFinished, Inspector, KeySequence, KeyTable, Readonly};
use ghostty_apprt::structs::{
Clipboard, ClipboardRequest, ContentScale, CursorPos, ImePos, SurfaceSize,
use std::{
cell::{Cell, RefCell},
collections::HashMap,
io::Write as _,
rc::Rc,
sync::OnceLock,
};
use ghostty_apprt::surface::{ChildExited, NewSurfaceContext, Scrollbar};
use ghostty_config::command::Command;
use ghostty_config::config::Config as CoreConfig;
use ghostty_config::path::Path as ConfigPath;
use ghostty_config::types_a::WorkingDirectory;
use ghostty_config::types_b::{
BellFeatures, NotifyOnCommandFinish, ResizeOverlay as ResizeOverlayMode, ResizeOverlayPosition,
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::{
action::{CommandFinished, Inspector, KeySequence, KeyTable, Readonly},
runtime_api::{
ClipboardError,
CoreSurface,
DesiredFontSize,
InputEffect,
MIN_WINDOW_HEIGHT_CELLS,
MIN_WINDOW_WIDTH_CELLS,
RtSurface,
SurfaceId,
},
structs::{Clipboard, ClipboardRequest, ContentScale, CursorPos, ImePos, SurfaceSize},
surface::{ChildExited, NewSurfaceContext, Scrollbar},
};
use ghostty_config::{
command::Command,
config::Config as CoreConfig,
path::Path as ConfigPath,
types_a::WorkingDirectory,
types_b::{
BellFeatures,
NotifyOnCommandFinish,
ResizeOverlay as ResizeOverlayMode,
ResizeOverlayPosition,
},
};
use ghostty_input::{Action as KeyAction, Key, KeyEvent, Mods, MouseButton, MouseButtonState};
use ghostty_vt::mouse_shape::MouseShape;
use ghostty_vt::osc::{ProgressReport, ProgressState};
use gtk::glib::subclass::Signal;
use gtk::glib::translate::{FromGlib, IntoGlib};
use gtk::{gdk, gio, glib};
use ghostty_vt::{
mouse_shape::MouseShape,
osc::{ProgressReport, ProgressState},
};
use gtk::{
gdk,
gio,
glib,
glib::{
subclass::Signal,
translate::{FromGlib, IntoGlib},
},
};
use crate::class::application::Application;
use crate::class::clipboard_confirmation_dialog::ClipboardConfirmationDialog;
use crate::class::config::Config;
use crate::class::inspector_window::InspectorWindow;
use crate::class::key_state_overlay::KeyStateOverlay;
use crate::class::resize_overlay::ResizeOverlay;
use crate::class::search_overlay::SearchOverlay;
use crate::class::surface_child_exited::SurfaceChildExited;
use crate::class::title_dialog::{self, TitleDialog};
use crate::class::window::Window;
use crate::key as gtk_key;
use ghostty_apprt::runtime_api::{
ClipboardError, CoreSurface, DesiredFontSize, InputEffect, MIN_WINDOW_HEIGHT_CELLS,
MIN_WINDOW_WIDTH_CELLS, RtSurface, SurfaceId,
use crate::{
class::{
application::Application,
clipboard_confirmation_dialog::ClipboardConfirmationDialog,
config::Config,
inspector_window::InspectorWindow,
key_state_overlay::KeyStateOverlay,
resize_overlay::ResizeOverlay,
search_overlay::SearchOverlay,
surface_child_exited::SurfaceChildExited,
title_dialog::{self, TitleDialog},
window::Window,
},
key as gtk_key,
};
/// Simple dimensions struct for the surface used by various properties
@@ -2268,12 +2292,18 @@ impl RtSurface for RtSurfaceHandle {
/// A namespace for our clipboard-related functions so Surface isn't SO large.
mod clipboard {
use adw::{prelude::*, subclass::prelude::ObjectSubclassIsExt};
use super::{
Clipboard, ClipboardConfirmationDialog, ClipboardError, ClipboardRequest, Surface, gdk,
gio, glib,
Clipboard,
ClipboardConfirmationDialog,
ClipboardError,
ClipboardRequest,
Surface,
gdk,
gio,
glib,
};
use adw::prelude::*;
use adw::subclass::prelude::ObjectSubclassIsExt;
/// Set the clipboard contents.
pub(super) fn set(
@@ -6,11 +6,9 @@
use std::sync::OnceLock;
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::surface::ChildExited;
use gtk::glib;
use gtk::glib::subclass::Signal;
use gtk::{glib, glib::subclass::Signal};
/// Boxed wrapper so `ChildExited` can be a GObject property.
#[derive(Debug, Clone, Copy, PartialEq, Eq, glib::Boxed)]
@@ -11,8 +11,7 @@
//! `GtkWidget` (any `crate::class::surface::Surface` is accepted) and the
//! `config` property as `GObject` (a `crate::class::config::Config`).
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use gtk::glib;
glib::wrapper! {
@@ -75,9 +74,10 @@ mod imp {
impl SurfaceScrolledWindow {
#[template_callback(function)]
fn scrollbar_policy(config: Option<glib::Object>) -> gtk::PolicyType {
use crate::class::config::Config;
use ghostty_config::types_b::Scrollbar;
use crate::class::config::Config;
let Some(config) = config.and_then(|c| c.downcast::<Config>().ok()) else {
return gtk::PolicyType::Automatic;
};
+12 -9
View File
@@ -5,17 +5,20 @@
use std::cell::RefCell;
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::surface::NewSurfaceContext;
use gtk::gio;
use gtk::glib::{self, clone, subclass::Signal};
use gtk::{
gio,
glib::{self, clone, subclass::Signal},
};
use super::application::Application;
use super::config::Config;
use super::split_tree::{SplitTree, SurfaceTree};
use super::surface::{Surface, SurfaceOverrides};
use super::title_dialog::{Target as TitleTarget, TitleDialog};
use super::{
application::Application,
config::Config,
split_tree::{SplitTree, SurfaceTree},
surface::{Surface, SurfaceOverrides},
title_dialog::{Target as TitleTarget, TitleDialog},
};
glib::wrapper! {
pub struct Tab(ObjectSubclass<imp::Tab>)
@@ -1,13 +1,14 @@
//! Port of apprt/gtk/class/title_dialog.zig (`GhosttyTitleDialog`).
//! Properties `target`, `initial-value`; signal `set(title: string)`.
use adw::prelude::*;
use adw::subclass::prelude::*;
use std::{
cell::{Cell, RefCell},
sync::OnceLock,
};
use adw::{prelude::*, subclass::prelude::*};
use ghostty_os::i18n::tr;
use gtk::glib;
use gtk::glib::subclass::Signal;
use std::cell::{Cell, RefCell};
use std::sync::OnceLock;
use gtk::{glib, glib::subclass::Signal};
/// `GhosttyTitleDialogTarget`.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, glib::Enum)]
@@ -29,13 +30,20 @@ impl Target {
}
mod imp {
use gtk::{glib, glib::prelude::*, subclass::prelude::*};
use super::{
AdwAlertDialogImpl, AdwDialogImpl, Cell, ObjectImpl, ObjectSubclass, OnceLock, RefCell,
Signal, Target, WidgetImpl,
AdwAlertDialogImpl,
AdwDialogImpl,
Cell,
ObjectImpl,
ObjectSubclass,
OnceLock,
RefCell,
Signal,
Target,
WidgetImpl,
};
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::subclass::prelude::*;
#[derive(Default, glib::Properties, gtk::CompositeTemplate)]
#[properties(wrapper_type = super::TitleDialog)]
+60 -28
View File
@@ -13,34 +13,51 @@
//! [`Surface`] object (Zig took the `*CoreSurface` and used
//! `rt_surface.gobj()`); the core surface is looked up via `Surface::core()`.
use std::cell::{Cell, RefCell};
use std::rc::Rc;
use std::time::Duration;
use std::{
cell::{Cell, RefCell},
rc::Rc,
time::Duration,
};
use adw::prelude::*;
use adw::subclass::prelude::*;
use adw::{prelude::*, subclass::prelude::*};
use ghostty_apprt::surface::NewSurfaceContext;
use ghostty_config::command::Command as ConfigCommand;
use ghostty_config::types_a::WindowSubtitle;
use ghostty_config::types_b::{
GtkTabsLocation, GtkTitlebarStyle, GtkToolbarStyle, WindowDecoration, WindowNewTabPosition,
WindowShowTabBar, WindowTheme,
use ghostty_config::{
command::Command as ConfigCommand,
types_a::WindowSubtitle,
types_b::{
GtkTabsLocation,
GtkTitlebarStyle,
GtkToolbarStyle,
WindowDecoration,
WindowNewTabPosition,
WindowShowTabBar,
WindowTheme,
},
};
use ghostty_input::binding::{Action as BindingAction, CloseTabMode};
use ghostty_os::i18n::tr;
use gtk::glib::{self, clone};
use gtk::{CompositeTemplate, TemplateChild, gio};
use gtk::{
CompositeTemplate,
TemplateChild,
gio,
glib::{self, clone},
};
use super::application::Application;
use super::close_confirmation_dialog::{CloseConfirmationDialog, Target as CloseTarget};
use super::command_palette::CommandPalette;
use super::config::Config;
use super::debug_warning::DebugWarning;
use super::split_tree::{SplitTree, SurfaceTree, Tree};
use super::surface::{Surface, SurfaceOverrides};
use super::tab::Tab;
use crate::winproto::{self, WindowHost};
use crate::{adw_version, gtk_version};
use super::{
application::Application,
close_confirmation_dialog::{CloseConfirmationDialog, Target as CloseTarget},
command_palette::CommandPalette,
config::Config,
debug_warning::DebugWarning,
split_tree::{SplitTree, SurfaceTree, Tree},
surface::{Surface, SurfaceOverrides},
tab::Tab,
};
use crate::{
adw_version,
gtk_version,
winproto::{self, WindowHost},
};
/// Which tab to select (Zig: `Window.SelectTab`).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -108,15 +125,30 @@ impl WindowHost for Host {
}
mod imp {
use std::marker::PhantomData;
use adw::{prelude::*, subclass::prelude::*};
use super::{
Cell, CommandPalette, CompositeTemplate, Config, DebugWarning, NewSurfaceContext, RefCell,
SplitTree, Surface, Tab, TabOverrides, TemplateChild, TitlebarStyle, Window as WindowObj,
WindowDecoration, glib, gtk_version,
Cell,
CommandPalette,
CompositeTemplate,
Config,
DebugWarning,
NewSurfaceContext,
RefCell,
SplitTree,
Surface,
Tab,
TabOverrides,
TemplateChild,
TitlebarStyle,
Window as WindowObj,
WindowDecoration,
glib,
gtk_version,
};
use crate::winproto;
use adw::prelude::*;
use adw::subclass::prelude::*;
use std::marker::PhantomData;
#[derive(glib::Properties, CompositeTemplate)]
#[properties(wrapper_type = WindowObj)]
+1 -3
View File
@@ -12,9 +12,7 @@
use std::fmt::Write as _;
use ghostty_config::config::Config;
use ghostty_config::path::Path;
use ghostty_config::types_b::WindowTheme;
use ghostty_config::{config::Config, path::Path, types_b::WindowTheme};
use gtk::{gdk, glib, prelude::*};
/// Maximum size of a `gtk-custom-css` file.
+3 -9
View File
@@ -36,17 +36,11 @@
//! with a few lowercase aliases (`enter`, `esc`, `up`, ...). Commands act on
//! the active surface of the active window at the time they run.
use std::cell::RefCell;
use std::rc::Rc;
use std::time::Duration;
use std::{cell::RefCell, rc::Rc, time::Duration};
use gtk::glib::translate::IntoGlib;
use gtk::prelude::*;
use gtk::{gdk, glib};
use gtk::{gdk, glib, glib::translate::IntoGlib, prelude::*};
use crate::class::application::Application;
use crate::class::surface::Surface;
use crate::class::window::Window;
use crate::class::{application::Application, surface::Surface, window::Window};
/// One parsed command.
#[derive(Debug, Clone, PartialEq)]
+1 -4
View File
@@ -1,9 +1,6 @@
//! GAction helpers (port of `apprt/gtk/ext/actions.zig`).
use gtk::gio;
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::prelude::*;
use gtk::{gio, glib, glib::prelude::*, prelude::*};
fn g_action_name_is_valid(name: &str) -> bool {
!name.is_empty()
+1 -4
View File
@@ -6,12 +6,9 @@
pub mod actions;
pub mod slice;
use gtk::{glib, glib::prelude::*, prelude::*};
pub use slice::StringList;
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::prelude::*;
/// Get the first ancestor of `widget` of type `T`.
pub fn get_ancestor<T: IsA<gtk::Widget>>(widget: &impl IsA<gtk::Widget>) -> Option<T> {
widget.ancestor(T::static_type()).and_downcast::<T>()
+2 -1
View File
@@ -20,9 +20,10 @@ impl StringList {
#[cfg(test)]
mod tests {
use super::*;
use gtk::glib::prelude::*;
use super::*;
#[test]
fn string_list_create_and_destroy() {
let list = StringList::create(&["hello", "world"]);
+1 -2
View File
@@ -7,8 +7,7 @@
//! `glow::Context::from_loader_function` need. Call it only while the GLArea
//! context is current.
use std::ffi::c_void;
use std::sync::OnceLock;
use std::{ffi::c_void, sync::OnceLock};
fn epoxy() -> Option<&'static libloading::Library> {
static LIB: OnceLock<Option<libloading::Library>> = OnceLock::new();
+1 -2
View File
@@ -1,7 +1,6 @@
//! Typed access to `GtkSettings` (port of `apprt/gtk/gsettings.zig`).
use gtk::glib;
use gtk::prelude::*;
use gtk::{glib, prelude::*};
/// Settings keys we read (the GTK property names).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+1 -3
View File
@@ -1,9 +1,7 @@
//! D-Bus helper for IPC (port of `apprt/gtk/ipc/DBus.zig`).
use ghostty_apprt::ipc::{Error, Target};
use gtk::gio;
use gtk::glib;
use gtk::prelude::*;
use gtk::{gio, glib, prelude::*};
/// A pending `org.gtk.Actions.Activate` call.
pub struct DBus {
+6 -7
View File
@@ -2,13 +2,12 @@
use std::fmt::Write as _;
use ghostty_input::binding::{Trigger, TriggerKey};
use ghostty_input::key::{Action, Key as K};
use ghostty_input::key_mods::{ModSide, Mods};
use gtk::gdk;
use gtk::gdk::prelude::DeviceExt;
use gtk::glib::translate::IntoGlib;
use gtk::prelude::*;
use ghostty_input::{
binding::{Trigger, TriggerKey},
key::{Action, Key as K},
key_mods::{ModSide, Mods},
};
use gtk::{gdk, gdk::prelude::DeviceExt, glib::translate::IntoGlib, prelude::*};
/// Name of a keyval (`gdk.keyvalName`).
fn keyval_name(keyval: u32) -> Option<String> {
+5 -4
View File
@@ -1,10 +1,11 @@
//! Parent post-fork hook creating the transient scope (port of
//! `apprt/gtk/post_fork.zig`).
use ghostty_config::config::Config;
use ghostty_config::types_b::{GtkSingleInstance, LinuxCgroup};
use gtk::gio;
use gtk::prelude::*;
use ghostty_config::{
config::Config,
types_b::{GtkSingleInstance, LinuxCgroup},
};
use gtk::{gio, prelude::*};
use crate::cgroup;
+4 -2
View File
@@ -4,8 +4,10 @@
//! sleeps. The wait loop is shared with `ghostty-termio` via
//! `ghostty_os::cgroup::wait_for_scope`.
use ghostty_config::config::Config;
use ghostty_config::types_b::{GtkSingleInstance, LinuxCgroup};
use ghostty_config::{
config::Config,
types_b::{GtkSingleInstance, LinuxCgroup},
};
use crate::cgroup;
+1 -2
View File
@@ -2,8 +2,7 @@
//! already provides `glib::WeakRef<T>`; this wrapper keeps the Zig API
//! (`set`/`get`/`empty`).
use gtk::glib;
use gtk::glib::prelude::*;
use gtk::{glib, glib::prelude::*};
/// A weak reference to a GObject of type `T`.
#[derive(Debug, Default)]
+3 -7
View File
@@ -8,15 +8,11 @@
//! code held a `*ApprtWindow` pointer; here the window GObject implements
//! [`WindowHost`] (a small, weak-referencing adapter), see below.
use std::rc::Rc;
use std::sync::Arc;
use std::{rc::Rc, sync::Arc};
use gtk::gdk;
use gtk::prelude::*;
use ghostty_config::config::Config;
use ghostty_config::types_b::WindowDecoration;
use ghostty_config::{config::Config, types_b::WindowDecoration};
use ghostty_input::Mods;
use gtk::{gdk, prelude::*};
pub mod noop;
pub mod wayland;
@@ -3,10 +3,10 @@
use std::rc::Rc;
use ghostty_input::Mods;
use gtk::gdk;
use super::{Result, WindowHost};
use ghostty_input::Mods;
#[derive(Debug, Default, Clone, Copy)]
pub struct App;
@@ -17,42 +17,59 @@
//! first (or run with `LD_PRELOAD=libgtk4-layer-shell.so`). Without it,
//! `layer_shell::is_supported()` is false and the quick terminal is disabled.
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::atomic::{AtomicBool, Ordering};
use gdk4_wayland::WaylandDisplay;
use gdk4_wayland::prelude::*;
use gtk::gdk;
use gtk::glib;
use gtk::prelude::*;
use gtk4_layer_shell::{self as layer_shell, LayerShell};
use wayland_client::globals::{GlobalListContents, registry_queue_init};
use wayland_client::protocol::wl_registry::WlRegistry;
use wayland_client::protocol::wl_surface::WlSurface;
use wayland_client::{Connection, Dispatch, EventQueue, Proxy, QueueHandle};
use wayland_protocols::xdg::activation::v1::client::xdg_activation_token_v1::{
self, XdgActivationTokenV1,
use std::{
cell::RefCell,
rc::Rc,
sync::{
Arc,
Mutex,
atomic::{AtomicBool, Ordering},
},
};
use wayland_protocols::xdg::activation::v1::client::xdg_activation_v1::XdgActivationV1;
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur::OrgKdeKwinBlur;
use wayland_protocols_plasma::blur::client::org_kde_kwin_blur_manager::OrgKdeKwinBlurManager;
use wayland_protocols_plasma::server_decoration::client::org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration;
use wayland_protocols_plasma::server_decoration::client::org_kde_kwin_server_decoration_manager::{
self, OrgKdeKwinServerDecorationManager,
};
use wayland_protocols_plasma::slide::client::org_kde_kwin_slide::OrgKdeKwinSlide;
use wayland_protocols_plasma::slide::client::org_kde_kwin_slide_manager::OrgKdeKwinSlideManager;
use super::{Error, Result, WindowHost};
use ghostty_config::config::Config;
use ghostty_config::types_b::{
QuickTerminalDimensions, QuickTerminalKeyboardInteractivity, QuickTerminalLayer,
QuickTerminalPosition, WindowDecoration,
use gdk4_wayland::{WaylandDisplay, prelude::*};
use ghostty_config::{
config::Config,
types_b::{
QuickTerminalDimensions,
QuickTerminalKeyboardInteractivity,
QuickTerminalLayer,
QuickTerminalPosition,
WindowDecoration,
},
};
use ghostty_input::Mods;
use gtk::{gdk, glib, prelude::*};
use gtk4_layer_shell::{self as layer_shell, LayerShell};
use wayland_client::{
Connection,
Dispatch,
EventQueue,
Proxy,
QueueHandle,
globals::{GlobalListContents, registry_queue_init},
protocol::{wl_registry::WlRegistry, wl_surface::WlSurface},
};
use wayland_protocols::xdg::activation::v1::client::{
xdg_activation_token_v1::{self, XdgActivationTokenV1},
xdg_activation_v1::XdgActivationV1,
};
use wayland_protocols_plasma::{
blur::client::{
org_kde_kwin_blur::OrgKdeKwinBlur,
org_kde_kwin_blur_manager::OrgKdeKwinBlurManager,
},
server_decoration::client::{
org_kde_kwin_server_decoration::OrgKdeKwinServerDecoration,
org_kde_kwin_server_decoration_manager::{self, OrgKdeKwinServerDecorationManager},
},
slide::client::{
org_kde_kwin_slide::OrgKdeKwinSlide,
org_kde_kwin_slide_manager::OrgKdeKwinSlideManager,
},
};
use super::{Error, Result, WindowHost};
/// `org_kde_kwin_server_decoration_manager.mode` values.
const DECO_NONE: u32 = 0;
+7 -8
View File
@@ -5,17 +5,16 @@
//! comments.
#![allow(unsafe_code)]
use std::ffi::{c_int, c_long, c_uchar, c_uint, c_ulong, c_void};
use std::rc::Rc;
use std::{
ffi::{c_int, c_long, c_uchar, c_uint, c_ulong, c_void},
rc::Rc,
};
use gdk4_x11::x11::xlib;
use gdk4_x11::{X11Display, X11Surface};
use gtk::gdk;
use gtk::glib;
use gtk::prelude::*;
use gdk4_x11::{X11Display, X11Surface, x11::xlib};
use ghostty_input::Mods;
use gtk::{gdk, glib, prelude::*};
use super::{Error, Result, WindowHost};
use ghostty_input::Mods;
// XKB bits we need that the `x11` crate doesn't expose (XKBlib.h / XKB.h).
const XKB_MAJOR_VERSION: c_int = 1;