Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:17:53+00:00 2026-06-07T10:17:53+00:00

I want to show a custom menu item for a ToolItem when it is

  • 0

I want to show a custom menu item for a ToolItem when it is in the toolbar’s overflow menu. This seems to be the purpose of the set_proxy_menu_item method. However, when I set the proxy menu item via using this method, it has no effect on the overflow menu. It still uses the default menu item (with the ToolItem’s name as the label).

Here is a simple project (in Vala) that reproduces the problem. It creates a tiny window containing a toolbar with 3 buttons. The window should be small enough that all but one of these buttons is in the overflow menu.

When I view the overflow menu, I should see “proxy” for as the menu item for edit_button. Instead, I see “edit”.

What am I doing wrong?

void main(string[] args) {
    Gtk.init(ref args);
    MainWindow main_window = new MainWindow();
    main_window.show_all();
    Gtk.main();
}

public class MainWindow : Gtk.Window {
    public MainWindow() {
        destroy.connect(Gtk.main_quit);
        title = "Main Window";

        Gtk.Box main_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 6);
        add(main_box);

        Gtk.Toolbar toolbar = new Gtk.Toolbar();
        main_box.pack_start(toolbar, false, false);

        Gtk.ToolButton new_button = new Gtk.ToolButton.from_stock(Gtk.Stock.NEW);
        Gtk.ToolButton edit_button = new Gtk.ToolButton.from_stock(Gtk.Stock.EDIT);
        Gtk.ToolButton delete_button = new Gtk.ToolButton.from_stock(Gtk.Stock.DELETE);

        Gtk.MenuItem proxy = new Gtk.MenuItem.with_label("proxy");
        proxy.show_all();
        edit_button.set_proxy_menu_item("proxy_menuitem", proxy);

        toolbar.add(new_button);
        toolbar.add(edit_button);
        toolbar.add(delete_button);

        Gtk.Label content_label = new Gtk.Label("Placeholder");
        main_box.pack_start(content_label, false, false);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:17:55+00:00Added an answer on June 7, 2026 at 10:17 am

    It turns out that set_proxy_menu_item is temporary, and should be used in a response to the create-menu-proxy signal. I can’t find this documented anywhere on the web, but here it is from the Gtk+ source code:

    /**
     * GtkToolItem::create-menu-proxy:
     * @tool_item: the object the signal was emitted on
     *
     * This signal is emitted when the toolbar needs information from @tool_item
     * about whether the item should appear in the toolbar overflow menu. In
     * response the tool item should either
     * <itemizedlist>
     * <listitem>call gtk_tool_item_set_proxy_menu_item() with a %NULL
     * pointer and return %TRUE to indicate that the item should not appear
     * in the overflow menu
     * </listitem>
     * <listitem> call gtk_tool_item_set_proxy_menu_item() with a new menu
     * item and return %TRUE, or 
     * </listitem>
     * <listitem> return %FALSE to indicate that the signal was not
     * handled by the item. This means that
     * the item will not appear in the overflow menu unless a later handler
     * installs a menu item.
     * </listitem>
     * </itemizedlist>
     *
     * The toolbar may cache the result of this signal. When the tool item changes
     * how it will respond to this signal it must call gtk_tool_item_rebuild_menu()
     * to invalidate the cache and ensure that the toolbar rebuilds its overflow
     * menu.
     *
     * Return value: %TRUE if the signal was handled, %FALSE if not
     **/
    

    So the right way to solve this would be something like:

    edit_button.create_menu_proxy.connect(on_create_menu_proxy);
    
    ...
    
    private bool on_create_menu_proxy(Gtk.ToolItem tool_item) {
        Gtk.MenuItem proxy = new Gtk.MenuItem.with_label("proxy");
        tool_item.set_proxy_menu_item("proxy_menuitem", proxy);
        return true;
    }
    

    You may not actually want to create a new proxy every time the signal is fired, but that should be enough to help anyone reading this get started.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to show four custom clock on screen i try with this code
I want to add a custom right-click menu to my web application. Can this
I am using Delphi, and I want to show custom text in the buttons
I want to show a custom image with some data in it while clicking
I want to show my custom objects (images, formulas) in UITableView row name. Is
I want my Application to show Custom Dialog When an Uncatch Exception occur. For
I have a custom control (C#, visual studio). I want to show a tooltip
This is what I would like: I want to keep the Silverlight default menu
Want to show a custom message in form's error list, if the two fields
I want to show a custom mouse cursor, in a size that matches the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.