[go: up one dir, main page]

gtk 0.4.0

Rust bindings for the GTK+ 3 library
Documentation
// This file was generated by gir (https://github.com/gtk-rs/gir @ fbb95f4)
// from gir-files (https://github.com/gtk-rs/gir-files @ 77d1f70)
// DO NOT EDIT

use Box;
use Buildable;
use Container;
use FileChooser;
use FileChooserAction;
use Orientable;
use Widget;
use ffi;
use glib;
use glib::StaticType;
use glib::Value;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use libc;
use std::boxed::Box as Box_;
use std::mem;
use std::mem::transmute;
use std::ptr;

glib_wrapper! {
    pub struct FileChooserWidget(Object<ffi::GtkFileChooserWidget, ffi::GtkFileChooserWidgetClass>): Box, Container, Widget, Buildable, Orientable, FileChooser;

    match fn {
        get_type => || ffi::gtk_file_chooser_widget_get_type(),
    }
}

impl FileChooserWidget {
    pub fn new(action: FileChooserAction) -> FileChooserWidget {
        assert_initialized_main_thread!();
        unsafe {
            Widget::from_glib_none(ffi::gtk_file_chooser_widget_new(action.to_glib())).downcast_unchecked()
        }
    }
}

pub trait FileChooserWidgetExt {
    fn get_property_search_mode(&self) -> bool;

    fn set_property_search_mode(&self, search_mode: bool);

    fn get_property_subtitle(&self) -> Option<String>;

    fn connect_desktop_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_desktop_folder(&self);

    fn connect_down_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_down_folder(&self);

    fn connect_home_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_home_folder(&self);

    fn connect_location_popup<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_location_popup(&self, path: &str);

    fn connect_location_popup_on_paste<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_location_popup_on_paste(&self);

    fn connect_location_toggle_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_location_toggle_popup(&self);

    fn connect_places_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_places_shortcut(&self);

    fn connect_quick_bookmark<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_quick_bookmark(&self, bookmark_index: i32);

    fn connect_recent_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_recent_shortcut(&self);

    fn connect_search_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_search_shortcut(&self);

    fn connect_show_hidden<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_show_hidden(&self);

    fn connect_up_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn emit_up_folder(&self);

    fn connect_property_search_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;

    fn connect_property_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<FileChooserWidget> + IsA<glib::object::Object> + glib::object::ObjectExt> FileChooserWidgetExt for O {
    fn get_property_search_mode(&self) -> bool {
        unsafe {
            let mut value = Value::from_type(<bool as StaticType>::static_type());
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "search-mode".to_glib_none().0, value.to_glib_none_mut().0);
            value.get().unwrap()
        }
    }

    fn set_property_search_mode(&self, search_mode: bool) {
        unsafe {
            gobject_ffi::g_object_set_property(self.to_glib_none().0, "search-mode".to_glib_none().0, Value::from(&search_mode).to_glib_none().0);
        }
    }

    fn get_property_subtitle(&self) -> Option<String> {
        unsafe {
            let mut value = Value::from_type(<String as StaticType>::static_type());
            gobject_ffi::g_object_get_property(self.to_glib_none().0, "subtitle".to_glib_none().0, value.to_glib_none_mut().0);
            value.get()
        }
    }

    fn connect_desktop_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "desktop-folder",
                transmute(desktop_folder_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_desktop_folder(&self) {
        let _ = self.emit("desktop-folder", &[]).unwrap();
    }

    fn connect_down_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "down-folder",
                transmute(down_folder_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_down_folder(&self) {
        let _ = self.emit("down-folder", &[]).unwrap();
    }

    fn connect_home_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "home-folder",
                transmute(home_folder_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_home_folder(&self) {
        let _ = self.emit("home-folder", &[]).unwrap();
    }

    fn connect_location_popup<F: Fn(&Self, &str) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, &str) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "location-popup",
                transmute(location_popup_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_location_popup(&self, path: &str) {
        let _ = self.emit("location-popup", &[&path]).unwrap();
    }

    fn connect_location_popup_on_paste<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "location-popup-on-paste",
                transmute(location_popup_on_paste_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_location_popup_on_paste(&self) {
        let _ = self.emit("location-popup-on-paste", &[]).unwrap();
    }

    fn connect_location_toggle_popup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "location-toggle-popup",
                transmute(location_toggle_popup_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_location_toggle_popup(&self) {
        let _ = self.emit("location-toggle-popup", &[]).unwrap();
    }

    fn connect_places_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "places-shortcut",
                transmute(places_shortcut_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_places_shortcut(&self) {
        let _ = self.emit("places-shortcut", &[]).unwrap();
    }

    fn connect_quick_bookmark<F: Fn(&Self, i32) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self, i32) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "quick-bookmark",
                transmute(quick_bookmark_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_quick_bookmark(&self, bookmark_index: i32) {
        let _ = self.emit("quick-bookmark", &[&bookmark_index]).unwrap();
    }

    fn connect_recent_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "recent-shortcut",
                transmute(recent_shortcut_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_recent_shortcut(&self) {
        let _ = self.emit("recent-shortcut", &[]).unwrap();
    }

    fn connect_search_shortcut<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "search-shortcut",
                transmute(search_shortcut_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_search_shortcut(&self) {
        let _ = self.emit("search-shortcut", &[]).unwrap();
    }

    fn connect_show_hidden<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "show-hidden",
                transmute(show_hidden_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_show_hidden(&self) {
        let _ = self.emit("show-hidden", &[]).unwrap();
    }

    fn connect_up_folder<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "up-folder",
                transmute(up_folder_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn emit_up_folder(&self) {
        let _ = self.emit("up-folder", &[]).unwrap();
    }

    fn connect_property_search_mode_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::search-mode",
                transmute(notify_search_mode_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }

    fn connect_property_subtitle_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
        unsafe {
            let f: Box_<Box_<Fn(&Self) + 'static>> = Box_::new(Box_::new(f));
            connect(self.to_glib_none().0, "notify::subtitle",
                transmute(notify_subtitle_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
        }
    }
}

unsafe extern "C" fn desktop_folder_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn down_folder_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn home_folder_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn location_popup_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, path: *mut libc::c_char, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P, &str) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked(), &String::from_glib_none(path))
}

unsafe extern "C" fn location_popup_on_paste_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn location_toggle_popup_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn places_shortcut_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn quick_bookmark_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, bookmark_index: libc::c_int, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P, i32) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked(), bookmark_index)
}

unsafe extern "C" fn recent_shortcut_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn search_shortcut_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn show_hidden_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn up_folder_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_search_mode_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_subtitle_trampoline<P>(this: *mut ffi::GtkFileChooserWidget, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<FileChooserWidget> {
    callback_guard!();
    let f: &&(Fn(&P) + 'static) = transmute(f);
    f(&FileChooserWidget::from_glib_borrow(this).downcast_unchecked())
}