Add RadioToolButton #584
Add RadioToolButton #584
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)) | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::ptr; | ||
|
||
use RadioToolButton; | ||
use ToolItem; | ||
use ffi; | ||
use glib::object::Downcast; | ||
use glib::translate::*; | ||
|
||
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() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is deprecated since 3.10, maybe let's not add it? Docs say that Also it probably makes sense to expose something for the weird groups API it provides? IIRC we already have the same problem with other group API elsewhere in GTK ( @GuillaumeGomez you remember? ) so let's take inspiration from there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't recall which at all. :-/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @EPashkin Maybe? Some other RadioWhatever API (the plain RadioButton? RadioMenuItems?) where you have groups of things. I don't have time for looking closer now and GTK UI stuff is not really my main area of expertise so I would have to look up, sorry :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You meant #488? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually missed that the For the group API, I will try to implement what @EPashkin proposed below. At the moment one has to use one of the |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
ToolItem
and notRadioToolButton
? And generally, you can just usefrom_glib_none
and let the compiler figure out the right implementationThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good catch, didn't see it at all...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It because says Gtk-3.0.gir:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be best to be consistent with what gets auto-generated for similar functions, even if it does not really make a difference how one calls
from_glib_none
.