Skip to content

Commit

Permalink
Merge pull request gtk-rs#227 from gtk-rs/bilelmoussaoui/doc-alias
Browse files Browse the repository at this point in the history
add manual doc aliases
  • Loading branch information
GuillaumeGomez authored Jan 12, 2021
2 parents 9df8a0c + 06f945a commit 4e8911b
Show file tree
Hide file tree
Showing 122 changed files with 586 additions and 0 deletions.
1 change: 1 addition & 0 deletions atk/src/editable_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use glib::object::IsA;
use glib::translate::*;

pub trait EditableTextExtManual: 'static {
#[doc(alias = "atk_editable_text_insert_text")]
fn insert_text(&self, string: &str, position: i32) -> i32;
}

Expand Down
3 changes: 3 additions & 0 deletions atk/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use glib::object::IsA;
use glib::translate::*;

pub trait TableExtManual: 'static {
#[doc(alias = "atk_table_get_selected_columns")]
fn get_selected_columns(&self) -> Vec<i32>;

#[doc(alias = "atk_table_get_selected_rows")]
fn get_selected_rows(&self) -> Vec<i32>;
}

Expand Down
15 changes: 15 additions & 0 deletions gdk-pixbuf/src/pixbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use std::future::Future;
use crate::{Colorspace, Pixbuf, PixbufFormat};

impl Pixbuf {
#[doc(alias = "gdk_pixbuf_new_from_data")]
pub fn from_mut_slice<T: AsMut<[u8]>>(
data: T,
colorspace: Colorspace,
Expand Down Expand Up @@ -84,6 +85,8 @@ impl Pixbuf {
Pixbuf::from_stream(&gio::ReadInputStream::new(r), None::<&gio::Cancellable>)
}

#[doc(alias = "gdk_pixbuf_new_from_file")]
#[doc(alias = "gdk_pixbuf_new_from_file_utf8")]
pub fn from_file<T: AsRef<Path>>(filename: T) -> Result<Pixbuf, Error> {
#[cfg(not(windows))]
use ffi::gdk_pixbuf_new_from_file;
Expand All @@ -101,6 +104,8 @@ impl Pixbuf {
}
}

#[doc(alias = "gdk_pixbuf_new_from_file_at_size")]
#[doc(alias = "gdk_pixbuf_new_from_file_at_size_utf8")]
pub fn from_file_at_size<T: AsRef<Path>>(
filename: T,
width: i32,
Expand All @@ -127,6 +132,8 @@ impl Pixbuf {
}
}

#[doc(alias = "gdk_pixbuf_new_from_file_at_scale")]
#[doc(alias = "gdk_pixbuf_new_from_file_at_scale_utf8")]
pub fn from_file_at_scale<T: AsRef<Path>>(
filename: T,
width: i32,
Expand Down Expand Up @@ -155,6 +162,7 @@ impl Pixbuf {
}
}

#[doc(alias = "gdk_pixbuf_new_from_stream_async")]
pub fn from_stream_async<
P: IsA<gio::InputStream>,
Q: IsA<gio::Cancellable>,
Expand Down Expand Up @@ -208,6 +216,7 @@ impl Pixbuf {
}))
}

