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