stylecontext: Change semantics of gtk_style_context_get_path()

Widget contexts now return NULL here. A non-NULL result requires a
previous call to gtk_style_context_set_path()
This commit is contained in:
Benjamin Otte 2020-01-21 02:54:55 +01:00
parent b9c81b1b94
commit c85d9a3259
2 changed files with 16 additions and 4 deletions

View File

@ -262,7 +262,7 @@ draw_menu (GtkWidget *widget,
gint toggle_x, toggle_y, toggle_width, toggle_height;
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
menu_context = get_style (NULL, "menu");
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
menuitem_context = get_style (menu_context, "menuitem");

View File

@ -970,14 +970,26 @@ gtk_style_context_set_path (GtkStyleContext *context,
* gtk_style_context_get_path:
* @context: a #GtkStyleContext
*
* Returns the widget path used for style matching.
* Returns the widget path used for style matching set via
* gtk_style_context_set_path().
*
* Returns: (transfer none): A #GtkWidgetPath
* If no path has been set - in particular if this style context
* was returned from a #GtkWidget - this function returns %NULL.
*
* Returns: (transfer none) (nullable): A #GtkWidgetPath or %NULL
**/
const GtkWidgetPath *
gtk_style_context_get_path (GtkStyleContext *context)
{
return gtk_css_node_get_widget_path (gtk_style_context_get_root (context));
GtkCssNode *root;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
root = gtk_style_context_get_root (context);
if (!GTK_IS_CSS_PATH_NODE (root))
return NULL;
return gtk_css_path_node_get_widget_path (GTK_CSS_PATH_NODE (root));
}
/**