volay 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +0 -1
- data/bin/volay +2 -2
- data/glade/volay.glade +8 -0
- data/lib/volay.rb +2 -2
- data/lib/volay/app.rb +7 -3
- data/lib/volay/config.rb +1 -0
- data/lib/volay/mixer/pulse.rb +12 -11
- data/lib/volay/utils.rb +1 -0
- data/lib/volay/version.rb +1 -1
- data/lib/volay/volay.rb +2 -2
- data/lib/volay/widget/events.rb +1 -0
- data/lib/volay/widget/system_tray.rb +54 -27
- data/lib/volay/widget/volume_control.rb +0 -9
- data/spec/spec_helper.rb +1 -1
- data/spec/volay/app_spec.rb +12 -1
- data/spec/volay/mixer/pulse_spec.rb +2 -2
- data/spec/volay/widget/volume_control_spec.rb +21 -5
- data/task/manifest.rake +1 -1
- data/volay.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e383f672606a89520f19cc97e3704539037a44b65cd8f97b4e965ba8b3bd2a0
|
4
|
+
data.tar.gz: b0cfb666b0b3cdce544bb105fb58986311c72660a377df8fab2863e67e535e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f157a6475a185d45d55b0348c8b96c0164eeab49d23f0bc8bb793e109548e729f36f95f72fdde2a8762fc2984f34e4a9c14b8a2668e7fe3718cced3623e3524b
|
7
|
+
data.tar.gz: 59a3bec0c005d48f56e51eb8591e34718334a1f33fbefa62653d412a735e37a2afa1161fb5038b5ba871f8155412e8c4547d5d834e219d9c41128040af64090b
|
data/Rakefile
CHANGED
data/bin/volay
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require File.expand_path('
|
4
|
+
require File.expand_path('../lib/volay', __dir__)
|
5
5
|
|
6
6
|
# Module volay
|
7
7
|
module Volay
|
@@ -26,7 +26,7 @@ module Volay
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def app
|
29
|
-
Volay::App.new(File.expand_path('
|
29
|
+
Volay::App.new(File.expand_path('../glade/volay.glade', __dir__))
|
30
30
|
Gtk.main
|
31
31
|
end
|
32
32
|
end
|
data/glade/volay.glade
CHANGED
@@ -13,6 +13,14 @@
|
|
13
13
|
<object class="GtkMenu" id="popup_menu">
|
14
14
|
<property name="visible">True</property>
|
15
15
|
<property name="can_focus">False</property>
|
16
|
+
<property name="no_show_all">True</property>
|
17
|
+
<child>
|
18
|
+
<object class="GtkMenuItem" id="popup_menu_cards">
|
19
|
+
<property name="can_focus">False</property>
|
20
|
+
<property name="label">Cards</property>
|
21
|
+
<property name="use_underline">True</property>
|
22
|
+
</object>
|
23
|
+
</child>
|
16
24
|
<child>
|
17
25
|
<object class="GtkImageMenuItem" id="popup_menu_quit">
|
18
26
|
<property name="label">gtk-quit</property>
|
data/lib/volay.rb
CHANGED
@@ -5,8 +5,8 @@ require 'logger'
|
|
5
5
|
require 'mixlib/cli'
|
6
6
|
require 'mixlib/shellout'
|
7
7
|
|
8
|
-
unless $LOAD_PATH.include?(File.expand_path('
|
9
|
-
$LOAD_PATH.unshift(File.expand_path('
|
8
|
+
unless $LOAD_PATH.include?(File.expand_path('', __dir__))
|
9
|
+
$LOAD_PATH.unshift(File.expand_path('', __dir__))
|
10
10
|
end
|
11
11
|
|
12
12
|
require 'volay/version'
|
data/lib/volay/app.rb
CHANGED
@@ -55,9 +55,13 @@ module Volay
|
|
55
55
|
# Override Icon path to prevent
|
56
56
|
# Gtk-CRITICAL **:gtk_icon_source_set_filename:
|
57
57
|
ui = File.read(path)
|
58
|
-
ui.gsub!(
|
59
|
-
|
60
|
-
|
58
|
+
ui.gsub!(
|
59
|
+
%r{/glade/icons},
|
60
|
+
File.expand_path(
|
61
|
+
'../glade/icons',
|
62
|
+
File.dirname(__dir__)
|
63
|
+
)
|
64
|
+
)
|
61
65
|
add_from_string(ui)
|
62
66
|
end
|
63
67
|
end
|
data/lib/volay/config.rb
CHANGED
data/lib/volay/mixer/pulse.rb
CHANGED
@@ -77,17 +77,6 @@ module Volay
|
|
77
77
|
refresh
|
78
78
|
end
|
79
79
|
|
80
|
-
private
|
81
|
-
|
82
|
-
##
|
83
|
-
# Get volume percent
|
84
|
-
#
|
85
|
-
# @return Integer
|
86
|
-
#
|
87
|
-
def volume_percent(value)
|
88
|
-
value * 100 / MAX_VALUE
|
89
|
-
end
|
90
|
-
|
91
80
|
##
|
92
81
|
# Refresh cards data
|
93
82
|
#
|
@@ -110,6 +99,17 @@ module Volay
|
|
110
99
|
set_long_names
|
111
100
|
end
|
112
101
|
|
102
|
+
private
|
103
|
+
|
104
|
+
##
|
105
|
+
# Get volume percent
|
106
|
+
#
|
107
|
+
# @return Integer
|
108
|
+
#
|
109
|
+
def volume_percent(value)
|
110
|
+
value * 100 / MAX_VALUE
|
111
|
+
end
|
112
|
+
|
113
113
|
##
|
114
114
|
# Set cards data such as default sink
|
115
115
|
# volume and if card is muted
|
@@ -119,6 +119,7 @@ module Volay
|
|
119
119
|
def set_data(args)
|
120
120
|
@cards.each do |id, card|
|
121
121
|
next if args[1].nil? || !args[1].include?(card['name'])
|
122
|
+
|
122
123
|
case args[0]
|
123
124
|
when 'set-default-sink'
|
124
125
|
@default_sink_id = id
|
data/lib/volay/utils.rb
CHANGED
data/lib/volay/version.rb
CHANGED
data/lib/volay/volay.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'gtk3'
|
4
4
|
require 'mixlib-cli'
|
5
5
|
|
6
|
-
unless $LOAD_PATH.include?(File.expand_path('
|
7
|
-
$LOAD_PATH.unshift(File.expand_path('
|
6
|
+
unless $LOAD_PATH.include?(File.expand_path('', __dir__))
|
7
|
+
$LOAD_PATH.unshift(File.expand_path('', __dir__))
|
8
8
|
end
|
9
9
|
|
10
10
|
require 'volay/version'
|
data/lib/volay/widget/events.rb
CHANGED
@@ -6,36 +6,15 @@ module Volay
|
|
6
6
|
module Widget
|
7
7
|
# Events class
|
8
8
|
class SystemTray < Events
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
KEYCODE_MOUSE_CLICK_LEFT = 1
|
10
|
+
KEYCODE_MOUSE_CLICK_RIGHT = 3
|
11
|
+
KEYCODE_M = 47
|
12
12
|
|
13
13
|
##
|
14
14
|
# When popup window menu is draw
|
15
15
|
#
|
16
16
|
def init
|
17
|
-
|
18
|
-
|
19
|
-
cards_menu = Gtk::MenuItem.new(label: 'Cards')
|
20
|
-
menu = Gtk::Menu.new
|
21
|
-
last_item = nil
|
22
|
-
@app.mixer.cards.each do |id, card|
|
23
|
-
radio_menu_item = Gtk::RadioMenuItem.new(nil, card['long_name'])
|
24
|
-
radio_menu_item.join_group(last_item) if last_item
|
25
|
-
radio_menu_item.name = "card_menu_#{id}"
|
26
|
-
radio_menu_item.active = @app.mixer.default_sink_id == id
|
27
|
-
last_item = radio_menu_item
|
28
|
-
menu.append(radio_menu_item)
|
29
|
-
|
30
|
-
radio_menu_item.signal_connect('activate') do |widget|
|
31
|
-
next unless widget.active?
|
32
|
-
@app.mixer.change_card(id)
|
33
|
-
@app.utils.update_status_icon
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
cards_menu.submenu = menu
|
38
|
-
@app.get_object('popup_menu').prepend(cards_menu)
|
17
|
+
refresh_cards_menu
|
39
18
|
end
|
40
19
|
|
41
20
|
##
|
@@ -46,7 +25,8 @@ module Volay
|
|
46
25
|
#
|
47
26
|
def on_status_icon_button_press_event(_widget, event)
|
48
27
|
return unless event.is_a?(Gdk::EventButton) &&
|
49
|
-
event.button ==
|
28
|
+
event.button == KEYCODE_MOUSE_CLICK_LEFT
|
29
|
+
|
50
30
|
return on_system_tray_window_focus_out_event if
|
51
31
|
@app.get_object('system_tray_window').visible?
|
52
32
|
|
@@ -68,7 +48,8 @@ module Volay
|
|
68
48
|
#
|
69
49
|
def on_system_tray_window_key_release_event(_widget, event)
|
70
50
|
return unless event.is_a?(Gdk::EventKey) &&
|
71
|
-
event.hardware_keycode ==
|
51
|
+
event.hardware_keycode == KEYCODE_M
|
52
|
+
|
72
53
|
@app.mixer.toggle
|
73
54
|
@app.utils.update_status_icon
|
74
55
|
end
|
@@ -92,6 +73,18 @@ module Volay
|
|
92
73
|
Gtk.main_quit
|
93
74
|
end
|
94
75
|
|
76
|
+
##
|
77
|
+
# When system tray window is showed
|
78
|
+
#
|
79
|
+
def on_system_tray_window_show
|
80
|
+
@app.mixer.refresh
|
81
|
+
refresh_cards_menu
|
82
|
+
|
83
|
+
@app.get_object('volume_adjustement')
|
84
|
+
.value = @app.mixer.percent
|
85
|
+
@app.utils.update_status_icon
|
86
|
+
end
|
87
|
+
|
95
88
|
##
|
96
89
|
# Retrieve the good position to be above
|
97
90
|
# the status icon
|
@@ -129,6 +122,40 @@ module Volay
|
|
129
122
|
|
130
123
|
[posx, posy]
|
131
124
|
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
##
|
129
|
+
# Refresh card menu items
|
130
|
+
#
|
131
|
+
def refresh_cards_menu
|
132
|
+
@app.get_object('popup_menu_cards').visible = false
|
133
|
+
|
134
|
+
return unless @app&.mixer&.cards
|
135
|
+
return if @app.mixer.cards.keys.count <= 1
|
136
|
+
|
137
|
+
menu = Gtk::Menu.new
|
138
|
+
last_item = nil
|
139
|
+
@app.mixer.cards.each do |id, card|
|
140
|
+
radio_menu_item = Gtk::RadioMenuItem.new(nil, card['long_name'])
|
141
|
+
radio_menu_item.join_group(last_item) if last_item
|
142
|
+
radio_menu_item.name = "card_menu_#{id}"
|
143
|
+
radio_menu_item.visible = true
|
144
|
+
radio_menu_item.active = @app.mixer.default_sink_id == id
|
145
|
+
last_item = radio_menu_item
|
146
|
+
menu.append(radio_menu_item)
|
147
|
+
|
148
|
+
radio_menu_item.signal_connect('activate') do |widget|
|
149
|
+
next unless widget.active?
|
150
|
+
|
151
|
+
@app.mixer.change_card(id)
|
152
|
+
@app.utils.update_status_icon
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
@app.get_object('popup_menu_cards').visible = true
|
157
|
+
@app.get_object('popup_menu_cards').submenu = menu
|
158
|
+
end
|
132
159
|
end
|
133
160
|
end
|
134
161
|
end
|
@@ -6,15 +6,6 @@ module Volay
|
|
6
6
|
module Widget
|
7
7
|
# Events class
|
8
8
|
class VolumeControl < Events
|
9
|
-
##
|
10
|
-
# When system tray window is showed
|
11
|
-
#
|
12
|
-
def on_system_tray_window_show
|
13
|
-
@app.get_object('volume_adjustement')
|
14
|
-
.value = @app.mixer.percent
|
15
|
-
@app.utils.update_status_icon
|
16
|
-
end
|
17
|
-
|
18
9
|
##
|
19
10
|
# When slider have its adjustement value changed
|
20
11
|
#
|
data/spec/spec_helper.rb
CHANGED
data/spec/volay/app_spec.rb
CHANGED
@@ -16,15 +16,26 @@ describe 'Volay::App' do
|
|
16
16
|
include FakeFS::SpecHelpers
|
17
17
|
|
18
18
|
context '#events' do
|
19
|
+
let(:popup_menu_cards) do
|
20
|
+
pmc = double
|
21
|
+
allow(pmc).to receive(:visible=).and_return(true)
|
22
|
+
|
23
|
+
pmc
|
24
|
+
end
|
25
|
+
|
19
26
|
it 'should initiliaze events' do
|
20
27
|
allow_any_instance_of(Volay::App).to receive(:initialize_mixer)
|
21
28
|
allow_any_instance_of(Volay::App).to receive(:initialize_ui)
|
22
29
|
allow_any_instance_of(Volay::Utils).to receive(:update_status_icon)
|
23
30
|
allow_any_instance_of(Volay::App).to receive(:connect_signals)
|
24
31
|
.and_yield('on_status_icon_button_press_event')
|
32
|
+
allow_any_instance_of(Volay::App).to receive(:get_object)
|
33
|
+
.with('popup_menu_cards')
|
34
|
+
.and_return(popup_menu_cards)
|
25
35
|
|
26
36
|
File.write('something', '')
|
27
37
|
app = Volay::App.new('something')
|
38
|
+
|
28
39
|
expect(app.signals_list).to be_a(Hash)
|
29
40
|
end
|
30
41
|
end
|
@@ -45,7 +56,7 @@ describe 'Volay::App' do
|
|
45
56
|
</sources>
|
46
57
|
</object>
|
47
58
|
</interface>
|
48
|
-
XML
|
59
|
+
XML
|
49
60
|
|
50
61
|
File.write('something', xml)
|
51
62
|
app = Volay::App.new('something')
|
@@ -26,13 +26,13 @@ describe 'Volay::Mixer::Pulse' do
|
|
26
26
|
stub_shellout(
|
27
27
|
'dump',
|
28
28
|
File.read(
|
29
|
-
File.expand_path('
|
29
|
+
File.expand_path('stubs/pulse_dump.stub', __dir__)
|
30
30
|
)
|
31
31
|
)
|
32
32
|
stub_shellout(
|
33
33
|
"list-cards | grep -e device.string -e 'name:' -e 'card_name'",
|
34
34
|
File.read(
|
35
|
-
File.expand_path('
|
35
|
+
File.expand_path('stubs/pulse_list-cards.stub', __dir__)
|
36
36
|
)
|
37
37
|
)
|
38
38
|
end
|
@@ -12,18 +12,34 @@ describe 'Volay::Widget::VolumeControl' do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:vc) do
|
15
|
+
allow(Thread).to receive(:new).and_yield
|
15
16
|
Volay::Widget::VolumeControl.new(app)
|
16
17
|
end
|
17
18
|
|
18
19
|
it 'on volume scale' do
|
19
20
|
utils = double
|
20
21
|
volume = double
|
21
|
-
|
22
|
-
allow(
|
23
|
-
|
22
|
+
|
23
|
+
allow(volume).to receive(:value).once.and_return(20)
|
24
|
+
allow(utils).to receive(:update_status_icon).once.and_return(true)
|
25
|
+
|
24
26
|
allow(app).to receive(:utils).once.and_return(utils)
|
27
|
+
allow(app.mixer).to receive(:value=).with(20).once
|
28
|
+
|
29
|
+
vc.on_volume_adjustement_value_changed(volume)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'no volume mute' do
|
33
|
+
utils = double
|
34
|
+
volume = double
|
35
|
+
|
36
|
+
allow(volume).to receive(:active?).once.and_return(true)
|
25
37
|
allow(utils).to receive(:update_status_icon).once.and_return(true)
|
26
|
-
|
27
|
-
|
38
|
+
|
39
|
+
allow(app).to receive(:utils).once.and_return(utils)
|
40
|
+
allow(app.mixer).to receive(:muted?).once.and_return(true)
|
41
|
+
allow(app.mixer).to receive(:toggle).once
|
42
|
+
|
43
|
+
vc.on_toggle_mute_toggled(volume)
|
28
44
|
end
|
29
45
|
end
|
data/task/manifest.rake
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
desc 'Generates the MANIFEST file'
|
4
4
|
task :manifest do
|
5
5
|
files = `git ls-files`.split("\n").sort
|
6
|
-
handle = File.open(File.expand_path('
|
6
|
+
handle = File.open(File.expand_path('../MANIFEST', __dir__), 'w')
|
7
7
|
|
8
8
|
handle.write(files.join("\n"))
|
9
9
|
handle.close
|
data/volay.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require File.expand_path('
|
3
|
+
require File.expand_path('lib/volay/version', __dir__)
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'volay'
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.homepage = 'http://github.com/PierreRambaud/volay'
|
13
13
|
s.description = 'Really simple volume system tray written in ruby.'
|
14
14
|
s.executables = ['volay']
|
15
|
-
s.files = File.read(File.expand_path('
|
15
|
+
s.files = File.read(File.expand_path('MANIFEST', __dir__)).split("\n")
|
16
16
|
|
17
17
|
s.required_ruby_version = '> 2.3'
|
18
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pierre Rambaud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glib2
|
@@ -229,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
229
|
version: '0'
|
230
230
|
requirements: []
|
231
231
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.7.
|
232
|
+
rubygems_version: 2.7.3
|
233
233
|
signing_key:
|
234
234
|
specification_version: 4
|
235
235
|
summary: The Volume system tray
|