pulseaudio 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gem "wref"
7
7
  gem "gir_ffi"
8
8
  gem "gtk3assist"
9
9
  gem "gettext"
10
+ gem "knjrbfw"
10
11
 
11
12
  # Add dependencies to develop your gem here.
12
13
  # Include everything needed to run rake, tests, features, etc.
@@ -1,6 +1,7 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
+ datet (0.0.20)
4
5
  diff-lcs (1.1.3)
5
6
  ffi (1.0.11)
6
7
  gettext (2.3.1)
@@ -14,6 +15,7 @@ GEM
14
15
  gtk3assist (0.0.5)
15
16
  gir_ffi-gtk
16
17
  xml-simple
18
+ http2 (0.0.11)
17
19
  indentation (0.0.6)
18
20
  jeweler (1.8.4)
19
21
  bundler (~> 1.0)
@@ -21,7 +23,16 @@ GEM
21
23
  rake
22
24
  rdoc
23
25
  json (1.7.5)
26
+ knjrbfw (0.0.99)
27
+ datet
28
+ http2
29
+ php4r
30
+ tsafe
31
+ wref
24
32
  locale (2.0.8)
33
+ php4r (0.0.3)
34
+ datet
35
+ http2
25
36
  rake (0.9.2.2)
26
37
  rdoc (3.12)
27
38
  json (~> 1.4)
@@ -33,6 +44,7 @@ GEM
33
44
  rspec-expectations (2.8.0)
34
45
  diff-lcs (~> 1.1.2)
35
46
  rspec-mocks (2.8.0)
47
+ tsafe (0.0.11)
36
48
  wref (0.0.5)
37
49
  xml-simple (1.1.1)
38
50
 
@@ -45,6 +57,7 @@ DEPENDENCIES
45
57
  gir_ffi
46
58
  gtk3assist
47
59
  jeweler (~> 1.8.3)
60
+ knjrbfw
48
61
  rdoc (~> 3.12)
49
62
  rspec (~> 2.8.0)
50
63
  wref
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
@@ -27,12 +27,25 @@
27
27
  <property name="can_focus">False</property>
28
28
  <property name="left_padding">12</property>
29
29
  <child>
30
- <object class="GtkTreeView" id="tvSinks">
30
+ <object class="GtkViewport" id="viewport1">
31
31
  <property name="visible">True</property>
32
- <property name="can_focus">True</property>
33
- <signal name="cursor-changed" handler="on_tvSinks_cursor_changed" swapped="no"/>
34
- <child internal-child="selection">
35
- <object class="GtkTreeSelection" id="treeview-selection1"/>
32
+ <property name="can_focus">False</property>
33
+ <child>
34
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
35
+ <property name="visible">True</property>
36
+ <property name="can_focus">True</property>
37
+ <property name="shadow_type">in</property>
38
+ <child>
39
+ <object class="GtkTreeView" id="tvSinks">
40
+ <property name="visible">True</property>
41
+ <property name="can_focus">True</property>
42
+ <signal name="cursor-changed" handler="on_tvSinks_cursor_changed" swapped="no"/>
43
+ <child internal-child="selection">
44
+ <object class="GtkTreeSelection" id="treeview-selection1"/>
45
+ </child>
46
+ </object>
47
+ </child>
48
+ </object>
36
49
  </child>
37
50
  </object>
38
51
  </child>
@@ -68,12 +81,19 @@
68
81
  <property name="visible">True</property>
69
82
  <property name="can_focus">False</property>
70
83
  <child>
71
- <object class="GtkTreeView" id="tvSources">
84
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
72
85
  <property name="visible">True</property>
73
86
  <property name="can_focus">True</property>
74
- <signal name="cursor-changed" handler="on_tvSources_cursor_changed" swapped="no"/>
75
- <child internal-child="selection">
76
- <object class="GtkTreeSelection" id="treeview-selection2"/>
87
+ <property name="shadow_type">in</property>
88
+ <child>
89
+ <object class="GtkTreeView" id="tvSources">
90
+ <property name="visible">True</property>
91
+ <property name="can_focus">True</property>
92
+ <signal name="cursor-changed" handler="on_tvSources_cursor_changed" swapped="no"/>
93
+ <child internal-child="selection">
94
+ <object class="GtkTreeSelection" id="treeview-selection"/>
95
+ </child>
96
+ </object>
77
97
  </child>
