Sha256: 18fa66373b4027247923ca2368faec093878063796aecae76700028b486c2aa8

Contents?: true

Size: 1001 Bytes

Versions: 2

Compression:

Stored size: 1001 Bytes

Contents

# frozen_string_literal: true

module SSHTunnel
  module UI
    module Helpers
      module Common
        module ModalHelper

          def initialize(application, window, *)
            super application: application

            # Set instance variables
            @application = application
            @window      = window

            # Bind listeners
            bind_submit_button
            bind_cancel_button
          end


          private

            def bind_cancel_button
              # Not all modals have a cancel button
              if respond_to?(:button_cancel)
                button_cancel.label = t('button.cancel')
                button_cancel.signal_connect :clicked do
                  close
                end
              end

              # Bind escape key stroke
              signal_connect :key_press_event do |_widget, event|
                event.keyval == 65_307 ? close : false
              end
            end

        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ssh-hull-2.0 lib/ssh-hull/ui/helpers/common/modal_helper.rb
ssh-hull-1.0.0 lib/ssh-hull/ui/helpers/common/modal_helper.rb