Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Update manual code
Browse files Browse the repository at this point in the history
  • Loading branch information
sdroege committed Apr 26, 2021
1 parent bdc519d commit 3c602a7
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 51 deletions.
4 changes: 2 additions & 2 deletions examples/css/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ fn build_ui(application: &gtk::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();
Expand Down
5 changes: 1 addition & 4 deletions examples/gio_task/file_size/ffi.rs
Original file line number Diff line number Diff line change
@@ -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 = <super::imp::FileSize as ObjectSubclass>::Instance;
Expand Down
5 changes: 1 addition & 4 deletions examples/gio_task/file_size/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion examples/overlay/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn build_ui(application: &gtk::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);
Expand Down
2 changes: 1 addition & 1 deletion gio/src/cancellable.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion gio/src/file_enumerator.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion gio/src/gio_future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F, O, T, E> {
obj: O,
Expand Down
2 changes: 1 addition & 1 deletion gio/src/inet_address.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand Down
2 changes: 1 addition & 1 deletion gio/src/inet_socket_address.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion gio/src/input_stream.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 1 addition & 3 deletions gio/src/io_stream.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
1 change: 0 additions & 1 deletion gio/src/output_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion gio/src/pollable_input_stream.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
3 changes: 1 addition & 2 deletions gio/src/pollable_output_stream.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions gio/src/settings.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down
4 changes: 1 addition & 3 deletions gio/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions gio/src/tls_connection.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions gio/src/unix_socket_address.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions gtk/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions gtk/src/builder.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
6 changes: 1 addition & 5 deletions gtk/src/dialog.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
5 changes: 2 additions & 3 deletions gtk/src/style_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -12,7 +11,7 @@ pub trait StyleContextExtManual: 'static {

impl<O: IsA<StyleContext>> StyleContextExtManual for O {
fn font(&self, state: StateFlags) -> FontDescription {
self.property("font", state)
<Self as crate::prelude::StyleContextExt>::property(self, "font", state)
.get()
.expect("font property is not pango::FontDescription")
}
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/subclass/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions gtk/src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
widget: glib::WeakRef<Widget>,
}

impl TickCallbackId {
Expand Down

0 comments on commit 3c602a7

Please sign in to comment.