From 2308cec36a8b71b940b3ebb86d8e08dd2dc95bcd Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 16 Oct 2023 18:21:04 +0200 Subject: [PATCH] misc: Use nightly rustfmt on manual source code The imports grouping & docs bits are super handy. --- gdk4-wayland/src/lib.rs | 8 +- gdk4-wayland/src/prelude.rs | 4 +- gdk4-wayland/src/wayland_device.rs | 11 +- gdk4-wayland/src/wayland_display.rs | 5 +- gdk4-wayland/src/wayland_monitor.rs | 8 +- gdk4-wayland/src/wayland_seat.rs | 8 +- gdk4-wayland/src/wayland_surface.rs | 7 +- gdk4-win32/src/win32_display.rs | 4 +- gdk4-win32/src/win32_hcursor.rs | 6 +- gdk4-win32/src/win32_surface.rs | 4 +- gdk4-x11/src/functions.rs | 10 +- gdk4-x11/src/lib.rs | 7 +- gdk4-x11/src/x11_display.rs | 15 +- gdk4-x11/src/x11_monitor.rs | 7 +- gdk4-x11/src/x11_screen.rs | 7 +- gdk4-x11/src/x11_surface.rs | 7 +- gdk4/src/builders.rs | 4 +- gdk4/src/button_event.rs | 3 +- gdk4/src/cairo_interaction.rs | 3 +- gdk4/src/clipboard.rs | 7 +- gdk4/src/content_deserializer.rs | 7 +- gdk4/src/content_formats.rs | 10 +- gdk4/src/content_formats_builder.rs | 3 +- gdk4/src/content_provider.rs | 6 +- gdk4/src/content_serializer.rs | 7 +- gdk4/src/crossing_event.rs | 3 +- gdk4/src/delete_event.rs | 3 +- gdk4/src/display.rs | 9 +- gdk4/src/dnd_event.rs | 3 +- gdk4/src/drag_surface.rs | 9 +- gdk4/src/draw_context.rs | 6 +- gdk4/src/drop.rs | 10 +- gdk4/src/event.rs | 6 +- gdk4/src/focus_event.rs | 3 +- gdk4/src/functions.rs | 6 +- gdk4/src/gl_texture.rs | 10 +- gdk4/src/gl_texture_builder.rs | 3 +- gdk4/src/grab_broken_event.rs | 3 +- gdk4/src/key_event.rs | 6 +- gdk4/src/keymap_key.rs | 3 +- gdk4/src/keys.rs | 5 +- gdk4/src/lib.rs | 4 +- gdk4/src/motion_event.rs | 3 +- gdk4/src/pad_event.rs | 3 +- gdk4/src/popup_layout.rs | 3 +- gdk4/src/prelude.rs | 29 ++-- gdk4/src/proximity_event.rs | 3 +- gdk4/src/rectangle.rs | 6 +- gdk4/src/rgba.rs | 13 +- gdk4/src/scroll_event.rs | 3 +- gdk4/src/subclass/content_provider.rs | 6 +- gdk4/src/subclass/mod.rs | 6 +- gdk4/src/subclass/paintable.rs | 6 +- gdk4/src/surface.rs | 6 +- gdk4/src/texture.rs | 6 +- gdk4/src/time_coord.rs | 6 +- gdk4/src/toplevel.rs | 9 +- gdk4/src/toplevel_size.rs | 3 +- gdk4/src/touch_event.rs | 3 +- gdk4/src/touchpad_event.rs | 3 +- gdk4/sys/build.rs | 3 +- gsk4/src/border_node.rs | 3 +- gsk4/src/builders.rs | 4 +- gsk4/src/color_stop.rs | 10 +- gsk4/src/container_node.rs | 3 +- gsk4/src/gl_shader.rs | 3 +- gsk4/src/gl_shader_node.rs | 3 +- gsk4/src/ngl_renderer.rs | 6 +- gsk4/src/path.rs | 3 +- gsk4/src/path_builder.rs | 3 +- gsk4/src/path_point.rs | 3 +- gsk4/src/prelude.rs | 6 +- gsk4/src/render_node.rs | 7 +- gsk4/src/rounded_rect.rs | 3 +- gsk4/src/shadow.rs | 3 +- gsk4/src/shadow_node.rs | 3 +- gsk4/src/stroke.rs | 4 +- gsk4/src/transform.rs | 3 +- gtk4-macros/src/blueprint.rs | 7 +- gtk4-macros/src/composite_template_derive.rs | 8 +- gtk4-macros/src/lib.rs | 146 ++++++++++-------- .../src/template_callbacks_attribute.rs | 3 +- gtk4-macros/tests/templates.rs | 14 +- gtk4/src/accessible.rs | 25 +-- gtk4/src/actionable.rs | 6 +- gtk4/src/application.rs | 5 +- gtk4/src/assistant.rs | 3 +- gtk4/src/bitset_iter.rs | 6 +- gtk4/src/bookmark_list.rs | 10 +- gtk4/src/border.rs | 6 +- gtk4/src/builder.rs | 6 +- gtk4/src/builder_rust_scope.rs | 22 +-- gtk4/src/builders.rs | 9 +- gtk4/src/cell_area.rs | 9 +- gtk4/src/cell_layout.rs | 6 +- gtk4/src/closure_expression.rs | 3 +- gtk4/src/color_chooser.rs | 6 +- gtk4/src/combo_box.rs | 6 +- gtk4/src/constant_expression.rs | 7 +- gtk4/src/constraint_guide.rs | 6 +- gtk4/src/constraint_layout.rs | 3 +- gtk4/src/css_location.rs | 3 +- gtk4/src/custom_filter.rs | 6 +- gtk4/src/custom_sorter.rs | 6 +- gtk4/src/dialog.rs | 21 +-- gtk4/src/directory_list.rs | 10 +- gtk4/src/drawing_area.rs | 9 +- gtk4/src/drop_target.rs | 9 +- gtk4/src/editable.rs | 9 +- gtk4/src/editable_label.rs | 5 +- gtk4/src/entry.rs | 6 +- gtk4/src/entry_buffer.rs | 6 +- gtk4/src/entry_completion.rs | 3 +- gtk4/src/enums.rs | 6 +- gtk4/src/event_controller_key.rs | 6 +- gtk4/src/expression.rs | 48 +++--- gtk4/src/expression_watch.rs | 3 +- gtk4/src/file_chooser.rs | 6 +- gtk4/src/file_chooser_dialog.rs | 6 +- gtk4/src/flow_box.rs | 6 +- gtk4/src/font_chooser.rs | 6 +- gtk4/src/font_dialog.rs | 6 +- gtk4/src/functions.rs | 6 +- gtk4/src/gesture_stylus.rs | 3 +- gtk4/src/icon_theme.rs | 3 +- gtk4/src/im_context_simple.rs | 6 +- gtk4/src/keyval_trigger.rs | 6 +- gtk4/src/label.rs | 3 +- gtk4/src/lib.rs | 5 +- gtk4/src/list_box.rs | 6 +- gtk4/src/list_store.rs | 6 +- gtk4/src/map_list_model.rs | 3 +- gtk4/src/media_stream.rs | 3 +- gtk4/src/menu_button.rs | 3 +- gtk4/src/message_dialog.rs | 3 +- gtk4/src/mnemonic_trigger.rs | 6 +- gtk4/src/native_dialog.rs | 17 +- gtk4/src/notebook.rs | 3 +- gtk4/src/object_expression.rs | 3 +- gtk4/src/overlay.rs | 6 +- gtk4/src/pad_action_entry.rs | 5 +- gtk4/src/page_range.rs | 3 +- gtk4/src/param_spec_expression.rs | 11 +- gtk4/src/prelude.rs | 57 +++---- gtk4/src/print_job.rs | 6 +- gtk4/src/print_operation.rs | 3 +- gtk4/src/print_settings.rs | 3 +- gtk4/src/property_expression.rs | 6 +- gtk4/src/recent_data.rs | 3 +- gtk4/src/requisition.rs | 3 +- gtk4/src/response_type.rs | 5 +- gtk4/src/rt.rs | 9 +- gtk4/src/scale.rs | 3 +- gtk4/src/shortcut_trigger.rs | 6 +- gtk4/src/shortcuts_section.rs | 6 +- gtk4/src/signal_list_item_factory.rs | 8 +- gtk4/src/snapshot.rs | 3 +- gtk4/src/spin_button.rs | 6 +- gtk4/src/string_list.rs | 4 +- gtk4/src/string_object.rs | 3 +- gtk4/src/style_context.rs | 3 +- gtk4/src/subclass/accessible.rs | 9 +- gtk4/src/subclass/accessible_range.rs | 6 +- gtk4/src/subclass/actionable.rs | 6 +- gtk4/src/subclass/adjustment.rs | 3 +- gtk4/src/subclass/application.rs | 7 +- gtk4/src/subclass/application_window.rs | 3 +- gtk4/src/subclass/buildable.rs | 74 ++++----- gtk4/src/subclass/builder_scope.rs | 6 +- gtk4/src/subclass/button.rs | 3 +- gtk4/src/subclass/cell_area.rs | 6 +- gtk4/src/subclass/cell_area_context.rs | 6 +- gtk4/src/subclass/cell_editable.rs | 6 +- gtk4/src/subclass/cell_layout.rs | 6 +- gtk4/src/subclass/cell_renderer.rs | 5 +- gtk4/src/subclass/cell_renderer_text.rs | 6 +- gtk4/src/subclass/check_button.rs | 3 +- gtk4/src/subclass/color_chooser.rs | 6 +- gtk4/src/subclass/combo_box.rs | 3 +- gtk4/src/subclass/constraint_target.rs | 3 +- gtk4/src/subclass/dialog.rs | 3 +- gtk4/src/subclass/drawing_area.rs | 3 +- gtk4/src/subclass/editable.rs | 6 +- gtk4/src/subclass/entry.rs | 3 +- gtk4/src/subclass/entry_buffer.rs | 2 +- gtk4/src/subclass/filter.rs | 3 +- gtk4/src/subclass/flow_box_child.rs | 3 +- gtk4/src/subclass/font_chooser.rs | 5 +- gtk4/src/subclass/frame.rs | 3 +- gtk4/src/subclass/gl_area.rs | 3 +- gtk4/src/subclass/im_context.rs | 3 +- gtk4/src/subclass/layout_manager.rs | 5 +- gtk4/src/subclass/list_box_row.rs | 3 +- gtk4/src/subclass/media_file.rs | 3 +- gtk4/src/subclass/media_stream.rs | 3 +- gtk4/src/subclass/mod.rs | 138 ++++++++--------- gtk4/src/subclass/native_dialog.rs | 3 +- gtk4/src/subclass/orientable.rs | 3 +- gtk4/src/subclass/popover.rs | 3 +- gtk4/src/subclass/print_operation.rs | 3 +- gtk4/src/subclass/print_operation_preview.rs | 6 +- gtk4/src/subclass/range.rs | 3 +- gtk4/src/subclass/recent_manager.rs | 3 +- gtk4/src/subclass/scale.rs | 3 +- gtk4/src/subclass/scale_button.rs | 3 +- gtk4/src/subclass/scrollable.rs | 6 +- gtk4/src/subclass/section_model.rs | 6 +- gtk4/src/subclass/selection_model.rs | 6 +- gtk4/src/subclass/shortcut_manager.rs | 6 +- gtk4/src/subclass/sorter.rs | 3 +- gtk4/src/subclass/style_context.rs | 3 +- gtk4/src/subclass/symbolic_paintable.rs | 6 +- gtk4/src/subclass/text_buffer.rs | 3 +- gtk4/src/subclass/text_view.rs | 3 +- gtk4/src/subclass/toggle_button.rs | 3 +- gtk4/src/subclass/tree_drag_dest.rs | 6 +- gtk4/src/subclass/tree_drag_source.rs | 6 +- gtk4/src/subclass/tree_model_filter.rs | 3 +- gtk4/src/subclass/tree_view.rs | 3 +- gtk4/src/subclass/widget.rs | 59 ++++--- gtk4/src/subclass/window.rs | 3 +- gtk4/src/text.rs | 6 +- gtk4/src/text_buffer.rs | 9 +- gtk4/src/tree_model.rs | 9 +- gtk4/src/tree_model_filter.rs | 6 +- gtk4/src/tree_path.rs | 3 +- gtk4/src/tree_row_reference.rs | 3 +- gtk4/src/tree_selection.rs | 3 +- gtk4/src/tree_sortable.rs | 9 +- gtk4/src/tree_store.rs | 3 +- gtk4/src/tree_view.rs | 6 +- gtk4/src/tree_view_column.rs | 3 +- gtk4/src/widget.rs | 4 +- 233 files changed, 1061 insertions(+), 719 deletions(-) diff --git a/gdk4-wayland/src/lib.rs b/gdk4-wayland/src/lib.rs index a604c196b521..cb774e727ec0 100644 --- a/gdk4-wayland/src/lib.rs +++ b/gdk4-wayland/src/lib.rs @@ -7,14 +7,12 @@ pub use ffi; pub use gdk; pub use gio; pub use glib; -#[cfg(feature = "wayland_crate")] -#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] -pub use wayland_client; - #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] pub use khronos_egl; - +#[cfg(feature = "wayland_crate")] +#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] +pub use wayland_client; #[cfg(all(feature = "v4_4", feature = "xkb_crate"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "xkb_crate"))))] pub use xkb; diff --git a/gdk4-wayland/src/prelude.rs b/gdk4-wayland/src/prelude.rs index 7cb35e6106a8..637e34090774 100644 --- a/gdk4-wayland/src/prelude.rs +++ b/gdk4-wayland/src/prelude.rs @@ -3,11 +3,11 @@ // rustdoc-stripper-ignore-next //! Traits intended for blanket imports. -pub use crate::wayland_surface::WaylandSurfaceExtManual; - #[doc(hidden)] pub use gdk::prelude::*; #[doc(hidden)] pub use gio::prelude::*; #[doc(hidden)] pub use glib::prelude::*; + +pub use crate::wayland_surface::WaylandSurfaceExtManual; diff --git a/gdk4-wayland/src/wayland_device.rs b/gdk4-wayland/src/wayland_device.rs index 907e0749a1be..f4cb26034432 100644 --- a/gdk4-wayland/src/wayland_device.rs +++ b/gdk4-wayland/src/wayland_device.rs @@ -1,16 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -#[cfg(feature = "wayland_crate")] -#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] -use crate::prelude::*; -use crate::WaylandDevice; #[cfg(any(feature = "wayland_crate", feature = "xkb_crate"))] #[cfg_attr( docsrs, doc(cfg(any(feature = "wayland_crate", feature = "xkb_crate"))) )] use glib::translate::*; - #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] use wayland_client::{ @@ -18,11 +13,15 @@ use wayland_client::{ protocol::{wl_keyboard::WlKeyboard, wl_pointer::WlPointer, wl_seat::WlSeat}, Proxy, }; - #[cfg(all(feature = "v4_4", feature = "xkb_crate"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "xkb_crate"))))] use xkb::Keymap; +#[cfg(feature = "wayland_crate")] +#[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] +use crate::prelude::*; +use crate::WaylandDevice; + impl WaylandDevice { #[doc(alias = "gdk_wayland_device_get_wl_keyboard")] #[doc(alias = "get_wl_keyboard")] diff --git a/gdk4-wayland/src/wayland_display.rs b/gdk4-wayland/src/wayland_display.rs index caa6f94a1550..3d3903dcf02b 100644 --- a/gdk4-wayland/src/wayland_display.rs +++ b/gdk4-wayland/src/wayland_display.rs @@ -1,14 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::WaylandDisplay; #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] use glib::{once_cell::sync::Lazy, prelude::*, translate::*, Quark}; - #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] use khronos_egl as egl; - #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] use wayland_client::{ @@ -17,6 +14,8 @@ use wayland_client::{ Proxy, }; +use crate::WaylandDisplay; + #[cfg(feature = "wayland_crate")] static WAYLAND_DISPLAY_CONNECTION_QUARK: Lazy = Lazy::new(|| Quark::from_str("gtk-rs-wayland-display-connection-quark")); diff --git a/gdk4-wayland/src/wayland_monitor.rs b/gdk4-wayland/src/wayland_monitor.rs index bcaf47584720..41ad63a17f3b 100644 --- a/gdk4-wayland/src/wayland_monitor.rs +++ b/gdk4-wayland/src/wayland_monitor.rs @@ -1,13 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::WaylandMonitor; #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] -use {crate::prelude::*, glib::translate::*}; - +use wayland_client::{backend::ObjectId, protocol::wl_output::WlOutput, Proxy}; #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] -use wayland_client::{backend::ObjectId, protocol::wl_output::WlOutput, Proxy}; +use {crate::prelude::*, glib::translate::*}; + +use crate::WaylandMonitor; impl WaylandMonitor { #[doc(alias = "gdk_wayland_monitor_get_wl_output")] diff --git a/gdk4-wayland/src/wayland_seat.rs b/gdk4-wayland/src/wayland_seat.rs index cf66b6811507..f27a9d792313 100644 --- a/gdk4-wayland/src/wayland_seat.rs +++ b/gdk4-wayland/src/wayland_seat.rs @@ -1,13 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::WaylandSeat; #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] -use {crate::prelude::*, glib::translate::*}; - +use wayland_client::{backend::ObjectId, protocol::wl_seat::WlSeat, Proxy}; #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] -use wayland_client::{backend::ObjectId, protocol::wl_seat::WlSeat, Proxy}; +use {crate::prelude::*, glib::translate::*}; + +use crate::WaylandSeat; impl WaylandSeat { #[doc(alias = "gdk_wayland_seat_get_wl_seat")] diff --git a/gdk4-wayland/src/wayland_surface.rs b/gdk4-wayland/src/wayland_surface.rs index b4938bba0abb..86358242d35e 100644 --- a/gdk4-wayland/src/wayland_surface.rs +++ b/gdk4-wayland/src/wayland_surface.rs @@ -1,21 +1,22 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, WaylandSurface}; #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] use glib::translate::*; - #[cfg(feature = "wayland_crate")] #[cfg_attr(docsrs, doc(cfg(feature = "wayland_crate")))] use wayland_client::{backend::ObjectId, protocol::wl_surface::WlSurface, Proxy}; +use crate::{prelude::*, WaylandSurface}; + mod sealed { pub trait Sealed {} impl> Sealed for T {} } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`WaylandSurface`](crate::WaylandSurface). +/// Trait containing manually implemented methods of +/// [`WaylandSurface`](crate::WaylandSurface). pub trait WaylandSurfaceExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_wayland_surface_get_wl_surface")] #[doc(alias = "get_wl_surface")] diff --git a/gdk4-win32/src/win32_display.rs b/gdk4-win32/src/win32_display.rs index 56e038de7221..24bbbda8c3b4 100644 --- a/gdk4-win32/src/win32_display.rs +++ b/gdk4-win32/src/win32_display.rs @@ -1,12 +1,12 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Win32Display, Win32MessageFilterReturn, MSG}; use glib::translate::*; - #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] use khronos_egl as egl; +use crate::{Win32Display, Win32MessageFilterReturn, MSG}; + impl Win32Display { #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] diff --git a/gdk4-win32/src/win32_hcursor.rs b/gdk4-win32/src/win32_hcursor.rs index 5117b2653e66..72fee69730c8 100644 --- a/gdk4-win32/src/win32_hcursor.rs +++ b/gdk4-win32/src/win32_hcursor.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Win32HCursor, HCURSOR}; -use glib::{translate::*, types::Pointee}; use std::ptr::NonNull; +use glib::{translate::*, types::Pointee}; + +use crate::{prelude::*, Win32HCursor, HCURSOR}; + impl Win32HCursor { #[doc(alias = "gdk_win32_hcursor_new")] pub fn new( diff --git a/gdk4-win32/src/win32_surface.rs b/gdk4-win32/src/win32_surface.rs index 75228096a87a..447ca86e0d37 100644 --- a/gdk4-win32/src/win32_surface.rs +++ b/gdk4-win32/src/win32_surface.rs @@ -1,9 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Win32Surface, HWND}; - use glib::translate::*; +use crate::{prelude::*, Win32Surface, HWND}; + impl Win32Surface { #[doc(alias = "gdk_win32_surface_lookup_for_display")] pub fn lookup_for_display( diff --git a/gdk4-x11/src/functions.rs b/gdk4-x11/src/functions.rs index 385cdc1a4c40..852c82229ac7 100644 --- a/gdk4-x11/src/functions.rs +++ b/gdk4-x11/src/functions.rs @@ -1,15 +1,15 @@ // Take a look at the license at the top of the repository in the LICENSE file. -pub use crate::auto::functions::*; -use crate::X11Display; use glib::{translate::*, IntoGStr}; - -#[cfg(not(feature = "xlib"))] -use crate::XAtom; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use x11::xlib::Atom as XAtom; +pub use crate::auto::functions::*; +use crate::X11Display; +#[cfg(not(feature = "xlib"))] +use crate::XAtom; + #[doc(alias = "gdk_x11_get_xatom_by_name_for_display")] pub fn x11_get_xatom_by_name_for_display(display: &X11Display, atom_name: impl IntoGStr) -> XAtom { skip_assert_initialized!(); diff --git a/gdk4-x11/src/lib.rs b/gdk4-x11/src/lib.rs index a22d33e18ca1..216e54a87131 100644 --- a/gdk4-x11/src/lib.rs +++ b/gdk4-x11/src/lib.rs @@ -7,13 +7,12 @@ pub use ffi; pub use gdk; pub use gio; pub use glib; -#[cfg(feature = "xlib")] -#[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] -pub use x11; - #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] pub use khronos_egl; +#[cfg(feature = "xlib")] +#[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] +pub use x11; #[macro_use] mod rt; diff --git a/gdk4-x11/src/x11_display.rs b/gdk4-x11/src/x11_display.rs index 23925e5cf8d7..1163ab61a9c9 100644 --- a/gdk4-x11/src/x11_display.rs +++ b/gdk4-x11/src/x11_display.rs @@ -1,25 +1,26 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, X11Display}; +#[cfg(feature = "xlib")] +#[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] +use std::{boxed::Box as Box_, mem::transmute}; + #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use glib::signal::{connect_raw, SignalHandlerId}; +use glib::{translate::*, IntoGStr}; #[cfg(all(feature = "v4_4", feature = "egl"))] #[cfg_attr(docsrs, doc(cfg(all(feature = "v4_4", feature = "egl"))))] use khronos_egl as egl; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] -use std::{boxed::Box as Box_, mem::transmute}; +use x11::xlib; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] -use x11::xlib; +use x11::xlib::{Cursor as XCursor, Window as XWindow}; +use crate::{prelude::*, X11Display}; #[cfg(not(feature = "xlib"))] use crate::{XCursor, XWindow}; -use glib::{translate::*, IntoGStr}; -#[cfg(feature = "xlib")] -#[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] -use x11::xlib::{Cursor as XCursor, Window as XWindow}; impl X11Display { #[cfg(all(feature = "v4_4", feature = "egl"))] diff --git a/gdk4-x11/src/x11_monitor.rs b/gdk4-x11/src/x11_monitor.rs index 0474927878e2..fb8b91558efd 100644 --- a/gdk4-x11/src/x11_monitor.rs +++ b/gdk4-x11/src/x11_monitor.rs @@ -1,13 +1,14 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::X11Monitor; -#[cfg(not(feature = "xlib"))] -use crate::XID; use glib::translate::*; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use x11::xlib::XID; +use crate::X11Monitor; +#[cfg(not(feature = "xlib"))] +use crate::XID; + impl X11Monitor { #[doc(alias = "gdk_x11_monitor_get_output")] #[doc(alias = "get_output")] diff --git a/gdk4-x11/src/x11_screen.rs b/gdk4-x11/src/x11_screen.rs index e1a5a657289d..df50e1c49d04 100644 --- a/gdk4-x11/src/x11_screen.rs +++ b/gdk4-x11/src/x11_screen.rs @@ -1,13 +1,14 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::X11Screen; -#[cfg(not(feature = "xlib"))] -use crate::XID; use glib::translate::*; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use x11::xlib::{self, XID}; +use crate::X11Screen; +#[cfg(not(feature = "xlib"))] +use crate::XID; + impl X11Screen { #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] diff --git a/gdk4-x11/src/x11_surface.rs b/gdk4-x11/src/x11_surface.rs index b073f96948bb..297177e48f93 100644 --- a/gdk4-x11/src/x11_surface.rs +++ b/gdk4-x11/src/x11_surface.rs @@ -1,13 +1,14 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::X11Surface; -#[cfg(not(feature = "xlib"))] -use crate::XWindow; use glib::translate::*; #[cfg(feature = "xlib")] #[cfg_attr(docsrs, doc(cfg(feature = "xlib")))] use x11::xlib::Window as XWindow; +use crate::X11Surface; +#[cfg(not(feature = "xlib"))] +use crate::XWindow; + impl X11Surface { #[doc(alias = "gdk_x11_surface_get_xid")] #[doc(alias = "get_xid")] diff --git a/gdk4/src/builders.rs b/gdk4/src/builders.rs index 16e20a9e5a41..a92a9904f2ef 100644 --- a/gdk4/src/builders.rs +++ b/gdk4/src/builders.rs @@ -3,9 +3,7 @@ // rustdoc-stripper-ignore-next //! Builder pattern types. -pub use crate::auto::builders::*; -pub use crate::rgba::RGBABuilder; -pub use crate::ContentFormatsBuilder; #[cfg(feature = "v4_12")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] pub use crate::GLTextureBuilder; +pub use crate::{auto::builders::*, rgba::RGBABuilder, ContentFormatsBuilder}; diff --git a/gdk4/src/button_event.rs b/gdk4/src/button_event.rs index d380d7568ee3..f90e0121695e 100644 --- a/gdk4/src/button_event.rs +++ b/gdk4/src/button_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{ButtonEvent, EventType}; use std::fmt; +use crate::{ButtonEvent, EventType}; + define_event! { ButtonEvent, ffi::GdkButtonEvent, diff --git a/gdk4/src/cairo_interaction.rs b/gdk4/src/cairo_interaction.rs index 1c4fbe6b6ec1..2b23c387e18a 100644 --- a/gdk4/src/cairo_interaction.rs +++ b/gdk4/src/cairo_interaction.rs @@ -1,10 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Rectangle, Surface, RGBA}; use cairo::{Context, Region}; use gdk_pixbuf::Pixbuf; use glib::translate::*; +use crate::{Rectangle, Surface, RGBA}; + // rustdoc-stripper-ignore-next /// Trait containing integration methods with [`cairo::Surface`]. pub trait GdkCairoSurfaceExt { diff --git a/gdk4/src/clipboard.rs b/gdk4/src/clipboard.rs index 4fc945133315..1702ffb03912 100644 --- a/gdk4/src/clipboard.rs +++ b/gdk4/src/clipboard.rs @@ -1,10 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Clipboard}; -use glib::translate::*; -use glib::GString; use std::{future, pin::Pin, ptr}; +use glib::{translate::*, GString}; + +use crate::{prelude::*, Clipboard}; + impl Clipboard { #[doc(alias = "gdk_clipboard_read_async")] pub fn read_async) + 'static>( diff --git a/gdk4/src/content_deserializer.rs b/gdk4/src/content_deserializer.rs index 897177382716..52068f5f94fa 100644 --- a/gdk4/src/content_deserializer.rs +++ b/gdk4/src/content_deserializer.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use glib::{translate::*, value::FromValue}; + use crate::ContentDeserializer; -use glib::translate::*; -use glib::value::FromValue; impl ContentDeserializer { pub fn set_value(&self, value: glib::Value) { @@ -26,7 +26,8 @@ impl ContentDeserializer { } // rustdoc-stripper-ignore-next - /// Similar to [`Self::value`] but panics if the value is of a different type. + /// Similar to [`Self::value`] but panics if the value is of a different + /// type. #[doc(alias = "gdk_content_deserializer_get_value")] #[doc(alias = "get_value")] pub fn value_as FromValue<'b> + 'static>(&self) -> V { diff --git a/gdk4/src/content_formats.rs b/gdk4/src/content_formats.rs index 8e4eaeab0635..f5958058a0f9 100644 --- a/gdk4/src/content_formats.rs +++ b/gdk4/src/content_formats.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{ContentFormats, ContentFormatsBuilder}; use glib::{translate::*, Slice}; +use crate::{ContentFormats, ContentFormatsBuilder}; + impl ContentFormats { #[doc(alias = "gdk_content_formats_get_gtypes")] #[doc(alias = "get_gtypes")] @@ -17,9 +18,12 @@ impl ContentFormats { } // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`ContentFormats`] objects. + /// Creates a new builder-pattern struct instance to construct + /// [`ContentFormats`] objects. /// - /// This method returns an instance of [`ContentFormatsBuilder`](crate::builders::ContentFormatsBuilder) which can be used to create [`ContentFormats`] objects. + /// This method returns an instance of + /// [`ContentFormatsBuilder`](crate::builders::ContentFormatsBuilder) which + /// can be used to create [`ContentFormats`] objects. pub fn builder() -> ContentFormatsBuilder { ContentFormatsBuilder::default() } diff --git a/gdk4/src/content_formats_builder.rs b/gdk4/src/content_formats_builder.rs index 3f2fd704b26f..98d314fd128a 100644 --- a/gdk4/src/content_formats_builder.rs +++ b/gdk4/src/content_formats_builder.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{ContentFormats, ContentFormatsBuilder}; use glib::{translate::*, IntoGStr}; +use crate::{ContentFormats, ContentFormatsBuilder}; + impl ContentFormatsBuilder { #[doc(alias = "gdk_content_formats_builder_add_formats")] #[must_use] diff --git a/gdk4/src/content_provider.rs b/gdk4/src/content_provider.rs index 9bd12a34b5f0..1380989a532f 100644 --- a/gdk4/src/content_provider.rs +++ b/gdk4/src/content_provider.rs @@ -1,15 +1,17 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, ContentProvider}; use glib::translate::*; +use crate::{prelude::*, ContentProvider}; + mod sealed { pub trait Sealed {} impl> Sealed for T {} } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`ContentProvider`](crate::ContentProvider). +/// Trait containing manually implemented methods of +/// [`ContentProvider`](crate::ContentProvider). pub trait ContentProviderExtManual: sealed::Sealed + IsA { #[doc(alias = "gdk_content_provider_get_value")] fn value(&self, type_: glib::Type) -> Result { diff --git a/gdk4/src/content_serializer.rs b/gdk4/src/content_serializer.rs index 94887129f0c4..7ef5dab89e2a 100644 --- a/gdk4/src/content_serializer.rs +++ b/gdk4/src/content_serializer.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use glib::{translate::*, value::FromValue}; + use crate::ContentSerializer; -use glib::translate::*; -use glib::value::FromValue; impl ContentSerializer { #[doc(alias = "gdk_content_serializer_get_priority")] @@ -16,7 +16,8 @@ impl ContentSerializer { } // rustdoc-stripper-ignore-next - /// Similar to [`Self::value`] but panics if the value is of a different type. + /// Similar to [`Self::value`] but panics if the value is of a different + /// type. #[doc(alias = "gdk_content_serializer_get_value")] #[doc(alias = "get_value")] pub fn value_as FromValue<'b> + 'static>(&self) -> V { diff --git a/gdk4/src/crossing_event.rs b/gdk4/src/crossing_event.rs index 7cbe0db89644..8b694cc2f210 100644 --- a/gdk4/src/crossing_event.rs +++ b/gdk4/src/crossing_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{CrossingEvent, EventType}; use std::fmt; +use crate::{CrossingEvent, EventType}; + define_event! { CrossingEvent, ffi::GdkCrossingEvent, diff --git a/gdk4/src/delete_event.rs b/gdk4/src/delete_event.rs index c2616ae9287c..147665d8406f 100644 --- a/gdk4/src/delete_event.rs +++ b/gdk4/src/delete_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{DeleteEvent, EventType}; use std::fmt; +use crate::{DeleteEvent, EventType}; + define_event! { DeleteEvent, ffi::GdkDeleteEvent, diff --git a/gdk4/src/display.rs b/gdk4/src/display.rs index 0ee691207bdf..729cb655ac97 100644 --- a/gdk4/src/display.rs +++ b/gdk4/src/display.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Display, Key, KeymapKey, ModifierType}; -use glib::{translate::*, IntoGStr}; use std::{mem, ptr}; +use glib::{translate::*, IntoGStr}; + +use crate::{prelude::*, Display, Key, KeymapKey, ModifierType}; + #[derive(Debug, PartialEq, Eq, Ord, PartialOrd)] pub enum Backend { Wayland, @@ -56,7 +58,8 @@ mod sealed { } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`Display`](crate::Display). +/// Trait containing manually implemented methods of +/// [`Display`](crate::Display). pub trait DisplayExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_display_translate_key")] fn translate_key( diff --git a/gdk4/src/dnd_event.rs b/gdk4/src/dnd_event.rs index 8f29119e047f..d03d448752aa 100644 --- a/gdk4/src/dnd_event.rs +++ b/gdk4/src/dnd_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{DNDEvent, EventType}; use std::fmt; +use crate::{DNDEvent, EventType}; + define_event! { DNDEvent, ffi::GdkDNDEvent, diff --git a/gdk4/src/drag_surface.rs b/gdk4/src/drag_surface.rs index d7294d13147b..089b42426782 100644 --- a/gdk4/src/drag_surface.rs +++ b/gdk4/src/drag_surface.rs @@ -1,11 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, DragSurface, DragSurfaceSize}; +use std::{boxed::Box as Box_, mem::transmute}; + use glib::{ signal::{connect_raw, SignalHandlerId}, translate::*, }; -use std::{boxed::Box as Box_, mem::transmute}; + +use crate::{prelude::*, DragSurface, DragSurfaceSize}; mod sealed { pub trait Sealed {} @@ -13,7 +15,8 @@ mod sealed { } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`DragSurface`](crate::DragSurface). +/// Trait containing manually implemented methods of +/// [`DragSurface`](crate::DragSurface). pub trait DragSurfaceExtManual: sealed::Sealed + IsA { #[cfg(feature = "v4_12")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] diff --git a/gdk4/src/draw_context.rs b/gdk4/src/draw_context.rs index 87e1ed752ee2..45938f0ebffe 100644 --- a/gdk4/src/draw_context.rs +++ b/gdk4/src/draw_context.rs @@ -1,15 +1,17 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, DrawContext}; use glib::translate::*; +use crate::{prelude::*, DrawContext}; + mod sealed { pub trait Sealed {} impl> Sealed for T {} } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`DrawContext`](crate::DrawContext). +/// Trait containing manually implemented methods of +/// [`DrawContext`](crate::DrawContext). pub trait DrawContextExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_draw_context_get_frame_region")] #[doc(alias = "get_frame_region")] diff --git a/gdk4/src/drop.rs b/gdk4/src/drop.rs index a782fb1d3534..c6b216e36743 100644 --- a/gdk4/src/drop.rs +++ b/gdk4/src/drop.rs @@ -1,12 +1,10 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::{future, pin::Pin, ptr}; + +use glib::{object::IsA, translate::*, GString}; + use crate::Drop; -use glib::object::IsA; -use glib::translate::*; -use glib::GString; -use std::future; -use std::pin::Pin; -use std::ptr; impl Drop { #[doc(alias = "gdk_drop_read_async")] diff --git a/gdk4/src/event.rs b/gdk4/src/event.rs index eaab291b468e..085a5f1ab92a 100644 --- a/gdk4/src/event.rs +++ b/gdk4/src/event.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Event, EventType}; -use glib::{translate::*, StaticType}; use std::{fmt, mem}; +use glib::{translate::*, StaticType}; + +use crate::{Event, EventType}; + impl Event { #[inline] pub fn is(&self) -> bool { diff --git a/gdk4/src/focus_event.rs b/gdk4/src/focus_event.rs index 8ea85ceac25b..4bb73139a121 100644 --- a/gdk4/src/focus_event.rs +++ b/gdk4/src/focus_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, FocusEvent}; use std::fmt; +use crate::{EventType, FocusEvent}; + define_event! { FocusEvent, ffi::GdkFocusEvent, diff --git a/gdk4/src/functions.rs b/gdk4/src/functions.rs index 51805fa9cae5..a59e7132091f 100644 --- a/gdk4/src/functions.rs +++ b/gdk4/src/functions.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::{future, pin::Pin, ptr}; + +use glib::translate::*; + pub use crate::auto::functions::*; use crate::{prelude::*, ContentDeserializer, ContentSerializer}; -use glib::translate::*; -use std::{future, pin::Pin, ptr}; #[repr(packed)] pub struct GRange(pub i32, pub i32); diff --git a/gdk4/src/gl_texture.rs b/gdk4/src/gl_texture.rs index 6562600dfbf1..74e58340d3c1 100644 --- a/gdk4/src/gl_texture.rs +++ b/gdk4/src/gl_texture.rs @@ -1,10 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use glib::translate::*; + #[cfg(feature = "v4_12")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] use crate::builders::GLTextureBuilder; use crate::{GLContext, GLTexture}; -use glib::translate::*; impl GLTexture { #[doc(alias = "gdk_gl_texture_new")] @@ -45,9 +46,12 @@ impl GLTexture { #[cfg(feature = "v4_12")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`GLTexture`] objects. + /// Creates a new builder-pattern struct instance to construct [`GLTexture`] + /// objects. /// - /// This method returns an instance of [`GLTextureBuilder`](crate::builders::GLTextureBuilder) which can be used to create [`GLTexture`] objects. + /// This method returns an instance of + /// [`GLTextureBuilder`](crate::builders::GLTextureBuilder) which can be + /// used to create [`GLTexture`] objects. pub fn builder() -> GLTextureBuilder { GLTextureBuilder::new() } diff --git a/gdk4/src/gl_texture_builder.rs b/gdk4/src/gl_texture_builder.rs index 5031c0b3a679..1ab9836509ec 100644 --- a/gdk4/src/gl_texture_builder.rs +++ b/gdk4/src/gl_texture_builder.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{GLContext, GLTextureBuilder, MemoryFormat, Texture}; use glib::{prelude::*, translate::*}; +use crate::{GLContext, GLTextureBuilder, MemoryFormat, Texture}; + #[cfg(not(feature = "gl"))] pub type GLsync = *const libc::c_void; diff --git a/gdk4/src/grab_broken_event.rs b/gdk4/src/grab_broken_event.rs index 6e0889080ab4..ebfa08409c6d 100644 --- a/gdk4/src/grab_broken_event.rs +++ b/gdk4/src/grab_broken_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, GrabBrokenEvent}; use std::fmt; +use crate::{EventType, GrabBrokenEvent}; + define_event! { GrabBrokenEvent, ffi::GdkGrabBrokenEvent, diff --git a/gdk4/src/key_event.rs b/gdk4/src/key_event.rs index b9ff86634599..c06dbc3ea99b 100644 --- a/gdk4/src/key_event.rs +++ b/gdk4/src/key_event.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, Key, KeyEvent, KeyMatch, ModifierType}; -use glib::translate::*; use std::{fmt, mem}; +use glib::translate::*; + +use crate::{EventType, Key, KeyEvent, KeyMatch, ModifierType}; + define_event! { KeyEvent, ffi::GdkKeyEvent, diff --git a/gdk4/src/keymap_key.rs b/gdk4/src/keymap_key.rs index 526f5345c19c..6886c6437dcc 100644 --- a/gdk4/src/keymap_key.rs +++ b/gdk4/src/keymap_key.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::translate::*; use std::fmt; +use glib::translate::*; + glib::wrapper! { #[doc(alias = "GdkKeymapKey")] pub struct KeymapKey(BoxedInline); diff --git a/gdk4/src/keys.rs b/gdk4/src/keys.rs index 7e04306eaee9..b32890017905 100644 --- a/gdk4/src/keys.rs +++ b/gdk4/src/keys.rs @@ -4676,8 +4676,9 @@ unsafe impl<'a> FromValue<'a> for Key { #[inline] unsafe fn from_value(value: &'a Value) -> Self { let res: u32 = glib::gobject_ffi::g_value_get_uint(value.to_glib_none().0); - // As most of gdk_keyval_ apis don't really do any check for the input value (the key number) - // other than gdk_keyval_from_name, it is safe to not do any checks and assume people will not mis-use it + // As most of gdk_keyval_ apis don't really do any check for the input value + // (the key number) other than gdk_keyval_from_name, it is safe to not + // do any checks and assume people will not mis-use it Key::from_glib(res) } } diff --git a/gdk4/src/lib.rs b/gdk4/src/lib.rs index 173841f80454..ddb65a4b5532 100644 --- a/gdk4/src/lib.rs +++ b/gdk4/src/lib.rs @@ -107,13 +107,11 @@ mod touch_event; mod touchpad_event; pub use auto::*; - -pub use functions::*; - pub use display::Backend; #[cfg(feature = "v4_12")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] pub use drag_surface_size::DragSurfaceSize; +pub use functions::*; pub use keymap_key::KeymapKey; pub use keys::Key; pub use time_coord::TimeCoord; diff --git a/gdk4/src/motion_event.rs b/gdk4/src/motion_event.rs index d14c0a102bb5..2a5b09e9a2b8 100644 --- a/gdk4/src/motion_event.rs +++ b/gdk4/src/motion_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, MotionEvent}; use std::fmt; +use crate::{EventType, MotionEvent}; + define_event! { MotionEvent, ffi::GdkMotionEvent, diff --git a/gdk4/src/pad_event.rs b/gdk4/src/pad_event.rs index 6b0a576ec771..dc3b64a49d94 100644 --- a/gdk4/src/pad_event.rs +++ b/gdk4/src/pad_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, PadEvent}; use std::fmt; +use crate::{EventType, PadEvent}; + define_event! { PadEvent, ffi::GdkPadEvent, diff --git a/gdk4/src/popup_layout.rs b/gdk4/src/popup_layout.rs index bfae49a75d87..3fc18e7af035 100644 --- a/gdk4/src/popup_layout.rs +++ b/gdk4/src/popup_layout.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::PopupLayout; use glib::translate::*; +use crate::PopupLayout; + impl PopupLayout { #[doc(alias = "gdk_popup_layout_get_offset")] #[doc(alias = "get_offset")] diff --git a/gdk4/src/prelude.rs b/gdk4/src/prelude.rs index 474e05012231..279c773d5e20 100644 --- a/gdk4/src/prelude.rs +++ b/gdk4/src/prelude.rs @@ -3,20 +3,6 @@ // rustdoc-stripper-ignore-next //! Traits intended for blanket imports. -pub use crate::auto::traits::*; - -pub use crate::cairo_interaction::{GdkCairoContextExt, GdkCairoSurfaceExt}; -pub use crate::content_provider::ContentProviderExtManual; -pub use crate::display::DisplayExtManual; -#[cfg(feature = "v4_12")] -#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] -pub use crate::drag_surface::DragSurfaceExtManual; -pub use crate::draw_context::DrawContextExtManual; -pub use crate::event::EventKind; -pub use crate::surface::SurfaceExtManual; -pub use crate::texture::TextureExtManual; -pub use crate::toplevel::ToplevelExtManual; - #[doc(hidden)] pub use gdk_pixbuf::prelude::*; #[doc(hidden)] @@ -25,3 +11,18 @@ pub use gio::prelude::*; pub use glib::prelude::*; #[doc(hidden)] pub use pango::prelude::*; + +#[cfg(feature = "v4_12")] +#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))] +pub use crate::drag_surface::DragSurfaceExtManual; +pub use crate::{ + auto::traits::*, + cairo_interaction::{GdkCairoContextExt, GdkCairoSurfaceExt}, + content_provider::ContentProviderExtManual, + display::DisplayExtManual, + draw_context::DrawContextExtManual, + event::EventKind, + surface::SurfaceExtManual, + texture::TextureExtManual, + toplevel::ToplevelExtManual, +}; diff --git a/gdk4/src/proximity_event.rs b/gdk4/src/proximity_event.rs index 84c1a9f9839b..e59106f8420d 100644 --- a/gdk4/src/proximity_event.rs +++ b/gdk4/src/proximity_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, ProximityEvent}; use std::fmt; +use crate::{EventType, ProximityEvent}; + define_event! { ProximityEvent, ffi::GdkProximityEvent, diff --git a/gdk4/src/rectangle.rs b/gdk4/src/rectangle.rs index 64e3d028d95a..0a44b379778e 100644 --- a/gdk4/src/rectangle.rs +++ b/gdk4/src/rectangle.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::Rectangle; +use std::fmt; + use cairo::RectangleInt; use glib::translate::*; -use std::fmt; + +use crate::Rectangle; impl Rectangle { #[inline] diff --git a/gdk4/src/rgba.rs b/gdk4/src/rgba.rs index 533f1e39c507..c16981f778eb 100644 --- a/gdk4/src/rgba.rs +++ b/gdk4/src/rgba.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::RGBA; -use glib::{translate::*, IntoGStr}; use std::{fmt, str::FromStr}; +use glib::{translate::*, IntoGStr}; + +use crate::RGBA; + #[derive(Debug)] // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`RGBA`] objects. @@ -146,9 +148,12 @@ impl RGBA { } // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`RGBA`] objects. + /// Creates a new builder-pattern struct instance to construct [`RGBA`] + /// objects. /// - /// This method returns an instance of [`RGBABuilder`](crate::builders::RGBABuilder) which can be used to create [`RGBA`] objects. + /// This method returns an instance of + /// [`RGBABuilder`](crate::builders::RGBABuilder) which can be used to + /// create [`RGBA`] objects. pub fn builder() -> RGBABuilder { RGBABuilder::default() } diff --git a/gdk4/src/scroll_event.rs b/gdk4/src/scroll_event.rs index be8a84a2f123..641426cf95eb 100644 --- a/gdk4/src/scroll_event.rs +++ b/gdk4/src/scroll_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, ScrollEvent}; use std::fmt; +use crate::{EventType, ScrollEvent}; + define_event! { ScrollEvent, ffi::GdkScrollEvent, diff --git a/gdk4/src/subclass/content_provider.rs b/gdk4/src/subclass/content_provider.rs index c46471d3f20e..7cdb10e81cf6 100644 --- a/gdk4/src/subclass/content_provider.rs +++ b/gdk4/src/subclass/content_provider.rs @@ -3,10 +3,12 @@ // rustdoc-stripper-ignore-next //! Traits intended for subclassing [`ContentProvider`](crate::ContentProvider). -use crate::{prelude::*, subclass::prelude::*, Clipboard, ContentFormats, ContentProvider}; -use glib::{translate::*, Value}; use std::{future::Future, pin::Pin}; +use glib::{translate::*, Value}; + +use crate::{prelude::*, subclass::prelude::*, Clipboard, ContentFormats, ContentProvider}; + pub trait ContentProviderImpl: ContentProviderImplExt + ObjectImpl { fn content_changed(&self) { self.parent_content_changed() diff --git a/gdk4/src/subclass/mod.rs b/gdk4/src/subclass/mod.rs index 27afcd19381a..cebd38079e64 100644 --- a/gdk4/src/subclass/mod.rs +++ b/gdk4/src/subclass/mod.rs @@ -14,6 +14,8 @@ pub mod prelude { #[doc(hidden)] pub use glib::subclass::prelude::*; - pub use super::content_provider::{ContentProviderImpl, ContentProviderImplExt}; - pub use super::paintable::{PaintableImpl, PaintableImplExt}; + pub use super::{ + content_provider::{ContentProviderImpl, ContentProviderImplExt}, + paintable::{PaintableImpl, PaintableImplExt}, + }; } diff --git a/gdk4/src/subclass/paintable.rs b/gdk4/src/subclass/paintable.rs index 7b34fa112b82..1514b4d1270e 100644 --- a/gdk4/src/subclass/paintable.rs +++ b/gdk4/src/subclass/paintable.rs @@ -1,11 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next -//! Traits intended for implementing the [`Paintable`](crate::Paintable) interface. +//! Traits intended for implementing the [`Paintable`](crate::Paintable) +//! interface. -use crate::{prelude::*, subclass::prelude::*, Paintable, PaintableFlags, Snapshot}; use glib::translate::*; +use crate::{prelude::*, subclass::prelude::*, Paintable, PaintableFlags, Snapshot}; + pub trait PaintableImpl: PaintableImplExt + ObjectImpl { #[doc(alias = "get_current_image")] fn current_image(&self) -> Paintable { diff --git a/gdk4/src/surface.rs b/gdk4/src/surface.rs index 3d094faccf27..044fedc96c78 100644 --- a/gdk4/src/surface.rs +++ b/gdk4/src/surface.rs @@ -1,15 +1,17 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Surface}; use glib::translate::*; +use crate::{prelude::*, Surface}; + mod sealed { pub trait Sealed {} impl> Sealed for T {} } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`Surface`](crate::Surface). +/// Trait containing manually implemented methods of +/// [`Surface`](crate::Surface). pub trait SurfaceExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_surface_create_similar_surface")] fn create_similar_surface( diff --git a/gdk4/src/texture.rs b/gdk4/src/texture.rs index 281c00f0ba3a..4531e88124e8 100644 --- a/gdk4/src/texture.rs +++ b/gdk4/src/texture.rs @@ -1,15 +1,17 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Texture}; use glib::translate::*; +use crate::{prelude::*, Texture}; + mod sealed { pub trait Sealed {} impl> Sealed for T {} } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`Texture`](crate::Texture). +/// Trait containing manually implemented methods of +/// [`Texture`](crate::Texture). pub trait TextureExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "gdk_texture_download")] fn download(&self, data: &mut [u8], stride: usize) { diff --git a/gdk4/src/time_coord.rs b/gdk4/src/time_coord.rs index d97e45264257..8631437005fe 100644 --- a/gdk4/src/time_coord.rs +++ b/gdk4/src/time_coord.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::AxisFlags; -use glib::translate::*; use std::fmt; +use glib::translate::*; + +use crate::AxisFlags; + glib::wrapper! { #[doc(alias = "GdkTimeCoord")] pub struct TimeCoord(BoxedInline); diff --git a/gdk4/src/toplevel.rs b/gdk4/src/toplevel.rs index 3290376d3324..6e0a3815ef86 100644 --- a/gdk4/src/toplevel.rs +++ b/gdk4/src/toplevel.rs @@ -1,11 +1,13 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Toplevel, ToplevelSize}; +use std::{boxed::Box as Box_, mem::transmute}; + use glib::{ signal::{connect_raw, SignalHandlerId}, translate::*, }; -use std::{boxed::Box as Box_, mem::transmute}; + +use crate::{prelude::*, Toplevel, ToplevelSize}; mod sealed { pub trait Sealed {} @@ -13,7 +15,8 @@ mod sealed { } // rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`Toplevel`](crate::Toplevel). +/// Trait containing manually implemented methods of +/// [`Toplevel`](crate::Toplevel). pub trait ToplevelExtManual: sealed::Sealed + IsA { fn connect_compute_size( &self, diff --git a/gdk4/src/toplevel_size.rs b/gdk4/src/toplevel_size.rs index 227edf01e649..f6669c87c272 100644 --- a/gdk4/src/toplevel_size.rs +++ b/gdk4/src/toplevel_size.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use glib::translate::*; use std::fmt; +use glib::translate::*; + glib::wrapper! { #[doc(alias = "GdkToplevelSize")] diff --git a/gdk4/src/touch_event.rs b/gdk4/src/touch_event.rs index 667ef3086ac7..577d89197240 100644 --- a/gdk4/src/touch_event.rs +++ b/gdk4/src/touch_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, TouchEvent}; use std::fmt; +use crate::{EventType, TouchEvent}; + define_event! { TouchEvent, ffi::GdkTouchEvent, diff --git a/gdk4/src/touchpad_event.rs b/gdk4/src/touchpad_event.rs index c63abb834032..097f1308f0cf 100644 --- a/gdk4/src/touchpad_event.rs +++ b/gdk4/src/touchpad_event.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{EventType, TouchpadEvent}; use std::fmt; +use crate::{EventType, TouchpadEvent}; + define_event! { TouchpadEvent, ffi::GdkTouchpadEvent, diff --git a/gdk4/sys/build.rs b/gdk4/sys/build.rs index 3489f6ecbb4a..d3846828f7cf 100644 --- a/gdk4/sys/build.rs +++ b/gdk4/sys/build.rs @@ -41,7 +41,8 @@ fn check_features() { println!("cargo:backends={targets}"); for target in targets.split_whitespace() { // For whatever reasons,calling pkg-config --variable=targets gtk4 - // returns broadway\ wayland\ x11. So we drop those from the configured gtk_backend + // returns broadway\ wayland\ x11. So we drop those from the configured + // gtk_backend println!( "cargo:rustc-cfg=gdk_backend=\"{}\"", target.trim_end_matches('\\') diff --git a/gsk4/src/border_node.rs b/gsk4/src/border_node.rs index b3ddd4694e4e..99839691f779 100644 --- a/gsk4/src/border_node.rs +++ b/gsk4/src/border_node.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{BorderNode, RenderNodeType, RoundedRect}; use glib::translate::*; +use crate::{BorderNode, RenderNodeType, RoundedRect}; + define_render_node!(BorderNode, ffi::GskBorderNode, RenderNodeType::BorderNode); impl BorderNode { diff --git a/gsk4/src/builders.rs b/gsk4/src/builders.rs index 0f8ce108b58d..00d059209d38 100644 --- a/gsk4/src/builders.rs +++ b/gsk4/src/builders.rs @@ -3,9 +3,7 @@ // rustdoc-stripper-ignore-next //! Builder pattern types. -pub use crate::auto::builders::*; -pub use crate::color_stop::ColorStopBuilder; #[cfg(feature = "v4_14")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))] pub use crate::stroke::StrokeBuilder; -pub use crate::ShaderArgsBuilder; +pub use crate::{auto::builders::*, color_stop::ColorStopBuilder, ShaderArgsBuilder}; diff --git a/gsk4/src/color_stop.rs b/gsk4/src/color_stop.rs index d8afbd566879..95a181db41e4 100644 --- a/gsk4/src/color_stop.rs +++ b/gsk4/src/color_stop.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::fmt; + use gdk::RGBA; use glib::translate::*; -use std::fmt; glib::wrapper! { #[doc(alias = "GskColorStop")] @@ -22,9 +23,12 @@ impl ColorStop { } // rustdoc-stripper-ignore-next - /// Creates a new builder-pattern struct instance to construct [`ColorStop`] objects. + /// Creates a new builder-pattern struct instance to construct [`ColorStop`] + /// objects. /// - /// This method returns an instance of [`ColorStopBuilder`](crate::builders::ColorStopBuilder) which can be used to create [`ColorStop`] objects. + /// This method returns an instance of + /// [`ColorStopBuilder`](crate::builders::ColorStopBuilder) which can be + /// used to create [`ColorStop`] objects. pub fn builder() -> ColorStopBuilder { ColorStopBuilder::default() } diff --git a/gsk4/src/container_node.rs b/gsk4/src/container_node.rs index 956c49b0092a..b276347ebd5c 100644 --- a/gsk4/src/container_node.rs +++ b/gsk4/src/container_node.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{ContainerNode, RenderNode, RenderNodeType}; use glib::translate::*; +use crate::{ContainerNode, RenderNode, RenderNodeType}; + define_render_node!( ContainerNode, ffi::GskContainerNode, diff --git a/gsk4/src/gl_shader.rs b/gsk4/src/gl_shader.rs index 9482642bc605..b4084bb1611c 100644 --- a/gsk4/src/gl_shader.rs +++ b/gsk4/src/gl_shader.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::GLShader; use glib::translate::*; +use crate::GLShader; + impl GLShader { #[doc(alias = "gsk_gl_shader_get_arg_vec2")] #[doc(alias = "get_arg_vec2")] diff --git a/gsk4/src/gl_shader_node.rs b/gsk4/src/gl_shader_node.rs index 5894910df3fa..9fe8ec856f0a 100644 --- a/gsk4/src/gl_shader_node.rs +++ b/gsk4/src/gl_shader_node.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{GLShaderNode, RenderNode, RenderNodeType}; use glib::translate::*; +use crate::{GLShaderNode, RenderNode, RenderNodeType}; + define_render_node!( GLShaderNode, ffi::GskGLShaderNode, diff --git a/gsk4/src/ngl_renderer.rs b/gsk4/src/ngl_renderer.rs index fffaaedbe0c0..8a3fc2640743 100644 --- a/gsk4/src/ngl_renderer.rs +++ b/gsk4/src/ngl_renderer.rs @@ -1,9 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{prelude::*, Renderer}; -use glib::translate::*; use std::fmt; +use glib::translate::*; + +use crate::{prelude::*, Renderer}; + glib::wrapper! { #[doc(alias = "GskNglRenderer")] pub struct NglRenderer(Object) @extends Renderer; diff --git a/gsk4/src/path.rs b/gsk4/src/path.rs index af98b444f75d..1f301f2a4d62 100644 --- a/gsk4/src/path.rs +++ b/gsk4/src/path.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Path, PathForeachFlags, PathOperation}; use glib::translate::*; +use crate::{Path, PathForeachFlags, PathOperation}; + impl Path { #[doc(alias = "gsk_path_foreach")] pub fn foreach glib::ControlFlow>( diff --git a/gsk4/src/path_builder.rs b/gsk4/src/path_builder.rs index e5462cb22e80..6ce61c86213f 100644 --- a/gsk4/src/path_builder.rs +++ b/gsk4/src/path_builder.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::PathBuilder; use glib::translate::*; +use crate::PathBuilder; + impl PathBuilder { #[doc(alias = "gsk_path_builder_add_cairo_path")] pub fn add_cairo_path(&self, path: &cairo::Path) { diff --git a/gsk4/src/path_point.rs b/gsk4/src/path_point.rs index d27ea2ae56aa..ef4af63e6a63 100644 --- a/gsk4/src/path_point.rs +++ b/gsk4/src/path_point.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Path, PathDirection, PathPoint}; use glib::translate::*; +use crate::{Path, PathDirection, PathPoint}; + impl PathPoint { #[doc(alias = "gsk_path_point_get_curvature")] #[doc(alias = "get_curvature")] diff --git a/gsk4/src/prelude.rs b/gsk4/src/prelude.rs index ba4df5e843ad..afa140570334 100644 --- a/gsk4/src/prelude.rs +++ b/gsk4/src/prelude.rs @@ -3,10 +3,6 @@ // rustdoc-stripper-ignore-next //! Traits intended for blanket imports. -pub use crate::auto::traits::*; - -pub use crate::render_node::IsRenderNode; - #[doc(hidden)] pub use gdk::prelude::*; #[doc(hidden)] @@ -15,3 +11,5 @@ pub use glib::prelude::*; pub use graphene::prelude::*; #[doc(hidden)] pub use pango::prelude::*; + +pub use crate::{auto::traits::*, render_node::IsRenderNode}; diff --git a/gsk4/src/render_node.rs b/gsk4/src/render_node.rs index 970267244a4c..f24d02341cea 100644 --- a/gsk4/src/render_node.rs +++ b/gsk4/src/render_node.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use glib::{translate::*, StaticType}; + use crate::{ParseLocation, RenderNode, RenderNodeType}; -use glib::translate::*; -use glib::StaticType; impl RenderNode { #[inline] @@ -95,7 +95,8 @@ impl std::fmt::Debug for RenderNode { } // rustdoc-stripper-ignore-next -/// A common trait implemented by the various [`RenderNode`](crate::RenderNode) types. +/// A common trait implemented by the various [`RenderNode`](crate::RenderNode) +/// types. /// /// # Safety /// diff --git a/gsk4/src/rounded_rect.rs b/gsk4/src/rounded_rect.rs index b21388c9905f..a4b7a422328e 100644 --- a/gsk4/src/rounded_rect.rs +++ b/gsk4/src/rounded_rect.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::mem; + use glib::translate::*; use graphene::{Point, Rect, Size}; -use std::mem; glib::wrapper! { #[doc(alias = "GskRoundedRect")] diff --git a/gsk4/src/shadow.rs b/gsk4/src/shadow.rs index 321ec562f192..79ca8a03956c 100644 --- a/gsk4/src/shadow.rs +++ b/gsk4/src/shadow.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::fmt; + use gdk::RGBA; use glib::translate::*; -use std::fmt; glib::wrapper! { #[doc(alias = "GskShadow")] diff --git a/gsk4/src/shadow_node.rs b/gsk4/src/shadow_node.rs index f92a5f6488c8..0db43507d749 100644 --- a/gsk4/src/shadow_node.rs +++ b/gsk4/src/shadow_node.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{RenderNodeType, Shadow, ShadowNode}; use glib::translate::*; +use crate::{RenderNodeType, Shadow, ShadowNode}; + define_render_node!(ShadowNode, ffi::GskShadowNode, RenderNodeType::ShadowNode); impl ShadowNode { diff --git a/gsk4/src/stroke.rs b/gsk4/src/stroke.rs index 5e5c988cc069..374a615a9c89 100644 --- a/gsk4/src/stroke.rs +++ b/gsk4/src/stroke.rs @@ -6,7 +6,9 @@ impl Stroke { // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct a [`Stroke`]. /// - /// This method returns an instance of [`StrokeBuilder`](crate::builders::StrokeBuilder) which can be used to create a [`Stroke`]. + /// This method returns an instance of + /// [`StrokeBuilder`](crate::builders::StrokeBuilder) which can be used to + /// create a [`Stroke`]. pub fn builder(line_width: f32) -> StrokeBuilder { assert_initialized_main_thread!(); StrokeBuilder(Stroke::new(line_width)) diff --git a/gsk4/src/transform.rs b/gsk4/src/transform.rs index 14b2f00c8bb2..e464538db71f 100644 --- a/gsk4/src/transform.rs +++ b/gsk4/src/transform.rs @@ -1,8 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::Transform; use glib::{translate::*, IntoGStr}; +use crate::Transform; + impl Transform { #[doc(alias = "gsk_transform_parse")] pub fn parse(string: impl IntoGStr) -> Result { diff --git a/gtk4-macros/src/blueprint.rs b/gtk4-macros/src/blueprint.rs index 6ed8a6c40cf6..9386bc7aee4f 100644 --- a/gtk4-macros/src/blueprint.rs +++ b/gtk4-macros/src/blueprint.rs @@ -1,8 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use std::{ + io::{Read, Write}, + process::{Command, Stdio}, +}; + use anyhow::{bail, Result}; -use std::io::{Read, Write}; -use std::process::{Command, Stdio}; pub(crate) fn compile_blueprint(blueprint: &[u8]) -> Result { let mut compiler = Command::new("blueprint-compiler") diff --git a/gtk4-macros/src/composite_template_derive.rs b/gtk4-macros/src/composite_template_derive.rs index b1466c4c7eb4..36ef6f5418fd 100644 --- a/gtk4-macros/src/composite_template_derive.rs +++ b/gtk4-macros/src/composite_template_derive.rs @@ -1,5 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. +#[cfg(feature = "xml_validation")] +use std::collections::HashMap; +use std::string::ToString; + use proc_macro2::TokenStream; use proc_macro_error::{emit_call_site_error, emit_error}; #[cfg(feature = "xml_validation")] @@ -7,10 +11,6 @@ use quick_xml::name::QName; use quote::quote; use syn::Data; -#[cfg(feature = "xml_validation")] -use std::collections::HashMap; -use std::string::ToString; - #[cfg(feature = "blueprint")] use crate::blueprint::*; use crate::{attribute_parser::*, util::*}; diff --git a/gtk4-macros/src/lib.rs b/gtk4-macros/src/lib.rs index 78a9a110520d..00d72c279a42 100644 --- a/gtk4-macros/src/lib.rs +++ b/gtk4-macros/src/lib.rs @@ -15,7 +15,8 @@ use proc_macro::TokenStream; use proc_macro_error::proc_macro_error; use syn::{parse_macro_input, DeriveInput}; -/// That macro includes and compiles blueprint file by path relative to project rood +/// That macro includes and compiles blueprint file by path relative to project +/// rood /// /// It expected to run inside composite_template_derive, not by users #[cfg(feature = "blueprint")] @@ -69,7 +70,8 @@ pub fn include_blueprint(input: TokenStream) -> TokenStream { /// The `template_child` attribute is used to mark all internal widgets /// we need to have programmatic access to. It can take two parameters: /// - `id` which defaults to the item name if not defined -/// - `internal_child` whether the child should be accessible as an “internal-child”, defaults to `false` +/// - `internal_child` whether the child should be accessible as an +/// “internal-child”, defaults to `false` /// /// # Example /// @@ -135,7 +137,8 @@ pub fn include_blueprint(input: TokenStream) -> TokenStream { /// /// The [`CompositeTemplate`] macro can also be used with [Blueprint](https://jwestman.pages.gitlab.gnome.org/blueprint-compiler/) /// if the feature `blueprint` is enabled. -/// you can use `string` or `file` relative to the project directory but not `resource` +/// you can use `string` or `file` relative to the project directory but not +/// `resource` /// /// ```ignore /// # fn main() {} @@ -190,7 +193,6 @@ pub fn include_blueprint(input: TokenStream) -> TokenStream { /// pub struct MyWidget(ObjectSubclass) @extends gtk::Widget; /// } /// ``` -/// #[proc_macro_derive(CompositeTemplate, attributes(template, template_child))] #[proc_macro_error] pub fn composite_template_derive(input: TokenStream) -> TokenStream { @@ -201,65 +203,77 @@ pub fn composite_template_derive(input: TokenStream) -> TokenStream { /// Attribute macro for creating template callbacks from Rust methods. /// -/// Widgets with [`CompositeTemplate`] can then make use of these callbacks from within their -/// template XML definition. The attribute must be applied to an `impl` statement of a struct. -/// Functions marked as callbacks within the `impl` will be stored in a static array. Then, in the -/// [`ObjectSubclass`] implementation you will need to call [`bind_template_callbacks`] and/or +/// Widgets with [`CompositeTemplate`] can then make use of these callbacks from +/// within their template XML definition. The attribute must be applied to an +/// `impl` statement of a struct. Functions marked as callbacks within the +/// `impl` will be stored in a static array. Then, in the [`ObjectSubclass`] +/// implementation you will need to call [`bind_template_callbacks`] and/or /// [`bind_template_instance_callbacks`] in the [`class_init`] function. /// -/// Template callbacks can be specified on both a widget's public wrapper `impl` or on its private -/// subclass `impl`, or from external types. If callbacks are specified on the public wrapper, then -/// `bind_template_instance_callbacks` must be called in `class_init`. If callbacks are specified -/// on the private subclass, then `bind_template_callbacks` must be called in `class_init`. To use -/// the callbacks from an external type, call [`T::bind_template_callbacks`] in `class_init`, where -/// `T` is the other type. See the example below for usage of all three. -/// -/// These callbacks can be bound using the `` or `` tags in the template file. -/// Note that the arguments and return type will only be checked at run time when the method is -/// invoked. -/// -/// Template callbacks can optionally take `self` or `&self` as a first parameter. In this case, -/// the attribute `swapped="true"` will usually have to be set on the `` or `` tag -/// in order to invoke the function correctly. Note that by-value `self` will only work with -/// template callbacks on the wrapper type. -/// -/// Template callbacks that have no return value can also be `async`, in which case the callback -/// will be spawned as new future on the default main context using -/// [`glib::MainContext::spawn_local`]. Invoking the callback multiple times will spawn an -/// additional future each time it is invoked. This means that multiple futures for an async -/// callback can be active at any given time, so care must be taken to avoid any kind of data -/// races. Async callbacks may prefer communicating back to the caller or widget over channels -/// instead of mutating internal widget state, or may want to make use of a locking flag to ensure -/// only one future can be active at once. Widgets may also want to show a visual indicator such as -/// a [`Spinner`] while the future is active to communicate to the user that a background task is -/// running. +/// Template callbacks can be specified on both a widget's public wrapper `impl` +/// or on its private subclass `impl`, or from external types. If callbacks are +/// specified on the public wrapper, then `bind_template_instance_callbacks` +/// must be called in `class_init`. If callbacks are specified on the private +/// subclass, then `bind_template_callbacks` must be called in `class_init`. To +/// use the callbacks from an external type, call [`T::bind_template_callbacks`] +/// in `class_init`, where `T` is the other type. See the example below for +/// usage of all three. +/// +/// These callbacks can be bound using the `` or `` tags in the +/// template file. Note that the arguments and return type will only be checked +/// at run time when the method is invoked. +/// +/// Template callbacks can optionally take `self` or `&self` as a first +/// parameter. In this case, the attribute `swapped="true"` will usually have to +/// be set on the `` or `` tag in order to invoke the function +/// correctly. Note that by-value `self` will only work with template callbacks +/// on the wrapper type. +/// +/// Template callbacks that have no return value can also be `async`, in which +/// case the callback will be spawned as new future on the default main context +/// using [`glib::MainContext::spawn_local`]. Invoking the callback multiple +/// times will spawn an additional future each time it is invoked. This means +/// that multiple futures for an async callback can be active at any given time, +/// so care must be taken to avoid any kind of data races. Async callbacks may +/// prefer communicating back to the caller or widget over channels instead of +/// mutating internal widget state, or may want to make use of a locking flag to +/// ensure only one future can be active at once. Widgets may also want to show +/// a visual indicator such as a [`Spinner`] while the future is active to +/// communicate to the user that a background task is running. /// /// The following options are supported on the attribute: -/// - `functions` makes all callbacks use the `function` attribute by default. (see below) +/// - `functions` makes all callbacks use the `function` attribute by default. +/// (see below) /// -/// The `template_callback` attribute is used to mark methods that will be exposed to the template -/// scope. It can take the following options: +/// The `template_callback` attribute is used to mark methods that will be +/// exposed to the template scope. It can take the following options: /// - `name` renames the callback. Defaults to the function name if not defined. -/// - `function` ignores the first value when calling the callback and disallows `self`. Useful +/// - `function` ignores the first value when calling the callback and disallows +/// `self`. Useful /// for callbacks called from `` tags. -/// - `function = false` reverts the effects of `functions` used on the `impl`, so the callback -/// gets the first value and can take `self` again. Mainly useful for callbacks that are invoked -/// with `swapped="true"`. -/// -/// The `rest` attribute can be placed on the last argument of a template callback. This attribute -/// must be used on an argument of type &\[[glib::Value]\] and will pass in the -/// remaining arguments. The first and last values will be omitted from the slice if this callback -/// is a `function`. -/// -/// Arguments and return types in template callbacks have some special restrictions, similar to the -/// restrictions on [`glib::closure`]. Each argument's type must implement -/// [From]<Type> for [glib::Value]. The last argument can also be -/// &\[[glib::Value]\] annotated with `#[rest]` as described above. The return type of -/// a callback, if present, must implement [`glib::FromValue`]. Type-checking of inputs and outputs -/// is done at run-time; if the argument types or return type do not match the type of the signal -/// or closure then the callback will panic. To implement your own type checking or to use dynamic -/// typing, an argument's type can be left as a &[glib::Value]. This can also be used -/// if you need custom unboxing, such as if the target type does not implement `FromValue`. +/// - `function = false` reverts the effects of `functions` used on the `impl`, +/// so the callback +/// gets the first value and can take `self` again. Mainly useful for callbacks +/// that are invoked with `swapped="true"`. +/// +/// The `rest` attribute can be placed on the last argument of a template +/// callback. This attribute must be used on an argument of type +/// &\[[glib::Value]\] and will pass in the remaining arguments. +/// The first and last values will be omitted from the slice if this callback is +/// a `function`. +/// +/// Arguments and return types in template callbacks have some special +/// restrictions, similar to the restrictions on [`glib::closure`]. Each +/// argument's type must implement [From]<Type> for +/// [glib::Value]. The last argument can also be &\[[glib::Value]\ +/// ] annotated with `#[rest]` as described above. The return type of +/// a callback, if present, must implement [`glib::FromValue`]. Type-checking of +/// inputs and outputs is done at run-time; if the argument types or return type +/// do not match the type of the signal or closure then the callback will panic. +/// To implement your own type checking or to use dynamic typing, an argument's +/// type can be left as a &[glib::Value]. This can also be used +/// if you need custom unboxing, such as if the target type does not implement +/// `FromValue`. /// /// [`glib::closure`]: ../glib/macro.closure.html /// [`glib::wrapper`]: ../glib/macro.wrapper.html @@ -343,7 +357,11 @@ pub fn composite_template_derive(input: TokenStream) -> TokenStream { /// #[template_callback] /// pub fn print_both_labels(&self) { /// let imp = self.imp(); -/// println!("{} {}", imp.label.label(), imp.button.label().unwrap().as_str()); +/// println!( +/// "{} {}", +/// imp.label.label(), +/// imp.button.label().unwrap().as_str() +/// ); /// } /// } /// @@ -380,15 +398,17 @@ pub fn template_callbacks(attr: TokenStream, item: TokenStream) -> TokenStream { /// Attribute macro for declaring GTK tests. /// -/// Wraps the standard Rust [`test`] attribute with setup logic for GTK. All tests that call -/// into GTK must use this attribute. This attribute can also be used on asynchronous functions; -/// the asynchronous test will be run on the main thread context. +/// Wraps the standard Rust [`test`] attribute with setup logic for GTK. All +/// tests that call into GTK must use this attribute. This attribute can also be +/// used on asynchronous functions; the asynchronous test will be run on the +/// main thread context. /// /// # Technical Details /// -/// GTK is a single-threaded library, so Rust's normal multi-threaded test behavior cannot be used. -/// The `#[gtk::test]` attribute creates a main thread for GTK and runs all tests on that thread. -/// This has the side effect of making all tests run serially, not in parallel. +/// GTK is a single-threaded library, so Rust's normal multi-threaded test +/// behavior cannot be used. The `#[gtk::test]` attribute creates a main thread +/// for GTK and runs all tests on that thread. This has the side effect of +/// making all tests run serially, not in parallel. /// /// [`test`]: /// diff --git a/gtk4-macros/src/template_callbacks_attribute.rs b/gtk4-macros/src/template_callbacks_attribute.rs index b43db65f479a..6f5f2842ab91 100644 --- a/gtk4-macros/src/template_callbacks_attribute.rs +++ b/gtk4-macros/src/template_callbacks_attribute.rs @@ -1,11 +1,12 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::util::*; use proc_macro2::TokenStream; use proc_macro_error::{emit_call_site_error, emit_error}; use quote::{quote, ToTokens, TokenStreamExt}; use syn::{parse::Parse, Token}; +use crate::util::*; + pub const WRONG_PLACE_MSG: &str = "This macro should be used on the `impl` block for a CompositeTemplate widget"; diff --git a/gtk4-macros/tests/templates.rs b/gtk4-macros/tests/templates.rs index f3654de68e9c..c581d190c79d 100644 --- a/gtk4-macros/tests/templates.rs +++ b/gtk4-macros/tests/templates.rs @@ -1,13 +1,11 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use gtk::prelude::*; -use gtk::subclass::prelude::*; -use gtk::{glib, CompositeTemplate}; +use gtk::{glib, prelude::*, subclass::prelude::*}; mod imp { use super::*; - #[derive(Debug, Default, CompositeTemplate)] + #[derive(Debug, Default, gtk::CompositeTemplate)] #[template(string = r#"