Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #584 from pizzaiter/radiotoolbutton
Browse files Browse the repository at this point in the history
Add RadioToolButton
  • Loading branch information
GuillaumeGomez committed Oct 25, 2017
2 parents 1d9fb9d + 3a18a7c commit 8d5f44a
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Gir.toml
Expand Up @@ -1162,6 +1162,27 @@ status = "generate"
name = "group"
ignore = true

[[object]]
name = "Gtk.RadioToolButton"
status = "generate"
[[object.function]]
pattern = ".+_from_widget"
[[object.function.parameter]]
name = "group"
nullable = false
[[object.function]]
name = "new"
ignore = true
[[object.function]]
name = "new_from_stock"
ignore = true
[[object.function]]
name = "set_group"
ignore = true
[[object.property]]
name = "group"
ignore = true

[[object]]
name = "Gtk.Range"
status = "generate"
Expand Down
5 changes: 5 additions & 0 deletions src/auto/mod.rs
Expand Up @@ -522,6 +522,10 @@ mod radio_menu_item;
pub use self::radio_menu_item::RadioMenuItem;
pub use self::radio_menu_item::RadioMenuItemExt;

mod radio_tool_button;
pub use self::radio_tool_button::RadioToolButton;
pub use self::radio_tool_button::RadioToolButtonExt;

mod range;
pub use self::range::Range;
pub use self::range::RangeExt;
Expand Down Expand Up @@ -1059,6 +1063,7 @@ pub mod traits {
pub use super::ProgressBarExt;
pub use super::RadioButtonExt;
pub use super::RadioMenuItemExt;
pub use super::RadioToolButtonExt;
pub use super::RangeExt;
pub use super::RecentChooserExt;
pub use super::RecentFilterExt;
Expand Down
55 changes: 55 additions & 0 deletions src/auto/radio_tool_button.rs
@@ -0,0 +1,55 @@
// This file was generated by gir (0fe730d) from gir-files (db49619)
// DO NOT EDIT

use Actionable;
use Bin;
use Container;
use RadioButton;
use ToggleToolButton;
use ToolButton;
use ToolItem;
use Widget;
use ffi;
use glib::object::Downcast;
use glib::object::IsA;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;

glib_wrapper! {
pub struct RadioToolButton(Object<ffi::GtkRadioToolButton>): ToggleToolButton, ToolButton, ToolItem, Bin, Container, Widget, Actionable;

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

impl RadioToolButton {
pub fn new_from_widget(group: &RadioToolButton) -> RadioToolButton {
skip_assert_initialized!();
unsafe {
ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new_from_widget(group.to_glib_none().0)).downcast_unchecked()
}
}

pub fn new_with_stock_from_widget(group: &RadioToolButton, stock_id: &str) -> RadioToolButton {
skip_assert_initialized!();
unsafe {
ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new_with_stock_from_widget(group.to_glib_none().0, stock_id.to_glib_none().0)).downcast_unchecked()
}
}
}

pub trait RadioToolButtonExt {
fn get_group(&self) -> Vec<RadioButton>;
}

impl<O: IsA<RadioToolButton>> RadioToolButtonExt for O {
fn get_group(&self) -> Vec<RadioButton> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::gtk_radio_tool_button_get_group(self.to_glib_none().0))
}
}
}
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -215,6 +215,7 @@ mod message_dialog;
mod notebook;
mod radio_button;
mod radio_menu_item;
mod radio_tool_button;
mod recent_chooser_dialog;
mod recent_data;
mod requisition;
Expand Down
32 changes: 32 additions & 0 deletions src/radio_tool_button.rs
@@ -0,0 +1,32 @@
use std::ptr;

use RadioToolButton;
use ToolItem;
use ffi;
use glib::object::Downcast;
use glib::translate::*;
use glib::Value;
use gobject_ffi;

impl RadioToolButton {
pub fn new() -> RadioToolButton {
assert_initialized_main_thread!();
unsafe {
ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new(ptr::null_mut())).downcast_unchecked()
}
}

pub fn new_from_stock(stock_id: &str) -> RadioToolButton {
assert_initialized_main_thread!();
unsafe {
ToolItem::from_glib_none(ffi::gtk_radio_tool_button_new_from_stock(ptr::null_mut(), stock_id.to_glib_none().0)).downcast_unchecked()
}
}

pub fn join_group<'a, P: Into<Option<&'a RadioToolButton>>>(&self, group: P) {
let group = group.into();
unsafe {
gobject_ffi::g_object_set_property(self.to_glib_none().0, "group".to_glib_none().0, Value::from(group).to_glib_none().0);
}
}
}

0 comments on commit 8d5f44a

Please sign in to comment.