wnck 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1,6 @@
1
+ README.rdoc
2
+ Rakefile
3
+ lib/wnck.rb
4
+ spec/wnck_screen_spec.rb
5
+ spec/wnck_window_spec.rb
6
+ Manifest
@@ -0,0 +1,14 @@
1
+ = WNCK for Ruby
2
+
3
+ Use the GNOME Window Navigator Construction Kit library with Ruby.
4
+
5
+ == Install
6
+
7
+ gem install rezonant-wnck --source http://gems.github.com/
8
+
9
+
10
+ == Usage
11
+
12
+ This gem provides two classes Wnck::Screen and Wnck::Window which provide access to the
13
+ services of libwnck. Alternatively you may use the direct C-style bindings from the Wnck
14
+ module, such as Wnck::wnck_screen_get_default.
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('wnck', '0.1.0') do |p|
6
+ p.description = "Use the GNOME Window Navigator Construction Kit from Ruby"
7
+ p.url = "http://github.com/rezonant/wnck"
8
+ p.author = "William Lahti"
9
+ p.email = "wilahti@gmail.com"
10
+ p.ignore_pattern = ["tmp/*", "script/*", "*.bak", "*.swp", "*~"]
11
+ p.development_dependencies = []
12
+ p.runtime_dependencies = ["gtk2", "ffi"]
13
+ end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
@@ -0,0 +1,327 @@
1
+ #
2
+ # wnck for ruby
3
+ #
4
+ # Copyright © 2010 William Lahti
5
+ #
6
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ # of this software and associated documentation files (the "Software"), to deal
8
+ # in the Software without restriction, including without limitation the rights
9
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ # copies of the Software, and to permit persons to whom the Software is
11
+ # furnished to do so, subject to the following conditions:
12
+ #
13
+ # The above copyright notice and this permission notice shall be included in
14
+ # all copies or substantial portions of the Software.
15
+ #
16
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ # THE SOFTWARE.
23
+ #
24
+
25
+ #require 'rubygems'
26
+ require 'gtk2' # gtk initialization must be done or wnck functions segfault
27
+ require 'ffi'
28
+
29
+ module Wnck
30
+ module GLib
31
+ extend FFI::Library
32
+ ffi_lib "libglib-2.0.so"
33
+ attach_function :g_list_nth_data, [:pointer, :uint32], :pointer
34
+ attach_function :g_list_length, [:pointer], :uint
35
+ end
36
+
37
+ extend FFI::Library
38
+ ffi_lib "libwnck-1.so.22"
39
+
40
+
41
+ # Shortcuts for C types used by the API
42
+ ptr = :pointer; ul = :ulong; str = :string; bool = :bool; int = :int;
43
+ uint = :uint; void = :void; u32 = :uint32; u = :uint;
44
+
45
+ # Enumerations
46
+ module WindowState
47
+ %w{NORMAL DESKTOP DOCK DIALOG TOOLBAR MENU UTILITY SPLASHSCREEN
48
+ }.inject(0) { |value,state| 1 + eval("#{state} = value") }
49
+ end
50
+
51
+ module WindowActions
52
+ %w{MOVE RESIZE SHADE STICK MAXIMIZE_HORIZONTALLY MAXIMIZE_VERTICALLY CHANGE_WORKSPACE CLOSE UNMAXIMIZE_HORIZONTALLY
53
+ UNMAXIMIZE_VERTICALLY UNSHADE UNSTICK MINIMIZE UNMINIMIZE MAXIMIZE UNMAXIMIZE FULLSCREEN ABOVE BELOW
54
+ }.inject(1) { |value,state| (eval "#{state} = value") << 1 }
55
+ end
56
+
57
+ module WindowGravity
58
+ %w{CURRENT NORTHWEST NORTH NORTHEAST WEST CENTER EAST SOUTHWEST SOUTH SOUTHEAST STATIC
59
+ }.inject(0) { |value,state| 1 + (eval "#{state} = value") }
60
+ end
61
+
62
+ module WnckWindowMoveResizeMask
63
+ %w{CHANGE_X CHANGE_Y CHANGE_WIDTH CHANGE_HEIGHT
64
+ }.inject(1) { |value,state| (eval "#{state} = value") << 1 }
65
+ end
66
+
67
+ # class WnckScreen
68
+ attach_function :wnck_screen_get_default, [], ptr
69
+ attach_function :wnck_screen_get, [int], ptr
70
+ attach_function :wnck_screen_get_for_root, [ul], ptr
71
+ attach_function :wnck_screen_get_number, [ptr], int
72
+ attach_function :wnck_screen_get_width, [ptr], int
73
+ attach_function :wnck_screen_get_height, [ptr], int
74
+ attach_function :wnck_screen_force_update, [ptr], void
75
+ attach_function :wnck_screen_get_window_manager_name, [ptr], str
76
+ attach_function :wnck_screen_net_wm_supports, [ptr, str], bool
77
+ attach_function :wnck_screen_get_active_window, [ptr], ptr
78
+ attach_function :wnck_screen_get_previously_active_window, [ptr], ptr
79
+ attach_function :wnck_screen_get_windows, [ptr], ptr
80
+ attach_function :wnck_screen_get_windows_stacked, [ptr], ptr
81
+ attach_function :wnck_screen_get_active_workspace, [ptr], ptr
82
+ attach_function :wnck_screen_get_workspaces, [ptr], ptr
83
+ attach_function :wnck_screen_get_workspace, [ptr, int], ptr
84
+ attach_function :wnck_screen_get_workspace_index, [ptr, ptr], int
85
+ attach_function :wnck_screen_get_workspace_neighbor, [ptr, ptr, int], int
86
+ attach_function :wnck_screen_toggle_showing_desktop, [ptr, bool], void
87
+
88
+ # class WnckWindow
89
+ attach_function :wnck_window_get, [ul], ptr
90
+ attach_function :wnck_window_get_screen, [ptr], ptr
91
+ attach_function :wnck_window_has_name, [ptr], bool
92
+ attach_function :wnck_window_get_name, [ptr], str
93
+ attach_function :wnck_window_has_icon_name, [ptr], bool
94
+ attach_function :wnck_window_get_icon_name, [ptr], str
95
+ attach_function :wnck_window_get_icon_is_fallback, [ptr], bool
96
+ attach_function :wnck_window_get_icon, [ptr], ptr
97
+ attach_function :wnck_window_get_mini_icon, [ptr], ptr
98
+ attach_function :wnck_window_get_application, [ptr], ptr
99
+ attach_function :wnck_window_get_transient, [ptr], ptr
100
+ attach_function :wnck_window_get_group_leader, [ptr], ul
101
+ attach_function :wnck_window_get_xid, [ptr], ul
102
+ attach_function :wnck_window_get_class_group, [ptr], ptr
103
+ attach_function :wnck_window_get_session_id, [ptr], str
104
+ attach_function :wnck_window_get_session_id_utf8, [ptr], str
105
+ attach_function :wnck_window_get_pid, [ptr], int
106
+ attach_function :wnck_window_get_sort_order, [ptr], int
107
+ attach_function :wnck_window_set_sort_order, [ptr, int], void
108
+ attach_function :wnck_window_get_window_type, [ptr], int
109
+ attach_function :wnck_window_set_window_type, [ptr, int], void
110
+ attach_function :wnck_window_get_state, [ptr], int
111
+ attach_function :wnck_window_is_minimized, [ptr], bool
112
+ attach_function :wnck_window_is_maximized_horizontally, [ptr], bool
113
+ attach_function :wnck_window_is_maximized_vertically, [ptr], bool
114
+ attach_function :wnck_window_is_maximized, [ptr], bool
115
+ attach_function :wnck_window_is_shaded, [ptr], bool
116
+ attach_function :wnck_window_is_pinned, [ptr], bool
117
+ attach_function :wnck_window_is_sticky, [ptr], bool
118
+ attach_function :wnck_window_is_above, [ptr], bool
119
+ attach_function :wnck_window_is_below, [ptr], bool
120
+ attach_function :wnck_window_is_skip_pager, [ptr], bool
121
+ attach_function :wnck_window_is_skip_tasklist, [ptr], bool
122
+ attach_function :wnck_window_is_fullscreen, [ptr], bool
123
+ attach_function :wnck_window_needs_attention, [ptr], bool
124
+ attach_function :wnck_window_or_transient_needs_attention, [ptr], bool
125
+ attach_function :wnck_window_minimize, [ptr], void
126
+ attach_function :wnck_window_get_actions, [ptr], int
127
+ attach_function :wnck_window_maximize_horizontally, [ptr], void
128
+ attach_function :wnck_window_unminimize, [ptr, uint], void
129
+ attach_function :wnck_window_unmaximize_horizontally, [ptr], void
130
+ attach_function :wnck_window_maximize_vertically, [ptr], void
131
+ attach_function :wnck_window_unmaximize_vertically, [ptr], void
132
+ attach_function :wnck_window_maximize, [ptr], void
133
+ attach_function :wnck_window_unmaximize, [ptr], void
134
+ attach_function :wnck_window_shade, [ptr], void
135
+ attach_function :wnck_window_unshade, [ptr], void
136
+ attach_function :wnck_window_pin, [ptr], void
137
+ attach_function :wnck_window_unpin, [ptr], void
138
+ attach_function :wnck_window_stick, [ptr], void
139
+ attach_function :wnck_window_unstick, [ptr], void
140
+ attach_function :wnck_window_make_above, [ptr], void
141
+ attach_function :wnck_window_unmake_above, [ptr], void
142
+ attach_function :wnck_window_make_below, [ptr], void
143
+ attach_function :wnck_window_unmake_below, [ptr], void
144
+ attach_function :wnck_window_set_skip_pager, [ptr, bool], void
145
+ attach_function :wnck_window_set_skip_tasklist, [ptr, bool], void
146
+ attach_function :wnck_window_set_fullscreen, [ptr, bool], void
147
+ attach_function :wnck_window_close, [ptr, u32], void
148
+ attach_function :wnck_window_get_workspace, [ptr], ptr
149
+ attach_function :wnck_window_is_on_workspace, [ptr, ptr], bool
150
+
151
+ attach_function :wnck_window_is_visible_on_workspace, [ptr, ptr], bool
152
+ attach_function :wnck_window_move_to_workspace, [ptr, ptr], void
153
+ attach_function :wnck_window_is_in_viewport, [ptr, ptr], bool
154
+ attach_function :wnck_window_activate, [ptr, u32], void
155
+ attach_function :wnck_window_is_active, [ptr], bool
156
+ attach_function :wnck_window_is_most_recently_activated, [ptr], bool
157
+ attach_function :wnck_window_activate_transient, [ptr, u32], void
158
+ attach_function :wnck_window_transient_is_most_recently_activated, [ptr], bool
159
+ attach_function :wnck_window_set_icon_geometry, [ptr, int, int, int, int], void
160
+ attach_function :wnck_window_get_client_window_geometry, [ptr, ptr, ptr, ptr, ptr], void
161
+ attach_function :wnck_window_get_geometry, [ptr, ptr, ptr, ptr, ptr], void
162
+ attach_function :wnck_window_set_geometry, [ptr, int, int, int, int, int, int], void
163
+ attach_function :wnck_window_keyboard_move, [ptr], void
164
+ attach_function :wnck_window_keyboard_size, [ptr], void
165
+
166
+ class Screen
167
+ def initialize(handle)
168
+ @handle = handle
169
+ Wnck::wnck_screen_force_update handle
170
+ end
171
+
172
+ def self.new(handle)
173
+ return get(handle) if handle.kind_of? Integer
174
+ return nil if handle.null?
175
+ super handle
176
+ end
177
+
178
+ def self.default() Screen.new(Wnck::wnck_screen_get_default) end
179
+ def self.count() i = 0; i += 1 while get i; i end
180
+ def self.screens() (0 ... Screen.count).collect { |i| Screen.get(i) } end
181
+ def self.each(&b) screens.each &b end
182
+ def self.get(i)
183
+ h = Wnck::wnck_screen_get(i)
184
+ (h.null?) ? nil : Screen.new(h)
185
+ end
186
+
187
+ private
188
+ def self.add_accessor(method, native = "get_#{method}")
189
+ return method.each { |pair| add_accessor *pair } if method.kind_of? Hash
190
+ eval "define_method(method) { r = Wnck.send(:wnck_screen_#{native}, @handle); (yield self, r if block_given?) or r }"
191
+ end
192
+
193
+ def self.add_accessors(*names, &b)
194
+ names.each do |n|
195
+ ((n.kind_of?(Hash) and n.length > 1) ?
196
+ n.each { |pair| add_accessor *pair, &b } :
197
+ add_accessor(n, &b))
198
+ end
199
+ end
200
+
201
+ public
202
+ attr_reader :handle
203
+
204
+ def net_wm_supports?(atom) Wnck::wnck_screen_net_wm_supports(@handle, atom) end
205
+
206
+ add_accessors :width, :height, :number,
207
+ :force_update => 'force_update',
208
+ :name => 'get_window_manager_name',
209
+ :toggle_show_desktop => 'toggle_showing_desktop'
210
+
211
+ add_accessors(:active_window => 'get_active_window',
212
+ :previously_active_window => 'get_previously_active_window'
213
+ ) { |s,handle| Window.new s, handle }
214
+
215
+ # def force_update() Wnck::wnck_screen_force_update(@handle) end
216
+ # def width() Wnck::wnck_screen_get_width(@handle) end
217
+ # def height() Wnck::wnck_screen_get_height(@handle) end
218
+ # def number() Wnck::wnck_screen_get_number(@handle) end
219
+ # def name() Wnck::wnck_screen_get_window_manager_name(@handle) end
220
+ # def active_window() Window.new(self, Wnck::wnck_screen_get_active_window(@handle)) end
221
+ # def previously_active_window() Window.new(self, Wnck::wnck_screen_get_previously_active_window(@handle)) end
222
+ # def toggle_show_desktop() Wnck::wnck_screen_toggle_showing_desktop(@handle) end
223
+ def workspace_at(index) Workspace.new Wnck::wnck_screen_get_workspace(@handle, index) end
224
+ def workspace_index(ws) Wnck::wnck_screen_get_workspace_index(@handle, ws.handle) end
225
+
226
+ { :workspaces => proc { |s,d| Workspace.new s, d },
227
+ :windows => proc { |s,d| Window.new d },
228
+ }.each do |name, generator|
229
+ define_method(name) do
230
+ list = Wnck.send "wnck_screen_get_#{name}", @handle
231
+ items = []
232
+
233
+ GLib::g_list_length(list).times do |i|
234
+ items << (generator.call self, GLib::g_list_nth_data(list, i))
235
+ end
236
+
237
+ items
238
+ end
239
+ end
240
+ end
241
+
242
+ class Window
243
+ def initialize(handle)
244
+ screen = self.class.prepare_screen(Screen.new(Wnck::wnck_window_get_screen(handle)))
245
+ @screen = screen
246
+ @handle = handle
247
+ end
248
+
249
+ def self.new(handle)
250
+ return get(handle) if handle.kind_of? Integer
251
+ return nil if handle.null?
252
+ super handle
253
+ end
254
+
255
+ attr_reader :handle, :screen
256
+
257
+ private
258
+ def self.prepare_screen(scr) scr.kind_of?(Integer) ? Screen.get(scr) : scr end
259
+
260
+ public
261
+ def self.get(xid)
262
+ screen = prepare_screen(screen)
263
+ h = Wnck::wnck_window_get(xid)
264
+ return nil if h.null?
265
+ Window.new(h)
266
+ end
267
+
268
+ def maximize_horizontally() Wnck::wnck_window_maximize_horizontally(@handle) end
269
+ def unminimize() Wnck::wnck_window_unminimize(@handle) end
270
+ def unmaximize_horizontally() Wnck::wnck_window_unmaximize_horizontally(@handle) end
271
+ def maximize_vertically() Wnck::wnck_window_maximize_vertically(@handle) end
272
+ def unmaximize_vertically() Wnck::wnck_window_unmaximize_vertically(@handle) end
273
+ def maximize() Wnck::wnck_window_maximize(@handle) end
274
+ def unmaximize() Wnck::wnck_window_unmaximize(@handle) end
275
+ def shade() Wnck::wnck_window_shade(@handle) end
276
+ def unshade() Wnck::wnck_window_unshade(@handle) end
277
+ def pin() Wnck::wnck_window_pin(@handle) end
278
+ def unpin() Wnck::wnck_window_unpin(@handle) end
279
+ def stick() Wnck::wnck_window_stick(@handle) end
280
+ def unstick() Wnck::wnck_window_unstick(@handle) end
281
+ def make_above() Wnck::wnck_window_make_above(@handle) end
282
+ def unmake_above() Wnck::wnck_window_unmake_above(@handle) end
283
+ def unmake_below() Wnck::wnck_window_unmake_below(@handle) end
284
+ def make_below() Wnck::wnck_window_make_below(@handle) end
285
+ def close() Wnck::wnck_window_close(@handle) end
286
+ def minimize() Wnck::wnck_window_minimize(@handle) end
287
+ def maximize() Wnck::wnck_window_maximize(@handle) end
288
+ def unmaximize() Wnck::wnck_window_unmaximize(@handle) end
289
+ def unminimize(ts) Wnck::wnck_window_unminimize(@handle, ts) end
290
+
291
+ def actions() Wnck::wnck_window_get_actions(@handle) end
292
+ def name() Wnck::wnck_window_get_name(@handle) end
293
+ def icon_name() Wnck::wnck_window_get_name(@handle) end
294
+ def skip_pager=(v) Wnck::wnck_window_set_skip_pager(@handle, v) end
295
+ def skip_tasklist=(v) Wnck::wnck_window_set_skip_tasklist(@handle, v) end
296
+ def fullscreen=(v) Wnck::wnck_window_set_fullscreen(@handle, v) end
297
+
298
+ private
299
+ def self.add_accessor(name, custom_name = nil) # Add Window#method for Wnck::window_method()
300
+ custom_name = name unless name
301
+ define_method(custom_name) do
302
+ Wnck.send("wnck_window_#{name}", @handle)
303
+ end
304
+ end
305
+
306
+ def self.add_predicate(name) # Add Window#pred? for Wnck::window_is_pred()
307
+ name = name.to_s
308
+ add_accessor "is_#{name[0,name.length - 1]}", name
309
+ end
310
+ public
311
+
312
+ add_accessor :has_name, :has_name?
313
+ add_accessor :has_icon_name, :has_icon_name?
314
+ add_predicate :minimized?
315
+ add_predicate :maximized?
316
+ add_predicate :maximized_horizontally?
317
+ add_predicate :maximized_vertically?
318
+ add_predicate :shaded?
319
+ add_predicate :above?
320
+ add_predicate :pinned?
321
+ add_predicate :skip_pager?
322
+ add_predicate :skip_tasklist?
323
+ add_predicate :fullscreen?
324
+ add_predicate :sticky?
325
+ add_predicate :below?
326
+ end
327
+ end
@@ -0,0 +1,100 @@
1
+ require ::File.dirname(__FILE__) + '/../lib/wnck.rb'
2
+ require 'ostruct'
3
+
4
+ # NOTE: Run these from an environment with DISPLAY set to a valid, listening X11 server!
5
+
6
+ describe Wnck do
7
+ def self.it_wraps(method, pred = {})
8
+ it "wraps #{method}" do
9
+ Wnck.should respond_to method
10
+ end
11
+ end
12
+
13
+ it_wraps "wnck_screen_get_default"
14
+ it_wraps "wnck_screen_get"
15
+ it_wraps "wnck_screen_get_windows"
16
+ end
17
+
18
+ describe Wnck::Screen do
19
+ it "can retrieve the default screen" do
20
+ screen = Wnck::Screen.default
21
+ screen.should be_a_kind_of Wnck::Screen
22
+ end
23
+
24
+ it "knows how many screens there are" do
25
+ Wnck::Screen.count.should be_a Numeric
26
+ end
27
+
28
+ it "gives a realistic number for screen count" do
29
+ Wnck::Screen.count.should > 0
30
+ end
31
+
32
+ it "can retrieve screens by index" do
33
+ Wnck::Screen.count.times { |i| Wnck::Screen.get(i).should be_a Wnck::Screen }
34
+ end
35
+
36
+ end
37
+
38
+ describe Wnck::Screen do
39
+ before(:each) do
40
+ @screen = Wnck::Screen.default
41
+ end
42
+
43
+ it "knows its own height" do
44
+ @screen.height.should be_a_kind_of Numeric
45
+ end
46
+
47
+ it "knows its own width" do
48
+ @screen.width.should be_a_kind_of Numeric
49
+ end
50
+
51
+ it "knows the name given to it by the window manager" do
52
+ @screen.name
53
+ end
54
+
55
+ it "gives a reasonable width for the default screen" do
56
+ @screen.width.should >= 320
57
+ @screen.width.should < 250000
58
+ end
59
+
60
+ it "gives a reasonable height for the default screen" do
61
+ @screen.height.should >= 240
62
+ @screen.height.should < 250000
63
+ end
64
+
65
+ it "provides toggle_show_desktop" do
66
+ @screen.should respond_to :toggle_show_desktop
67
+ end
68
+
69
+ it "can provide the active window" do
70
+ @screen.should respond_to :active_window
71
+ @screen.active_window
72
+ end
73
+
74
+ it "can provide the previously active window" do
75
+ @screen.should respond_to :previously_active_window
76
+ @screen.previously_active_window
77
+ end
78
+
79
+ it "can list its windows" do
80
+ windows = @screen.windows
81
+ windows.should be_true
82
+ windows.should respond_to :each
83
+ end
84
+
85
+ it "gives a realistic number of total windows amongst all screens" do
86
+ total = 0
87
+ Wnck::Screen.count.times { |i| total += Wnck::Screen.get(i).windows.length }
88
+ total.should > 1
89
+ end
90
+
91
+ it "can query the window manager for supported features" do
92
+ @screen.should respond_to :net_wm_supports?
93
+ @screen.net_wm_supports? "_NET_WM_STATE_STICKY"
94
+ end
95
+
96
+ it "can force the list of windows to be updated." do
97
+ @screen.should respond_to :force_update
98
+ @screen.force_update
99
+ end
100
+ end
@@ -0,0 +1,170 @@
1
+ require ::File.dirname(__FILE__) + '/../lib/wnck.rb'
2
+
3
+ describe Wnck::Window do
4
+ before(:all) do
5
+ Gtk.init
6
+ gw = Gtk::Window.new
7
+ gw.title = "WnckTestWindow"
8
+ gw.realize
9
+ gw.present
10
+
11
+ 10.times { Gtk.main_iteration; Wnck::Screen.default.force_update; sleep 1 }
12
+ @window = Wnck::Window.new(gw.window.xid)
13
+
14
+ raise Exception.new "Could not find test window!" unless @window
15
+ end
16
+
17
+ def self.it_has_predicate(p)
18
+ it "knows if it's #{p.to_s.gsub('_', ' ')}" do
19
+ @window.should respond_to p
20
+ @window.send p
21
+ end
22
+ end
23
+
24
+ it_has_predicate :minimized?
25
+ it_has_predicate :maximized?
26
+ it_has_predicate :maximized_horizontally?
27
+ it_has_predicate :maximized_vertically?
28
+ it_has_predicate :shaded?
29
+ it_has_predicate :above?
30
+ it_has_predicate :pinned?
31
+ it_has_predicate :skip_pager?
32
+ it_has_predicate :skip_tasklist?
33
+ it_has_predicate :fullscreen?
34
+ it_has_predicate :sticky?
35
+ it_has_predicate :below?
36
+ it_has_predicate :has_name?
37
+ it_has_predicate :has_icon_name?
38
+
39
+ it "can horizontally maximize itself" do
40
+ @window.should respond_to :maximize_horizontally
41
+ @window.maximize_horizontally
42
+ end
43
+
44
+ it "can unminimize itself" do
45
+ @window.should respond_to :unminimize
46
+ @window.unminimize Gtk.current_event_time
47
+ end
48
+
49
+ it "can horizontally unmaximize itself" do
50
+ @window.should respond_to :unmaximize_horizontally
51
+ @window.unmaximize_horizontally
52
+ end
53
+
54
+ it "can vertically maximize itself" do
55
+ @window.should respond_to :maximize_vertically
56
+ @window.maximize_vertically
57
+ end
58
+
59
+ it "can vertically unmaximize itself" do
60
+ @window.should respond_to :unmaximize_vertically
61
+ @window.unmaximize_vertically
62
+ end
63
+
64
+ it "can maximize itself" do
65
+ @window.should respond_to :maximize
66
+ @window.maximize
67
+ end
68
+
69
+ it "can unmaximize itself" do
70
+ @window.should respond_to :unmaximize
71
+ @window.unmaximize
72
+ end
73
+
74
+ it "can shade itself" do
75
+ @window.should respond_to :shade
76
+ @window.shade
77
+ end
78
+
79
+ it "can unshade itself" do
80
+ @window.should respond_to :unshade
81
+ @window.unshade
82
+ end
83
+
84
+ it "can pin itself" do
85
+ @window.should respond_to :pin
86
+ @window.pin
87
+ end
88
+
89
+ it "can unpin itself" do
90
+ @window.should respond_to :unpin
91
+ @window.unpin
92
+ end
93
+
94
+ it "can stick itself" do
95
+ @window.should respond_to :stick
96
+ @window.stick
97
+ end
98
+
99
+ it "can unstick itself" do
100
+ @window.should respond_to :unstick
101
+ @window.unstick
102
+ end
103
+
104
+ it "can put itself above other windows" do
105
+ @window.should respond_to :make_above
106
+ @window.make_above
107
+ end
108
+
109
+ it "can stop itself from being above other windows" do
110
+ @window.should respond_to :unmake_above
111
+ @window.unmake_above
112
+ end
113
+
114
+ it "can stop itself from being below other windows" do
115
+ @window.should respond_to :unmake_below
116
+ @window.unmake_below
117
+ end
118
+
119
+ it "can put itself below other windows" do
120
+ @window.should respond_to :make_below
121
+ @window.make_below
122
+ end
123
+
124
+ it "can close itself" do
125
+ @window.should respond_to :close
126
+ #@window.close # this really doesn't seem like a nice thing to do to testers...
127
+ end
128
+
129
+ it "can minimize itself" do
130
+ @window.should respond_to :minimize
131
+ @window.minimize
132
+ end
133
+
134
+ it "can maximize itself" do
135
+ @window.should respond_to :maximize
136
+ @window.maximize
137
+ end
138
+
139
+ it "can unmaximize itself" do
140
+ @window.should respond_to :unmaximize
141
+ @window.unmaximize
142
+ end
143
+
144
+ it "can minimize itself" do
145
+ @window.should respond_to :minimize
146
+ @window.minimize
147
+ end
148
+
149
+ it "knows its icon name" do
150
+ @window.should respond_to :icon_name
151
+ @window.icon_name.should be_an_instance_of String
152
+ end
153
+
154
+ it "knows its name" do
155
+ @window.should respond_to :name
156
+ @window.name.should be_an_instance_of String
157
+ end
158
+
159
+ it "can maximize and unmaximize a window" do
160
+ @window.should respond_to :maximize
161
+ @window.should respond_to :unmaximize
162
+ if @window.maximized? # Might as well try not to screw up the tester's desktop too badly :-)
163
+ @window.unmaximize
164
+ @window.maximize
165
+ else
166
+ @window.maximize
167
+ @window.unmaximize
168
+ end
169
+ end
170
+ end
@@ -0,0 +1,38 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{wnck}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["William Lahti"]
9
+ s.cert_chain = ["/home/liam/.gemcert/gem-public_cert.pem"]
10
+ s.date = %q{2010-11-02}
11
+ s.description = %q{Use the GNOME Window Navigator Construction Kit from Ruby}
12
+ s.email = %q{wilahti@gmail.com}
13
+ s.extra_rdoc_files = ["README.rdoc", "lib/wnck.rb"]
14
+ s.files = ["README.rdoc", "Rakefile", "lib/wnck.rb", "spec/wnck_screen_spec.rb", "spec/wnck_window_spec.rb", "Manifest", "wnck.gemspec"]
15
+ s.homepage = %q{http://github.com/rezonant/wnck}
16
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Wnck", "--main", "README.rdoc"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{wnck}
19
+ s.rubygems_version = %q{1.3.5}
20
+ s.signing_key = %q{/home/liam/.gemcert/gem-private_key.pem}
21
+ s.summary = %q{Use the GNOME Window Navigator Construction Kit from Ruby}
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<gtk2>, [">= 0"])
29
+ s.add_runtime_dependency(%q<ffi>, [">= 0"])
30
+ else
31
+ s.add_dependency(%q<gtk2>, [">= 0"])
32
+ s.add_dependency(%q<ffi>, [">= 0"])
33
+ end
34
+ else
35
+ s.add_dependency(%q<gtk2>, [">= 0"])
36
+ s.add_dependency(%q<ffi>, [">= 0"])
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wnck
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - William Lahti
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIDMDCCAhigAwIBAgIBADANBgkqhkiG9w0BAQUFADA+MRAwDgYDVQQDDAd3aWxh
20
+ aHRpMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
21
+ HhcNMTAxMTAxMTQ0MzQ5WhcNMTExMTAxMTQ0MzQ5WjA+MRAwDgYDVQQDDAd3aWxh
22
+ aHRpMRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/IsZAEZFgNjb20w
23
+ ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDVnqmTO3Nluq+BOeFWZivA
24
+ B6nEQD9IR8uuAAib1s16fmxpxh72kyvvriqeMUcr+d3efY/lMQKEzq4s/4gbYVkX
25
+ y/ijfsXuYo4O3gIP/Jz8sjZ0U1X9OR5QsT8piCDjWtvAVbHZcwtQ4JJkBcGCbeHG
26
+ jb9YllCyYpyoLTPe/PsRiyep+O4niZu22e9StWqR94DqBe2WT7BHIM5yGWL5yn2F
27
+ d/tly9IG3UjZsTfmm//E5/j1o65JPnVzvPIsXKtrlSagQhYc7inS5h3lpPybZCOW
28
+ 4ynsCpSwZuFTWKXLpImJB8+cYJnkpCAByLZlV2Gg3VXNY0K2IVxot4pK2emgn7IR
29
+ AgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQWBBRLrs/u
30
+ JL88+1zz4lVD9fTBYjrmmTANBgkqhkiG9w0BAQUFAAOCAQEAPgvQyOGqq+4Lw7wR
31
+ XCoYp5MwjEmjv+2lmYEvrLwkzzQYcR2IPKFVn2wxK2Oh/RY1MbH4+b9qZh90hwfp
32
+ Jrr01B4C4IK/WirWWjlfu3Cfe0SGWRNn4BDjfBPC6/cA0AqT6AUBXNXPDvxL/Jua
33
+ hYOr19fk7sVbqPErUDE4uOUu7U3cH4xXipD47ZqlAnd1/uuSd8HQJUpdo451bo4Z
34
+ iaE1u3oCobV/iRFncxRGWBTjxyzXif+SXm9YOHaq6XxyFIu+uhNojKzeqBA9TdmM
35
+ z+kqh3j5Vvja8aeb1n8eRFf92wc8Pyt0oNKtIpM21d6z8RxlC2JpdpTWCWHlVu28
36
+ uUq8NQ==
37
+ -----END CERTIFICATE-----
38
+
39
+ date: 2010-11-02 00:00:00 -04:00
40
+ default_executable:
41
+ dependencies:
42
+ - !ruby/object:Gem::Dependency
43
+ name: gtk2
44
+ prerelease: false
45
+ requirement: &id001 !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ type: :runtime
55
+ version_requirements: *id001
56
+ - !ruby/object:Gem::Dependency
57
+ name: ffi
58
+ prerelease: false
59
+ requirement: &id002 !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 3
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ type: :runtime
69
+ version_requirements: *id002
70
+ description: Use the GNOME Window Navigator Construction Kit from Ruby
71
+ email: wilahti@gmail.com
72
+ executables: []
73
+
74
+ extensions: []
75
+
76
+ extra_rdoc_files:
77
+ - README.rdoc
78
+ - lib/wnck.rb
79
+ files:
80
+ - README.rdoc
81
+ - Rakefile
82
+ - lib/wnck.rb
83
+ - spec/wnck_screen_spec.rb
84
+ - spec/wnck_window_spec.rb
85
+ - Manifest
86
+ - wnck.gemspec
87
+ has_rdoc: true
88
+ homepage: http://github.com/rezonant/wnck
89
+ licenses: []
90
+
91
+ post_install_message:
92
+ rdoc_options:
93
+ - --line-numbers
94
+ - --inline-source
95
+ - --title
96
+ - Wnck
97
+ - --main
98
+ - README.rdoc
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
109
+ version: "0"
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ hash: 11
116
+ segments:
117
+ - 1
118
+ - 2
119
+ version: "1.2"
120
+ requirements: []
121
+
122
+ rubyforge_project: wnck
123
+ rubygems_version: 1.3.7
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: Use the GNOME Window Navigator Construction Kit from Ruby
127
+ test_files: []
128
+
Binary file