gtk/auto/socket.rs
1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{Align, Buildable, Container, ResizeMode, Widget, ffi, xlib};
6use glib::{
7 object::ObjectType as _,
8 prelude::*,
9 signal::{SignalHandlerId, connect_raw},
10 translate::*,
11};
12use std::boxed::Box as Box_;
13
14glib::wrapper! {
15 ///
16 /// GtkWidget *socket = gtk_socket_new ();
17 /// gtk_widget_show (socket);
18 /// gtk_container_add (GTK_CONTAINER (parent), socket);
19 ///
20 /// // The following call is only necessary if one of
21 /// // the ancestors of the socket is not yet visible.
22 /// gtk_widget_realize (socket);
23 /// g_print ("The ID of the sockets window is %`x`\n",
24 /// gtk_socket_get_id (socket));
25 /// ]|
26 ///
27 /// Note that if you pass the window ID of the socket to another
28 /// process that will create a plug in the socket, you must make
29 /// sure that the socket widget is not destroyed until that plug
30 /// is created. Violating this rule will cause unpredictable
31 /// consequences, the most likely consequence being that the plug
32 /// will appear as a separate toplevel window. You can check if
33 /// the plug has been created by using [`GtkSocketExt::plug_window()`][crate::prelude::GtkSocketExt::plug_window()].
34 /// If it returns a non-[`None`] value, then the plug has been
35 /// successfully created inside of the socket.
36 ///
37 /// When GTK+ is notified that the embedded window has been destroyed,
38 /// then it will destroy the socket as well. You should always,
39 /// therefore, be prepared for your sockets to be destroyed at any
40 /// time when the main event loop is running. To prevent this from
41 /// happening, you can connect to the [`plug-removed`][struct@crate::Socket#plug-removed] signal.
42 ///
43 /// The communication between a [`Socket`][crate::Socket] and a [`Plug`][crate::Plug] follows the
44 /// [XEmbed Protocol](http://www.freedesktop.org/Standards/xembed-spec).
45 /// This protocol has also been implemented in other toolkits, e.g. Qt,
46 /// allowing the same level of integration when embedding a Qt widget
47 /// in GTK or vice versa.
48 ///
49 /// The [`Plug`][crate::Plug] and [`Socket`][crate::Socket] widgets are only available when GTK+
50 /// is compiled for the X11 platform and `GDK_WINDOWING_X11` is defined.
51 /// They can only be used on a `GdkX11Display`. To use [`Plug`][crate::Plug] and
52 /// [`Socket`][crate::Socket], you need to include the `gtk/gtkx.h` header.
53 ///
54 /// ## Signals
55 ///
56 ///
57 /// #### `plug-added`
58 /// This signal is emitted when a client is successfully
59 /// added to the socket.
60 ///
61 ///
62 ///
63 ///
64 /// #### `plug-removed`
65 /// This signal is emitted when a client is removed from the socket.
66 /// The default action is to destroy the [`Socket`][crate::Socket] widget, so if you
67 /// want to reuse it you must add a signal handler that returns [`true`].
68 ///
69 ///
70 /// <details><summary><h4>Container</h4></summary>
71 ///
72 ///
73 /// #### `add`
74 ///
75 ///
76 ///
77 /// #### `check-resize`
78 ///
79 ///
80 ///
81 /// #### `remove`
82 ///
83 ///
84 ///
85 /// #### `set-focus-child`
86 ///
87 /// </details>
88 /// <details><summary><h4>Widget</h4></summary>
89 ///
90 ///
91 /// #### `accel-closures-changed`
92 ///
93 ///
94 ///
95 /// #### `button-press-event`
96 /// The ::button-press-event signal will be emitted when a button
97 /// (typically from a mouse) is pressed.
98 ///
99 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
100 /// widget needs to enable the [`gdk::EventMask::BUTTON_PRESS_MASK`][crate::gdk::EventMask::BUTTON_PRESS_MASK] mask.
101 ///
102 /// This signal will be sent to the grab widget if there is one.
103 ///
104 ///
105 ///
106 ///
107 /// #### `button-release-event`
108 /// The ::button-release-event signal will be emitted when a button
109 /// (typically from a mouse) is released.
110 ///
111 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the
112 /// widget needs to enable the [`gdk::EventMask::BUTTON_RELEASE_MASK`][crate::gdk::EventMask::BUTTON_RELEASE_MASK] mask.
113 ///
114 /// This signal will be sent to the grab widget if there is one.
115 ///
116 ///
117 ///
118 ///
119 /// #### `can-activate-accel`
120 /// Determines whether an accelerator that activates the signal
121 /// identified by `signal_id` can currently be activated.
122 /// This signal is present to allow applications and derived
123 /// widgets to override the default [`Widget`][crate::Widget] handling
124 /// for determining whether an accelerator can be activated.
125 ///
126 ///
127 ///
128 ///
129 /// #### `child-notify`
130 /// The ::child-notify signal is emitted for each
131 /// [child property][child-properties] that has
132 /// changed on an object. The signal's detail holds the property name.
133 ///
134 /// Detailed
135 ///
136 ///
137 /// #### `composited-changed`
138 /// The ::composited-changed signal is emitted when the composited
139 /// status of `widgets` screen changes.
140 /// See [`Screen::is_composited()`][crate::gdk::Screen::is_composited()].
141 ///
142 /// Action
143 ///
144 ///
145 /// #### `configure-event`
146 /// The ::configure-event signal will be emitted when the size, position or
147 /// stacking of the `widget`'s window has changed.
148 ///
149 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
150 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
151 /// automatically for all new windows.
152 ///
153 ///
154 ///
155 ///
156 /// #### `damage-event`
157 /// Emitted when a redirected window belonging to `widget` gets drawn into.
158 /// The region/area members of the event shows what area of the redirected
159 /// drawable was drawn into.
160 ///
161 ///
162 ///
163 ///
164 /// #### `delete-event`
165 /// The ::delete-event signal is emitted if a user requests that
166 /// a toplevel window is closed. The default handler for this signal
167 /// destroys the window. Connecting [`WidgetExtManual::hide_on_delete()`][crate::prelude::WidgetExtManual::hide_on_delete()] to
168 /// this signal will cause the window to be hidden instead, so that
169 /// it can later be shown again without reconstructing it.
170 ///
171 ///
172 ///
173 ///
174 /// #### `destroy`
175 /// Signals that all holders of a reference to the widget should release
176 /// the reference that they hold. May result in finalization of the widget
177 /// if all references are released.
178 ///
179 /// This signal is not suitable for saving widget state.
180 ///
181 ///
182 ///
183 ///
184 /// #### `destroy-event`
185 /// The ::destroy-event signal is emitted when a [`gdk::Window`][crate::gdk::Window] is destroyed.
186 /// You rarely get this signal, because most widgets disconnect themselves
187 /// from their window before they destroy it, so no widget owns the
188 /// window at destroy time.
189 ///
190 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
191 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
192 /// automatically for all new windows.
193 ///
194 ///
195 ///
196 ///
197 /// #### `direction-changed`
198 /// The ::direction-changed signal is emitted when the text direction
199 /// of a widget changes.
200 ///
201 ///
202 ///
203 ///
204 /// #### `drag-begin`
205 /// The ::drag-begin signal is emitted on the drag source when a drag is
206 /// started. A typical reason to connect to this signal is to set up a
207 /// custom drag icon with e.g. [`WidgetExt::drag_source_set_icon_pixbuf()`][crate::prelude::WidgetExt::drag_source_set_icon_pixbuf()].
208 ///
209 /// Note that some widgets set up a drag icon in the default handler of
210 /// this signal, so you may have to use `g_signal_connect_after()` to
211 /// override what the default handler did.
212 ///
213 ///
214 ///
215 ///
216 /// #### `drag-data-delete`
217 /// The ::drag-data-delete signal is emitted on the drag source when a drag
218 /// with the action [`gdk::DragAction::MOVE`][crate::gdk::DragAction::MOVE] is successfully completed. The signal
219 /// handler is responsible for deleting the data that has been dropped. What
220 /// "delete" means depends on the context of the drag operation.
221 ///
222 ///
223 ///
224 ///
225 /// #### `drag-data-get`
226 /// The ::drag-data-get signal is emitted on the drag source when the drop
227 /// site requests the data which is dragged. It is the responsibility of
228 /// the signal handler to fill `data` with the data in the format which
229 /// is indicated by `info`. See [`SelectionData::set()`][crate::SelectionData::set()] and
230 /// [`SelectionData::set_text()`][crate::SelectionData::set_text()].
231 ///
232 ///
233 ///
234 ///
235 /// #### `drag-data-received`
236 /// format == 8))
237 /// {
238 /// GdkDragAction action;
239 ///
240 /// // handle data here
241 ///
242 /// action = gdk_drag_context_get_selected_action (context);
243 /// if (action == GDK_ACTION_ASK)
244 /// {
245 /// GtkWidget *dialog;
246 /// gint response;
247 ///
248 /// dialog = gtk_message_dialog_new (NULL,
249 /// GTK_DIALOG_MODAL |
250 /// GTK_DIALOG_DESTROY_WITH_PARENT,
251 /// GTK_MESSAGE_INFO,
252 /// GTK_BUTTONS_YES_NO,
253 /// "Move the data ?\n");
254 /// response = gtk_dialog_run (GTK_DIALOG (dialog));
255 /// gtk_widget_destroy (dialog);
256 ///
257 /// if (response == GTK_RESPONSE_YES)
258 /// action = GDK_ACTION_MOVE;
259 /// else
260 /// action = GDK_ACTION_COPY;
261 /// }
262 ///
263 /// gtk_drag_finish (context, TRUE, action == GDK_ACTION_MOVE, time);
264 /// }
265 /// else
266 /// gtk_drag_finish (context, FALSE, FALSE, time);
267 /// }
268 /// ]|
269 ///
270 ///
271 ///
272 ///
273 /// #### `drag-drop`
274 /// The ::drag-drop signal is emitted on the drop site when the user drops
275 /// the data onto the widget. The signal handler must determine whether
276 /// the cursor position is in a drop zone or not. If it is not in a drop
277 /// zone, it returns [`false`] and no further processing is necessary.
278 /// Otherwise, the handler returns [`true`]. In this case, the handler must
279 /// ensure that `gtk_drag_finish()` is called to let the source know that
280 /// the drop is done. The call to `gtk_drag_finish()` can be done either
281 /// directly or in a [`drag-data-received`][struct@crate::Widget#drag-data-received] handler which gets
282 /// triggered by calling [`WidgetExt::drag_get_data()`][crate::prelude::WidgetExt::drag_get_data()] to receive the data for one
283 /// or more of the supported targets.
284 ///
285 ///
286 ///
287 ///
288 /// #### `drag-end`
289 /// The ::drag-end signal is emitted on the drag source when a drag is
290 /// finished. A typical reason to connect to this signal is to undo
291 /// things done in [`drag-begin`][struct@crate::Widget#drag-begin].
292 ///
293 ///
294 ///
295 ///
296 /// #### `drag-failed`
297 /// The ::drag-failed signal is emitted on the drag source when a drag has
298 /// failed. The signal handler may hook custom code to handle a failed DnD
299 /// operation based on the type of error, it returns [`true`] is the failure has
300 /// been already handled (not showing the default "drag operation failed"
301 /// animation), otherwise it returns [`false`].
302 ///
303 ///
304 ///
305 ///
306 /// #### `drag-leave`
307 /// The ::drag-leave signal is emitted on the drop site when the cursor
308 /// leaves the widget. A typical reason to connect to this signal is to
309 /// undo things done in [`drag-motion`][struct@crate::Widget#drag-motion], e.g. undo highlighting
310 /// with [`WidgetExt::drag_unhighlight()`][crate::prelude::WidgetExt::drag_unhighlight()].
311 ///
312 ///
313 /// Likewise, the [`drag-leave`][struct@crate::Widget#drag-leave] signal is also emitted before the
314 /// ::drag-drop signal, for instance to allow cleaning up of a preview item
315 /// created in the [`drag-motion`][struct@crate::Widget#drag-motion] signal handler.
316 ///
317 ///
318 ///
319 ///
320 /// #### `drag-motion`
321 /// suggested_action,
322 /// time);
323 /// }
324 /// else
325 /// {
326 /// // accept the drop
327 /// }
328 /// }
329 /// ]|
330 ///
331 ///
332 ///
333 ///
334 /// #### `draw`
335 /// This signal is emitted when a widget is supposed to render itself.
336 /// The `widget`'s top left corner must be painted at the origin of
337 /// the passed in context and be sized to the values returned by
338 /// [`WidgetExt::allocated_width()`][crate::prelude::WidgetExt::allocated_width()] and
339 /// [`WidgetExt::allocated_height()`][crate::prelude::WidgetExt::allocated_height()].
340 ///
341 /// Signal handlers connected to this signal can modify the cairo
342 /// context passed as `cr` in any way they like and don't need to
343 /// restore it. The signal emission takes care of calling `cairo_save()`
344 /// before and `cairo_restore()` after invoking the handler.
345 ///
346 /// The signal handler will get a `cr` with a clip region already set to the
347 /// widget's dirty region, i.e. to the area that needs repainting. Complicated
348 /// widgets that want to avoid redrawing themselves completely can get the full
349 /// extents of the clip region with `gdk_cairo_get_clip_rectangle()`, or they can
350 /// get a finer-grained representation of the dirty region with
351 /// `cairo_copy_clip_rectangle_list()`.
352 ///
353 ///
354 ///
355 ///
356 /// #### `enter-notify-event`
357 /// The ::enter-notify-event will be emitted when the pointer enters
358 /// the `widget`'s window.
359 ///
360 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
361 /// to enable the [`gdk::EventMask::ENTER_NOTIFY_MASK`][crate::gdk::EventMask::ENTER_NOTIFY_MASK] mask.
362 ///
363 /// This signal will be sent to the grab widget if there is one.
364 ///
365 ///
366 ///
367 ///
368 /// #### `event`
369 /// The GTK+ main loop will emit three signals for each GDK event delivered
370 /// to a widget: one generic ::event signal, another, more specific,
371 /// signal that matches the type of event delivered (e.g.
372 /// [`key-press-event`][struct@crate::Widget#key-press-event]) and finally a generic
373 /// [`event-after`][struct@crate::Widget#event-after] signal.
374 ///
375 ///
376 ///
377 ///
378 /// #### `event-after`
379 /// After the emission of the [`event`][struct@crate::Widget#event] signal and (optionally)
380 /// the second more specific signal, ::event-after will be emitted
381 /// regardless of the previous two signals handlers return values.
382 ///
383 ///
384 ///
385 ///
386 /// #### `focus`
387 ///
388 ///
389 ///
390 /// #### `focus-in-event`
391 /// The ::focus-in-event signal will be emitted when the keyboard focus
392 /// enters the `widget`'s window.
393 ///
394 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
395 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
396 ///
397 ///
398 ///
399 ///
400 /// #### `focus-out-event`
401 /// The ::focus-out-event signal will be emitted when the keyboard focus
402 /// leaves the `widget`'s window.
403 ///
404 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
405 /// to enable the [`gdk::EventMask::FOCUS_CHANGE_MASK`][crate::gdk::EventMask::FOCUS_CHANGE_MASK] mask.
406 ///
407 ///
408 ///
409 ///
410 /// #### `grab-broken-event`
411 /// Emitted when a pointer or keyboard grab on a window belonging
412 /// to `widget` gets broken.
413 ///
414 /// On X11, this happens when the grab window becomes unviewable
415 /// (i.e. it or one of its ancestors is unmapped), or if the same
416 /// application grabs the pointer or keyboard again.
417 ///
418 ///
419 ///
420 ///
421 /// #### `grab-focus`
422 /// Action
423 ///
424 ///
425 /// #### `grab-notify`
426 /// The ::grab-notify signal is emitted when a widget becomes
427 /// shadowed by a GTK+ grab (not a pointer or keyboard grab) on
428 /// another widget, or when it becomes unshadowed due to a grab
429 /// being removed.
430 ///
431 /// A widget is shadowed by a [`WidgetExt::grab_add()`][crate::prelude::WidgetExt::grab_add()] when the topmost
432 /// grab widget in the grab stack of its window group is not
433 /// its ancestor.
434 ///
435 ///
436 ///
437 ///
438 /// #### `hide`
439 /// The ::hide signal is emitted when `widget` is hidden, for example with
440 /// [`WidgetExt::hide()`][crate::prelude::WidgetExt::hide()].
441 ///
442 ///
443 ///
444 ///
445 /// #### `hierarchy-changed`
446 /// The ::hierarchy-changed signal is emitted when the
447 /// anchored state of a widget changes. A widget is
448 /// “anchored” when its toplevel
449 /// ancestor is a [`Window`][crate::Window]. This signal is emitted when
450 /// a widget changes from un-anchored to anchored or vice-versa.
451 ///
452 ///
453 ///
454 ///
455 /// #### `key-press-event`
456 /// The ::key-press-event signal is emitted when a key is pressed. The signal
457 /// emission will reoccur at the key-repeat rate when the key is kept pressed.
458 ///
459 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
460 /// to enable the [`gdk::EventMask::KEY_PRESS_MASK`][crate::gdk::EventMask::KEY_PRESS_MASK] mask.
461 ///
462 /// This signal will be sent to the grab widget if there is one.
463 ///
464 ///
465 ///
466 ///
467 /// #### `key-release-event`
468 /// The ::key-release-event signal is emitted when a key is released.
469 ///
470 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
471 /// to enable the [`gdk::EventMask::KEY_RELEASE_MASK`][crate::gdk::EventMask::KEY_RELEASE_MASK] mask.
472 ///
473 /// This signal will be sent to the grab widget if there is one.
474 ///
475 ///
476 ///
477 ///
478 /// #### `keynav-failed`
479 /// Gets emitted if keyboard navigation fails.
480 /// See [`WidgetExt::keynav_failed()`][crate::prelude::WidgetExt::keynav_failed()] for details.
481 ///
482 ///
483 ///
484 ///
485 /// #### `leave-notify-event`
486 /// The ::leave-notify-event will be emitted when the pointer leaves
487 /// the `widget`'s window.
488 ///
489 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
490 /// to enable the [`gdk::EventMask::LEAVE_NOTIFY_MASK`][crate::gdk::EventMask::LEAVE_NOTIFY_MASK] mask.
491 ///
492 /// This signal will be sent to the grab widget if there is one.
493 ///
494 ///
495 ///
496 ///
497 /// #### `map`
498 /// The ::map signal is emitted when `widget` is going to be mapped, that is
499 /// when the widget is visible (which is controlled with
500 /// [`WidgetExt::set_visible()`][crate::prelude::WidgetExt::set_visible()]) and all its parents up to the toplevel widget
501 /// are also visible. Once the map has occurred, [`map-event`][struct@crate::Widget#map-event] will
502 /// be emitted.
503 ///
504 /// The ::map signal can be used to determine whether a widget will be drawn,
505 /// for instance it can resume an animation that was stopped during the
506 /// emission of [`unmap`][struct@crate::Widget#unmap].
507 ///
508 ///
509 ///
510 ///
511 /// #### `map-event`
512 /// The ::map-event signal will be emitted when the `widget`'s window is
513 /// mapped. A window is mapped when it becomes visible on the screen.
514 ///
515 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
516 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
517 /// automatically for all new windows.
518 ///
519 ///
520 ///
521 ///
522 /// #### `mnemonic-activate`
523 /// The default handler for this signal activates `widget` if `group_cycling`
524 /// is [`false`], or just makes `widget` grab focus if `group_cycling` is [`true`].
525 ///
526 ///
527 ///
528 ///
529 /// #### `motion-notify-event`
530 /// The ::motion-notify-event signal is emitted when the pointer moves
531 /// over the widget's [`gdk::Window`][crate::gdk::Window].
532 ///
533 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget
534 /// needs to enable the [`gdk::EventMask::POINTER_MOTION_MASK`][crate::gdk::EventMask::POINTER_MOTION_MASK] mask.
535 ///
536 /// This signal will be sent to the grab widget if there is one.
537 ///
538 ///
539 ///
540 ///
541 /// #### `move-focus`
542 /// Action
543 ///
544 ///
545 /// #### `parent-set`
546 /// The ::parent-set signal is emitted when a new parent
547 /// has been set on a widget.
548 ///
549 ///
550 ///
551 ///
552 /// #### `popup-menu`
553 /// This signal gets emitted whenever a widget should pop up a context
554 /// menu. This usually happens through the standard key binding mechanism;
555 /// by pressing a certain key while a widget is focused, the user can cause
556 /// the widget to pop up a menu. For example, the [`Entry`][crate::Entry] widget creates
557 /// a menu with clipboard commands. See the
558 /// [Popup Menu Migration Checklist][checklist-popup-menu]
559 /// for an example of how to use this signal.
560 ///
561 /// Action
562 ///
563 ///
564 /// #### `property-notify-event`
565 /// The ::property-notify-event signal will be emitted when a property on
566 /// the `widget`'s window has been changed or deleted.
567 ///
568 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
569 /// to enable the [`gdk::EventMask::PROPERTY_CHANGE_MASK`][crate::gdk::EventMask::PROPERTY_CHANGE_MASK] mask.
570 ///
571 ///
572 ///
573 ///
574 /// #### `proximity-in-event`
575 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
576 /// to enable the [`gdk::EventMask::PROXIMITY_IN_MASK`][crate::gdk::EventMask::PROXIMITY_IN_MASK] mask.
577 ///
578 /// This signal will be sent to the grab widget if there is one.
579 ///
580 ///
581 ///
582 ///
583 /// #### `proximity-out-event`
584 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
585 /// to enable the [`gdk::EventMask::PROXIMITY_OUT_MASK`][crate::gdk::EventMask::PROXIMITY_OUT_MASK] mask.
586 ///
587 /// This signal will be sent to the grab widget if there is one.
588 ///
589 ///
590 ///
591 ///
592 /// #### `query-tooltip`
593 /// Emitted when [`has-tooltip`][struct@crate::Widget#has-tooltip] is [`true`] and the hover timeout
594 /// has expired with the cursor hovering "above" `widget`; or emitted when `widget` got
595 /// focus in keyboard mode.
596 ///
597 /// Using the given coordinates, the signal handler should determine
598 /// whether a tooltip should be shown for `widget`. If this is the case
599 /// [`true`] should be returned, [`false`] otherwise. Note that if
600 /// `keyboard_mode` is [`true`], the values of `x` and `y` are undefined and
601 /// should not be used.
602 ///
603 /// The signal handler is free to manipulate `tooltip` with the therefore
604 /// destined function calls.
605 ///
606 ///
607 ///
608 ///
609 /// #### `realize`
610 /// The ::realize signal is emitted when `widget` is associated with a
611 /// [`gdk::Window`][crate::gdk::Window], which means that [`WidgetExt::realize()`][crate::prelude::WidgetExt::realize()] has been called or the
612 /// widget has been mapped (that is, it is going to be drawn).
613 ///
614 ///
615 ///
616 ///
617 /// #### `screen-changed`
618 /// The ::screen-changed signal gets emitted when the
619 /// screen of a widget has changed.
620 ///
621 ///
622 ///
623 ///
624 /// #### `scroll-event`
625 /// The ::scroll-event signal is emitted when a button in the 4 to 7
626 /// range is pressed. Wheel mice are usually configured to generate
627 /// button press events for buttons 4 and 5 when the wheel is turned.
628 ///
629 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
630 /// to enable the [`gdk::EventMask::SCROLL_MASK`][crate::gdk::EventMask::SCROLL_MASK] mask.
631 ///
632 /// This signal will be sent to the grab widget if there is one.
633 ///
634 ///
635 ///
636 ///
637 /// #### `selection-clear-event`
638 /// The ::selection-clear-event signal will be emitted when the
639 /// the `widget`'s window has lost ownership of a selection.
640 ///
641 ///
642 ///
643 ///
644 /// #### `selection-get`
645 ///
646 ///
647 ///
648 /// #### `selection-notify-event`
649 ///
650 ///
651 ///
652 /// #### `selection-received`
653 ///
654 ///
655 ///
656 /// #### `selection-request-event`
657 /// The ::selection-request-event signal will be emitted when
658 /// another client requests ownership of the selection owned by
659 /// the `widget`'s window.
660 ///
661 ///
662 ///
663 ///
664 /// #### `show`
665 /// The ::show signal is emitted when `widget` is shown, for example with
666 /// [`WidgetExt::show()`][crate::prelude::WidgetExt::show()].
667 ///
668 ///
669 ///
670 ///
671 /// #### `show-help`
672 /// Action
673 ///
674 ///
675 /// #### `size-allocate`
676 ///
677 ///
678 ///
679 /// #### `state-changed`
680 /// The ::state-changed signal is emitted when the widget state changes.
681 /// See `gtk_widget_get_state()`.
682 ///
683 ///
684 ///
685 ///
686 /// #### `state-flags-changed`
687 /// The ::state-flags-changed signal is emitted when the widget state
688 /// changes, see [`WidgetExt::state_flags()`][crate::prelude::WidgetExt::state_flags()].
689 ///
690 ///
691 ///
692 ///
693 /// #### `style-set`
694 /// The ::style-set signal is emitted when a new style has been set
695 /// on a widget. Note that style-modifying functions like
696 /// `gtk_widget_modify_base()` also cause this signal to be emitted.
697 ///
698 /// Note that this signal is emitted for changes to the deprecated
699 /// `GtkStyle`. To track changes to the [`StyleContext`][crate::StyleContext] associated
700 /// with a widget, use the [`style-updated`][struct@crate::Widget#style-updated] signal.
701 ///
702 ///
703 ///
704 ///
705 /// #### `style-updated`
706 /// The ::style-updated signal is a convenience signal that is emitted when the
707 /// [`changed`][struct@crate::StyleContext#changed] signal is emitted on the `widget`'s associated
708 /// [`StyleContext`][crate::StyleContext] as returned by [`WidgetExt::style_context()`][crate::prelude::WidgetExt::style_context()].
709 ///
710 /// Note that style-modifying functions like `gtk_widget_override_color()` also
711 /// cause this signal to be emitted.
712 ///
713 ///
714 ///
715 ///
716 /// #### `touch-event`
717 ///
718 ///
719 ///
720 /// #### `unmap`
721 /// The ::unmap signal is emitted when `widget` is going to be unmapped, which
722 /// means that either it or any of its parents up to the toplevel widget have
723 /// been set as hidden.
724 ///
725 /// As ::unmap indicates that a widget will not be shown any longer, it can be
726 /// used to, for example, stop an animation on the widget.
727 ///
728 ///
729 ///
730 ///
731 /// #### `unmap-event`
732 /// The ::unmap-event signal will be emitted when the `widget`'s window is
733 /// unmapped. A window is unmapped when it becomes invisible on the screen.
734 ///
735 /// To receive this signal, the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
736 /// to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable this mask
737 /// automatically for all new windows.
738 ///
739 ///
740 ///
741 ///
742 /// #### `unrealize`
743 /// The ::unrealize signal is emitted when the [`gdk::Window`][crate::gdk::Window] associated with
744 /// `widget` is destroyed, which means that [`WidgetExt::unrealize()`][crate::prelude::WidgetExt::unrealize()] has been
745 /// called or the widget has been unmapped (that is, it is going to be
746 /// hidden).
747 ///
748 ///
749 ///
750 ///
751 /// #### `visibility-notify-event`
752 /// The ::visibility-notify-event will be emitted when the `widget`'s
753 /// window is obscured or unobscured.
754 ///
755 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget needs
756 /// to enable the [`gdk::EventMask::VISIBILITY_NOTIFY_MASK`][crate::gdk::EventMask::VISIBILITY_NOTIFY_MASK] mask.
757 ///
758 ///
759 ///
760 ///
761 /// #### `window-state-event`
762 /// The ::window-state-event will be emitted when the state of the
763 /// toplevel window associated to the `widget` changes.
764 ///
765 /// To receive this signal the [`gdk::Window`][crate::gdk::Window] associated to the widget
766 /// needs to enable the [`gdk::EventMask::STRUCTURE_MASK`][crate::gdk::EventMask::STRUCTURE_MASK] mask. GDK will enable
767 /// this mask automatically for all new windows.
768 ///
769 ///
770 /// </details>
771 ///
772 /// # Implements
773 ///
774 /// [`GtkSocketExt`][trait@crate::prelude::GtkSocketExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
775 #[doc(alias = "GtkSocket")]
776 pub struct Socket(Object<ffi::GtkSocket, ffi::GtkSocketClass>) @extends Container, Widget, @implements Buildable;
777
778 match fn {
779 type_ => || ffi::gtk_socket_get_type(),
780 }
781}
782
783impl Socket {
784 pub const NONE: Option<&'static Socket> = None;
785
786 /// Create a new empty [`Socket`][crate::Socket].
787 ///
788 /// # Returns
789 ///
790 /// the new [`Socket`][crate::Socket].
791 #[doc(alias = "gtk_socket_new")]
792 pub fn new() -> Socket {
793 assert_initialized_main_thread!();
794 unsafe { Widget::from_glib_none(ffi::gtk_socket_new()).unsafe_cast() }
795 }
796
797 // rustdoc-stripper-ignore-next
798 /// Creates a new builder-pattern struct instance to construct [`Socket`] objects.
799 ///
800 /// This method returns an instance of [`SocketBuilder`](crate::builders::SocketBuilder) which can be used to create [`Socket`] objects.
801 pub fn builder() -> SocketBuilder {
802 SocketBuilder::new()
803 }
804}
805
806impl Default for Socket {
807 fn default() -> Self {
808 Self::new()
809 }
810}
811
812// rustdoc-stripper-ignore-next
813/// A [builder-pattern] type to construct [`Socket`] objects.
814///
815/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
816#[must_use = "The builder must be built to be used"]
817pub struct SocketBuilder {
818 builder: glib::object::ObjectBuilder<'static, Socket>,
819}
820
821impl SocketBuilder {
822 fn new() -> Self {
823 Self {
824 builder: glib::object::Object::builder(),
825 }
826 }
827
828 pub fn border_width(self, border_width: u32) -> Self {
829 Self {
830 builder: self.builder.property("border-width", border_width),
831 }
832 }
833
834 pub fn child(self, child: &impl IsA<Widget>) -> Self {
835 Self {
836 builder: self.builder.property("child", child.clone().upcast()),
837 }
838 }
839
840 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
841 Self {
842 builder: self.builder.property("resize-mode", resize_mode),
843 }
844 }
845
846 pub fn app_paintable(self, app_paintable: bool) -> Self {
847 Self {
848 builder: self.builder.property("app-paintable", app_paintable),
849 }
850 }
851
852 pub fn can_default(self, can_default: bool) -> Self {
853 Self {
854 builder: self.builder.property("can-default", can_default),
855 }
856 }
857
858 pub fn can_focus(self, can_focus: bool) -> Self {
859 Self {
860 builder: self.builder.property("can-focus", can_focus),
861 }
862 }
863
864 pub fn events(self, events: gdk::EventMask) -> Self {
865 Self {
866 builder: self.builder.property("events", events),
867 }
868 }
869
870 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
871 pub fn expand(self, expand: bool) -> Self {
872 Self {
873 builder: self.builder.property("expand", expand),
874 }
875 }
876
877 /// Whether the widget should grab focus when it is clicked with the mouse.
878 ///
879 /// This property is only relevant for widgets that can take focus.
880 ///
881 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
882 /// GtkComboBox) implemented this property individually.
883 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
884 Self {
885 builder: self.builder.property("focus-on-click", focus_on_click),
886 }
887 }
888
889 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
890 pub fn halign(self, halign: Align) -> Self {
891 Self {
892 builder: self.builder.property("halign", halign),
893 }
894 }
895
896 pub fn has_default(self, has_default: bool) -> Self {
897 Self {
898 builder: self.builder.property("has-default", has_default),
899 }
900 }
901
902 pub fn has_focus(self, has_focus: bool) -> Self {
903 Self {
904 builder: self.builder.property("has-focus", has_focus),
905 }
906 }
907
908 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
909 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
910 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
911 /// whether it will provide a tooltip or not.
912 ///
913 /// Note that setting this property to [`true`] for the first time will change
914 /// the event masks of the GdkWindows of this widget to include leave-notify
915 /// and motion-notify events. This cannot and will not be undone when the
916 /// property is set to [`false`] again.
917 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
918 Self {
919 builder: self.builder.property("has-tooltip", has_tooltip),
920 }
921 }
922
923 pub fn height_request(self, height_request: i32) -> Self {
924 Self {
925 builder: self.builder.property("height-request", height_request),
926 }
927 }
928
929 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
930 pub fn hexpand(self, hexpand: bool) -> Self {
931 Self {
932 builder: self.builder.property("hexpand", hexpand),
933 }
934 }
935
936 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
937 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
938 Self {
939 builder: self.builder.property("hexpand-set", hexpand_set),
940 }
941 }
942
943 pub fn is_focus(self, is_focus: bool) -> Self {
944 Self {
945 builder: self.builder.property("is-focus", is_focus),
946 }
947 }
948
949 /// Sets all four sides' margin at once. If read, returns max
950 /// margin on any side.
951 pub fn margin(self, margin: i32) -> Self {
952 Self {
953 builder: self.builder.property("margin", margin),
954 }
955 }
956
957 /// Margin on bottom side of widget.
958 ///
959 /// This property adds margin outside of the widget's normal size
960 /// request, the margin will be added in addition to the size from
961 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
962 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
963 Self {
964 builder: self.builder.property("margin-bottom", margin_bottom),
965 }
966 }
967
968 /// Margin on end of widget, horizontally. This property supports
969 /// left-to-right and right-to-left text directions.
970 ///
971 /// This property adds margin outside of the widget's normal size
972 /// request, the margin will be added in addition to the size from
973 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
974 pub fn margin_end(self, margin_end: i32) -> Self {
975 Self {
976 builder: self.builder.property("margin-end", margin_end),
977 }
978 }
979
980 /// Margin on start of widget, horizontally. This property supports
981 /// left-to-right and right-to-left text directions.
982 ///
983 /// This property adds margin outside of the widget's normal size
984 /// request, the margin will be added in addition to the size from
985 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
986 pub fn margin_start(self, margin_start: i32) -> Self {
987 Self {
988 builder: self.builder.property("margin-start", margin_start),
989 }
990 }
991
992 /// Margin on top side of widget.
993 ///
994 /// This property adds margin outside of the widget's normal size
995 /// request, the margin will be added in addition to the size from
996 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
997 pub fn margin_top(self, margin_top: i32) -> Self {
998 Self {
999 builder: self.builder.property("margin-top", margin_top),
1000 }
1001 }
1002
1003 pub fn name(self, name: impl Into<glib::GString>) -> Self {
1004 Self {
1005 builder: self.builder.property("name", name.into()),
1006 }
1007 }
1008
1009 pub fn no_show_all(self, no_show_all: bool) -> Self {
1010 Self {
1011 builder: self.builder.property("no-show-all", no_show_all),
1012 }
1013 }
1014
1015 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
1016 /// more details about window opacity.
1017 ///
1018 /// Before 3.8 this was only available in GtkWindow
1019 pub fn opacity(self, opacity: f64) -> Self {
1020 Self {
1021 builder: self.builder.property("opacity", opacity),
1022 }
1023 }
1024
1025 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
1026 Self {
1027 builder: self.builder.property("parent", parent.clone().upcast()),
1028 }
1029 }
1030
1031 pub fn receives_default(self, receives_default: bool) -> Self {
1032 Self {
1033 builder: self.builder.property("receives-default", receives_default),
1034 }
1035 }
1036
1037 pub fn sensitive(self, sensitive: bool) -> Self {
1038 Self {
1039 builder: self.builder.property("sensitive", sensitive),
1040 }
1041 }
1042
1043 /// Sets the text of tooltip to be the given string, which is marked up
1044 /// with the [Pango text markup language][PangoMarkupFormat].
1045 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
1046 ///
1047 /// This is a convenience property which will take care of getting the
1048 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1049 /// will automatically be set to [`true`] and there will be taken care of
1050 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1051 ///
1052 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1053 /// are set, the last one wins.
1054 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
1055 Self {
1056 builder: self
1057 .builder
1058 .property("tooltip-markup", tooltip_markup.into()),
1059 }
1060 }
1061
1062 /// Sets the text of tooltip to be the given string.
1063 ///
1064 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
1065 ///
1066 /// This is a convenience property which will take care of getting the
1067 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1068 /// will automatically be set to [`true`] and there will be taken care of
1069 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1070 ///
1071 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1072 /// are set, the last one wins.
1073 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1074 Self {
1075 builder: self.builder.property("tooltip-text", tooltip_text.into()),
1076 }
1077 }
1078
1079 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1080 pub fn valign(self, valign: Align) -> Self {
1081 Self {
1082 builder: self.builder.property("valign", valign),
1083 }
1084 }
1085
1086 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1087 pub fn vexpand(self, vexpand: bool) -> Self {
1088 Self {
1089 builder: self.builder.property("vexpand", vexpand),
1090 }
1091 }
1092
1093 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1094 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1095 Self {
1096 builder: self.builder.property("vexpand-set", vexpand_set),
1097 }
1098 }
1099
1100 pub fn visible(self, visible: bool) -> Self {
1101 Self {
1102 builder: self.builder.property("visible", visible),
1103 }
1104 }
1105
1106 pub fn width_request(self, width_request: i32) -> Self {
1107 Self {
1108 builder: self.builder.property("width-request", width_request),
1109 }
1110 }
1111
1112 // rustdoc-stripper-ignore-next
1113 /// Build the [`Socket`].
1114 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1115 pub fn build(self) -> Socket {
1116 assert_initialized_main_thread!();
1117 self.builder.build()
1118 }
1119}
1120
1121/// Trait containing all [`struct@Socket`] methods.
1122///
1123/// # Implementors
1124///
1125/// [`Socket`][struct@crate::Socket]
1126pub trait GtkSocketExt: IsA<Socket> + 'static {
1127 /// Adds an XEMBED client, such as a [`Plug`][crate::Plug], to the [`Socket`][crate::Socket]. The
1128 /// client may be in the same process or in a different process.
1129 ///
1130 /// To embed a [`Plug`][crate::Plug] in a [`Socket`][crate::Socket], you can either create the
1131 /// [`Plug`][crate::Plug] with `gtk_plug_new (0)`, call
1132 /// [`PlugExt::id()`][crate::prelude::PlugExt::id()] to get the window ID of the plug, and then pass that to the
1133 /// [`add_id()`][Self::add_id()], or you can call [`id()`][Self::id()] to get the
1134 /// window ID for the socket, and call [`Plug::new()`][crate::Plug::new()] passing in that
1135 /// ID.
1136 ///
1137 /// The [`Socket`][crate::Socket] must have already be added into a toplevel window
1138 /// before you can make this call.
1139 /// ## `window`
1140 /// the Window of a client participating in the XEMBED protocol.
1141 #[doc(alias = "gtk_socket_add_id")]
1142 fn add_id(&self, window: xlib::Window) {
1143 unsafe {
1144 ffi::gtk_socket_add_id(self.as_ref().to_glib_none().0, window);
1145 }
1146 }
1147
1148 /// Gets the window ID of a [`Socket`][crate::Socket] widget, which can then
1149 /// be used to create a client embedded inside the socket, for
1150 /// instance with [`Plug::new()`][crate::Plug::new()].
1151 ///
1152 /// The [`Socket`][crate::Socket] must have already be added into a toplevel window
1153 /// before you can make this call.
1154 ///
1155 /// # Returns
1156 ///
1157 /// the window ID for the socket
1158 #[doc(alias = "gtk_socket_get_id")]
1159 #[doc(alias = "get_id")]
1160 fn id(&self) -> xlib::Window {
1161 unsafe { ffi::gtk_socket_get_id(self.as_ref().to_glib_none().0) }
1162 }
1163
1164 /// Retrieves the window of the plug. Use this to check if the plug has
1165 /// been created inside of the socket.
1166 ///
1167 /// # Returns
1168 ///
1169 /// the window of the plug if
1170 /// available, or [`None`]
1171 #[doc(alias = "gtk_socket_get_plug_window")]
1172 #[doc(alias = "get_plug_window")]
1173 fn plug_window(&self) -> Option<gdk::Window> {
1174 unsafe {
1175 from_glib_none(ffi::gtk_socket_get_plug_window(
1176 self.as_ref().to_glib_none().0,
1177 ))
1178 }
1179 }
1180
1181 /// This signal is emitted when a client is successfully
1182 /// added to the socket.
1183 #[doc(alias = "plug-added")]
1184 fn connect_plug_added<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1185 unsafe extern "C" fn plug_added_trampoline<P: IsA<Socket>, F: Fn(&P) + 'static>(
1186 this: *mut ffi::GtkSocket,
1187 f: glib::ffi::gpointer,
1188 ) {
1189 unsafe {
1190 let f: &F = &*(f as *const F);
1191 f(Socket::from_glib_borrow(this).unsafe_cast_ref())
1192 }
1193 }
1194 unsafe {
1195 let f: Box_<F> = Box_::new(f);
1196 connect_raw(
1197 self.as_ptr() as *mut _,
1198 c"plug-added".as_ptr(),
1199 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1200 plug_added_trampoline::<Self, F> as *const (),
1201 )),
1202 Box_::into_raw(f),
1203 )
1204 }
1205 }
1206
1207 /// This signal is emitted when a client is removed from the socket.
1208 /// The default action is to destroy the [`Socket`][crate::Socket] widget, so if you
1209 /// want to reuse it you must add a signal handler that returns [`true`].
1210 ///
1211 /// # Returns
1212 ///
1213 /// [`true`] to stop other handlers from being invoked.
1214 #[doc(alias = "plug-removed")]
1215 fn connect_plug_removed<F: Fn(&Self) -> bool + 'static>(&self, f: F) -> SignalHandlerId {
1216 unsafe extern "C" fn plug_removed_trampoline<
1217 P: IsA<Socket>,
1218 F: Fn(&P) -> bool + 'static,
1219 >(
1220 this: *mut ffi::GtkSocket,
1221 f: glib::ffi::gpointer,
1222 ) -> glib::ffi::gboolean {
1223 unsafe {
1224 let f: &F = &*(f as *const F);
1225 f(Socket::from_glib_borrow(this).unsafe_cast_ref()).into_glib()
1226 }
1227 }
1228 unsafe {
1229 let f: Box_<F> = Box_::new(f);
1230 connect_raw(
1231 self.as_ptr() as *mut _,
1232 c"plug-removed".as_ptr(),
1233 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1234 plug_removed_trampoline::<Self, F> as *const (),
1235 )),
1236 Box_::into_raw(f),
1237 )
1238 }
1239 }
1240}
1241
1242impl<O: IsA<Socket>> GtkSocketExt for O {}