Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

None constants as associated constants #684

Merged
merged 3 commits into from Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/clipboard/main.rs
Expand Up @@ -64,7 +64,7 @@ fn build_ui(application: &gtk::Application) {

let paste_btn = gtk::Button::with_label("Paste");
paste_btn.connect_clicked(clone!(@weak clipboard, @weak into_entry => move |_btn| {
clipboard.read_text_async(gio::NONE_CANCELLABLE, clone!(@weak into_entry => move|res| {
clipboard.read_text_async(gio::Cancellable::NONE, clone!(@weak into_entry => move|res| {
if let Ok(Some(text)) = res {
into_entry.set_text(&text);
}
Expand Down Expand Up @@ -115,7 +115,7 @@ fn build_ui(application: &gtk::Application) {
.valign(gtk::Align::Center)
.build();
paste_texture_btn.connect_clicked(clone!(@weak clipboard => move |_btn| {
clipboard.read_texture_async(gio::NONE_CANCELLABLE, clone!(@weak image_into => move |res| {
clipboard.read_texture_async(gio::Cancellable::NONE, clone!(@weak image_into => move |res| {
if let Ok(Some(texture)) = res {
image_into.set_paintable(Some(&texture));
}
Expand Down
2 changes: 1 addition & 1 deletion examples/video_player/video_player_window/imp.rs
Expand Up @@ -19,7 +19,7 @@ impl ObjectSubclass for VideoPlayerWindow {
fn new() -> Self {
let dialog = gtk::FileChooserNative::new(
Some("Open File"),
gtk::NONE_WINDOW,
gtk::Window::NONE,
gtk::FileChooserAction::Open,
Some("Open"),
Some("Cancel"),
Expand Down
2 changes: 1 addition & 1 deletion gdk4-wayland/src/auto/mod.rs
Expand Up @@ -21,7 +21,7 @@ mod wayland_seat;
pub use self::wayland_seat::WaylandSeat;

mod wayland_surface;
pub use self::wayland_surface::{WaylandSurface, NONE_WAYLAND_SURFACE};
pub use self::wayland_surface::WaylandSurface;

mod wayland_toplevel;
pub use self::wayland_toplevel::WaylandToplevel;
Expand Down
2 changes: 1 addition & 1 deletion gdk4-wayland/src/auto/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)
4 changes: 3 additions & 1 deletion gdk4-wayland/src/auto/wayland_surface.rs
Expand Up @@ -15,7 +15,9 @@ glib::wrapper! {

impl WaylandSurface {}

pub const NONE_WAYLAND_SURFACE: Option<&WaylandSurface> = None;
impl WaylandSurface {
pub const NONE: Option<&'static WaylandSurface> = None;
}

impl fmt::Display for WaylandSurface {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion gdk4-wayland/sys/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)
2 changes: 1 addition & 1 deletion gdk4-x11/src/auto/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)
2 changes: 1 addition & 1 deletion gdk4-x11/sys/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)
4 changes: 3 additions & 1 deletion gdk4/src/auto/app_launch_context.rs
Expand Up @@ -16,7 +16,9 @@ glib::wrapper! {
}
}

pub const NONE_APP_LAUNCH_CONTEXT: Option<&AppLaunchContext> = None;
impl AppLaunchContext {
pub const NONE: Option<&'static AppLaunchContext> = None;
}

pub trait AppLaunchContextExt: 'static {
#[doc(alias = "gdk_app_launch_context_get_display")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/content_provider.rs
Expand Up @@ -60,7 +60,9 @@ impl ContentProvider {
}
}

pub const NONE_CONTENT_PROVIDER: Option<&ContentProvider> = None;
impl ContentProvider {
pub const NONE: Option<&'static ContentProvider> = None;
}

pub trait ContentProviderExt: 'static {
#[doc(alias = "gdk_content_provider_content_changed")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/device.rs
Expand Up @@ -29,7 +29,9 @@ glib::wrapper! {
}
}

pub const NONE_DEVICE: Option<&Device> = None;
impl Device {
pub const NONE: Option<&'static Device> = None;
}

pub trait DeviceExt: 'static {
#[doc(alias = "gdk_device_get_caps_lock_state")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/device_pad.rs
Expand Up @@ -17,7 +17,9 @@ glib::wrapper! {
}
}

pub const NONE_DEVICE_PAD: Option<&DevicePad> = None;
impl DevicePad {
pub const NONE: Option<&'static DevicePad> = None;
}

pub trait DevicePadExt: 'static {
#[doc(alias = "gdk_device_pad_get_feature_group")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/display.rs
Expand Up @@ -55,7 +55,9 @@ impl fmt::Display for Display {
}
}

pub const NONE_DISPLAY: Option<&Display> = None;
impl Display {
pub const NONE: Option<&'static Display> = None;
}

pub trait DisplayExt: 'static {
#[doc(alias = "gdk_display_beep")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/drag.rs
Expand Up @@ -52,7 +52,9 @@ impl Drag {
}
}

pub const NONE_DRAG: Option<&Drag> = None;
impl Drag {
pub const NONE: Option<&'static Drag> = None;
}

pub trait DragExt: 'static {
#[doc(alias = "gdk_drag_drop_done")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/drag_surface.rs
Expand Up @@ -16,7 +16,9 @@ glib::wrapper! {
}
}

pub const NONE_DRAG_SURFACE: Option<&DragSurface> = None;
impl DragSurface {
pub const NONE: Option<&'static DragSurface> = None;
}

pub trait DragSurfaceExt: 'static {
#[doc(alias = "gdk_drag_surface_present")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/draw_context.rs
Expand Up @@ -17,7 +17,9 @@ glib::wrapper! {
}
}

pub const NONE_DRAW_CONTEXT: Option<&DrawContext> = None;
impl DrawContext {
pub const NONE: Option<&'static DrawContext> = None;
}

pub trait DrawContextExt: 'static {
#[doc(alias = "gdk_draw_context_begin_frame")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/gl_context.rs
Expand Up @@ -53,7 +53,9 @@ impl GLContext {
}
}

pub const NONE_GL_CONTEXT: Option<&GLContext> = None;
impl GLContext {
pub const NONE: Option<&'static GLContext> = None;
}

pub trait GLContextExt: 'static {
#[cfg(any(feature = "v4_6", feature = "dox"))]
Expand Down
32 changes: 16 additions & 16 deletions gdk4/src/auto/mod.rs
Expand Up @@ -3,7 +3,7 @@
// DO NOT EDIT

mod app_launch_context;
pub use self::app_launch_context::{AppLaunchContext, NONE_APP_LAUNCH_CONTEXT};
pub use self::app_launch_context::AppLaunchContext;

mod cairo_context;
pub use self::cairo_context::CairoContext;
Expand All @@ -16,7 +16,7 @@ mod content_deserializer;
pub use self::content_deserializer::ContentDeserializer;

mod content_provider;
pub use self::content_provider::{ContentProvider, NONE_CONTENT_PROVIDER};
pub use self::content_provider::ContentProvider;

mod content_serializer;
pub use self::content_serializer::ContentSerializer;
Expand All @@ -26,29 +26,29 @@ pub use self::cursor::Cursor;
pub use self::cursor::CursorBuilder;

mod device;
pub use self::device::{Device, NONE_DEVICE};
pub use self::device::Device;

mod device_pad;
pub use self::device_pad::{DevicePad, NONE_DEVICE_PAD};
pub use self::device_pad::DevicePad;

mod device_tool;
pub use self::device_tool::DeviceTool;
pub use self::device_tool::DeviceToolBuilder;

mod display;
pub use self::display::{Display, NONE_DISPLAY};
pub use self::display::Display;

mod display_manager;
pub use self::display_manager::DisplayManager;

mod drag;
pub use self::drag::{Drag, NONE_DRAG};
pub use self::drag::Drag;

mod drag_surface;
pub use self::drag_surface::{DragSurface, NONE_DRAG_SURFACE};
pub use self::drag_surface::DragSurface;

mod draw_context;
pub use self::draw_context::{DrawContext, NONE_DRAW_CONTEXT};
pub use self::draw_context::DrawContext;

mod drop;
pub use self::drop::Drop;
Expand All @@ -57,7 +57,7 @@ mod frame_clock;
pub use self::frame_clock::FrameClock;

mod gl_context;
pub use self::gl_context::{GLContext, NONE_GL_CONTEXT};
pub use self::gl_context::GLContext;

mod gl_texture;
pub use self::gl_texture::GLTexture;
Expand All @@ -66,28 +66,28 @@ mod memory_texture;
pub use self::memory_texture::MemoryTexture;

mod monitor;
pub use self::monitor::{Monitor, NONE_MONITOR};
pub use self::monitor::Monitor;

mod paintable;
pub use self::paintable::{Paintable, NONE_PAINTABLE};
pub use self::paintable::Paintable;

mod popup;
pub use self::popup::{Popup, NONE_POPUP};
pub use self::popup::Popup;

mod seat;
pub use self::seat::{Seat, NONE_SEAT};
pub use self::seat::Seat;

mod snapshot;
pub use self::snapshot::Snapshot;

mod surface;
pub use self::surface::{Surface, NONE_SURFACE};
pub use self::surface::Surface;

mod texture;
pub use self::texture::{Texture, NONE_TEXTURE};
pub use self::texture::Texture;

mod toplevel;
pub use self::toplevel::{Toplevel, NONE_TOPLEVEL};
pub use self::toplevel::Toplevel;

mod vulkan_context;
pub use self::vulkan_context::VulkanContext;
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/monitor.rs
Expand Up @@ -23,7 +23,9 @@ glib::wrapper! {
}
}

pub const NONE_MONITOR: Option<&Monitor> = None;
impl Monitor {
pub const NONE: Option<&'static Monitor> = None;
}

pub trait MonitorExt: 'static {
#[doc(alias = "gdk_monitor_get_connector")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/paintable.rs
Expand Up @@ -36,7 +36,9 @@ impl Paintable {
}
}

pub const NONE_PAINTABLE: Option<&Paintable> = None;
impl Paintable {
pub const NONE: Option<&'static Paintable> = None;
}

pub trait PaintableExt: 'static {
#[doc(alias = "gdk_paintable_compute_concrete_size")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/popup.rs
Expand Up @@ -18,7 +18,9 @@ glib::wrapper! {
}
}

pub const NONE_POPUP: Option<&Popup> = None;
impl Popup {
pub const NONE: Option<&'static Popup> = None;
}

pub trait PopupExt: 'static {
#[doc(alias = "gdk_popup_get_autohide")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/seat.rs
Expand Up @@ -24,7 +24,9 @@ glib::wrapper! {
}
}

pub const NONE_SEAT: Option<&Seat> = None;
impl Seat {
pub const NONE: Option<&'static Seat> = None;
}

pub trait SeatExt: 'static {
#[doc(alias = "gdk_seat_get_capabilities")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/surface.rs
Expand Up @@ -55,7 +55,9 @@ impl Surface {
}
}

pub const NONE_SURFACE: Option<&Surface> = None;
impl Surface {
pub const NONE: Option<&'static Surface> = None;
}

pub trait SurfaceExt: 'static {
#[doc(alias = "gdk_surface_beep")]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/texture.rs
Expand Up @@ -87,7 +87,9 @@ impl Texture {
}
}

pub const NONE_TEXTURE: Option<&Texture> = None;
impl Texture {
pub const NONE: Option<&'static Texture> = None;
}

pub trait TextureExt: 'static {
//#[cfg(any(feature = "v4_6", feature = "dox"))]
Expand Down
4 changes: 3 additions & 1 deletion gdk4/src/auto/toplevel.rs
Expand Up @@ -30,7 +30,9 @@ glib::wrapper! {
}
}

pub const NONE_TOPLEVEL: Option<&Toplevel> = None;
impl Toplevel {
pub const NONE: Option<&'static Toplevel> = None;
}

pub trait ToplevelExt: 'static {
#[doc(alias = "gdk_toplevel_begin_move")]
Expand Down
2 changes: 1 addition & 1 deletion gdk4/src/auto/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)
4 changes: 2 additions & 2 deletions gdk4/src/event.rs
Expand Up @@ -19,8 +19,6 @@ glib::wrapper! {
}
}

pub const NONE_EVENT: Option<&Event> = None;

impl StaticType for Event {
#[doc(alias = "gdk_event_get_type")]
fn static_type() -> Type {
Expand All @@ -29,6 +27,8 @@ impl StaticType for Event {
}

impl Event {
pub const NONE: Option<&'static Event> = None;

pub fn downcast<T: EventKind>(self) -> Result<T, Event> {
unsafe {
if T::event_types().contains(&self.event_type()) {
Expand Down
2 changes: 1 addition & 1 deletion gdk4/src/lib.rs
Expand Up @@ -107,7 +107,7 @@ pub use crossing_event::CrossingEvent;
pub use delete_event::DeleteEvent;
pub use display::Backend;
pub use dnd_event::DNDEvent;
pub use event::{Event, EventKind, NONE_EVENT};
pub use event::{Event, EventKind};
pub use focus_event::FocusEvent;
pub use grab_broken_event::GrabBrokenEvent;
pub use key_event::KeyEvent;
Expand Down
2 changes: 1 addition & 1 deletion gdk4/sys/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)
2 changes: 1 addition & 1 deletion gsk4/src/auto/mod.rs
Expand Up @@ -20,7 +20,7 @@ pub use self::gl_shader::GLShader;
pub use self::gl_shader::GLShaderBuilder;

mod renderer;
pub use self::renderer::{Renderer, NONE_RENDERER};
pub use self::renderer::Renderer;

mod shader_args_builder;
pub use self::shader_args_builder::ShaderArgsBuilder;
Expand Down
4 changes: 3 additions & 1 deletion gsk4/src/auto/renderer.rs
Expand Up @@ -30,7 +30,9 @@ impl Renderer {
}
}

pub const NONE_RENDERER: Option<&Renderer> = None;
impl Renderer {
pub const NONE: Option<&'static Renderer> = None;
}

pub trait GskRenderer: 'static {
#[doc(alias = "gsk_renderer_get_surface")]
Expand Down
2 changes: 1 addition & 1 deletion gsk4/src/auto/versions.txt
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 9c362508f28e)
Generated by gir (https://github.com/gtk-rs/gir @ e0b1709803a7)
from gir-files (https://github.com/gtk-rs/gir-files.git @ 46f24acbe4c2)