~rainct/screenruler/screenruler-gtk3

« back to all changes in this revision

Viewing changes to screenruler.rb

  • Committer: Ian McIntosh
  • Date: 2011-08-12 20:13:24 UTC
  • Revision ID: ian@openanswers.org-20110812201324-t35xgp0l97akhivq
- add gettext support and .pot file

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
Dir.chdir(File.dirname(__FILE__))       # So that this file can be run from anywhere
22
22
$LOAD_PATH << './utils'
23
23
 
24
 
# removed while we figure out why some users have problems with glade and safe mode $SAFE = 2    # http://www.rubycentral.com/book/taint.html
 
24
require 'gettext'               # Internationalization Support
 
25
include GetText
 
26
bindtextdomain("screenruler", :path => "locale")
25
27
 
26
28
###################################################################
27
29
# Constants
29
31
UNIT_PIXELS, UNIT_CENTIMETERS, UNIT_INCHES, UNIT_PICAS, UNIT_POINTS, UNIT_PERCENTAGE = (0..5).to_a
30
32
UNIT_LAST = UNIT_PERCENTAGE
31
33
 
32
 
APP_NAME                                        = 'Screen Ruler'
 
34
APP_NAME                                        = _('Screen Ruler')
33
35
APP_COPYRIGHT                   = "Copyright (c) #{Time.now.year} Ian McIntosh"
34
36
APP_AUTHORS                     = ['Ian McIntosh <ian@openanswers.org>']
35
37
APP_ARTISTS                             = ['János Horváth <horvathhans@gmail.com>']
36
 
APP_VERSION                             = '0.9.3'
 
38
APP_VERSION                             = '0.9.4'
37
39
APP_LOGO_FILENAME = 'screenruler-logo.png'
38
40
 
39
41
GCONF_ROOT              = '/apps/screenruler'
41
43
###################################################################
42
44
# Includes
43
45
###################################################################
44
 
puts 'Loading libraries...'
 
46
puts _('Loading libraries...')
45
47
 
46
48
require 'addons_ruby'                                                                   # for multi-file 'require'
47
49
require 'gtk2', 'libglade2', 'gconf2', 'addons_gtk', 'ruler_window', 'preferences_window', 'help_window'
53
55
 
54
56
APP_ICON_LIST = ['screenruler-icon-16x16.png', 'screenruler-icon-32x32.png', 'screenruler-icon-64x64.png'].collect { |filename| Gdk::Pixbuf.new(filename) }
55
57
 
56
 
puts 'Connecting to GConf...'
 
58
puts _('Connecting to GConf...')
57
59
        gconf = GConf::Client.default
58
60
        gconf.set_root(GCONF_ROOT)
59
61
 
60
 
puts 'Creating windows...'
 
62
puts _('Creating windows...')
61
63
        $preferences_window = PreferencesWindow.new
62
64
        $ruler_window = RulerWindow.new
63
65
        $ruler_popup_menu = RulerPopupMenu.new
64
66
        $help_window = HelpWindow.new
65
67
 
66
 
puts 'Reading settings...'
 
68
puts _('Reading settings...')
67
69
        $preferences_window.read_settings(gconf)
68
70
        $ruler_window.read_settings(gconf)
69
71
        $ruler_popup_menu.read_settings(gconf)
70
72
 
71
 
puts 'Presenting ruler...'
 
73
puts _('Presenting ruler...')
72
74
        $ruler_window.present
73
75
 
74
76
begin
75
77
        Gtk.main
76
78
ensure
77
 
        puts 'Shutting down...'
 
79
        puts _('Shutting down...')
78
80
        [$ruler_window, $ruler_popup_menu, $preferences_window].each { |win| win.hide }                         # feels snappy
79
81
        [$ruler_window, $ruler_popup_menu, $preferences_window].each { |win| win.write_settings(gconf) }
80
82
end