Notebook.setTabDetachable

Sets whether the tab can be detached from @notebook to another notebook or widget.

Note that two notebooks must share a common group identificator (see [method@Gtk.Notebook.set_group_name]) to allow automatic tabs interchange between them.

If you want a widget to interact with a notebook through DnD (i.e.: accept dragged tabs from it) it must be set as a drop destination and accept the target “GTK_NOTEBOOK_TAB”. The notebook will fill the selection with a GtkWidget** pointing to the child widget that corresponds to the dropped tab.

Note that you should use [method@Gtk.Notebook.detach_tab] instead of [method@Gtk.Notebook.remove_page] if you want to remove the 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.

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);
}

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

class Notebook
void
setTabDetachable

Parameters

child Widget

a child GtkWidget

detachable bool

whether the tab is detachable or not

Meta