code: def _setup_gtk(tb):
      from gi.repository import Gio, GLib, Gtk
  
      for idx in range(tb.get_n_items()):
          children = tb.get_nth_item(idx).get_children()
          if children and isinstance(children[0], Gtk.Label):
              break
  
      toolitem = Gtk.SeparatorToolItem()
      tb.insert(toolitem, idx)
  
      image = Gtk.Image.new_from_gicon(
          Gio.Icon.new_for_string(
              str(Path(__file__).parent / "images/eye-symbolic.svg")
          ),
          Gtk.IconSize.LARGE_TOOLBAR,
      )
  
      # The type of menu is progressively downgraded depending on GTK version.
      if Gtk.check_version(3, 6, 0) is None:
          group = Gio.SimpleActionGroup.new()
          action = Gio.SimpleAction.new_stateful(
              "cvdsim", GLib.VariantType("s"), GLib.Variant("s", "none")
          )
          group.add_action(action)
  
          @functools.partial(action.connect, "activate")
          def set_filter(action, parameter):
              _set_menu_entry(tb, parameter.get_string())
              action.set_state(parameter)
  
          menu = Gio.Menu()
          for name in _MENU_ENTRIES:
              menu.append(name, f"local.cvdsim::{name}")
  
          button = Gtk.MenuButton.new()
          button.remove(button.get_children()[0])
          button.add(image)
          button.insert_action_group("local", group)
          button.set_menu_model(menu)
          button.get_style_context().add_class("flat")
  
          item = Gtk.ToolItem()
          item.add(button)
          tb.insert(item, idx + 1)
  
      else:
          menu = Gtk.Menu()
          group = []
          for name in _MENU_ENTRIES:
              item = Gtk.RadioMenuItem.new_with_label(group, name)
              item.set_active(name == "None")
              item.connect(
                  "activate",
                  lambda item: _set_menu_entry(tb, item.get_label()),
              )
              group.append(item)
              menu.append(item)
          menu.show_all()
  
          tbutton = Gtk.MenuToolButton.new(image, _BUTTON_NAME)
          tbutton.set_menu(menu)
          tb.insert(tbutton, idx + 1)
  
      tb.show_all()
  
file_path: matplotlib/galleries/examples/user_interfaces/mplcvd.py
imports: import functools
  from pathlib import Path
  import colorspacious
  import numpy
label_desc: Use image node_id 4 for calling a global function with example usage: _setup_gtk(tb) without return types