#[doc(alias = "gdk_pixbuf_new_from_stream_at_scale_async")]
pub fn from_stream_at_scale_async<
P: IsA<gio::InputStream>,
Q: IsA<gio::Cancellable>,
Expand Down Expand Up @@ -279,6 +288,7 @@ impl Pixbuf {

#[allow(clippy::mut_from_ref)]
#[allow(clippy::missing_safety_doc)]
#[doc(alias = "gdk_pixbuf_get_pixels_with_length")]
pub unsafe fn get_pixels(&self) -> &mut [u8] {
let mut len = 0;
let ptr = ffi::gdk_pixbuf_get_pixels_with_length(self.to_glib_none().0, &mut len);
Expand Down Expand Up @@ -313,6 +323,7 @@ impl Pixbuf {
}
}

#[doc(alias = "gdk_pixbuf_get_file_info")]
pub fn get_file_info<T: AsRef<Path>>(filename: T) -> Option<(PixbufFormat, i32, i32)> {
unsafe {
let mut width = mem::MaybeUninit::uninit();
Expand All @@ -336,6 +347,7 @@ impl Pixbuf {

#[cfg(any(feature = "v2_32", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_32")))]
#[doc(alias = "gdk_pixbuf_get_file_info_async")]
pub fn get_file_info_async<
P: IsA<gio::Cancellable>,
Q: FnOnce(Result<Option<(PixbufFormat, i32, i32)>, Error>) + Send + 'static,
Expand Down Expand Up @@ -405,6 +417,7 @@ impl Pixbuf {
}))
}

#[doc(alias = "gdk_pixbuf_save_to_bufferv")]
pub fn save_to_bufferv(&self, type_: &str, options: &[(&str, &str)]) -> Result<Vec<u8>, Error> {
unsafe {
let mut buffer = ptr::null_mut();
Expand Down Expand Up @@ -465,6 +478,7 @@ impl Pixbuf {

#[cfg(any(feature = "v2_36", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
#[doc(alias = "gdk_pixbuf_save_to_streamv_async")]
pub fn save_to_streamv_async<
P: IsA<gio::OutputStream>,
Q: IsA<gio::Cancellable>,
Expand Down Expand Up @@ -548,6 +562,7 @@ impl Pixbuf {
}))
}

#[doc(alias = "gdk_pixbuf_savev")]
pub fn savev<T: AsRef<Path>>(
&self,
filename: T,
Expand Down
1 change: 1 addition & 0 deletions gdk-pixbuf/src/pixbuf_animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::ptr;
use std::time::SystemTime;

pub trait PixbufAnimationExtManual {
#[doc(alias = "gdk_pixbuf_animation_get_iter")]
fn get_iter(&self, start_time: Option<SystemTime>) -> PixbufAnimationIter;
}

Expand Down
4 changes: 4 additions & 0 deletions gdk-pixbuf/src/pixbuf_animation_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ glib::wrapper! {
}

impl PixbufAnimationIter {
#[doc(alias = "gdk_pixbuf_animation_iter_advance")]
pub fn advance(&self, start_time: SystemTime) -> bool {
let diff = start_time
.duration_since(SystemTime::UNIX_EPOCH)
Expand All @@ -30,6 +31,7 @@ impl PixbufAnimationIter {
}
}

#[doc(alias = "gdk_pixbuf_animation_iter_get_pixbuf")]
pub fn get_pixbuf(&self) -> Pixbuf {
unsafe {
from_glib_none(ffi::gdk_pixbuf_animation_iter_get_pixbuf(
Expand All @@ -38,10 +40,12 @@ impl PixbufAnimationIter {
}
}

#[doc(alias = "gdk_pixbuf_animation_iter_get_delay_time")]
pub fn get_delay_time(&self) -> i32 {
unsafe { ffi::gdk_pixbuf_animation_iter_get_delay_time(self.to_glib_none().0) }
}

#[doc(alias = "gdk_pixbuf_animation_iter_on_currently_loading_frame")]
pub fn on_currently_loading_frame(&self) -> bool {
unsafe {
from_glib(ffi::gdk_pixbuf_animation_iter_on_currently_loading_frame(
Expand Down
2 changes: 2 additions & 0 deletions gdk/src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub const SELECTION_TYPE_WINDOW: Atom = Atom(33 as *mut _);
pub const SELECTION_TYPE_STRING: Atom = Atom(31 as *mut _);

impl Atom {
#[doc(alias = "gdk_atom_intern")]
pub fn intern(atom_name: &str) -> Atom {
assert_initialized_main_thread!();
unsafe {
Expand All @@ -37,6 +38,7 @@ impl Atom {
}
}

#[doc(alias = "gdk_atom_name")]
pub fn name(self) -> GString {
unsafe { from_glib_full(ffi::gdk_atom_name(self.0)) }
}
Expand Down
2 changes: 2 additions & 0 deletions gdk/src/cairo_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use glib::object::IsA;
use glib::translate::*;

pub trait GdkSurfaceExt {
#[doc(alias = "gdk_cairo_region_create_from_surface")]
fn create_region(&self) -> Option<Region>;
}

Expand All @@ -22,6 +23,7 @@ impl GdkSurfaceExt for Surface {
}

pub trait GdkPixbufExt {
#[doc(alias = "gdk_cairo_surface_create_from_pixbuf")]
fn create_surface<W: IsA<Window>>(&self, scale: i32, for_window: Option<&W>)
-> Option<Surface>;
}
Expand Down
2 changes: 2 additions & 0 deletions gdk/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::mem;
use std::ptr;

impl Device {
#[doc(alias = "gdk_device_get_axis")]
pub fn get_axis(&self, axes: &mut [f64], use_: AxisUse, value: &mut f64) -> bool {
unsafe {
from_glib(ffi::gdk_device_get_axis(
Expand All @@ -22,6 +23,7 @@ impl Device {
}
}

#[doc(alias = "gdk_device_get_history")]
pub fn get_history<P: IsA<Window>>(&self, window: &P, start: u32, stop: u32) -> Vec<TimeCoord> {
unsafe {
let mut events = ptr::null_mut();
Expand Down
1 change: 1 addition & 0 deletions gdk/src/device_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use crate::DeviceManager;

impl DeviceManager {
#[doc(alias = "gdk_disable_multidevice")]
pub fn disable_multidevice() {
assert_not_initialized!();
unsafe { ffi::gdk_disable_multidevice() }
Expand Down
13 changes: 13 additions & 0 deletions gdk/src/drag_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,27 @@ use glib::translate::*;
use std::ptr;

impl DragContext {
#[doc(alias = "gdk_drag_get_selection")]
pub fn drag_get_selection(&self) -> Atom {
unsafe { from_glib_none(ffi::gdk_drag_get_selection(self.to_glib_none().0) as *mut _) }
}

#[doc(alias = "gdk_drag_abort")]
pub fn drag_abort(&self, time_: u32) {
unsafe { ffi::gdk_drag_abort(self.to_glib_none().0, time_) }
}

#[doc(alias = "gdk_drop_reply")]
pub fn drop_reply(&self, accepted: bool, time_: u32) {
unsafe { ffi::gdk_drop_reply(self.to_glib_none().0, accepted.to_glib(), time_) }
}

#[doc(alias = "gdk_drag_drop")]
pub fn drop(&self, time_: u32) {
unsafe { ffi::gdk_drag_drop(self.to_glib_none().0, time_) }
}

#[doc(alias = "gdk_drag_find_window_for_screen")]
pub fn drag_find_window_for_screen(
&self,
drag_window: &Window,
Expand All @@ -52,6 +57,7 @@ impl DragContext {
}

#[allow(clippy::too_many_arguments)]
#[doc(alias = "gdk_drag_motion")]
pub fn drag_motion(
&self,
dest_window: &Window,
Expand All @@ -76,18 +82,22 @@ impl DragContext {
}
}

#[doc(alias = "gdk_drop_finish")]
pub fn drop_finish(&self, success: bool, time_: u32) {
unsafe { ffi::gdk_drop_finish(self.to_glib_none().0, success.to_glib(), time_) }
}

#[doc(alias = "gdk_drag_status")]
pub fn drag_status(&self, action: DragAction, time_: u32) {
unsafe { ffi::gdk_drag_status(self.to_glib_none().0, action.to_glib(), time_) }
}

#[doc(alias = "gdk_drag_drop_succeeded")]
pub fn drag_drop_succeeded(&self) -> bool {
unsafe { from_glib(ffi::gdk_drag_drop_succeeded(self.to_glib_none().0)) }
}

#[doc(alias = "gdk_drag_begin")]
pub fn drag_begin(window: &Window, targets: &[&Atom]) -> Option<DragContext> {
skip_assert_initialized!();
unsafe {
Expand All @@ -98,6 +108,7 @@ impl DragContext {
}
}

#[doc(alias = "gdk_drag_begin_for_device")]
pub fn drag_begin_for_device<P: IsA<Device>>(
window: &Window,
device: &P,
Expand All @@ -115,6 +126,7 @@ impl DragContext {

#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
#[doc(alias = "gdk_drag_begin_from_point")]
pub fn drag_begin_from_point<P: IsA<Device>>(
window: &Window,
device: &P,
Expand All @@ -136,6 +148,7 @@ impl DragContext {

#[cfg(any(feature = "v3_20", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
#[doc(alias = "gdk_drag_drop_done")]
pub fn drag_drop_done(&self, success: bool) {
skip_assert_initialized!();
unsafe {
Expand Down
Loading

0 comments on commit 4e8911b

Please sign in to comment.