gtk/
buildable.rs

1// Copyright 2016, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib::translate::*;
6use gtk_sys;
7use Buildable;
8use IsA;
9
10pub trait BuildableExtManual: 'static {
11    fn get_name(&self) -> Option<String>;
12
13    fn set_name(&self, name: &str);
14}
15
16impl<O: IsA<Buildable>> BuildableExtManual for O {
17    fn get_name(&self) -> Option<String> {
18        unsafe {
19            from_glib_none(gtk_sys::gtk_buildable_get_name(
20                self.as_ref().to_glib_none().0,
21            ))
22        }
23    }
24
25    fn set_name(&self, name: &str) {
26        unsafe {
27            gtk_sys::gtk_buildable_set_name(self.as_ref().to_glib_none().0, name.to_glib_none().0);
28        }
29    }
30}