Merge branch '1397-gtknotebook-built-in-popup-menu-listing-tabs-doesn-t-use-tab-label-text-for-the-last-tab' into 'gtk-3-24'

Notebook: Ensure menu label updates with tab_label

See merge request GNOME/gtk!385
This commit is contained in:
Matthias Clasen 2018-10-16 20:52:04 +00:00
commit c0b5d66069

View File

@ -562,6 +562,8 @@ static void gtk_notebook_menu_switch_page (GtkWidget *widget,
/*** GtkNotebook Menu Functions ***/ /*** GtkNotebook Menu Functions ***/
static void gtk_notebook_menu_item_create (GtkNotebook *notebook, static void gtk_notebook_menu_item_create (GtkNotebook *notebook,
GList *list); GList *list);
static void gtk_notebook_menu_item_recreate (GtkNotebook *notebook,
GList *list);
static void gtk_notebook_menu_label_unparent (GtkWidget *widget, static void gtk_notebook_menu_label_unparent (GtkWidget *widget,
gpointer data); gpointer data);
static void gtk_notebook_menu_detacher (GtkWidget *widget, static void gtk_notebook_menu_detacher (GtkWidget *widget,
@ -6335,6 +6337,7 @@ gtk_notebook_menu_switch_page (GtkWidget *widget,
/* Private GtkNotebook Menu Functions: /* Private GtkNotebook Menu Functions:
* *
* gtk_notebook_menu_item_create * gtk_notebook_menu_item_create
* gtk_notebook_menu_item_recreate
* gtk_notebook_menu_label_unparent * gtk_notebook_menu_label_unparent
* gtk_notebook_menu_detacher * gtk_notebook_menu_detacher
*/ */
@ -6368,6 +6371,19 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook,
gtk_widget_show (menu_item); gtk_widget_show (menu_item);
} }
static void
gtk_notebook_menu_item_recreate (GtkNotebook *notebook,
GList *list)
{
GtkNotebookPrivate *priv = notebook->priv;
GtkNotebookPage *page = list->data;
GtkWidget *menu_item = gtk_widget_get_parent (page->menu_label);
gtk_container_remove (GTK_CONTAINER (menu_item), page->menu_label);
gtk_container_remove (GTK_CONTAINER (priv->menu), menu_item);
gtk_notebook_menu_item_create (notebook, list);
}
static void static void
gtk_notebook_menu_label_unparent (GtkWidget *widget, gtk_notebook_menu_label_unparent (GtkWidget *widget,
gpointer data) gpointer data)
@ -7363,7 +7379,6 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
if (page->tab_label == tab_label) if (page->tab_label == tab_label)
return; return;
gtk_notebook_remove_tab_label (notebook, page); gtk_notebook_remove_tab_label (notebook, page);
if (tab_label) if (tab_label)
@ -7405,6 +7420,9 @@ gtk_notebook_set_tab_label (GtkNotebook *notebook,
gtk_widget_queue_resize (GTK_WIDGET (notebook)); gtk_widget_queue_resize (GTK_WIDGET (notebook));
} }
if (priv->menu)
gtk_notebook_menu_item_recreate (notebook, list);
gtk_widget_child_notify (child, "tab-label"); gtk_widget_child_notify (child, "tab-label");
} }
@ -7609,14 +7627,7 @@ gtk_notebook_child_reordered (GtkNotebook *notebook,
list = g_list_find (priv->children, page); list = g_list_find (priv->children, page);
if (priv->menu) if (priv->menu)
{ gtk_notebook_menu_item_recreate (notebook, list);
GtkWidget *menu_item;
menu_item = gtk_widget_get_parent (page->menu_label);
gtk_container_remove (GTK_CONTAINER (menu_item), page->menu_label);
gtk_container_remove (GTK_CONTAINER (priv->menu), menu_item);
gtk_notebook_menu_item_create (notebook, list);
}
if (list->prev) if (list->prev)
sibling = gtk_css_gadget_get_node (GTK_NOTEBOOK_PAGE (list->prev)->gadget); sibling = gtk_css_gadget_get_node (GTK_NOTEBOOK_PAGE (list->prev)->gadget);