diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 4e2090adea..2222aededa 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -2753,6 +2753,8 @@ gtk_notebook_set_group_id gtk_notebook_get_group_id gtk_notebook_set_group gtk_notebook_get_group +gtk_notebook_set_group_name +gtk_notebook_get_group_name gtk_notebook_set_action_widget gtk_notebook_get_action_widget GtkNotebookWindowCreationFunc diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index cae07db31c..18cdc510d4 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -2693,13 +2693,15 @@ gtk_notebook_set_tab_label_text gtk_notebook_set_tab_pos gtk_notebook_get_tab_hborder gtk_notebook_get_tab_vborder -gtk_notebook_set_window_creation_hook #ifndef GTK_DISABLE_DEPRECATED +gtk_notebook_set_window_creation_hook gtk_notebook_get_group_id gtk_notebook_set_group_id -#endif gtk_notebook_get_group gtk_notebook_set_group +#endif +gtk_notebook_get_group_name +gtk_notebook_set_group_name gtk_notebook_get_tab_reorderable gtk_notebook_set_tab_reorderable gtk_notebook_get_tab_detachable diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index 8054e2499e..4306672d6c 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -112,6 +112,7 @@ enum { PROP_ENABLE_POPUP, PROP_GROUP_ID, PROP_GROUP, + PROP_GROUP_NAME, PROP_HOMOGENEOUS }; @@ -666,7 +667,7 @@ gtk_notebook_class_init (GtkNotebookClass *class) -1, G_MAXINT, -1, - GTK_PARAM_READWRITE)); + GTK_PARAM_READWRITE|G_PARAM_DEPRECATED)); /** * GtkNotebook:group: @@ -674,13 +675,30 @@ gtk_notebook_class_init (GtkNotebookClass *class) * Group for tabs drag and drop. * * Since: 2.12 + * + * Deprecated: 2.24: Use #GtkNotebook:group-name instead */ g_object_class_install_property (gobject_class, PROP_GROUP, g_param_spec_pointer ("group", P_("Group"), P_("Group for tabs drag and drop"), - GTK_PARAM_READWRITE)); + GTK_PARAM_READWRITE|G_PARAM_DEPRECATED)); + + /** + * GtkNotebook:group-name: + * + * Group name for tabs drag and drop. + * + * Since: 2.24 + */ + g_object_class_install_property (gobject_class, + PROP_GROUP_NAME, + g_param_spec_string ("group-name", + P_("Group Name"), + P_("Group name for tabs drag and drop"), + NULL, + GTK_PARAM_READWRITE)); gtk_container_class_install_child_property (container_class, CHILD_PROP_TAB_LABEL, @@ -1554,6 +1572,9 @@ gtk_notebook_set_property (GObject *object, case PROP_GROUP: gtk_notebook_set_group (notebook, g_value_get_pointer (value)); break; + case PROP_GROUP_NAME: + gtk_notebook_set_group_name (notebook, g_value_get_string (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -1607,6 +1628,9 @@ gtk_notebook_get_property (GObject *object, case PROP_GROUP: g_value_set_pointer (value, priv->group); break; + case PROP_GROUP_NAME: + g_value_set_string (value, gtk_notebook_get_group_name (notebook)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -7712,9 +7736,11 @@ gtk_notebook_reorder_child (GtkNotebook *notebook, * * Installs a global function used to create a window * when a detached tab is dropped in an empty area. - * + * * Since: 2.10 - **/ + * + * Deprecated: 2.24: Use the #GtkNotebook::create-window signal instead +**/ void gtk_notebook_set_window_creation_hook (GtkNotebookWindowCreationFunc func, gpointer data, @@ -7739,7 +7765,7 @@ gtk_notebook_set_window_creation_hook (GtkNotebookWindowCreationFunc func, * not be able to exchange tabs with any other notebook. * * Since: 2.10 - * Deprecated: 2.12: use gtk_notebook_set_group() instead. + * Deprecated: 2.12: use gtk_notebook_set_group_name() instead. */ void gtk_notebook_set_group_id (GtkNotebook *notebook, @@ -7763,8 +7789,10 @@ gtk_notebook_set_group_id (GtkNotebook *notebook, * the same group identificator pointer will be able to exchange tabs * via drag and drop. A notebook with a %NULL group identificator will * not be able to exchange tabs with any other notebook. - * + * * Since: 2.12 + * + * Deprecated: 2.24: Use gtk_notebook_set_group_name() instead */ void gtk_notebook_set_group (GtkNotebook *notebook, @@ -7783,6 +7811,32 @@ gtk_notebook_set_group (GtkNotebook *notebook, } } +/** + * gtk_notebook_set_group_name: + * @notebook: a #GtkNotebook + * @name: (allow-none): the name of the notebook group, or %NULL to unset it + * + * Sets a group name for @notebook. + * + * Notebooks with the same name will be able to exchange tabs + * via drag and drop. A notebook with a %NULL group name will + * not be able to exchange tabs with any other notebook. + * + * Since: 2.24 + */ +void +gtk_notebook_set_group_name (GtkNotebook *notebook, + const gchar *group_name) +{ + gpointer group; + + g_return_if_fail (GTK_IS_NOTEBOOK (notebook)); + + group = (gpointer)g_intern_string (group_name); + gtk_notebook_set_group (notebook, group); + g_object_notify (G_OBJECT (notebook), "group-name"); +} + /** * gtk_notebook_get_group_id: * @notebook: a #GtkNotebook @@ -7792,7 +7846,7 @@ gtk_notebook_set_group (GtkNotebook *notebook, * Return Value: the group identificator, or -1 if none is set. * * Since: 2.10 - * Deprecated: 2.12: use gtk_notebook_get_group() instead. + * Deprecated: 2.12: use gtk_notebook_get_group_name() instead. */ gint gtk_notebook_get_group_id (GtkNotebook *notebook) @@ -7807,6 +7861,7 @@ gtk_notebook_get_group_id (GtkNotebook *notebook) return GPOINTER_TO_INT (priv->group) - 1; } + /** * gtk_notebook_get_group: * @notebook: a #GtkNotebook @@ -7816,6 +7871,8 @@ gtk_notebook_get_group_id (GtkNotebook *notebook) * Return Value: the group identificator, or %NULL if none is set. * * Since: 2.12 + * + * Deprecated: 2.24: Use gtk_notebook_get_group_name() instead **/ gpointer gtk_notebook_get_group (GtkNotebook *notebook) @@ -7828,6 +7885,31 @@ gtk_notebook_get_group (GtkNotebook *notebook) return priv->group; } +/** + * gtk_notebook_get_group_name: + * @notebook: a #GtkNotebook + * + * Gets the current group name for @notebook. + * + * Note that this funtion can emphasis not be used + * together with gtk_notebook_set_group() or + * gtk_notebook_set_group_id(). + * + Return Value: (transfer none): the group name, + * or %NULL if none is set. + * + * Since: 2.24 + */ +const gchar * +gtk_notebook_get_group_name (GtkNotebook *notebook) +{ + GtkNotebookPrivate *priv; + g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL); + + priv = GTK_NOTEBOOK_GET_PRIVATE (notebook); + return (const gchar *)priv->group; +} + /** * gtk_notebook_get_tab_reorderable: * @notebook: a #GtkNotebook diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h index 668285d312..62620a1f74 100644 --- a/gtk/gtknotebook.h +++ b/gtk/gtknotebook.h @@ -180,20 +180,22 @@ void gtk_notebook_remove_page (GtkNotebook *notebook, * Tabs drag and drop * ***********************************************************/ +#ifndef GTK_DISABLE_DEPRECATED void gtk_notebook_set_window_creation_hook (GtkNotebookWindowCreationFunc func, gpointer data, GDestroyNotify destroy); -#ifndef GTK_DISABLE_DEPRECATED void gtk_notebook_set_group_id (GtkNotebook *notebook, gint group_id); gint gtk_notebook_get_group_id (GtkNotebook *notebook); -#endif /* GTK_DISABLE_DEPRECATED */ - void gtk_notebook_set_group (GtkNotebook *notebook, gpointer group); gpointer gtk_notebook_get_group (GtkNotebook *notebook); +#endif /* GTK_DISABLE_DEPRECATED */ +void gtk_notebook_set_group_name (GtkNotebook *notebook, + const gchar *group_name); +const gchar *gtk_notebook_get_group_name (GtkNotebook *notebook); /*********************************************************** diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c index 04a4aef5dc..a90aeb5ce4 100644 --- a/tests/testnotebookdnd.c +++ b/tests/testnotebookdnd.c @@ -78,9 +78,11 @@ window_creation_function (GtkNotebook *source_notebook, window = gtk_window_new (GTK_WINDOW_TOPLEVEL); notebook = gtk_notebook_new (); + g_signal_connect (notebook, "create-window", + G_CALLBACK (window_creation_function), NULL); - gtk_notebook_set_group (GTK_NOTEBOOK (notebook), - gtk_notebook_get_group (source_notebook)); + gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), + gtk_notebook_get_group_name (source_notebook)); gtk_container_add (GTK_CONTAINER (window), notebook); @@ -150,11 +152,13 @@ create_notebook (gchar **labels, gint count = 0; notebook = gtk_notebook_new (); + g_signal_connect (notebook, "create-window", + G_CALLBACK (window_creation_function), NULL); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos); gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); gtk_container_set_border_width (GTK_CONTAINER (notebook), 6); - gtk_notebook_set_group (GTK_NOTEBOOK (notebook), group); + gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group); while (*labels) { @@ -192,11 +196,13 @@ create_notebook_with_notebooks (gchar **labels, gint count = 0; notebook = gtk_notebook_new (); + g_signal_connect (notebook, "create-window", + G_CALLBACK (window_creation_function), NULL); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), pos); gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE); gtk_container_set_border_width (GTK_CONTAINER (notebook), 6); - gtk_notebook_set_group (GTK_NOTEBOOK (notebook), group); + gtk_notebook_set_group_name (GTK_NOTEBOOK (notebook), group); while (*labels) { @@ -252,8 +258,6 @@ main (gint argc, gchar *argv[]) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); table = gtk_table_new (3, 2, FALSE); - gtk_notebook_set_window_creation_hook (window_creation_function, NULL, NULL); - gtk_table_attach_defaults (GTK_TABLE (table), create_notebook (tabs1, GROUP_A, PACK_ALTERNATE, GTK_POS_TOP), 0, 1, 0, 1);