Sha256: 0637ae448b5e821544c045bec55ff408a67a6ade2133f4fc2e7833a0c2a21b96

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

# Copyright (C) 2011 Cathal Mc Ginley
#
# Alexandria is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# Alexandria is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with Alexandria; see the file COPYING.  If not,
# write to the Free Software Foundation, Inc., 51 Franklin Street,
# Fifth Floor, Boston, MA 02110-1301 USA.

module Alexandria
  module UI
    class BuilderBase
      def initialize(filename, widget_names)
        file = File.join(Alexandria::Config::DATA_DIR, 'glade', filename)
        builder = Gtk::Builder.new
        builder.add_from_file(file)
        builder.connect_signals do |handler|
          begin
            method(handler)
          rescue => ex
            puts "Error: #{ex}" if $DEBUG
            nil
          end
        end
        widget_names.each do |name|
          begin
            instance_variable_set("@#{name}".intern, builder[name.to_s])
          rescue => err
            puts "Error: #{err}" if $DEBUG
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alexandria-book-collection-manager-0.7.1 lib/alexandria/ui/builder_base.rb
alexandria-book-collection-manager-0.7.0 lib/alexandria/ui/builder_base.rb
alexandria-book-collection-manager-0.6.9 lib/alexandria/ui/builder_base.rb
alexandria-book-collection-manager-0.6.9.pre1 lib/alexandria/ui/builder_base.rb