# File src/demos/gtk_demo_plugins/core/Workbench.rb, line 67
  def update(state, plugin)
    if !@notebook.destroyed? && (plugin.requires.include?(:workbench) || (plugin.extends && plugin.extends.keys.include?(name)))

      # remove any trace of the plugin from the workbench

      page_num = @notebook.page_num(@plug_ui[plugin])
      if page_num != -1
        @notebook.remove_page(page_num)
        @plug_ui[plugin] = nil
      end

      @logger.debug { "Workbench update event thrown, state #{state.inspect} for plugin #{plugin.name.to_s}" }
      if state == :started
        ui = plugin.get_ui
        plugin.add_observer(self)
        @notebook.append_page(ui, make_tab_widget(plugin.params[:ui_label], plugin.params[:ui_image]))
        @plug_ui[plugin] = ui
      elsif state == :stopped
        # already removed UI from workbench...

      else
        error_label = Gtk::Label.new("Bad state #{state.inspect} for plugin #{plugin.name.inspect}.")
        @plug_ui[plugin] = error_label
        @notebook.append_page(ui, make_tab_widget(plugin.params[:ui_label], plugin.params[:ui_image]))
      end
      @notebook.show_all
    end
  end