From 3c602a78d35c6763196d5d75213b1a70612c3bf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 26 Apr 2021 10:17:47 +0300 Subject: [PATCH] Update manual code --- examples/css/main.rs | 4 ++-- examples/gio_task/file_size/ffi.rs | 5 +---- examples/gio_task/file_size/mod.rs | 5 +---- examples/overlay/main.rs | 2 +- gio/src/cancellable.rs | 2 +- gio/src/file_enumerator.rs | 2 +- gio/src/gio_future.rs | 2 +- gio/src/inet_address.rs | 2 +- gio/src/inet_socket_address.rs | 2 +- gio/src/input_stream.rs | 2 +- gio/src/io_stream.rs | 4 +--- gio/src/output_stream.rs | 1 - gio/src/pollable_input_stream.rs | 2 +- gio/src/pollable_output_stream.rs | 3 +-- gio/src/settings.rs | 4 ++-- gio/src/task.rs | 4 +--- gio/src/tls_connection.rs | 4 ++-- gio/src/unix_socket_address.rs | 3 +-- gtk/src/application.rs | 3 +-- gtk/src/builder.rs | 3 +-- gtk/src/dialog.rs | 6 +----- gtk/src/style_context.rs | 5 ++--- gtk/src/subclass/widget.rs | 4 ++-- gtk/src/widget.rs | 7 +++---- 24 files changed, 30 insertions(+), 51 deletions(-) diff --git a/examples/css/main.rs b/examples/css/main.rs index 14842c72e3e3..215ed019672c 100644 --- a/examples/css/main.rs +++ b/examples/css/main.rs @@ -37,11 +37,11 @@ fn build_ui(application: >k::Application) { let label = gtk::Button::with_label("hover me!"); // We need to name it in order to be able to use its name as a CSS label to // apply CSS on it. - gtk::WidgetExt::set_widget_name(&label, "label1"); + label.set_widget_name("label1"); let entry = gtk::Entry::new(); // We need to name it in order to apply CSS on it. - gtk::WidgetExt::set_widget_name(&entry, "entry1"); + entry.set_widget_name("entry1"); entry.set_text("Some text"); let combo = gtk::ComboBoxText::new(); diff --git a/examples/gio_task/file_size/ffi.rs b/examples/gio_task/file_size/ffi.rs index 2554b97ed2dd..38a0dd15e7ae 100644 --- a/examples/gio_task/file_size/ffi.rs +++ b/examples/gio_task/file_size/ffi.rs @@ -1,9 +1,6 @@ use gtk::glib::subclass::prelude::*; use gtk::glib::translate::*; -use gtk::prelude::AsyncResultExt; -use gtk::prelude::Cast; -use gtk::prelude::FileExt; -use gtk::prelude::ToValue; +use gtk::prelude::*; use gtk::{gio, glib}; pub type FileSize = ::Instance; diff --git a/examples/gio_task/file_size/mod.rs b/examples/gio_task/file_size/mod.rs index f13dc51c39dc..0d9c399dc935 100644 --- a/examples/gio_task/file_size/mod.rs +++ b/examples/gio_task/file_size/mod.rs @@ -2,10 +2,7 @@ pub mod ffi; mod imp; use gtk::glib::subclass::prelude::*; -use gtk::prelude::AsyncResultExt; -use gtk::prelude::Cast; -use gtk::prelude::FileExt; -use gtk::prelude::ToValue; +use gtk::prelude::*; use gtk::{gio, glib}; glib::wrapper! { diff --git a/examples/overlay/main.rs b/examples/overlay/main.rs index 00ea40a16075..8d6e6f02bdbf 100644 --- a/examples/overlay/main.rs +++ b/examples/overlay/main.rs @@ -21,7 +21,7 @@ fn build_ui(application: >k::Application) { // The overlay label. let overlay_text = gtk::Label::new(Some("0")); // We need to name it in order to apply CSS on it. - gtk::WidgetExt::set_widget_name(&overlay_text, "overlay-label"); + overlay_text.set_widget_name("overlay-label"); // We put the overlay in the top-right corner of the window. overlay_text.set_halign(gtk::Align::End); overlay_text.set_valign(gtk::Align::Start); diff --git a/gio/src/cancellable.rs b/gio/src/cancellable.rs index 6f35073f74d1..02fb4b05cf7c 100644 --- a/gio/src/cancellable.rs +++ b/gio/src/cancellable.rs @@ -1,6 +1,6 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::CancellableExt; +use crate::prelude::*; #[test] fn check_callback() { diff --git a/gio/src/file_enumerator.rs b/gio/src/file_enumerator.rs index 00928a0adae2..b3836eea4796 100644 --- a/gio/src/file_enumerator.rs +++ b/gio/src/file_enumerator.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use crate::prelude::*; use crate::FileEnumerator; -use crate::FileEnumeratorExt; use crate::FileInfo; use std::iter::Iterator; diff --git a/gio/src/gio_future.rs b/gio/src/gio_future.rs index 9d19349b524e..a4609210ca65 100644 --- a/gio/src/gio_future.rs +++ b/gio/src/gio_future.rs @@ -5,8 +5,8 @@ use futures_core::task::{Context, Poll}; use std::future::Future; use std::pin::{self, Pin}; +use crate::prelude::*; use crate::Cancellable; -use crate::CancellableExt; pub struct GioFuture { obj: O, diff --git a/gio/src/inet_address.rs b/gio/src/inet_address.rs index 072363a01613..cf483bb752eb 100644 --- a/gio/src/inet_address.rs +++ b/gio/src/inet_address.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use crate::prelude::*; use crate::InetAddress; -use crate::InetAddressExt; use crate::SocketFamily; use glib::object::IsA; use glib::translate::*; diff --git a/gio/src/inet_socket_address.rs b/gio/src/inet_socket_address.rs index 34f6263a6901..66c5deac80fa 100644 --- a/gio/src/inet_socket_address.rs +++ b/gio/src/inet_socket_address.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use crate::prelude::*; use crate::InetAddress; use crate::InetSocketAddress; -use crate::InetSocketAddressExt; use std::net::SocketAddr; diff --git a/gio/src/input_stream.rs b/gio/src/input_stream.rs index 3bc6afb5c813..b141d9f95523 100644 --- a/gio/src/input_stream.rs +++ b/gio/src/input_stream.rs @@ -1,10 +1,10 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::error::to_std_io_result; +use crate::prelude::*; use crate::Cancellable; use crate::InputStream; use crate::Seekable; -use crate::SeekableExt; use futures_core::task::{Context, Poll}; use futures_io::{AsyncBufRead, AsyncRead}; use glib::object::IsA; diff --git a/gio/src/io_stream.rs b/gio/src/io_stream.rs index 1b6ec88f5322..466e90e98943 100644 --- a/gio/src/io_stream.rs +++ b/gio/src/io_stream.rs @@ -1,9 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::pollable_input_stream::PollableInputStreamExtManual; -use crate::pollable_output_stream::PollableOutputStreamExtManual; +use crate::prelude::*; use crate::IOStream; -use crate::IOStreamExt; use crate::InputStreamAsyncRead; use crate::OutputStreamAsyncWrite; use crate::PollableInputStream; diff --git a/gio/src/output_stream.rs b/gio/src/output_stream.rs index 42e55923b97b..8f645b7a80f9 100644 --- a/gio/src/output_stream.rs +++ b/gio/src/output_stream.rs @@ -5,7 +5,6 @@ use crate::prelude::*; use crate::Cancellable; use crate::OutputStream; use crate::Seekable; -use crate::SeekableExt; use glib::object::IsA; use glib::translate::*; use glib::Priority; diff --git a/gio/src/pollable_input_stream.rs b/gio/src/pollable_input_stream.rs index 7edb4ea11e3a..7e78fa46dcac 100644 --- a/gio/src/pollable_input_stream.rs +++ b/gio/src/pollable_input_stream.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use crate::prelude::*; use crate::Cancellable; use crate::PollableInputStream; -use crate::PollableInputStreamExt; use futures_core::task::{Context, Poll}; use futures_io::AsyncRead; use glib::object::{Cast, IsA}; diff --git a/gio/src/pollable_output_stream.rs b/gio/src/pollable_output_stream.rs index 7b2981a5f232..97fe98e175a9 100644 --- a/gio/src/pollable_output_stream.rs +++ b/gio/src/pollable_output_stream.rs @@ -1,10 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::error::to_std_io_result; +use crate::prelude::*; use crate::Cancellable; -use crate::OutputStreamExt; use crate::PollableOutputStream; -use crate::PollableOutputStreamExt; use futures_channel::oneshot; use futures_core::task::{Context, Poll}; use futures_core::Future; diff --git a/gio/src/settings.rs b/gio/src/settings.rs index 876ccf1482de..81b72dd353da 100644 --- a/gio/src/settings.rs +++ b/gio/src/settings.rs @@ -1,7 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::{Settings, SettingsBindFlags, SettingsExt}; -use glib::prelude::*; +use crate::prelude::*; +use crate::{Settings, SettingsBindFlags}; use glib::translate::{from_glib_borrow, from_glib_none, ToGlib, ToGlibPtr}; use glib::variant::FromVariant; use glib::{BoolError, IsA, ToVariant}; diff --git a/gio/src/task.rs b/gio/src/task.rs index adce3c615301..4c6ba93a6c37 100644 --- a/gio/src/task.rs +++ b/gio/src/task.rs @@ -90,10 +90,8 @@ impl Task { #[cfg(test)] mod test { use super::*; + use crate::prelude::*; use crate::test_util::run_async_local; - use crate::CancellableExt; - use glib::Cast; - use glib::ToValue; #[test] fn test_int_async_result() { diff --git a/gio/src/tls_connection.rs b/gio/src/tls_connection.rs index 5a9dca794b12..94d6bdd5e0a7 100644 --- a/gio/src/tls_connection.rs +++ b/gio/src/tls_connection.rs @@ -1,8 +1,8 @@ // Take a look at the license at the top of the repository in the LICENSE file. #[cfg(any(feature = "v2_66", feature = "dox"))] -use crate::auto::TlsChannelBindingType; -use crate::auto::TlsConnection; +use crate::TlsChannelBindingType; +use crate::TlsConnection; #[cfg(any(feature = "v2_66", feature = "dox"))] use glib::translate::*; use glib::IsA; diff --git a/gio/src/unix_socket_address.rs b/gio/src/unix_socket_address.rs index 26d384d74179..8e4c2dfda270 100644 --- a/gio/src/unix_socket_address.rs +++ b/gio/src/unix_socket_address.rs @@ -1,10 +1,9 @@ // Take a look at the license at the top of the repository in the LICENSE file. +use crate::prelude::*; use crate::SocketAddress; use crate::UnixSocketAddress; -use crate::UnixSocketAddressExt; use crate::UnixSocketAddressType; -use glib::object::{Cast, IsA}; use glib::translate::*; #[cfg(not(feature = "dox"))] use std::ffi::OsStr; diff --git a/gtk/src/application.rs b/gtk/src/application.rs index 9cc43805d00f..a6970b4d16a6 100644 --- a/gtk/src/application.rs +++ b/gtk/src/application.rs @@ -2,11 +2,10 @@ use crate::rt; use crate::Application; -use gio::ApplicationExt; +use gio::prelude::*; use gio::ApplicationFlags; use glib::signal::SignalHandlerId; use glib::translate::*; -use glib::ObjectExt; use std::cell::RefCell; use std::rc::Rc; diff --git a/gtk/src/builder.rs b/gtk/src/builder.rs index 63f3a2697372..cdc6f4083eb3 100644 --- a/gtk/src/builder.rs +++ b/gtk/src/builder.rs @@ -1,11 +1,10 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::Builder; -use glib::object::{Cast, IsA}; +use glib::prelude::*; use glib::translate::*; use glib::GString; use glib::Object; -use glib::ObjectExt; use std::path::Path; impl Builder { diff --git a/gtk/src/dialog.rs b/gtk/src/dialog.rs index 55c594ec756d..fb9eb5410475 100644 --- a/gtk/src/dialog.rs +++ b/gtk/src/dialog.rs @@ -1,16 +1,12 @@ // Take a look at the license at the top of the repository in the LICENSE file. -use crate::auto::DialogExt; +use crate::prelude::*; use crate::Dialog; use crate::DialogFlags; use crate::ResponseType; use crate::Widget; -use crate::WidgetExt; use crate::Window; -use glib::object::Cast; use glib::translate::*; -use glib::IsA; -use glib::ObjectExt; use std::cell::Cell; use std::future::Future; use std::pin::Pin; diff --git a/gtk/src/style_context.rs b/gtk/src/style_context.rs index 82643d206954..60c5eba5c27d 100644 --- a/gtk/src/style_context.rs +++ b/gtk/src/style_context.rs @@ -2,8 +2,7 @@ use crate::StateFlags; use crate::StyleContext; -use crate::StyleContextExt; -use glib::object::IsA; +use glib::prelude::*; use pango::FontDescription; pub trait StyleContextExtManual: 'static { @@ -12,7 +11,7 @@ pub trait StyleContextExtManual: 'static { impl> StyleContextExtManual for O { fn font(&self, state: StateFlags) -> FontDescription { - self.property("font", state) + ::property(self, "font", state) .get() .expect("font property is not pango::FontDescription") } diff --git a/gtk/src/subclass/widget.rs b/gtk/src/subclass/widget.rs index fe3f2c0ea4c8..75858c774049 100644 --- a/gtk/src/subclass/widget.rs +++ b/gtk/src/subclass/widget.rs @@ -7,8 +7,9 @@ use glib::translate::*; use glib::prelude::*; use glib::subclass::prelude::*; -use glib::{Cast, Object}; +use glib::Object; +use crate::prelude::*; use crate::Allocation; use crate::DragResult; use crate::Inhibit; @@ -17,7 +18,6 @@ use crate::SelectionData; use crate::SizeRequestMode; use crate::TextDirection; use crate::Widget; -use crate::WidgetExt; pub trait WidgetImpl: WidgetImplExt + ObjectImpl { fn adjust_baseline_allocation(&self, widget: &Self::Type, baseline: &mut i32) { diff --git a/gtk/src/widget.rs b/gtk/src/widget.rs index 29c942566417..04cb7ed5bd3b 100644 --- a/gtk/src/widget.rs +++ b/gtk/src/widget.rs @@ -2,19 +2,18 @@ use gdk::{DragAction, Event, ModifierType}; use glib::ffi::gboolean; -use glib::object::{Cast, IsA, WeakRef}; use glib::signal::{connect_raw, Inhibit, SignalHandlerId}; use glib::translate::*; use glib::Continue; -use glib::ObjectExt; use std::mem::transmute; use std::ptr; -use crate::{DestDefaults, Rectangle, TargetEntry, Widget, WidgetExt}; +use crate::prelude::*; +use crate::{DestDefaults, Rectangle, TargetEntry, Widget}; pub struct TickCallbackId { id: u32, - widget: WeakRef, + widget: glib::WeakRef, } impl TickCallbackId {