gtk3 1.2.6 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +17 -15
- data/ext/gtk3/rbgtk-tree-model.c +12 -0
- data/lib/gtk3/base.rb +1 -1
- data/sample/gtk-demo/appwindow.rb +2 -2
- data/sample/gtk-demo/button_box.rb +35 -36
- data/sample/gtk-demo/cairo-operator.rb +2 -2
- data/sample/gtk-demo/changedisplay.rb +138 -139
- data/sample/gtk-demo/clipboard.rb +13 -18
- data/sample/gtk-demo/colorsel.rb +3 -3
- data/sample/gtk-demo/common.rb +1 -1
- data/sample/gtk-demo/dialog.rb +13 -13
- data/sample/gtk-demo/drawingarea.rb +6 -6
- data/sample/gtk-demo/editable_cells.rb +8 -7
- data/sample/gtk-demo/entry_completion.rb +3 -3
- data/sample/gtk-demo/expander.rb +10 -8
- data/sample/gtk-demo/hypertext.rb +4 -4
- data/sample/gtk-demo/iconview.rb +31 -30
- data/sample/gtk-demo/images.rb +10 -10
- data/sample/gtk-demo/infobar.rb +78 -0
- data/sample/gtk-demo/item_factory.rb +4 -4
- data/sample/gtk-demo/links.rb +53 -0
- data/sample/gtk-demo/list_store.rb +3 -3
- data/sample/gtk-demo/main.rb +23 -21
- data/sample/gtk-demo/menus.rb +6 -6
- data/sample/gtk-demo/panes.rb +6 -6
- data/sample/gtk-demo/sizegroup.rb +4 -4
- data/sample/gtk-demo/spinner.rb +59 -0
- data/sample/gtk-demo/stock_browser.rb +10 -10
- data/sample/gtk-demo/textview.rb +10 -10
- data/sample/gtk-demo/tree_store.rb +4 -4
- metadata +17 -14
data/Rakefile
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
# -*- ruby -*-
|
2
2
|
|
3
3
|
$LOAD_PATH.unshift("./../glib2/lib")
|
4
|
-
require 'gnome2-
|
4
|
+
require 'gnome2/rake/package-task'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
6
|
+
package_task = GNOME2::Rake::PackageTask.new do |package|
|
7
|
+
package.summary = "Ruby/GTK3 is a Ruby binding of GTK+-3.x."
|
8
|
+
package.description = "Ruby/GTK3 is a Ruby binding of GTK+-3.x."
|
9
|
+
package.dependency.gem.runtime = [
|
10
|
+
"glib2",
|
11
|
+
"gio2",
|
12
|
+
"atk",
|
13
|
+
"pango",
|
14
|
+
"gdk_pixbuf2",
|
15
|
+
"gdk3",
|
16
|
+
]
|
17
|
+
package.windows.packages = []
|
18
|
+
package.windows.dependencies = []
|
19
|
+
package.required_ruby_version = ">= 1.9.2"
|
20
|
+
package.post_install_message = "This library is experimental."
|
19
21
|
end
|
20
|
-
|
22
|
+
package_task.define
|
data/ext/gtk3/rbgtk-tree-model.c
CHANGED
@@ -83,6 +83,17 @@ rg_get_iter(VALUE self, VALUE path)
|
|
83
83
|
return val;
|
84
84
|
}
|
85
85
|
|
86
|
+
static VALUE
|
87
|
+
rg_get_path(VALUE self, VALUE iter)
|
88
|
+
{
|
89
|
+
GtkTreePath *path;
|
90
|
+
VALUE rb_path;
|
91
|
+
path = gtk_tree_model_get_path(_SELF(self), RVAL2GTKTREEITER(iter));
|
92
|
+
rb_path = GTKTREEPATH2RVAL(path);
|
93
|
+
gtk_tree_path_free(path);
|
94
|
+
return rb_path;
|
95
|
+
}
|
96
|
+
|
86
97
|
static VALUE
|
87
98
|
rg_get_value(VALUE self, VALUE iter, VALUE column)
|
88
99
|
{
|
@@ -216,6 +227,7 @@ Init_gtk_treemodel(VALUE mGtk)
|
|
216
227
|
RG_DEF_METHOD(get_column_type, 1);
|
217
228
|
RG_DEF_METHOD(iter_first, 0);
|
218
229
|
RG_DEF_METHOD(get_iter, 1);
|
230
|
+
RG_DEF_METHOD(get_path, 1);
|
219
231
|
RG_DEF_METHOD(get_value, 2);
|
220
232
|
RG_DEF_METHOD(each, 0);
|
221
233
|
RG_DEF_METHOD(row_changed, 2);
|
data/lib/gtk3/base.rb
CHANGED
@@ -10,7 +10,7 @@ require 'gdk3'
|
|
10
10
|
base_dir = Pathname.new(__FILE__).dirname.dirname.dirname.expand_path
|
11
11
|
vendor_dir = base_dir + "vendor" + "local"
|
12
12
|
vendor_bin_dir = vendor_dir + "bin"
|
13
|
-
GLib.
|
13
|
+
GLib.prepend_dll_path(vendor_bin_dir)
|
14
14
|
begin
|
15
15
|
major, minor, _ = RUBY_VERSION.split(/\./)
|
16
16
|
require "#{major}.#{minor}/gtk3.so"
|
@@ -111,8 +111,8 @@ module Demo
|
|
111
111
|
|
112
112
|
## Create document
|
113
113
|
sw = Gtk::ScrolledWindow.new
|
114
|
-
sw.set_policy(
|
115
|
-
sw.shadow_type =
|
114
|
+
sw.set_policy(:automatic, :automatic)
|
115
|
+
sw.shadow_type = :in
|
116
116
|
table.attach(sw,
|
117
117
|
# X direction # Y direction
|
118
118
|
0, 1, 2, 3,
|
@@ -15,57 +15,56 @@ module Demo
|
|
15
15
|
super('Button Boxes')
|
16
16
|
set_border_width(10)
|
17
17
|
|
18
|
-
main_vbox = Gtk::
|
18
|
+
main_vbox = Gtk::Box.new(:vertical)
|
19
19
|
add(main_vbox)
|
20
20
|
|
21
21
|
frame_horiz = Gtk::Frame.new('Horizontal Button Boxes')
|
22
|
-
main_vbox.pack_start(frame_horiz, true, true, 10)
|
22
|
+
main_vbox.pack_start(frame_horiz, :expand => true, :fill => true, :padding => 10)
|
23
23
|
|
24
|
-
vbox = Gtk::
|
24
|
+
vbox = Gtk::Box.new(:vertical)
|
25
25
|
vbox.set_border_width(10)
|
26
26
|
frame_horiz.add(vbox)
|
27
27
|
|
28
|
-
vbox.pack_start(create_bbox(true, 'Spread', 40,
|
29
|
-
|
30
|
-
|
31
|
-
vbox.pack_start(create_bbox(true, 'Edge', 40,
|
32
|
-
|
33
|
-
|
34
|
-
vbox.pack_start(create_bbox(true, 'Start', 40,
|
35
|
-
|
36
|
-
|
37
|
-
vbox.pack_start(create_bbox(true, 'End', 40,
|
38
|
-
|
39
|
-
|
28
|
+
vbox.pack_start(create_bbox(true, 'Spread', 40, :spread),
|
29
|
+
:expand => true, :fill => true, :padding => 0)
|
30
|
+
|
31
|
+
vbox.pack_start(create_bbox(true, 'Edge', 40, :edge),
|
32
|
+
:expand => true, :fill => true, :padding => 5)
|
33
|
+
|
34
|
+
vbox.pack_start(create_bbox(true, 'Start', 40, :start),
|
35
|
+
:expand => true, :fill => true, :padding => 5)
|
36
|
+
|
37
|
+
vbox.pack_start(create_bbox(true, 'End', 40, :end),
|
38
|
+
:expand => true, :fill => true, :padding => 5)
|
39
|
+
|
40
40
|
frame_vert = Gtk::Frame.new('Vertical Button Boxes')
|
41
|
-
main_vbox.pack_start(frame_vert, true, true, 10)
|
41
|
+
main_vbox.pack_start(frame_vert, :expand => true, :fill => true, :padding => 10)
|
42
42
|
|
43
|
-
|
43
|
+
hbox = Gtk::Box.new(:horizontal, 0)
|
44
44
|
hbox.set_border_width(10)
|
45
45
|
frame_vert.add(hbox)
|
46
46
|
|
47
|
-
hbox.pack_start(create_bbox(false, 'Spread', 30,
|
48
|
-
|
49
|
-
|
50
|
-
hbox.pack_start(create_bbox(false, 'Edge', 30,
|
51
|
-
|
52
|
-
|
53
|
-
hbox.pack_start(create_bbox(false, 'Start', 30,
|
54
|
-
|
55
|
-
|
56
|
-
hbox.pack_start(create_bbox(false, 'End', 30,
|
57
|
-
|
58
|
-
|
47
|
+
hbox.pack_start(create_bbox(false, 'Spread', 30, :spread),
|
48
|
+
:expand => true, :fill => true, :padding => 0)
|
49
|
+
|
50
|
+
hbox.pack_start(create_bbox(false, 'Edge', 30, :edge),
|
51
|
+
:expand => true, :fill => true, :padding => 5)
|
52
|
+
|
53
|
+
hbox.pack_start(create_bbox(false, 'Start', 30, :start),
|
54
|
+
:expand => true, :fill => true, :padding => 5)
|
55
|
+
|
56
|
+
hbox.pack_start(create_bbox(false, 'End', 30, :end),
|
57
|
+
:expand => true, :fill => true, :padding => 5)
|
59
58
|
end
|
60
59
|
|
61
60
|
def create_bbox(horizontal, title, spacing, layout)
|
62
61
|
frame = Gtk::Frame.new(title)
|
63
|
-
|
62
|
+
|
64
63
|
bbox = if horizontal
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
Gtk::ButtonBox.new(:horizontal)
|
65
|
+
else
|
66
|
+
Gtk::ButtonBox.new(:vertical)
|
67
|
+
end
|
69
68
|
|
70
69
|
bbox.set_border_width(5)
|
71
70
|
frame.add(bbox)
|
@@ -74,8 +73,8 @@ module Demo
|
|
74
73
|
bbox.set_spacing(spacing)
|
75
74
|
|
76
75
|
[Gtk::Stock::OK, Gtk::Stock::CANCEL, Gtk::Stock::HELP].each do |stock|
|
77
|
-
|
78
|
-
|
76
|
+
button = Gtk::Button.new(:stock_id => stock)
|
77
|
+
bbox.add(button)
|
79
78
|
end
|
80
79
|
|
81
80
|
return frame
|
@@ -32,8 +32,8 @@ module Demo
|
|
32
32
|
remove(@drawing_area)
|
33
33
|
|
34
34
|
vbox = Gtk::VBox.new
|
35
|
-
vbox.pack_start(@drawing_area, true, true)
|
36
|
-
vbox.pack_start(operator_selector, false, false)
|
35
|
+
vbox.pack_start(@drawing_area, :expand => true, :fill => true)
|
36
|
+
vbox.pack_start(operator_selector, :expand => false, :fill => false)
|
37
37
|
add(vbox)
|
38
38
|
end
|
39
39
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
1
3
|
# Copyright (c) 2003-2005 Ruby-GNOME2 Project Team
|
2
4
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
5
|
#
|
@@ -54,45 +56,35 @@ module Demo
|
|
54
56
|
@current_display = nil
|
55
57
|
@current_screen = nil
|
56
58
|
|
57
|
-
super(
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
super(
|
60
|
+
:title => 'Change Screen or display',
|
61
|
+
:buttons => [
|
62
|
+
[:close, :close],
|
63
|
+
['Change', :ok]
|
64
|
+
]
|
65
|
+
)
|
62
66
|
|
63
67
|
set_default_size(300, 400)
|
64
68
|
signal_connect('response') do |dialog, response_id|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
else
|
72
|
-
destroy # Gtk.main_quit?
|
73
|
-
end
|
74
|
-
end
|
75
|
-
signal_connect('destroy') do
|
76
|
-
|
77
|
-
end
|
78
|
-
|
79
|
-
unless Gtk.check_version?(2, 2, 0)
|
80
|
-
vbox.add(Gtk::Label.new("This sample requires GTK+ 2.2.0 or later"))
|
81
|
-
return
|
69
|
+
if response_id == Gtk::ResponseType::OK
|
70
|
+
query_change_display
|
71
|
+
else
|
72
|
+
destroy
|
73
|
+
end
|
82
74
|
end
|
83
75
|
|
84
|
-
vbox = Gtk::
|
76
|
+
vbox = Gtk::Box.new(:vertical, 5)
|
85
77
|
vbox.set_border_width(8)
|
86
78
|
|
87
|
-
self.
|
79
|
+
self.child.pack_start(vbox, :expand => true, :fill => true)
|
88
80
|
|
89
|
-
@size_group = Gtk::SizeGroup.new(
|
81
|
+
@size_group = Gtk::SizeGroup.new(:horizontal)
|
90
82
|
|
91
83
|
frame = create_display_frame
|
92
|
-
vbox.pack_start(frame, true, true)
|
84
|
+
vbox.pack_start(frame, :expand => true, :fill => true)
|
93
85
|
|
94
86
|
frame = create_screen_frame
|
95
|
-
vbox.pack_start(frame, true, true)
|
87
|
+
vbox.pack_start(frame, :expand => true, :fill => true)
|
96
88
|
|
97
89
|
initialize_displays
|
98
90
|
end
|
@@ -104,14 +96,14 @@ module Demo
|
|
104
96
|
manager = Gdk::DisplayManager.get
|
105
97
|
|
106
98
|
manager.displays.each do |display|
|
107
|
-
|
99
|
+
add_display(display)
|
108
100
|
end
|
109
101
|
|
110
102
|
handler_id = manager.signal_connect('display_opened') do |display|
|
111
|
-
|
103
|
+
add_display(display)
|
112
104
|
end
|
113
105
|
signal_connect('destroy') do
|
114
|
-
|
106
|
+
manager.signal_handler_disconnect(handler_id)
|
115
107
|
end
|
116
108
|
end
|
117
109
|
|
@@ -120,17 +112,17 @@ module Demo
|
|
120
112
|
@screen_model.clear
|
121
113
|
|
122
114
|
if @current_display
|
123
|
-
|
115
|
+
n_screens = @current_display.n_screens
|
124
116
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
117
|
+
n_screens.times do |i|
|
118
|
+
iter = @screen_model.append
|
119
|
+
iter.set_value(SCREEN_COLUMN_NUMBER, i)
|
120
|
+
iter.set_value(SCREEN_COLUMN_SCREEN, @current_display.get_screen(i))
|
129
121
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
122
|
+
if i == 0
|
123
|
+
@screen_selection.select_iter(iter)
|
124
|
+
end
|
125
|
+
end
|
134
126
|
end
|
135
127
|
end
|
136
128
|
|
@@ -138,31 +130,31 @@ module Demo
|
|
138
130
|
def create_display_frame
|
139
131
|
frame, tree_view, button_vbox = create_frame('Display')
|
140
132
|
|
141
|
-
button = left_align_button_new('_Open
|
133
|
+
button = left_align_button_new('_Open…')
|
142
134
|
button.signal_connect('clicked') do
|
143
|
-
|
135
|
+
open_display_cb
|
144
136
|
end
|
145
|
-
button_vbox.pack_start(button, false, false, 0)
|
137
|
+
button_vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
146
138
|
|
147
139
|
button = left_align_button_new('_Close')
|
148
140
|
button.signal_connect('clicked') do
|
149
|
-
|
150
|
-
|
151
|
-
|
141
|
+
if @current_display
|
142
|
+
@current_display.close
|
143
|
+
end
|
152
144
|
end
|
153
|
-
button_vbox.pack_start(button, false, false, 0)
|
145
|
+
button_vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
154
146
|
|
155
147
|
@display_model = Gtk::ListStore.new(String, Gdk::Display)
|
156
148
|
tree_view.model = @display_model
|
157
149
|
|
158
150
|
column = Gtk::TreeViewColumn.new('Name',
|
159
|
-
|
160
|
-
|
151
|
+
Gtk::CellRendererText.new,
|
152
|
+
{'text' => DISPLAY_COLUMN_NAME})
|
161
153
|
tree_view.append_column(column)
|
162
154
|
|
163
155
|
selection = tree_view.selection
|
164
156
|
selection.signal_connect('changed') do
|
165
|
-
|
157
|
+
display_changed_cb(selection)
|
166
158
|
end
|
167
159
|
|
168
160
|
return frame
|
@@ -176,17 +168,17 @@ module Demo
|
|
176
168
|
tree_view.model = @screen_model
|
177
169
|
|
178
170
|
column = Gtk::TreeViewColumn.new('Number',
|
179
|
-
|
180
|
-
|
171
|
+
Gtk::CellRendererText.new,
|
172
|
+
{'text' => SCREEN_COLUMN_NUMBER})
|
181
173
|
tree_view.append_column(column)
|
182
174
|
|
183
175
|
@screen_selection = tree_view.selection
|
184
176
|
@screen_selection.signal_connect('changed') do |selection|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
177
|
+
@current_screen = if iter = selection.selected
|
178
|
+
iter.get_value(SCREEN_COLUMN_SCREEN)
|
179
|
+
else
|
180
|
+
nil
|
181
|
+
end
|
190
182
|
end
|
191
183
|
|
192
184
|
return frame
|
@@ -199,24 +191,24 @@ module Demo
|
|
199
191
|
def create_frame(title)
|
200
192
|
frame = Gtk::Frame.new(title)
|
201
193
|
|
202
|
-
hbox = Gtk::
|
194
|
+
hbox = Gtk::Box.new(:horizontal, 8)
|
203
195
|
hbox.set_border_width(8)
|
204
196
|
frame.add(hbox)
|
205
197
|
|
206
198
|
scrollwin = Gtk::ScrolledWindow.new
|
207
|
-
scrollwin.set_policy(
|
208
|
-
scrollwin.shadow_type =
|
209
|
-
hbox.pack_start(scrollwin, true, true)
|
199
|
+
scrollwin.set_policy(:never, :automatic)
|
200
|
+
scrollwin.shadow_type = :in
|
201
|
+
hbox.pack_start(scrollwin, :expand => true, :fill => true)
|
210
202
|
|
211
203
|
tree_view = Gtk::TreeView.new
|
212
204
|
tree_view.headers_visible = false
|
213
205
|
scrollwin.add(tree_view)
|
214
206
|
|
215
207
|
selection = tree_view.selection
|
216
|
-
selection.mode =
|
208
|
+
selection.mode = :browse
|
217
209
|
|
218
|
-
button_vbox = Gtk::
|
219
|
-
hbox.pack_start(button_vbox, false, false)
|
210
|
+
button_vbox = Gtk::Box.new(:vertical, 5)
|
211
|
+
hbox.pack_start(button_vbox, :expand => false, :fill => false)
|
220
212
|
|
221
213
|
@size_group.add_widget(button_vbox)
|
222
214
|
|
@@ -227,7 +219,7 @@ module Demo
|
|
227
219
|
# are left-aligned, rather than centered. This function creates a button
|
228
220
|
# and left-aligns it contents.
|
229
221
|
def left_align_button_new(label)
|
230
|
-
button = Gtk::Button.new(label
|
222
|
+
button = Gtk::Button.new(:mnemonic => label)
|
231
223
|
button.child.set_alignment(0.0, 0.5)
|
232
224
|
|
233
225
|
return button
|
@@ -237,16 +229,16 @@ module Demo
|
|
237
229
|
# Prompts the user for a toplevel window to move, and then moves
|
238
230
|
# that window to the currently selected display
|
239
231
|
def query_change_display
|
240
|
-
screen = self.
|
232
|
+
screen = self.screen
|
241
233
|
|
242
234
|
toplevel = query_for_toplevel(screen,
|
243
235
|
"Please select the toplevel\n"+
|
244
236
|
"to move to the new screen")
|
245
237
|
|
246
238
|
if toplevel
|
247
|
-
|
239
|
+
toplevel.screen = @current_screen
|
248
240
|
else
|
249
|
-
|
241
|
+
screen.display.beep
|
250
242
|
end
|
251
243
|
end
|
252
244
|
|
@@ -258,13 +250,13 @@ module Demo
|
|
258
250
|
|
259
251
|
display = screen.display
|
260
252
|
|
261
|
-
popup = Gtk::Window.new(
|
253
|
+
popup = Gtk::Window.new(:popup)
|
262
254
|
popup.screen = screen
|
263
255
|
popup.modal = true
|
264
|
-
popup.window_position =
|
256
|
+
popup.window_position = :center
|
265
257
|
|
266
258
|
frame = Gtk::Frame.new
|
267
|
-
frame.set_shadow_type(
|
259
|
+
frame.set_shadow_type(:out)
|
268
260
|
popup.add(frame)
|
269
261
|
|
270
262
|
label = Gtk::Label.new(prompt)
|
@@ -274,35 +266,38 @@ module Demo
|
|
274
266
|
popup.show_all
|
275
267
|
|
276
268
|
# TODO: Gdk::Cursor.new(screen.display, Gdk::Cursor::CROSSHAIR)
|
277
|
-
cursor = Gdk::Cursor.new(
|
278
|
-
|
279
|
-
if Gdk::pointer_grab(
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
269
|
+
cursor = Gdk::Cursor.new(:crosshair)
|
270
|
+
|
271
|
+
if Gdk::pointer_grab(
|
272
|
+
popup.window,
|
273
|
+
false,
|
274
|
+
:button_release_mask,
|
275
|
+
nil,
|
276
|
+
cursor,
|
277
|
+
Gdk::Event::CURRENT_TIME
|
278
|
+
) == Gdk::GRAB_SUCCESS
|
279
|
+
clicked = false
|
280
|
+
|
281
|
+
popup.signal_connect('button-release-event') do
|
282
|
+
clicked = true
|
283
|
+
end
|
284
|
+
|
285
|
+
# Process events until clicked is set by button_release_event_cb.
|
286
|
+
# We pass in may_block = true since we want to wait if there
|
287
|
+
# are no events currently.
|
288
|
+
until clicked
|
289
|
+
Gtk.main_iteration # TODO: GLib::main_context_iteration(nil, true)
|
290
|
+
|
291
|
+
toplevel = find_toplevel_at_pointer(screen.display)
|
292
|
+
if toplevel == popup
|
293
|
+
toplevel = nil
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
popup.destroy
|
298
|
+
Gdk.flush # Really release the grab
|
299
|
+
|
300
|
+
return toplevel
|
306
301
|
end
|
307
302
|
end
|
308
303
|
|
@@ -313,52 +308,56 @@ module Demo
|
|
313
308
|
# The user data field of a GdkWindow is used to store a pointer
|
314
309
|
# to the widget that created it.
|
315
310
|
if pointer_window
|
316
|
-
|
311
|
+
widget = pointer_window.user_data
|
317
312
|
end
|
318
313
|
|
319
314
|
return (if widget
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
315
|
+
widget.toplevel
|
316
|
+
else
|
317
|
+
nil
|
318
|
+
end)
|
324
319
|
end
|
325
320
|
|
326
321
|
# Called when the user clicks on 'Open...' in the display
|
327
322
|
# frame. Prompts for a new display, and then opens a connection
|
328
323
|
# to that display.
|
329
324
|
def open_display_cb
|
330
|
-
dialog = Gtk::Dialog.new(
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
325
|
+
dialog = Gtk::Dialog.new(
|
326
|
+
:title => 'Open Display',
|
327
|
+
:parent => self,
|
328
|
+
:flags => :modal,
|
329
|
+
:buttons => [
|
330
|
+
[:cancel, :cancel],
|
331
|
+
[:ok, :ok]
|
332
|
+
]
|
333
|
+
)
|
334
|
+
|
335
|
+
dialog.default_response = Gtk::ResponseType::OK
|
337
336
|
display_entry = Gtk::Entry.new
|
338
337
|
display_entry.activates_default = true
|
339
338
|
dialog_label =
|
340
|
-
|
339
|
+
Gtk::Label.new("Please enter the name of\nthe new display\n")
|
341
340
|
|
342
|
-
dialog.
|
343
|
-
dialog.
|
341
|
+
dialog.child.add(dialog_label)
|
342
|
+
dialog.child.add(display_entry)
|
344
343
|
|
345
344
|
display_entry.grab_focus
|
346
|
-
dialog.
|
345
|
+
dialog.child.show_all
|
347
346
|
|
348
347
|
result = nil
|
349
348
|
until result
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
349
|
+
response_id = dialog.run
|
350
|
+
break if response_id != Gtk::ResponseType::OK
|
351
|
+
|
352
|
+
new_screen_name = display_entry.text
|
353
|
+
|
354
|
+
unless new_screen_name.empty?
|
355
|
+
begin
|
356
|
+
result = Gdk::Dispaly.open(new_screen_name)
|
357
|
+
rescue
|
358
|
+
dialog_label.text = "Can't open display :\n\t%s\nplease try another one\n" % [new_screen_name]
|
359
|
+
end
|
360
|
+
end
|
362
361
|
end
|
363
362
|
dialog.destroy
|
364
363
|
end
|
@@ -368,11 +367,11 @@ module Demo
|
|
368
367
|
# screens.
|
369
368
|
def display_changed_cb(selection)
|
370
369
|
@current_display =
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
370
|
+
if iter = selection.selected
|
371
|
+
iter.get_value(DISPLAY_COLUMN_DISPLAY)
|
372
|
+
else
|
373
|
+
nil
|
374
|
+
end
|
376
375
|
fill_screens
|
377
376
|
end
|
378
377
|
|
@@ -385,11 +384,11 @@ module Demo
|
|
385
384
|
iter.set_value(DISPLAY_COLUMN_DISPLAY, display)
|
386
385
|
|
387
386
|
handler_id = display.signal_connect('closed') do
|
388
|
-
|
387
|
+
display_closed_cb(display)
|
389
388
|
end
|
390
389
|
|
391
390
|
signal_connect('destroy') do
|
392
|
-
|
391
|
+
display.signal_handler_disconnect(handler_id)
|
393
392
|
end
|
394
393
|
end
|
395
394
|
|
@@ -397,11 +396,11 @@ module Demo
|
|
397
396
|
# Remove it from our list of displays.
|
398
397
|
def display_closed_cb(display)
|
399
398
|
@display_model.each do |model, path, iter|
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
399
|
+
tmp_display = iter.get_value( DISPLAY_COLUMN_DISPLAY)
|
400
|
+
if tmp_display == display
|
401
|
+
@display_model.remove(iter)
|
402
|
+
break
|
403
|
+
end
|
405
404
|
end
|
406
405
|
end
|
407
406
|
end
|