GtkPopoverMenu

GtkPopoverMenu — Popovers to use as menus

Functions

Properties

gchar * visible-submenu Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── GInitiallyUnowned
        ╰── GtkWidget
            ╰── GtkContainer
                ╰── GtkBin
                    ╰── GtkPopover
                        ╰── GtkPopoverMenu

Implemented Interfaces

GtkPopoverMenu implements AtkImplementorIface and GtkBuildable.

Includes

#include <gtk/gtk.h>

Description

GtkPopoverMenu is a subclass of GtkPopover that treats its children like menus and allows switching between them. It is meant to be used primarily together with GtkModelButton, but any widget can be used, such as GtkSpinButton or GtkScale. In this respect, GtkPopoverMenu is more flexible than popovers that are created from a GMenuModel with gtk_popover_new_from_model().

To add a child as a submenu, use gtk_popover_menu_add_submenu(). To let the user open this submenu, add a GtkModelButton whose “menu-name” property is set to the name you've given to the submenu.

To add a named submenu in a ui file, set the “name” property of the widget that you are adding as a child of the popover menu.

By convention, the first child of a submenu should be a GtkModelButton to switch back to the parent menu. Such a button should use the “inverted” and “centered” properties to achieve a title-like appearance and place the submenu indicator at the opposite side. To switch back to the main menu, use "main" as the menu name.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<object class="GtkPopoverMenu">
  <child>
    <object class="GtkBox">
      <property name="visible">True</property>
      <property name="margin">10</property>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.frob</property>
          <property name="text" translatable="yes">Frob</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="menu-name">more</property>
          <property name="text" translatable="yes">More</property>
        </object>
      </child>
    </object>
  </child>
  <child>
    <object class="GtkBox">
      <property name="visible">True</property>
      <property name="margin">10</property>
      <property name="name">more</property>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.foo</property>
          <property name="text" translatable="yes">Foo</property>
        </object>
      </child>
      <child>
        <object class="GtkModelButton">
          <property name="visible">True</property>
          <property name="action-name">win.bar</property>
          <property name="text" translatable="yes">Bar</property>
        </object>
      </child>
    </object>
  </child>
</object>


CSS Nodes

GtkPopoverMenu is just a subclass of GtkPopover that adds custom content to it, therefore it has the same CSS nodes. It is one of the cases that add a .menu style class to the popover's contents node.

Functions

gtk_popover_menu_new ()

GtkWidget *
gtk_popover_menu_new (void);

Creates a new popover menu.

Returns

a new GtkPopoverMenu


gtk_popover_menu_add_submenu ()

void
gtk_popover_menu_add_submenu (GtkPopoverMenu *popover,
                              GtkWidget *submenu,
                              const char *name);

Adds a submenu to the popover menu.

Parameters

popover

a GtkPopoverMenu

 

submenu

a widget to add as submenu

 

name

the name for the submenu

 

gtk_popover_menu_open_submenu ()

void
gtk_popover_menu_open_submenu (GtkPopoverMenu *popover,
                               const char *name);

Opens a submenu of the popover . The name must be one of the names given to the submenus of popover with “submenu”, or "main" to switch back to the main menu.

GtkModelButton will open submenus automatically when the “menu-name” property is set, so this function is only needed when you are using other kinds of widgets to initiate menu changes.

Parameters

popover

a GtkPopoverMenu

 

name

the name of the menu to switch to

 

Types and Values

GtkPopoverMenu

typedef struct _GtkPopoverMenu GtkPopoverMenu;

Property Details

The “visible-submenu” property

  “visible-submenu”          gchar *

The name of the visible submenu.

Flags: Read / Write

Default value: NULL