Skip to content

Commit

Permalink
gtk: don't use arrow on context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
jcollie committed Jan 30, 2025
1 parent 000f75c commit fe72ad6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/apprt/gtk/Surface.zig
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ im_len: u7 = 0,
cgroup_path: ?[]const u8 = null,

/// Our context menu.
context_menu: Menu(Surface, "context_menu", .popover_menu),
context_menu: Menu(Surface, "context_menu", .popover_menu_no_arrow),

/// Configuration used for initializing the surface. We have to copy some
/// data since initialization is delayed with GTK (on realize).
Expand Down
8 changes: 6 additions & 2 deletions src/apprt/gtk/menu.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ const log = std.log.scoped(.gtk_menu);
pub fn Menu(
comptime T: type,
comptime variant: []const u8,
comptime style: enum { popover_menu, popover_menu_bar },
comptime style: enum { popover_menu, popover_menu_no_arrow, popover_menu_bar },
) type {
return struct {
const Self = @This();
const MenuWidget = switch (style) {
.popover_menu => c.GtkPopoverMenu,
.popover_menu_no_arrow => c.GtkPopoverMenu,
.popover_menu_bar => c.GtkPopoverMenuBar,
};

Expand All @@ -38,9 +39,12 @@ pub fn Menu(
const menu_model = builder.getObject(c.GMenuModel, "menu");

const menu_widget: *MenuWidget = switch (style) {
.popover_menu => brk: {
.popover_menu, .popover_menu_no_arrow => brk: {
const menu_widget: *MenuWidget = @ptrCast(@alignCast(c.gtk_popover_menu_new_from_model(menu_model)));
c.gtk_popover_menu_set_flags(menu_widget, c.GTK_POPOVER_MENU_NESTED);
if (style == .popover_menu_no_arrow) {
c.gtk_popover_set_has_arrow(@ptrCast(@alignCast(menu_widget)), 0);
}
_ = c.g_signal_connect_data(
@ptrCast(@alignCast(menu_widget)),
"closed",
Expand Down

0 comments on commit fe72ad6

Please sign in to comment.