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 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from webkit-gir-files
// DO NOT EDIT
use crate::ffi;
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// Window properties of a #WebKitWebView.
///
/// The content of a #WebKitWebView can request to change certain
/// properties of the window containing the view. This can include the x, y position
/// of the window, the width and height but also if a toolbar,
/// scrollbar, statusbar, locationbar should be visible to the user,
/// and the request to show the #WebKitWebView fullscreen.
///
/// The #WebKitWebView::ready-to-show signal handler is the proper place
/// to apply the initial window properties. Then you can monitor the
/// #WebKitWindowProperties by connecting to ::notify signal.
///
/// **⚠️ The following code is in c ⚠️**
///
/// ```c
/// static void ready_to_show_cb (WebKitWebView *web_view, gpointer user_data)
/// {
/// GtkWidget *window;
/// WebKitWindowProperties *window_properties;
/// gboolean visible;
///
/// // Create the window to contain the WebKitWebView.
/// window = browser_window_new ();
/// gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (web_view));
/// gtk_widget_show (GTK_WIDGET (web_view));
///
/// // Get the WebKitWindowProperties of the web view and monitor it.
/// window_properties = webkit_web_view_get_window_properties (web_view);
/// g_signal_connect (window_properties, "notify::geometry",
/// G_CALLBACK (window_geometry_changed), window);
/// g_signal_connect (window_properties, "notify::toolbar-visible",
/// G_CALLBACK (window_toolbar_visibility_changed), window);
/// g_signal_connect (window_properties, "notify::menubar-visible",
/// G_CALLBACK (window_menubar_visibility_changed), window);
///
/// // Apply the window properties before showing the window.
/// visible = webkit_window_properties_get_toolbar_visible (window_properties);
/// browser_window_set_toolbar_visible (BROWSER_WINDOW (window), visible);
/// visible = webkit_window_properties_get_menubar_visible (window_properties);
/// browser_window_set_menubar_visible (BROWSER_WINDOW (window), visible);
///
/// if (webkit_window_properties_get_fullscreen (window_properties)) {
/// gtk_window_fullscreen (GTK_WINDOW (window));
/// } else {
/// GdkRectangle geometry;
///
/// gtk_window_set_resizable (GTK_WINDOW (window),
/// webkit_window_properties_get_resizable (window_properties));
/// webkit_window_properties_get_geometry (window_properties, &geometry);
/// gtk_window_move (GTK_WINDOW (window), geometry.x, geometry.y);
/// gtk_window_resize (GTK_WINDOW (window), geometry.width, geometry.height);
/// }
///
/// gtk_widget_show (window);
/// }
/// ```
///
/// ## Properties
///
///
/// #### `fullscreen`
/// Whether window will be displayed fullscreen.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `geometry`
/// The size and position of the window on the screen.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `locationbar-visible`
/// Whether the locationbar should be visible for the window.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `menubar-visible`
/// Whether the menubar should be visible for the window.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `resizable`
/// Whether the window can be resized.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `scrollbars-visible`
/// Whether the scrollbars should be visible for the window.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `statusbar-visible`
/// Whether the statusbar should be visible for the window.
///
/// Readable | Writeable | Construct Only
///
///
/// #### `toolbar-visible`
/// Whether the toolbar should be visible for the window.
///
/// Readable | Writeable | Construct Only
#[doc(alias = "WebKitWindowProperties")]
pub struct WindowProperties(Object<ffi::WebKitWindowProperties, ffi::WebKitWindowPropertiesClass>);
match fn {
type_ => || ffi::webkit_window_properties_get_type(),
}
}
impl WindowProperties {
// rustdoc-stripper-ignore-next
/// Creates a new builder-pattern struct instance to construct [`WindowProperties`] objects.
///
/// This method returns an instance of [`WindowPropertiesBuilder`](crate::builders::WindowPropertiesBuilder) which can be used to create [`WindowProperties`] objects.
pub fn builder() -> WindowPropertiesBuilder {
WindowPropertiesBuilder::new()
}
/// Get whether the window should be shown in fullscreen state or not.
///
/// # Returns
///
/// [`true`] if the window should be fullscreen or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_fullscreen")]
#[doc(alias = "get_fullscreen")]
#[doc(alias = "fullscreen")]
pub fn is_fullscreen(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_fullscreen(
self.to_glib_none().0,
))
}
}
/// Get the geometry the window should have on the screen when shown.
///
/// # Returns
///
///
/// ## `geometry`
/// return location for the window geometry
#[doc(alias = "webkit_window_properties_get_geometry")]
#[doc(alias = "get_geometry")]
pub fn geometry(&self) -> gdk::Rectangle {
unsafe {
let mut geometry = gdk::Rectangle::uninitialized();
ffi::webkit_window_properties_get_geometry(
self.to_glib_none().0,
geometry.to_glib_none_mut().0,
);
geometry
}
}
/// Get whether the window should have the locationbar visible or not.
///
/// # Returns
///
/// [`true`] if locationbar should be visible or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_locationbar_visible")]
#[doc(alias = "get_locationbar_visible")]
#[doc(alias = "locationbar-visible")]
pub fn is_locationbar_visible(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_locationbar_visible(
self.to_glib_none().0,
))
}
}
/// Get whether the window should have the menubar visible or not.
///
/// # Returns
///
/// [`true`] if menubar should be visible or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_menubar_visible")]
#[doc(alias = "get_menubar_visible")]
#[doc(alias = "menubar-visible")]
pub fn is_menubar_visible(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_menubar_visible(
self.to_glib_none().0,
))
}
}
/// Get whether the window should be resizable by the user or not.
///
/// # Returns
///
/// [`true`] if the window should be resizable or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_resizable")]
#[doc(alias = "get_resizable")]
#[doc(alias = "resizable")]
pub fn is_resizable(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_resizable(
self.to_glib_none().0,
))
}
}
/// Get whether the window should have the scrollbars visible or not.
///
/// # Returns
///
/// [`true`] if scrollbars should be visible or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_scrollbars_visible")]
#[doc(alias = "get_scrollbars_visible")]
#[doc(alias = "scrollbars-visible")]
pub fn is_scrollbars_visible(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_scrollbars_visible(
self.to_glib_none().0,
))
}
}
/// Get whether the window should have the statusbar visible or not.
///
/// # Returns
///
/// [`true`] if statusbar should be visible or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_statusbar_visible")]
#[doc(alias = "get_statusbar_visible")]
#[doc(alias = "statusbar-visible")]
pub fn is_statusbar_visible(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_statusbar_visible(
self.to_glib_none().0,
))
}
}
/// Get whether the window should have the toolbar visible or not.
///
/// # Returns
///
/// [`true`] if toolbar should be visible or [`false`] otherwise.
#[doc(alias = "webkit_window_properties_get_toolbar_visible")]
#[doc(alias = "get_toolbar_visible")]
#[doc(alias = "toolbar-visible")]
pub fn is_toolbar_visible(&self) -> bool {
unsafe {
from_glib(ffi::webkit_window_properties_get_toolbar_visible(
self.to_glib_none().0,
))
}
}
}
// rustdoc-stripper-ignore-next
/// A [builder-pattern] type to construct [`WindowProperties`] 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 WindowPropertiesBuilder {
builder: glib::object::ObjectBuilder<'static, WindowProperties>,
}
impl WindowPropertiesBuilder {
fn new() -> Self {
Self {
builder: glib::object::Object::builder(),
}
}
/// Whether window will be displayed fullscreen.
pub fn fullscreen(self, fullscreen: bool) -> Self {
Self {
builder: self.builder.property("fullscreen", fullscreen),
}
}
/// The size and position of the window on the screen.
pub fn geometry(self, geometry: &gdk::Rectangle) -> Self {
Self {
builder: self.builder.property("geometry", geometry),
}
}
/// Whether the locationbar should be visible for the window.
pub fn locationbar_visible(self, locationbar_visible: bool) -> Self {
Self {
builder: self
.builder
.property("locationbar-visible", locationbar_visible),
}
}
/// Whether the menubar should be visible for the window.
pub fn menubar_visible(self, menubar_visible: bool) -> Self {
Self {
builder: self.builder.property("menubar-visible", menubar_visible),
}
}
/// Whether the window can be resized.
pub fn resizable(self, resizable: bool) -> Self {
Self {
builder: self.builder.property("resizable", resizable),
}
}
/// Whether the scrollbars should be visible for the window.
pub fn scrollbars_visible(self, scrollbars_visible: bool) -> Self {
Self {
builder: self
.builder
.property("scrollbars-visible", scrollbars_visible),
}
}
/// Whether the statusbar should be visible for the window.
pub fn statusbar_visible(self, statusbar_visible: bool) -> Self {
Self {
builder: self
.builder
.property("statusbar-visible", statusbar_visible),
}
}
/// Whether the toolbar should be visible for the window.
pub fn toolbar_visible(self, toolbar_visible: bool) -> Self {
Self {
builder: self.builder.property("toolbar-visible", toolbar_visible),
}
}
// rustdoc-stripper-ignore-next
/// Build the [`WindowProperties`].
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
pub fn build(self) -> WindowProperties {
self.builder.build()
}
}