Sha256: 5c1b2a40f6a442ee088e3b19ddd3a872042413f618e41a72642b850631cc86a3

Contents?: true

Size: 1.32 KB

Versions: 11

Compression:

Stored size: 1.32 KB

Contents

# Volay module
module Volay
  # App class
  class App < Gtk::Builder
    attr_accessor :signals_list
    attr_reader :mixer, :utils

    ##
    # Initialize application
    #
    # @param [String] path Path to glade file
    #
    def initialize(path)
      super()

      Gtk::Settings.default.gtk_button_images = true

      initialize_ui(path)
      initialize_mixer
      initialize_events
    end

    private

    ##
    # Initialize events
    #
    def initialize_events
      @signals_list = {}
      @utils = Volay::Utils.new(self)
      @utils.update_status_icon
      Volay::Widget::SystemTray.new(self)
      Volay::Widget::VolumeControl.new(self)

      connect_signals do |handler|
        @signals_list[handler] if @signals_list.key?(handler)
      end
    end

    ##
    # Initialize mixer for controlling volume
    #
    def initialize_mixer
      @mixer ||= Volay::Config.mixer
    end

    ##
    # Intiailize ui by overriding icons path
    #
    # @param [String] path Path to glade file
    #
    def initialize_ui(path)
      # Override Icon path to prevent
      # Gtk-CRITICAL **:gtk_icon_source_set_filename:
      ui = File.read(path)
      ui.gsub!(%r{/glade/icons},
               File.expand_path('../../glade/icons',
                                File.dirname(__FILE__)))
      add_from_string(ui)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
volay-1.1.0 lib/volay/app.rb
volay-1.0.1 lib/volay/app.rb
volay-1.0.0 lib/volay/app.rb
volay-0.7.0 lib/volay/app.rb
volay-0.6.0 lib/volay/app.rb
volay-0.5.0 lib/volay/app.rb
volay-0.4.0 lib/volay/app.rb
volay-0.3.0 lib/volay/app.rb
volay-0.2.0 lib/volay/app.rb
volay-0.1.0 lib/volay/app.rb
volay-0.0.1 lib/volay/app.rb