From 33ac663b13564b7762e13fa43f4be5c5e99efa5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 30 Oct 2015 15:08:18 +0100 Subject: [PATCH] popover: Use element name Pick "popover" and add .menu for popover menus --- gtk/gtkpopover.c | 14 +++++++++----- gtk/gtkpopovermenu.c | 10 +++++++++- gtk/theme/Adwaita/_common.scss | 2 +- gtk/theme/HighContrast/_common.scss | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/gtk/gtkpopover.c b/gtk/gtkpopover.c index 054158202e..1861dfbbb0 100644 --- a/gtk/gtkpopover.c +++ b/gtk/gtkpopover.c @@ -71,6 +71,10 @@ * * ]| * + * A popover has a single css node called "popover" and gets the + * .menu style class in case it has been created using + * gtk_popover_new_from_model. + * * Since: 3.12 */ @@ -180,7 +184,6 @@ static void gtk_popover_init (GtkPopover *popover) { GtkWidget *widget; - GtkStyleContext *context; widget = GTK_WIDGET (popover); gtk_widget_set_has_window (widget, TRUE); @@ -188,10 +191,6 @@ gtk_popover_init (GtkPopover *popover) popover->priv->modal = TRUE; popover->priv->tick_id = 0; popover->priv->transitions_enabled = TRUE; - - context = gtk_widget_get_style_context (widget); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_BACKGROUND); - gtk_style_context_add_class (context, GTK_STYLE_CLASS_POPOVER); } static void @@ -1694,6 +1693,7 @@ gtk_popover_class_init (GtkPopoverClass *klass) quark_widget_popovers = g_quark_from_static_string ("gtk-quark-widget-popovers"); gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_POPOVER_ACCESSIBLE); + gtk_widget_class_set_css_name (widget_class, "popover"); } static void @@ -2397,6 +2397,7 @@ gtk_popover_new_from_model (GtkWidget *relative_to, GMenuModel *model) { GtkWidget *popover; + GtkStyleContext *style_context; g_return_val_if_fail (relative_to == NULL || GTK_IS_WIDGET (relative_to), NULL); g_return_val_if_fail (G_IS_MENU_MODEL (model), NULL); @@ -2404,6 +2405,9 @@ gtk_popover_new_from_model (GtkWidget *relative_to, popover = gtk_popover_new (relative_to); gtk_popover_bind_model (GTK_POPOVER (popover), model, NULL); + style_context = gtk_widget_get_style_context (GTK_WIDGET (popover)); + gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_MENU); + return popover; } diff --git a/gtk/gtkpopovermenu.c b/gtk/gtkpopovermenu.c index dce87a2949..948b5102a6 100644 --- a/gtk/gtkpopovermenu.c +++ b/gtk/gtkpopovermenu.c @@ -18,6 +18,7 @@ #include "config.h" #include "gtkpopovermenu.h" #include "gtkstack.h" +#include "gtkstylecontext.h" #include "gtkintl.h" @@ -94,7 +95,10 @@ * * * ]| -* + * + * Just like normal popovers created using gtk_popover_new_from_model, + * #GtkPopoverMenu instances have a single css node called "popover" + * and get the .menu style class. */ struct _GtkPopoverMenu @@ -125,6 +129,7 @@ static void gtk_popover_menu_init (GtkPopoverMenu *popover) { GtkWidget *stack; + GtkStyleContext *style_context; stack = gtk_stack_new (); gtk_stack_set_vhomogeneous (GTK_STACK (stack), FALSE); @@ -134,6 +139,9 @@ gtk_popover_menu_init (GtkPopoverMenu *popover) gtk_container_add (GTK_CONTAINER (popover), stack); g_signal_connect (stack, "notify::visible-child-name", G_CALLBACK (visible_submenu_changed), popover); + + style_context = gtk_widget_get_style_context (GTK_WIDGET (popover)); + gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_MENU); } static void diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss index 6516d437d1..eb1eb87478 100644 --- a/gtk/theme/Adwaita/_common.scss +++ b/gtk/theme/Adwaita/_common.scss @@ -1512,7 +1512,7 @@ column-header.button.dnd { // for treeview-like derive widgets * Popovers * ***************/ -.popover { +popover { padding: 2px; border: 1px solid $borders_color; border-radius: 5px; diff --git a/gtk/theme/HighContrast/_common.scss b/gtk/theme/HighContrast/_common.scss index 2b5aec17de..acefe926d7 100644 --- a/gtk/theme/HighContrast/_common.scss +++ b/gtk/theme/HighContrast/_common.scss @@ -1175,7 +1175,7 @@ GtkTreeView.view.progressbar { //Progressbar in treeview cells * Popovers * ***************/ -.popover { +popover { margin: 10px; padding: 2px; border-color: $borders-color;