clock_indicator 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/Gemfile +15 -0
- data/Gemfile.lock +127 -0
- data/Guardfile +16 -0
- data/LICENSE.txt +22 -0
- data/README.md +40 -0
- data/Rakefile +9 -0
- data/bin/clock_indicator +5 -0
- data/clock_indicator.gemspec +27 -0
- data/clock_indicator_screenshot.png +0 -0
- data/lib/clock_indicator/calendar_window.rb +46 -0
- data/lib/clock_indicator/clock.rb +113 -0
- data/lib/clock_indicator/current_month_calendar.rb +9 -0
- data/lib/clock_indicator/last_month_calendar.rb +10 -0
- data/lib/clock_indicator/main.rb +14 -0
- data/lib/clock_indicator/next_month_calendar.rb +10 -0
- data/lib/clock_indicator/other_month_calendar.rb +25 -0
- data/lib/clock_indicator/sub_menu.rb +39 -0
- data/lib/clock_indicator/version.rb +3 -0
- data/lib/clock_indicator.rb +16 -0
- data/spec/lib/clock_indicator/calendar_window_spec.rb +2 -0
- data/spec/lib/clock_indicator/clock_spec.rb +2 -0
- data/spec/lib/clock_indicator/current_month_calendar_spec.rb +2 -0
- data/spec/lib/clock_indicator/last_month_calendar_spec.rb +2 -0
- data/spec/lib/clock_indicator/main_spec.rb +2 -0
- data/spec/lib/clock_indicator/next_month_calendar_spec.rb +2 -0
- data/spec/lib/clock_indicator/other_month_calendar_spec.rb +2 -0
- data/spec/lib/clock_indicator/sub_menu_spec.rb +2 -0
- data/spec/lib/clock_indicator_spec.rb +2 -0
- data/spec/spec_helper.rb +96 -0
- metadata +171 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 85d495e45d8317e8d1644ea5ccaa74cde8589eb1
|
|
4
|
+
data.tar.gz: d12028f69514c9706159451e3eafb03c4c99fabf
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 07533a9de7a15f43806c26a1307496fcf4eabab13182a9dcca0d9bf91b5779007ecc7488047526dbc318fb8cb03066c14b24b2328fcf68268bbe0c42251be7a0
|
|
7
|
+
data.tar.gz: 0242b1daa5b528fba7fa72efb36b0942588657fafbf512f892c532f761ac157ab5062ee0e498c92788fd9da8fa8ea336b519ab5a35674297dec089129d956ec8
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in clock_indicator.gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
gem 'json', '>= 1.7.7'
|
|
7
|
+
|
|
8
|
+
group :test do
|
|
9
|
+
gem 'rake'
|
|
10
|
+
gem 'rspec', '~> 3.2.0', :require => false
|
|
11
|
+
gem 'rspec-its', :require => false
|
|
12
|
+
gem 'guard-rspec', :require => false
|
|
13
|
+
gem 'libnotify', :require => false
|
|
14
|
+
gem "codeclimate-test-reporter", :require => false
|
|
15
|
+
end
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
clock_indicator (0.0.1)
|
|
5
|
+
activesupport
|
|
6
|
+
gir_ffi-gtk
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
activesupport (4.2.0)
|
|
12
|
+
i18n (~> 0.7)
|
|
13
|
+
json (~> 1.7, >= 1.7.7)
|
|
14
|
+
minitest (~> 5.1)
|
|
15
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
16
|
+
tzinfo (~> 1.1)
|
|
17
|
+
binding_of_caller (0.7.2)
|
|
18
|
+
debug_inspector (>= 0.0.1)
|
|
19
|
+
byebug (3.5.1)
|
|
20
|
+
columnize (~> 0.8)
|
|
21
|
+
debugger-linecache (~> 1.2)
|
|
22
|
+
slop (~> 3.6)
|
|
23
|
+
celluloid (0.16.0)
|
|
24
|
+
timers (~> 4.0.0)
|
|
25
|
+
codeclimate-test-reporter (0.4.6)
|
|
26
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
|
27
|
+
coderay (1.1.0)
|
|
28
|
+
columnize (0.9.0)
|
|
29
|
+
debug_inspector (0.0.2)
|
|
30
|
+
debugger-linecache (1.2.0)
|
|
31
|
+
diff-lcs (1.2.5)
|
|
32
|
+
docile (1.1.5)
|
|
33
|
+
ffi (1.9.6)
|
|
34
|
+
formatador (0.2.5)
|
|
35
|
+
gir_ffi (0.7.8)
|
|
36
|
+
ffi (~> 1.8)
|
|
37
|
+
indentation (~> 0.1.1)
|
|
38
|
+
gir_ffi-gtk (0.7.2)
|
|
39
|
+
gir_ffi (~> 0.7.6)
|
|
40
|
+
guard (2.12.1)
|
|
41
|
+
formatador (>= 0.2.4)
|
|
42
|
+
listen (~> 2.7)
|
|
43
|
+
lumberjack (~> 1.0)
|
|
44
|
+
nenv (~> 0.1)
|
|
45
|
+
notiffany (~> 0.0)
|
|
46
|
+
pry (>= 0.9.12)
|
|
47
|
+
shellany (~> 0.0)
|
|
48
|
+
thor (>= 0.18.1)
|
|
49
|
+
guard-compat (1.2.1)
|
|
50
|
+
guard-rspec (4.5.0)
|
|
51
|
+
guard (~> 2.1)
|
|
52
|
+
guard-compat (~> 1.1)
|
|
53
|
+
rspec (>= 2.99.0, < 4.0)
|
|
54
|
+
hitimes (1.2.2)
|
|
55
|
+
i18n (0.7.0)
|
|
56
|
+
indentation (0.1.1)
|
|
57
|
+
json (1.8.2)
|
|
58
|
+
libnotify (0.9.1)
|
|
59
|
+
ffi (>= 1.0.11)
|
|
60
|
+
listen (2.8.5)
|
|
61
|
+
celluloid (>= 0.15.2)
|
|
62
|
+
rb-fsevent (>= 0.9.3)
|
|
63
|
+
rb-inotify (>= 0.9)
|
|
64
|
+
lumberjack (1.0.9)
|
|
65
|
+
method_source (0.8.2)
|
|
66
|
+
minitest (5.5.1)
|
|
67
|
+
multi_json (1.10.1)
|
|
68
|
+
nenv (0.2.0)
|
|
69
|
+
notiffany (0.0.5)
|
|
70
|
+
nenv (~> 0.1)
|
|
71
|
+
shellany (~> 0.0)
|
|
72
|
+
pry (0.10.1)
|
|
73
|
+
coderay (~> 1.1.0)
|
|
74
|
+
method_source (~> 0.8.1)
|
|
75
|
+
slop (~> 3.4)
|
|
76
|
+
pry-byebug (3.0.1)
|
|
77
|
+
byebug (~> 3.4)
|
|
78
|
+
pry (~> 0.10)
|
|
79
|
+
rake (10.4.2)
|
|
80
|
+
rb-fsevent (0.9.4)
|
|
81
|
+
rb-inotify (0.9.5)
|
|
82
|
+
ffi (>= 0.5.0)
|
|
83
|
+
rspec (3.2.0)
|
|
84
|
+
rspec-core (~> 3.2.0)
|
|
85
|
+
rspec-expectations (~> 3.2.0)
|
|
86
|
+
rspec-mocks (~> 3.2.0)
|
|
87
|
+
rspec-core (3.2.0)
|
|
88
|
+
rspec-support (~> 3.2.0)
|
|
89
|
+
rspec-expectations (3.2.0)
|
|
90
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
91
|
+
rspec-support (~> 3.2.0)
|
|
92
|
+
rspec-its (1.2.0)
|
|
93
|
+
rspec-core (>= 3.0.0)
|
|
94
|
+
rspec-expectations (>= 3.0.0)
|
|
95
|
+
rspec-mocks (3.2.0)
|
|
96
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
97
|
+
rspec-support (~> 3.2.0)
|
|
98
|
+
rspec-support (3.2.1)
|
|
99
|
+
shellany (0.0.1)
|
|
100
|
+
simplecov (0.9.2)
|
|
101
|
+
docile (~> 1.1.0)
|
|
102
|
+
multi_json (~> 1.0)
|
|
103
|
+
simplecov-html (~> 0.9.0)
|
|
104
|
+
simplecov-html (0.9.0)
|
|
105
|
+
slop (3.6.0)
|
|
106
|
+
thor (0.19.1)
|
|
107
|
+
thread_safe (0.3.4)
|
|
108
|
+
timers (4.0.1)
|
|
109
|
+
hitimes
|
|
110
|
+
tzinfo (1.2.2)
|
|
111
|
+
thread_safe (~> 0.1)
|
|
112
|
+
|
|
113
|
+
PLATFORMS
|
|
114
|
+
ruby
|
|
115
|
+
|
|
116
|
+
DEPENDENCIES
|
|
117
|
+
binding_of_caller
|
|
118
|
+
bundler (~> 1.7)
|
|
119
|
+
clock_indicator!
|
|
120
|
+
codeclimate-test-reporter
|
|
121
|
+
guard-rspec
|
|
122
|
+
json (>= 1.7.7)
|
|
123
|
+
libnotify
|
|
124
|
+
pry-byebug
|
|
125
|
+
rake
|
|
126
|
+
rspec (~> 3.2.0)
|
|
127
|
+
rspec-its
|
data/Guardfile
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
|
2
|
+
require "guard/rspec/dsl"
|
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
4
|
+
|
|
5
|
+
# Feel free to open issues for suggestions and improvements
|
|
6
|
+
|
|
7
|
+
# RSpec files
|
|
8
|
+
rspec = dsl.rspec
|
|
9
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
10
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
11
|
+
watch(rspec.spec_files)
|
|
12
|
+
|
|
13
|
+
# Ruby files
|
|
14
|
+
ruby = dsl.ruby
|
|
15
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
16
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015 Juan C. Müller
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# ClockIndicator
|
|
2
|
+
[](https://codeclimate.com/github/jcmuller/clock_indicator)
|
|
3
|
+
[](https://codeclimate.com/github/jcmuller/clock_indicator)
|
|
4
|
+
[](https://gemnasium.com/jcmuller/clock_indicator)
|
|
5
|
+
|
|
6
|
+
## Motivation
|
|
7
|
+
|
|
8
|
+
I started using [i3](https://i3wm.org/) recently, and one thing I was
|
|
9
|
+
missing was having a full clock on the status bar (I am using
|
|
10
|
+
[trayer](://code.google.com/p/trayer/)). Ubuntu's Unity one just
|
|
11
|
+
wouldn't work. So, I set out to writing one.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
* Clock updates every five second
|
|
17
|
+
* Context menu
|
|
18
|
+
* On click, a row of monthly calendars is shown, with the current
|
|
19
|
+
month in the middle
|
|
20
|
+
|
|
21
|
+
## TODO
|
|
22
|
+
* Add preferences to select the format of the date displayed
|
|
23
|
+
* Add preferences for number of calendars shown
|
|
24
|
+
* Figure out how to have calendars window show up in the same screen
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
$ gem install clock_indicator
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
$ clock_indicator
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
1. Fork it ( https://github.com/jcmuller/clock_indicator/fork )
|
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
38
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
40
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/clock_indicator
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'clock_indicator'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "clock_indicator"
|
|
8
|
+
spec.version = ClockIndicator::VERSION
|
|
9
|
+
spec.authors = ["Juan C. Müller"]
|
|
10
|
+
spec.email = ["jcmuller@gmail.com"]
|
|
11
|
+
spec.summary = "A GTK Status indicator with the current time"
|
|
12
|
+
spec.homepage = "https://github.com/jcmuller/clock_indicator"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
|
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
18
|
+
spec.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
22
|
+
spec.add_development_dependency "pry-byebug"
|
|
23
|
+
spec.add_development_dependency "binding_of_caller"
|
|
24
|
+
|
|
25
|
+
spec.add_dependency "gir_ffi-gtk"
|
|
26
|
+
spec.add_dependency "activesupport"
|
|
27
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module ClockIndicator
|
|
2
|
+
class CalendarWindow
|
|
3
|
+
def initialize
|
|
4
|
+
add_calendars
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
delegate :show_all, :destroy, :to => :window
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
CAL_WIDTH = 200
|
|
12
|
+
|
|
13
|
+
def cals_in_window
|
|
14
|
+
(Gdk::Screen.width / CAL_WIDTH) / 2
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def window
|
|
18
|
+
@window ||= Gtk::Window.new(:toplevel).tap do |window|
|
|
19
|
+
window.position = Gtk::WindowPosition[:mouse]
|
|
20
|
+
window.type_hint = Gdk::WindowTypeHint[:dock]
|
|
21
|
+
window.add(hbox)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def add_calendars
|
|
26
|
+
cals_in_window.downto(1).each do |i|
|
|
27
|
+
hbox.add(LastMonthCalendar.new(i).calendar)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
hbox.add(current_month_calendar.calendar)
|
|
31
|
+
|
|
32
|
+
1.upto(cals_in_window).each do |i|
|
|
33
|
+
hbox.add(NextMonthCalendar.new(i).calendar)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def hbox
|
|
38
|
+
@hbox ||= Gtk::HBox.new(true, 10)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def current_month_calendar
|
|
42
|
+
@current_month_calendar ||= CurrentMonthCalendar.new
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
module ClockIndicator
|
|
2
|
+
class Clock
|
|
3
|
+
def initialize
|
|
4
|
+
set_ui
|
|
5
|
+
setup_callbacks
|
|
6
|
+
start_update_thread
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def set_ui
|
|
12
|
+
tray_icon.show_all
|
|
13
|
+
gtk_update_ui
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def tray_icon
|
|
17
|
+
@tray_icon ||= Gtkti::TrayIcon.new("ClockIndicator::Clock").tap do |ti|
|
|
18
|
+
ti.add(event_box)
|
|
19
|
+
ti.tooltip_text = tooltip_status
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def event_box
|
|
24
|
+
@event_box ||= Gtk::EventBox.new.tap do |eb|
|
|
25
|
+
eb.add(tray_label)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def tooltip_status
|
|
30
|
+
Time.new.to_s
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def time_item_text
|
|
34
|
+
Time.new.strftime("%A, %B %e, %Y %I:%M:%S %P")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def sub_menu
|
|
38
|
+
@sub_menu ||= SubMenu.new
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def setup_callbacks
|
|
42
|
+
GObject.signal_connect(event_box, "button-press-event") do |_, event, _|
|
|
43
|
+
case event.button
|
|
44
|
+
when 1
|
|
45
|
+
toggle_calendar
|
|
46
|
+
when 3
|
|
47
|
+
popup_sub_menu(event)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def pos(event)
|
|
53
|
+
proc { [event.x_root, 19] }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def toggle_calendar
|
|
57
|
+
if @calendar_window.nil?
|
|
58
|
+
calendar_window.show_all
|
|
59
|
+
else
|
|
60
|
+
calendar_window.destroy
|
|
61
|
+
@calendar_window = nil
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def popup_sub_menu(event)
|
|
66
|
+
gtk_update_ui
|
|
67
|
+
sub_menu.popup(nil, nil, pos(event), nil, event.button, event.time)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def calendar_window
|
|
71
|
+
@calendar_window ||= CalendarWindow.new
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def tray_label
|
|
75
|
+
@tray_label ||= Gtk::Label.new("")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def font
|
|
79
|
+
Pango::FontDescription.from_string("Ubuntu 12")
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def time
|
|
83
|
+
Time.new.strftime(time_format)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def time_format
|
|
87
|
+
"%a %m/%d/%Y <b>%I:%M%P</b> "
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def start_update_thread
|
|
91
|
+
Thread.new do
|
|
92
|
+
check_interval_sec = 5
|
|
93
|
+
loop do
|
|
94
|
+
update_ui
|
|
95
|
+
sleep(check_interval_sec)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def update_ui
|
|
101
|
+
run_in_gtk = proc { gtk_update_ui }
|
|
102
|
+
GLib.idle_add(GLib::PRIORITY_DEFAULT_IDLE, run_in_gtk, nil, nil)
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def gtk_update_ui
|
|
106
|
+
tray_label.markup = time
|
|
107
|
+
tray_label.override_font(font)
|
|
108
|
+
tray_icon.tooltip_text = tooltip_status
|
|
109
|
+
sub_menu.time = time_item_text
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module ClockIndicator
|
|
2
|
+
class OtherMonthCalendar
|
|
3
|
+
def initialize(i = 1)
|
|
4
|
+
@i = i
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def calendar
|
|
8
|
+
@calendar ||= Gtk::Calendar.new.tap do |c|
|
|
9
|
+
c.display_options = OTHER_CALENDAR_OPTIONS
|
|
10
|
+
c.day = 0
|
|
11
|
+
c.month = date.month - 1
|
|
12
|
+
c.year = date.year
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
|
|
18
|
+
attr_reader :i
|
|
19
|
+
|
|
20
|
+
OTHER_CALENDAR_OPTIONS =
|
|
21
|
+
Gtk::CalendarDisplayOptions[:no_month_change] |
|
|
22
|
+
Gtk::CalendarDisplayOptions[:show_day_names] |
|
|
23
|
+
Gtk::CalendarDisplayOptions[:show_heading]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
module ClockIndicator
|
|
2
|
+
class SubMenu
|
|
3
|
+
|
|
4
|
+
delegate :popup, :to => :menu
|
|
5
|
+
|
|
6
|
+
def time=(time)
|
|
7
|
+
time_item.label = time
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
|
|
12
|
+
def menu
|
|
13
|
+
@menu ||= Gtk::Menu.new.tap do |m|
|
|
14
|
+
m.append(time_item)
|
|
15
|
+
m.append(separator)
|
|
16
|
+
m.append(exit_item)
|
|
17
|
+
m.show_all
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def time_item
|
|
22
|
+
@time_item ||= Gtk::MenuItem.new.tap do |i|
|
|
23
|
+
# Not selectable
|
|
24
|
+
i.signal_connect("select") { i.deselect }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def separator
|
|
29
|
+
@separator ||= Gtk::SeparatorMenuItem.new
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def exit_item
|
|
33
|
+
@exit_item ||= Gtk::MenuItem.new_with_label("Quit").tap do |i|
|
|
34
|
+
i.signal_connect("activate") { Gtk.main_quit }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require 'gir_ffi-gtk3'
|
|
2
|
+
require 'active_support/time'
|
|
3
|
+
|
|
4
|
+
GirFFI.setup :Gtkti
|
|
5
|
+
|
|
6
|
+
module ClockIndicator
|
|
7
|
+
autoload :CalendarWindow, "clock_indicator/calendar_window"
|
|
8
|
+
autoload :Clock, "clock_indicator/clock"
|
|
9
|
+
autoload :CurrentMonthCalendar, "clock_indicator/current_month_calendar"
|
|
10
|
+
autoload :LastMonthCalendar, "clock_indicator/last_month_calendar"
|
|
11
|
+
autoload :Main, "clock_indicator/main"
|
|
12
|
+
autoload :NextMonthCalendar, "clock_indicator/next_month_calendar"
|
|
13
|
+
autoload :OtherMonthCalendar, "clock_indicator/other_month_calendar"
|
|
14
|
+
autoload :SubMenu, "clock_indicator/sub_menu"
|
|
15
|
+
autoload :VERSION, "clock_indicator/version"
|
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
require 'rspec/its'
|
|
2
|
+
require "codeclimate-test-reporter"
|
|
3
|
+
|
|
4
|
+
CodeClimate::TestReporter.start
|
|
5
|
+
|
|
6
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
|
7
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
8
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
9
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
|
10
|
+
# files.
|
|
11
|
+
#
|
|
12
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
13
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
14
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
15
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
16
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
17
|
+
# the additional setup, and require it from the spec files that actually need
|
|
18
|
+
# it.
|
|
19
|
+
#
|
|
20
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
|
21
|
+
# users commonly want.
|
|
22
|
+
#
|
|
23
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
24
|
+
RSpec.configure do |config|
|
|
25
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
26
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
27
|
+
# assertions if you prefer.
|
|
28
|
+
config.expect_with :rspec do |expectations|
|
|
29
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
30
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
31
|
+
# defined using `chain`, e.g.:
|
|
32
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
33
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
34
|
+
# ...rather than:
|
|
35
|
+
# # => "be bigger than 2"
|
|
36
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
40
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
41
|
+
config.mock_with :rspec do |mocks|
|
|
42
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
43
|
+
# a real object. This is generally recommended, and will default to
|
|
44
|
+
# `true` in RSpec 4.
|
|
45
|
+
mocks.verify_partial_doubles = true
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# The settings below are suggested to provide a good initial experience
|
|
49
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
50
|
+
=begin
|
|
51
|
+
# These two settings work together to allow you to limit a spec run
|
|
52
|
+
# to individual examples or groups you care about by tagging them with
|
|
53
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
|
54
|
+
# get run.
|
|
55
|
+
config.filter_run :focus
|
|
56
|
+
config.run_all_when_everything_filtered = true
|
|
57
|
+
|
|
58
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
59
|
+
# recommended. For more details, see:
|
|
60
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
|
61
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
|
62
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
|
63
|
+
config.disable_monkey_patching!
|
|
64
|
+
|
|
65
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
|
66
|
+
# be too noisy due to issues in dependencies.
|
|
67
|
+
config.warnings = true
|
|
68
|
+
|
|
69
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
70
|
+
# file, and it's useful to allow more verbose output when running an
|
|
71
|
+
# individual spec file.
|
|
72
|
+
if config.files_to_run.one?
|
|
73
|
+
# Use the documentation formatter for detailed output,
|
|
74
|
+
# unless a formatter has already been configured
|
|
75
|
+
# (e.g. via a command-line flag).
|
|
76
|
+
config.default_formatter = 'doc'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Print the 10 slowest examples and example groups at the
|
|
80
|
+
# end of the spec run, to help surface which specs are running
|
|
81
|
+
# particularly slow.
|
|
82
|
+
config.profile_examples = 10
|
|
83
|
+
|
|
84
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
85
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
86
|
+
# the seed, which is printed after each run.
|
|
87
|
+
# --seed 1234
|
|
88
|
+
config.order = :random
|
|
89
|
+
|
|
90
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
91
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
92
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
93
|
+
# as the one that triggered the failure.
|
|
94
|
+
Kernel.srand config.seed
|
|
95
|
+
=end
|
|
96
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: clock_indicator
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Juan C. Müller
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-02-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.7'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.7'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: pry-byebug
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: binding_of_caller
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: gir_ffi-gtk
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: activesupport
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - ">="
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '0'
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - ">="
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '0'
|
|
97
|
+
description:
|
|
98
|
+
email:
|
|
99
|
+
- jcmuller@gmail.com
|
|
100
|
+
executables:
|
|
101
|
+
- clock_indicator
|
|
102
|
+
extensions: []
|
|
103
|
+
extra_rdoc_files: []
|
|
104
|
+
files:
|
|
105
|
+
- ".gitignore"
|
|
106
|
+
- ".rspec"
|
|
107
|
+
- ".travis.yml"
|
|
108
|
+
- Gemfile
|
|
109
|
+
- Gemfile.lock
|
|
110
|
+
- Guardfile
|
|
111
|
+
- LICENSE.txt
|
|
112
|
+
- README.md
|
|
113
|
+
- Rakefile
|
|
114
|
+
- bin/clock_indicator
|
|
115
|
+
- clock_indicator.gemspec
|
|
116
|
+
- clock_indicator_screenshot.png
|
|
117
|
+
- lib/clock_indicator.rb
|
|
118
|
+
- lib/clock_indicator/calendar_window.rb
|
|
119
|
+
- lib/clock_indicator/clock.rb
|
|
120
|
+
- lib/clock_indicator/current_month_calendar.rb
|
|
121
|
+
- lib/clock_indicator/last_month_calendar.rb
|
|
122
|
+
- lib/clock_indicator/main.rb
|
|
123
|
+
- lib/clock_indicator/next_month_calendar.rb
|
|
124
|
+
- lib/clock_indicator/other_month_calendar.rb
|
|
125
|
+
- lib/clock_indicator/sub_menu.rb
|
|
126
|
+
- lib/clock_indicator/version.rb
|
|
127
|
+
- spec/lib/clock_indicator/calendar_window_spec.rb
|
|
128
|
+
- spec/lib/clock_indicator/clock_spec.rb
|
|
129
|
+
- spec/lib/clock_indicator/current_month_calendar_spec.rb
|
|
130
|
+
- spec/lib/clock_indicator/last_month_calendar_spec.rb
|
|
131
|
+
- spec/lib/clock_indicator/main_spec.rb
|
|
132
|
+
- spec/lib/clock_indicator/next_month_calendar_spec.rb
|
|
133
|
+
- spec/lib/clock_indicator/other_month_calendar_spec.rb
|
|
134
|
+
- spec/lib/clock_indicator/sub_menu_spec.rb
|
|
135
|
+
- spec/lib/clock_indicator_spec.rb
|
|
136
|
+
- spec/spec_helper.rb
|
|
137
|
+
homepage: https://github.com/jcmuller/clock_indicator
|
|
138
|
+
licenses:
|
|
139
|
+
- MIT
|
|
140
|
+
metadata: {}
|
|
141
|
+
post_install_message:
|
|
142
|
+
rdoc_options: []
|
|
143
|
+
require_paths:
|
|
144
|
+
- lib
|
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
|
+
requirements:
|
|
147
|
+
- - ">="
|
|
148
|
+
- !ruby/object:Gem::Version
|
|
149
|
+
version: '0'
|
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
151
|
+
requirements:
|
|
152
|
+
- - ">="
|
|
153
|
+
- !ruby/object:Gem::Version
|
|
154
|
+
version: '0'
|
|
155
|
+
requirements: []
|
|
156
|
+
rubyforge_project:
|
|
157
|
+
rubygems_version: 2.2.2
|
|
158
|
+
signing_key:
|
|
159
|
+
specification_version: 4
|
|
160
|
+
summary: A GTK Status indicator with the current time
|
|
161
|
+
test_files:
|
|
162
|
+
- spec/lib/clock_indicator/calendar_window_spec.rb
|
|
163
|
+
- spec/lib/clock_indicator/clock_spec.rb
|
|
164
|
+
- spec/lib/clock_indicator/current_month_calendar_spec.rb
|
|
165
|
+
- spec/lib/clock_indicator/last_month_calendar_spec.rb
|
|
166
|
+
- spec/lib/clock_indicator/main_spec.rb
|
|
167
|
+
- spec/lib/clock_indicator/next_month_calendar_spec.rb
|
|
168
|
+
- spec/lib/clock_indicator/other_month_calendar_spec.rb
|
|
169
|
+
- spec/lib/clock_indicator/sub_menu_spec.rb
|
|
170
|
+
- spec/lib/clock_indicator_spec.rb
|
|
171
|
+
- spec/spec_helper.rb
|