In my program, I have a GtkPopoverMenu
:
I understand that these are derived GtkPopover
s and can be styled with CSS.
However, I can’t figure out how to make the corners not rounded, as indicated in yellow in the screenshot there. Note that the actual corners of the menu are gray and rounded. The black, sharp corners actually represent what would normally be a transparent area around the menu (which is black because my compositor is disabled, so transparency falls back to solid black).
Ideally, I’d like the menu’s gray body to completely extend over this normally-transparent area, such that there’s no black border. (This would make the menu look the same to those on a desktop environment with no compositor or who turn their compositor off and those with a compositor enabled.)
The CSS I’m using is:
/* Style... everything */
* {
border-radius: 0 0 0 0;
}
/* Style menu entries */
.menu * {
color: white;
background-color: red;
}
I’m discouraged and puzzled by the fact that the *
rule – which should remove everything’s border radius – isn’t doing anything to those corners.
I’m applying that CSS like this:
// Apply CSS stylesheet.
GdkDisplay* display = gdk_display_get_default();
GtkCssProvider* css_provider = gtk_css_provider_new();
GFile* css_stylesheet = g_file_new_for_path("./prototype-gtk.css");
gtk_css_provider_load_from_file(css_provider,
css_stylesheet);
gtk_style_context_add_provider_for_display(display,
GTK_STYLE_PROVIDER(css_provider),
GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
g_object_unref(css_stylesheet);
g_object_unref(css_provider);
And, if it helps or if anyone’s curious, the code to add that menu is:
static void create_menus(GtkApplication* app, GtkWidget* window)
{
GMenu* menubar = g_menu_new();
// Make File menu.
GMenu* file_menu = g_menu_new();
// Make quit menu item.
GMenuItem* quit_item = g_menu_item_new("Quit",
"app.quit");
// Add `Ctrl+Q` shortcut accelerator to quit menu item.
// First, configure the item to respond to the shortcut (aka "accelerator").
gtk_application_set_accels_for_action(app,
"app.quit",
(const char *[]) {
"<Ctrl>q",
NULL,
});
// Second, make the item display the key combo.
g_menu_item_set_attribute(quit_item, "accel", "s", "<Control>q", NULL);
// Add quit menu item to File menu.
g_menu_append_item(file_menu, quit_item);
g_object_unref(quit_item);
// Add File menu to menubar.
g_menu_append_submenu(menubar,
"File",
G_MENU_MODEL(file_menu));
g_object_unref(file_menu);
// (Unrelated lines of code abridged...)
// Set and show menubar.
gtk_application_set_menubar(app, G_MENU_MODEL(menubar));
gtk_application_window_set_show_menubar(GTK_APPLICATION_WINDOW(window), TRUE);
g_object_unref(menubar);
}