Sha256: 8a5d8e6ee11e1041ccad895f0ba8f2155cf9135ba2398f66a4c4bdb383416205

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module SSHTunnel
  module UI
    class StatusIcon

      def initialize(application, window)
        @application = application
        @window      = window
        @status_icon = Gtk::StatusIcon.new
        @menu        = Gtk::Menu.new

        configure_status_icon
        create_popup_menu
      end


      private


        def configure_status_icon
          @status_icon.icon_name = 'network-workgroup-symbolic'
          @status_icon.signal_connect('activate') { |_icon| @window.toggle! }
          @status_icon.signal_connect('popup-menu') { |_tray, button, time| @menu.popup(nil, nil, button, time) }
        end


        def create_popup_menu
          # Build menu items
          info = Gtk::ImageMenuItem.new(label: 'Modifier')
          info.signal_connect('activate') { @window.show }

          quit = Gtk::ImageMenuItem.new(label: 'Quitter')
          quit.signal_connect('activate') { @application.quit }

          # Create menu
          @menu.append(info)
          @menu.append(Gtk::SeparatorMenuItem.new)
          @menu.append(quit)
          @menu.show_all
        end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ssh-hull-2.0 lib/ssh-hull/ui/status_icon.rb
ssh-hull-1.0.0 lib/ssh-hull/ui/status_icon.rb