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