File: screenruler.rb

package info (click to toggle)
screenruler 0.891%2Bbzr25-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 196 kB
  • ctags: 113
  • sloc: ruby: 642; makefile: 3
file content (83 lines) | stat: -rwxr-xr-x 3,166 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env ruby

 ###############################################################################
 #  Copyright 2008 Ian McIntosh <ian@openanswers.org>
 #
 #  This program 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.
 #
 #  This program 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 Library General Public License for more details.
 #
 #  You should have received a copy of the GNU General Public License
 #  along with this program; if not, write to the Free Software
 #  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 ###############################################################################

Dir.chdir(File.dirname(__FILE__))	# So that this file can be run from anywhere
$LOAD_PATH << './utils'

# removed while we figure out why some users have problems with glade and safe mode $SAFE = 2	 # http://www.rubycentral.com/book/taint.html

###################################################################
# Constants
###################################################################
UNIT_PIXELS, UNIT_CENTIMETERS, UNIT_INCHES, UNIT_PICAS, UNIT_POINTS, UNIT_PERCENTAGE = (0..5).to_a
UNIT_LAST = UNIT_PERCENTAGE

APP_NAME					= 'Screen Ruler'
APP_COPYRIGHT			= "Copyright (c) #{Time.now.year} Ian McIntosh"
APP_AUTHORS 			= ['Ian McIntosh <ian@openanswers.org>']
APP_ARTISTS				= ['János Horváth <horvathhans@gmail.com>']
APP_VERSION				= 0.891
APP_LOGO_FILENAME = 'screenruler-logo.png'

GCONF_ROOT		= '/apps/screenruler'

###################################################################
# Includes
###################################################################
puts 'Loading libraries...'

require 'addons_ruby'									# for multi-file 'require'
require 'gtk2', 'libglade2', 'gconf2', 'addons_gtk', 'ruler_window', 'preferences_window'

###################################################################
# Main
###################################################################
Gtk.init

APP_ICON_LIST = ['screenruler-icon-16x16.png', 'screenruler-icon-32x32.png', 'screenruler-icon-64x64.png'].collect { |filename| Gdk::Pixbuf.new(filename) }

puts 'Connecting to GConf...'
	gconf = GConf::Client.default
	gconf.set_root(GCONF_ROOT)

puts 'Creating windows...'
	$preferences_window = PreferencesWindow.new
	$ruler_window = RulerWindow.new
	$ruler_popup_menu = RulerPopupMenu.new

puts 'Reading settings...'
	$preferences_window.read_settings(gconf)
	$ruler_window.read_settings(gconf)
	$ruler_popup_menu.read_settings(gconf)

puts 'Presenting ruler...'
	$ruler_window.present

begin
	Gtk.main
ensure
	puts 'Shutting down...'
	[$ruler_window, $ruler_popup_menu, $preferences_window].each { |win| win.hide }				# feels snappy
	[$ruler_window, $ruler_popup_menu, $preferences_window].each { |win| win.write_settings(gconf) }
end

# Local Variables:
# tab-width: 2
# End: