Package: gtk

Function gtk:notebook-tab-detachable

Lambda List

gtk:notebook-tab-detachable (notebook child)

Syntax

(gtk:notebook-tab-detachable notebook child) => detachable
(setf (gtk:notebook-tab-detachable notebook child) detachable)

Arguments

notebook -- a gtk:notebook widget
child -- a gtk:widget child page
detachable -- a boolean whether the notbook tab is detachable or not

Details

Gets or sets whether the notbook tab content can be detached from the notebook to another notebook or widget.

Note that two notebooks must share a common group identifier, see the gtk:notebook-group-name function, to allow automatic notebook tabs interchange between them.

If you want a widget to interact with a notebook through DnD, that is, accept dragged notebook tabs from it, it must be set as a drop destination by adding to it a gtk:drop-target controller that accepts the GType "GtkNotebookPage". The :value value of said drop target will be preloaded with a gtk:notebook-page object that corresponds to the dropped notebook tab, so you can process the value via "accept" or "drop" signals.

Note that you should use the gtk:notebook-detach-tab function instead of the gtk:notebook-remove-page function if you want to remove the notebook tab from the source notebook as part of accepting a drop. Otherwise, the source notebook will think that the dragged tab was removed from underneath the ongoing drag operation, and will initiate a drag cancel animation.

If you want a notebook to accept drags from other widgets, you will have to set your own DnD code to do it.

Examples

static void
on_drag_data_received (GtkWidget        *widget,
                       GdkDrop          *drop,
                       GtkSelectionData *data,
                       guint             time,
                       gpointer          user_data)
{
  GtkDrag *drag;
  GtkWidget *notebook;
  GtkWidget **child;

drag = gtk_drop_get_drag (drop); notebook = g_object_get_data (drag, "gtk-notebook-drag-origin"); child = (void*) gtk_selection_data_get_data (data);

// process_widget (*child);

gtk_notebook_detach_tab (GTK_NOTEBOOK (notebook), *child); }
 

See also

2025-07-31