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 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// DO NOT EDIT
use crate::{HeaderBar, HeaderGroupChild};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::{boxed::Box as Box_, fmt, mem::transmute};
glib::wrapper! {
/// An object handling composite title bars.
///
/// The [`HeaderGroup`][crate::HeaderGroup] object handles the header bars of a composite title bar.
/// It splits the window decoration across the header bars, giving the left side
/// of the decorations to the leftmost header bar, and the right side of the
/// decorations to the rightmost header bar. See
/// [`HdyHeaderBarExt::set_decoration_layout()`][crate::prelude::HdyHeaderBarExt::set_decoration_layout()].
///
/// The [`decorate-all`][struct@crate::HeaderGroup#decorate-all] property can be used in conjunction
/// with [`folded`][struct@crate::Leaflet#folded] when the title bar is split across the pages
/// of a [`Leaflet`][crate::Leaflet] to automatically display the decorations on all the
/// pages when the leaflet is folded.
///
/// You can nest header groups, which is convenient when you nest leaflets too:
///
/// ```xml
/// <object class="HdyHeaderGroup" id="inner_header_group">
/// <property name="decorate-all" bind-source="inner_leaflet" bind-property="folded" bind-flags="sync-create"/>
/// <headerbars>
/// <headerbar name="inner_header_bar_1"/>
/// <headerbar name="inner_header_bar_2"/>
/// </headerbars>
/// </object>
/// <object class="HdyHeaderGroup" id="outer_header_group">
/// <property name="decorate-all" bind-source="outer_leaflet" bind-property="folded" bind-flags="sync-create"/>
/// <headerbars>
/// <headerbar name="inner_header_group"/>
/// <headerbar name="outer_header_bar"/>
/// </headerbars>
/// </object>
/// ```
///
/// ## Properties
///
///
/// #### `decorate-all`
/// Whether the elements of the group should all receive the full decoration.
///
/// This is useful in conjunction with [`folded`][struct@crate::Leaflet#folded] when the
/// leaflet contains the header bars of the group, as you want them all to
/// display the complete decoration when the leaflet is folded.
///
/// Readable | Writeable
///
/// ## Signals
///
///
/// #### `update-decoration-layouts`
/// This signal is emitted before updating the decoration layouts.
///
///
///
/// # Implements
///
/// [`trait@glib::ObjectExt`], [`trait@gtk::prelude::BuildableExt`]
#[doc(alias = "HdyHeaderGroup")]
pub struct HeaderGroup(Object<ffi::HdyHeaderGroup, ffi::HdyHeaderGroupClass>) @implements gtk::Buildable;
match fn {
type_ => || ffi::hdy_header_group_get_type(),
}
}
impl HeaderGroup {
/// Creates a new [`HeaderGroup`][crate::HeaderGroup].
///
/// # Returns
///
/// the newly created [`HeaderGroup`][crate::HeaderGroup]
#[doc(alias = "hdy_header_group_new")]
pub fn new() -> HeaderGroup {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::hdy_header_group_new()) }
}
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`HeaderGroup`] objects.
///
/// This method returns an instance of [`HeaderGroupBuilder`](crate::builders::HeaderGroupBuilder) which can be used to create [`HeaderGroup`] objects.
pub fn builder() -> HeaderGroupBuilder {
HeaderGroupBuilder::new()
}
/// Adds @header_bar to @self.
///
/// When the widget is destroyed or no longer referenced elsewhere, it will be
/// removed from the header group.
/// ## `header_bar`
/// the header bar to add
#[doc(alias = "hdy_header_group_add_gtk_header_bar")]
pub fn add_gtk_header_bar(&self, header_bar: &impl IsA<gtk::HeaderBar>) {
unsafe {
ffi::hdy_header_group_add_gtk_header_bar(
self.to_glib_none().0,
header_bar.as_ref().to_glib_none().0,
);
}
}
/// Adds @header_bar to @self.
///
/// When the widget is destroyed or no longer referenced elsewhere, it will be
/// removed from the header group.
/// ## `header_bar`
/// the header bar to add
#[doc(alias = "hdy_header_group_add_header_bar")]
pub fn add_header_bar(&self, header_bar: &impl IsA<HeaderBar>) {
unsafe {
ffi::hdy_header_group_add_header_bar(
self.to_glib_none().0,
header_bar.as_ref().to_glib_none().0,
);
}
}
/// Adds @header_group to @self.
///
/// When the nested group is no longer referenced elsewhere, it will be removed
/// from the header group.
/// ## `header_group`
/// the header group to add
#[doc(alias = "hdy_header_group_add_header_group")]
pub fn add_header_group(&self, header_group: &HeaderGroup) {
unsafe {
ffi::hdy_header_group_add_header_group(
self.to_glib_none().0,
header_group.to_glib_none().0,
);
}
}
/// Returns the list of children associated with @self.
///
/// # Returns
///
/// the list of
/// children
#[doc(alias = "hdy_header_group_get_children")]
#[doc(alias = "get_children")]
pub fn children(&self) -> Vec<HeaderGroupChild> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::hdy_header_group_get_children(
self.to_glib_none().0,
))
}
}
/// Gets whether the elements of the group should all receive the full
/// decoration.
///
/// # Returns
///
/// whether the elements of the group should all receive the full
/// decoration
#[doc(alias = "hdy_header_group_get_decorate_all")]
#[doc(alias = "get_decorate_all")]
pub fn is_decorate_all(&self) -> bool {
unsafe {
from_glib(ffi::hdy_header_group_get_decorate_all(
self.to_glib_none().0,
))
}
}
/// Removes @child from @self.
/// ## `child`
/// the header group child to remove
#[doc(alias = "hdy_header_group_remove_child")]
pub fn remove_child(&self, child: &HeaderGroupChild) {
unsafe {
ffi::hdy_header_group_remove_child(self.to_glib_none().0, child.to_glib_none().0);
}
}
/// Removes @header_bar from @self.
/// ## `header_bar`
/// the header bar to remove
#[doc(alias = "hdy_header_group_remove_gtk_header_bar")]
pub fn remove_gtk_header_bar(&self, header_bar: &impl IsA<gtk::HeaderBar>) {
unsafe {
ffi::hdy_header_group_remove_gtk_header_bar(
self.to_glib_none().0,
header_bar.as_ref().to_glib_none().0,
);
}
}
/// Removes @header_bar from @self.
/// ## `header_bar`
/// the header bar to remove
#[doc(alias = "hdy_header_group_remove_header_bar")]
pub fn remove_header_bar(&self, header_bar: &impl IsA<HeaderBar>) {
unsafe {
ffi::hdy_header_group_remove_header_bar(
self.to_glib_none().0,
header_bar.as_ref().to_glib_none().0,
);
}
}
/// Removes a nested [`HeaderGroup`][crate::HeaderGroup] from @self.
/// ## `header_group`
/// the header group to remove
#[doc(alias = "hdy_header_group_remove_header_group")]
pub fn remove_header_group(&self, header_group: &HeaderGroup) {
unsafe {
ffi::hdy_header_group_remove_header_group(
self.to_glib_none().0,
header_group.to_glib_none().0,
);
}
}
/// Sets whether the elements of the group should all receive the full
/// decoration.
/// ## `decorate_all`
/// whether the elements of the group should all receive the full
/// decoration
#[doc(alias = "hdy_header_group_set_decorate_all")]
pub fn set_decorate_all(&self, decorate_all: bool) {
unsafe {
ffi::hdy_header_group_set_decorate_all(self.to_glib_none().0, decorate_all.into_glib());
}
}
/// This signal is emitted before updating the decoration layouts.
#[doc(alias = "update-decoration-layouts")]
pub fn connect_update_decoration_layouts<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId {
unsafe extern "C" fn update_decoration_layouts_trampoline<F: Fn(&HeaderGroup) + 'static>(
this: *mut ffi::HdyHeaderGroup,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"update-decoration-layouts\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
update_decoration_layouts_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "decorate-all")]
pub fn connect_decorate_all_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_decorate_all_trampoline<F: Fn(&HeaderGroup) + 'static>(
this: *mut ffi::HdyHeaderGroup,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(&from_glib_borrow(this))
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
b"notify::decorate-all\0".as_ptr() as *const _,
Some(transmute::<_, unsafe extern "C" fn()>(
notify_decorate_all_trampoline::<F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl Default for HeaderGroup {
fn default() -> Self {
Self::new()
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`HeaderGroup`] objects.
///
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
#[must_use = "The builder must be built to be used"]
pub struct HeaderGroupBuilder {
builder: glib::object::ObjectBuilder<'static, HeaderGroup>,
}
impl HeaderGroupBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
/// Whether the elements of the group should all receive the full decoration.
///
/// This is useful in conjunction with [`folded`][struct@crate::Leaflet#folded] when the
/// leaflet contains the header bars of the group, as you want them all to
/// display the complete decoration when the leaflet is folded.
pub fn decorate_all(self, decorate_all: bool) -> Self {
Self {
builder: self.builder.property("decorate-all", decorate_all),
}
}
// rustdoc-stripper-ignore-next
/// Build the [`HeaderGroup`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> HeaderGroup {
self.builder.build()
}
}
impl fmt::Display for HeaderGroup {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("HeaderGroup")
}
}