gtk3valaxfce

Is it possible to use GtkPopover while writing a xfce4 panel plugin


I am trying to write a plugin for xfce4 panel. It should show a popup with complex container like GtkBox.

My code in vala is:

using Xfce;

public class ButtonPlugin : Xfce.PanelPlugin {
    private Gtk.MenuButton button;
    private Gtk.Popover popover;
    public override void @construct () {

        button = new Gtk.MenuButton();
        popover = new Gtk.Popover(button);

        button.set_image(
            new Gtk.Image.from_icon_name (
                "open-menu-symbolic",
                Gtk.IconSize.LARGE_TOOLBAR
            )
        );
        var menu_container = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
        menu_container.pack_start(new Gtk.Label("Hello World 1"));
        menu_container.pack_start(new Gtk.Label("Hello World 2"));
        menu_container.pack_start(new Gtk.Label("Hello World 3"));
        popover.add(menu_container);
        popover.show_all ();
        popover.hide();
        button.popover = popover;
        add (button);
        //button.show ();

        add_action_widget (button);

        save.connect (() => { message ("save yourself"); });
        free_data.connect (() => { message ("free yourself"); });
        size_changed.connect (() => { message ("panel size changed"); return false; });

        menu_show_about ();
        about.connect (() => {
                Gtk.show_about_dialog (null,
                    "program-name", "Button",
                    "comments", "Test plugin for the Xfce 4.14 Panel",
                    null);
            });
        destroy.connect (() => { Gtk.main_quit (); });
        show_all();
    }
}

[ModuleInit]
public Type xfce_panel_module_init (TypeModule module) {
    return typeof (ButtonPlugin);
}

The plugin starts, but doesn't show the popover when clicked.

Is it possible using Popover or should I switch to another widget ?


Solution

  • From what I understand, no, popovers won't work in Xfce panel plugins.

    Take a look at this gist: https://gist.github.com/andreldm/83c9b99e7aa133c924fb4165acc8427a

    The standalone app shows the popover correctly, but try making the window as small as the button, there is no room left for the popover, that's the same problem in a panel plugin. If I'm not mistaken context menus work because they are completely new windows while popover aren't.

    In the same gist you can find a diff against xfce4-sample-plugin with code similar to what you are trying.