78
98
  </object>
79
99
  </child>
@@ -9,6 +9,7 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
9
9
  @tv_sinks = Gtk3assist::Treeview.new(
10
10
  :tv => @ui["tvSinks"],
11
11
  :model => :liststore,
12
+ :sort_col => :name,
12
13
  :cols => [
13
14
  {:id => :id, :title => _("ID")},
14
15
  {:id => :name, :title => _("Name")}
@@ -20,7 +21,11 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
20
21
  @tv_sources = Gtk3assist::Treeview.new(
21
22
  :tv => @ui["tvSources"],
22
23
  :model => :liststore,
23
- :cols => [_("ID"), _("Name")]
24
+ :sort_col => :name,
25
+ :cols => [
26
+ {:id => :id, :title => _("ID")},
27
+ {:id => :name, :title => _("Name")}
28
+ ]
24
29
  )
25
30
  @ui["tvSources"].get_column(0).visible = false
26
31
  self.reload_sources
@@ -28,6 +33,10 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
28
33
  PulseAudio::Sink::Input.auto_redirect_new_inputs_to_default_sink
29
34
  PulseAudio::Source::Output.auto_redirect_new_outputs_to_default_source
30
35
 
36
+ events = PulseAudio::Events.instance
37
+ events.connect(:event => :remove, &self.method(:on_remove))
38
+ events.connect(:event => :new, &self.method(:on_new))
39
+
31
40
  @sicon = Gtk::StatusIcon.new
32
41
  @sicon.signal_connect("activate", &self.method(:on_sicon_activate))
33
42
  @sicon.signal_connect("popup-menu", &self.method(:on_sicon_popupmenu))
@@ -35,6 +44,42 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
35
44
  self.update_icon
36
45
  end
37
46
 
47
+ #Called when something is removed from PulseAudio. Removes items from the treeviews automatically.
48
+ def on_remove(args)
49
+ event, ele, ele_id = args[:args][:event].to_sym, args[:args][:element].to_s, args[:args][:element_id].to_i
50
+
51
+ if ele == "sink"
52
+ tv = @tv_sinks
53
+ elsif ele == "source"
54
+ tv = @tv_sources
55
+ else
56
+ return nil
57
+ end
58
+
59
+ tv.rows_remove do |data|
60
+ if data[:data][:id].to_i == ele_id
61
+ true
62
+ else
63
+ false
64
+ end
65
+ end
66
+ end
67
+
68
+ #Called when something is added to PulseAudio. Adds new items to the treeviews automatically.
69
+ def on_new(args)
70
+ event, ele, ele_id = args[:args][:event].to_sym, args[:args][:element].to_s, args[:args][:element_id].to_i
71
+
72
+ if ele == "sink"
73
+ sink = PulseAudio::Sink.by_id(ele_id.to_i)
74
+ self.add_sink(sink)
75
+ elsif ele == "source"
76
+ source = PulseAudio::Source.by_id(ele_id.to_i)
77
+ self.add_source(source)
78
+ else
79
+ return nil
80
+ end
81
+ end
82
+
38
83
  #Updates the statusicons icon based on the current sinks volume.
39
84
  def update_icon
40
85
  #Get the current active sink which should be manipulated.
@@ -88,11 +133,16 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
88
133
  Gtk.main_quit
89
134
  end
90
135
 
136
+ def add_sink(sink)
137
+ append_data = @tv_sinks.add_row(:data => {:id => sink.sink_id, :name => sink.args[:props]["description"]})
138
+ return append_data
139
+ end
140
+
91
141
  def reload_sinks
92
142
  @reloading = true
93
143
  @tv_sinks.model.clear
94
144
  PulseAudio::Sink.list do |sink|
95
- append_data = @tv_sinks.add_row(:data => {:id => sink.sink_id, :name => sink.args[:props]["description"]})
145
+ append_data = self.add_sink(sink)
96
146
 
97
147
  if sink.default?
98
148
  @ui["tvSinks"].selection.select_iter(append_data[:iter])
@@ -102,12 +152,17 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
102
152
  @reloading = false
103
153
  end
104
154
 
155
+ def add_source(source)
156
+ append_data = @tv_sources.add_row(:data => {:id => source.source_id, :name => source.args[:props]["description"]})
157
+ return append_data
158
+ end
159
+
105
160
  def reload_sources
106
161
  @reloading = true
107
162
 
108
163
  @tv_sources.model.clear
109
164
  PulseAudio::Source.list do |source|
110
- append_data = @tv_sources.add_row(:data => {:id => source.source_id, :name => source.args[:props]["description"]})
165
+ append_data = self.add_source(source)
111
166
 
112
167
  if source.default?
113
168
  @ui["tvSources"].selection.select_iter(append_data[:iter])
@@ -118,39 +173,48 @@ class PulseAudio::Gui::Choose_active_sink_gtk3
118
173
  end
119
174
 
120
175
  def on_tvSinks_cursor_changed(*args)
121
- return nil if @reloading or !@tv_sinks
122
- sel = @tv_sinks.sel
123
- return nil if !sel
124
-
125
- sink = nil
126
- PulseAudio::Sink.list do |sink_i|
127
- if sink_i.sink_id.to_i == sel[:data][:id].to_i
128
- sink = sink_i
129
- break
176
+ begin
177
+ return nil if @reloading or !@tv_sinks
178
+ sel = @tv_sinks.sel
179
+ return nil if !sel
180
+ puts sel
181
+
182
+ sink = nil
183
+ PulseAudio::Sink.list do |sink_i|
184
+ if sink_i.sink_id.to_i == sel[:data][:id].to_i
185
+ sink = sink_i
186
+ break
187
+ end
130
188
  end
189
+
190
+ raise "Could not find sink." if !sink
191
+ sink.default!
192
+ self.update_icon
193
+ rescue => e
194
+ Gtk3assist::Msgbox.error(e)
131
195
  end
132
-
133
- raise "Could not find sink." if !sink
134
- sink.default!
135
- self.update_icon
136
196
  end
137
197
 
138
198
  def on_tvSources_cursor_changed(*args)
139
- return nil if @reloading or !@tv_sources
140
- sel = @tv_sources.sel
141
- return nil if !sel
142
-
143
- source = nil
144
- PulseAudio::Source.list do |source_i|
145
- if source_i.source_id.to_i == sel[:data][:id].to_i
146
- source = source_i
147
- break
199
+ begin
200
+ return nil if @reloading or !@tv_sources
201
+ sel = @tv_sources.sel
202
+ return nil if !sel
203
+
204
+ source = nil
205
+ PulseAudio::Source.list do |source_i|
206
+ if source_i.source_id.to_i == sel[:data][:id].to_i
207
+ source = source_i
208
+ break
209
+ end
148
210
  end
211
+
212
+ raise "Could not find source." if !source
213
+ source.default!
214
+ self.update_icon
215
+ rescue => e
216
+ Gtk3assist::Msgbox.error(e)
149
217
  end
150
-
151
- raise "Could not find source." if !source
152
- source.default!
153
- self.update_icon
154
218
  end
155
219
 
156
220
  def on_window_delete_event(*args)
@@ -1,4 +1,4 @@
1
- #Subclass for gui elements.
1
+ #Subclass for GUI elements.
2
2
  class PulseAudio::Gui
3
3
  #Autoloader for subclasses.
4
4
  def self.const_missing(name)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pulseaudio"
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = "2012-09-19"
12
+ s.date = "2012-09-30"
13
13
  s.description = "Ruby-library for controlling PulseAudio via 'pactl'."
14
14
  s.email = "k@spernj.org"
15
15
  s.executables = ["pulseaudio_volume.rb"]
@@ -63,6 +63,7 @@ Gem::Specification.new do |s|
63
63
  s.add_runtime_dependency(%q<gir_ffi>, [">= 0"])
64
64
  s.add_runtime_dependency(%q<gtk3assist>, [">= 0"])
65
65
  s.add_runtime_dependency(%q<gettext>, [">= 0"])
66
+ s.add_runtime_dependency(%q<knjrbfw>, [">= 0"])
66
67
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
67
68
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
68
69
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
@@ -72,6 +73,7 @@ Gem::Specification.new do |s|
72
73
  s.add_dependency(%q<gir_ffi>, [">= 0"])
73
74
  s.add_dependency(%q<gtk3assist>, [">= 0"])
74
75
  s.add_dependency(%q<gettext>, [">= 0"])
76
+ s.add_dependency(%q<knjrbfw>, [">= 0"])
75
77
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
76
78
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
77
79
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
@@ -82,6 +84,7 @@ Gem::Specification.new do |s|
82
84
  s.add_dependency(%q<gir_ffi>, [">= 0"])
83
85
  s.add_dependency(%q<gtk3assist>, [">= 0"])
84
86
  s.add_dependency(%q<gettext>, [">= 0"])
87
+ s.add_dependency(%q<knjrbfw>, [">= 0"])
85
88
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
86
89
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
87
90
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
@@ -1,16 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- Dir.chdir(File.dirname(__FILE__))
4
- require "../lib/pulseaudio.rb"
3
+ require "#{File.realpath(File.dirname(__FILE__))}/../lib/pulseaudio.rb"
5
4
 
6
5
  require "rubygems"
7
6
  require "gir_ffi"
8
7
  require "gir_ffi-gtk3"
9
- require "/home/kaspernj/Dev/Ruby/Gems/knjrbfw/lib/knjrbfw.rb"
10
8
  require "gettext"
9
+
10
+ #Try to load development-version of 'knjrbfw'.
11
+ begin
12
+ require "#{File.realpath(File.dirname(__FILE__))}/../../knjrbfw/lib/knjrbfw.rb"
13
+ rescue LoadError
14
+ require "knjrbfw"
15
+ end
16
+
11
17
  Knj.gem_require(:Gtk3assist, "gtk3assist")
12
18
 
13
- Gtk3assist.enable_threadding
19
+ Gtk3assist::Threadding.enable_threadding
14
20
 
15
21
  def _(str)
16
22
  return GetText._(str)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: pulseaudio
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-09-19 00:00:00 Z
13
+ date: 2012-09-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: wref
@@ -57,8 +57,19 @@ dependencies:
57
57
  prerelease: false
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
60
- name: rspec
60
+ name: knjrbfw
61
61
  requirement: &id005 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ type: :runtime
68
+ prerelease: false
69
+ version_requirements: *id005
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: &id006 !ruby/object:Gem::Requirement
62
73
  none: false
63
74
  requirements:
64
75
  - - ~>
@@ -66,10 +77,10 @@ dependencies:
66
77
  version: 2.8.0
67
78
  type: :development
68
79
  prerelease: false
69
- version_requirements: *id005
80
+ version_requirements: *id006
70
81
  - !ruby/object:Gem::Dependency
71
82
  name: rdoc
72
- requirement: &id006 !ruby/object:Gem::Requirement
83
+ requirement: &id007 !ruby/object:Gem::Requirement
73
84
  none: false
74
85
  requirements:
75
86
  - - ~>
@@ -77,10 +88,10 @@ dependencies:
77
88
  version: "3.12"
78
89
  type: :development
79
90
  prerelease: false
80
- version_requirements: *id006
91
+ version_requirements: *id007
81
92
  - !ruby/object:Gem::Dependency
82
93
  name: bundler
83
- requirement: &id007 !ruby/object:Gem::Requirement
94
+ requirement: &id008 !ruby/object:Gem::Requirement
84
95
  none: false
85
96
  requirements:
86
97
  - - ">="
@@ -88,10 +99,10 @@ dependencies:
88
99
  version: 1.0.0
89
100
  type: :development
90
101
  prerelease: false
91
- version_requirements: *id007
102
+ version_requirements: *id008
92
103
  - !ruby/object:Gem::Dependency
93
104
  name: jeweler
94
- requirement: &id008 !ruby/object:Gem::Requirement
105
+ requirement: &id009 !ruby/object:Gem::Requirement
95
106
  none: false
96
107
  requirements:
97
108
  - - ~>
@@ -99,7 +110,7 @@ dependencies:
99
110
  version: 1.8.3
100
111
  type: :development
101
112
  prerelease: false
102
- version_requirements: *id008
113
+ version_requirements: *id009
103
114
  description: Ruby-library for controlling PulseAudio via 'pactl'.
104
115
  email: k@spernj.org
105
116
  executables:
@@ -153,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
164
  requirements:
154
165
  - - ">="
155
166
  - !ruby/object:Gem::Version
156
- hash: -2237121306229402843
167
+ hash: -1301824168619278043
157
168
  segments:
158
169
  - 0
159
170
  version: "0"