1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// This file was generated by gir (4b09025) from gir-files (71d73f0)
// DO NOT EDIT

use ffi;
use glib::object::IsA;
use glib::translate::*;
use gobject_ffi;
use std::mem;

glib_wrapper! {
    pub struct Editable(Object<ffi::GtkEditable>);

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

pub trait EditableExt {
    fn copy_clipboard(&self);

    fn cut_clipboard(&self);

    fn delete_selection(&self);

    fn delete_text(&self, start_pos: i32, end_pos: i32);

    fn get_chars(&self, start_pos: i32, end_pos: i32) -> Option<String>;

    fn get_editable(&self) -> bool;

    fn get_position(&self) -> i32;

    fn get_selection_bounds(&self) -> Option<(i32, i32)>;

    fn insert_text(&self, new_text: &str, new_text_length: i32, position: &mut i32);

    fn paste_clipboard(&self);

    fn select_region(&self, start_pos: i32, end_pos: i32);

    fn set_editable(&self, is_editable: bool);

    fn set_position(&self, position: i32);
}

impl<O: IsA<Editable>> EditableExt for O {
    fn copy_clipboard(&self) {
        unsafe {
            ffi::gtk_editable_copy_clipboard(self.to_glib_none().0);
        }
    }

    fn cut_clipboard(&self) {
        unsafe {
            ffi::gtk_editable_cut_clipboard(self.to_glib_none().0);
        }
    }

    fn delete_selection(&self) {
        unsafe {
            ffi::gtk_editable_delete_selection(self.to_glib_none().0);
        }
    }

    fn delete_text(&self, start_pos: i32, end_pos: i32) {
        unsafe {
            ffi::gtk_editable_delete_text(self.to_glib_none().0, start_pos, end_pos);
        }
    }

    fn get_chars(&self, start_pos: i32, end_pos: i32) -> Option<String> {
        unsafe {
            from_glib_full(ffi::gtk_editable_get_chars(self.to_glib_none().0, start_pos, end_pos))
        }
    }

    fn get_editable(&self) -> bool {
        unsafe {
            from_glib(ffi::gtk_editable_get_editable(self.to_glib_none().0))
        }
    }

    fn get_position(&self) -> i32 {
        unsafe {
            ffi::gtk_editable_get_position(self.to_glib_none().0)
        }
    }

    fn get_selection_bounds(&self) -> Option<(i32, i32)> {
        unsafe {
            let mut start_pos = mem::uninitialized();
            let mut end_pos = mem::uninitialized();
            let ret = from_glib(ffi::gtk_editable_get_selection_bounds(self.to_glib_none().0, &mut start_pos, &mut end_pos));
            if ret { Some((start_pos, end_pos)) } else { None }
        }
    }

    fn insert_text(&self, new_text: &str, new_text_length: i32, position: &mut i32) {
        unsafe {
            ffi::gtk_editable_insert_text(self.to_glib_none().0, new_text.to_glib_none().0, new_text_length, position);
        }
    }

    fn paste_clipboard(&self) {
        unsafe {
            ffi::gtk_editable_paste_clipboard(self.to_glib_none().0);
        }
    }

    fn select_region(&self, start_pos: i32, end_pos: i32) {
        unsafe {
            ffi::gtk_editable_select_region(self.to_glib_none().0, start_pos, end_pos);
        }
    }

    fn set_editable(&self, is_editable: bool) {
        unsafe {
            ffi::gtk_editable_set_editable(self.to_glib_none().0, is_editable.to_glib());
        }
    }

    fn set_position(&self, position: i32) {
        unsafe {
            ffi::gtk_editable_set_position(self.to_glib_none().0, position);
        }
    }
}