gtk3 3.1.0-x64-mingw32 → 3.1.1-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/2.2/gtk3.so +0 -0
- data/lib/2.3/gtk3.so +0 -0
- data/lib/2.4/gtk3.so +0 -0
- data/lib/gtk3/container.rb +2 -7
- data/lib/gtk3/dialog.rb +10 -1
- data/lib/gtk3/loader.rb +0 -14
- data/lib/gtk3/tree-selection.rb +0 -2
- data/lib/gtk3/tree-view-column.rb +34 -8
- data/sample/gtk-demo/TODO +19 -20
- data/sample/gtk-demo/assistant.rb +0 -2
- data/sample/gtk-demo/blendmodes.ui +391 -0
- data/sample/gtk-demo/blends.png +0 -0
- data/sample/gtk-demo/button_box.rb +16 -19
- data/sample/gtk-demo/clipboard.rb +2 -3
- data/sample/gtk-demo/cmy.jpg +0 -0
- data/sample/gtk-demo/colorsel.rb +1 -2
- data/sample/gtk-demo/context_menu_cursor.png +0 -0
- data/sample/gtk-demo/css_accordion.css +1 -1
- data/sample/gtk-demo/css_blendmodes.css +77 -0
- data/sample/gtk-demo/cssview.css +1 -1
- data/sample/gtk-demo/data/16x16/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/16x16/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/22x22/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/22x22/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/24x24/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/24x24/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/256x256/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/256x256/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/32x32/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/32x32/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/48x48/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/48x48/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/data/512x512/{gtk3-demo-symbolic.symbolic.png → gtk4-demo-symbolic.symbolic.png} +0 -0
- data/sample/gtk-demo/data/512x512/{gtk3-demo.png → gtk4-demo.png} +0 -0
- data/sample/gtk-demo/demo.gresource.xml +15 -2
- data/sample/gtk-demo/demo.ui +2 -1
- data/sample/gtk-demo/dialog.rb +2 -3
- data/sample/gtk-demo/drawingarea.rb +1 -2
- data/sample/gtk-demo/ducky.png +0 -0
- data/sample/gtk-demo/editable_cells.rb +1 -1
- data/sample/gtk-demo/entry_buffer.rb +1 -1
- data/sample/gtk-demo/entry_completion.rb +1 -1
- data/sample/gtk-demo/filtermodel.ui +15 -6
- data/sample/gtk-demo/fishbowl.ui +49 -0
- data/sample/gtk-demo/{glarea-fragment.glsl → glarea-gl.fs.glsl} +0 -0
- data/sample/gtk-demo/{glarea-vertex.glsl → glarea-gl.vs.glsl} +0 -0
- data/sample/gtk-demo/glarea-gles.fs.glsl +7 -0
- data/sample/gtk-demo/glarea-gles.vs.glsl +7 -0
- data/sample/gtk-demo/glarea.rb +15 -6
- data/sample/gtk-demo/hypertext.rb +0 -1
- data/sample/gtk-demo/images.rb +151 -168
- data/sample/gtk-demo/infobar.rb +5 -3
- data/sample/gtk-demo/links.rb +0 -1
- data/sample/gtk-demo/list_store.rb +1 -1
- data/sample/gtk-demo/listbox.ui +1 -1
- data/sample/gtk-demo/main.rb +4 -1
- data/sample/gtk-demo/markup.rb +2 -0
- data/sample/gtk-demo/menus.rb +0 -2
- data/sample/gtk-demo/no_drop_cursor.png +0 -0
- data/sample/gtk-demo/{cairo-arc-negative.rb → old_demos/cairo-arc-negative.rb} +0 -0
- data/sample/gtk-demo/{cairo-arc.rb → old_demos/cairo-arc.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip-image.rb → old_demos/cairo-clip-image.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip-rectangle.rb → old_demos/cairo-clip-rectangle.rb} +0 -0
- data/sample/gtk-demo/{cairo-clip.rb → old_demos/cairo-clip.rb} +0 -0
- data/sample/gtk-demo/{cairo-curve-rectangle.rb → old_demos/cairo-curve-rectangle.rb} +0 -0
- data/sample/gtk-demo/{cairo-curve-to.rb → old_demos/cairo-curve-to.rb} +0 -0
- data/sample/gtk-demo/{cairo-dash.rb → old_demos/cairo-dash.rb} +0 -0
- data/sample/gtk-demo/{cairo-fill-and-stroke.rb → old_demos/cairo-fill-and-stroke.rb} +0 -0
- data/sample/gtk-demo/{cairo-fill-and-stroke2.rb → old_demos/cairo-fill-and-stroke2.rb} +0 -0
- data/sample/gtk-demo/{cairo-gradient.rb → old_demos/cairo-gradient.rb} +0 -0
- data/sample/gtk-demo/{cairo-image-pattern.rb → old_demos/cairo-image-pattern.rb} +0 -0
- data/sample/gtk-demo/{cairo-image.rb → old_demos/cairo-image.rb} +0 -0
- data/sample/gtk-demo/{cairo-line-cap.rb → old_demos/cairo-line-cap.rb} +0 -0
- data/sample/gtk-demo/{cairo-line-join.rb → old_demos/cairo-line-join.rb} +0 -0
- data/sample/gtk-demo/{cairo-long-lines.rb → old_demos/cairo-long-lines.rb} +0 -0
- data/sample/gtk-demo/{cairo-operator.rb → old_demos/cairo-operator.rb} +0 -0
- data/sample/gtk-demo/{cairo-path.rb → old_demos/cairo-path.rb} +0 -0
- data/sample/gtk-demo/{cairo-pattern-fill.rb → old_demos/cairo-pattern-fill.rb} +0 -0
- data/sample/gtk-demo/{cairo-self-intersect.rb → old_demos/cairo-self-intersect.rb} +0 -0
- data/sample/gtk-demo/{cairo-text-align-center.rb → old_demos/cairo-text-align-center.rb} +0 -0
- data/sample/gtk-demo/{cairo-text-extents.rb → old_demos/cairo-text-extents.rb} +0 -0
- data/sample/gtk-demo/{cairo-text.rb → old_demos/cairo-text.rb} +0 -0
- data/sample/gtk-demo/{changedisplay.rb → old_demos/changedisplay.rb} +0 -0
- data/sample/gtk-demo/{common.rb → old_demos/common.rb} +0 -0
- data/sample/gtk-demo/{item_factory.rb → old_demos/item_factory.rb} +0 -0
- data/sample/gtk-demo/{stock_browser.rb → old_demos/stock_browser.rb} +0 -0
- data/sample/gtk-demo/old_demos/textview.rb +436 -0
- data/sample/gtk-demo/{tree_store.rb → old_demos/tree_store.rb} +0 -0
- data/sample/gtk-demo/panes.rb +2 -3
- data/sample/gtk-demo/pickers.rb +6 -5
- data/sample/gtk-demo/popover.rb +2 -7
- data/sample/gtk-demo/popover.ui +1 -0
- data/sample/gtk-demo/revealer.rb +4 -2
- data/sample/gtk-demo/revealer.ui +0 -1
- data/sample/gtk-demo/scale.ui +7 -1
- data/sample/gtk-demo/search_entry.rb +1 -2
- data/sample/gtk-demo/search_entry2.rb +0 -3
- data/sample/gtk-demo/shortcuts-builder.ui +42 -27
- data/sample/gtk-demo/sizegroup.rb +15 -14
- data/sample/gtk-demo/spinner.rb +1 -1
- data/sample/gtk-demo/textview.rb +358 -382
- data/sample/gtk-demo/theming.ui +0 -29
- data/sample/gtk-demo/theming_style_classes.rb +0 -1
- data/sample/gtk-demo/transparent.rb +0 -1
- data/test/test-gtk-tree-view-column.rb +44 -1
- metadata +77 -63
@@ -0,0 +1,49 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<interface>
|
3
|
+
<!-- interface-requires gtk+ 3.6 -->
|
4
|
+
<object class="GtkWindow" id="window">
|
5
|
+
<property name="title" translatable="yes">Fishbowl</property>
|
6
|
+
<child type="titlebar">
|
7
|
+
<object class="GtkHeaderBar" id="">
|
8
|
+
<property name="visible">True</property>
|
9
|
+
<property name="show-close-button">True</property>
|
10
|
+
<child>
|
11
|
+
<object class="GtkLabel" id="info_label">
|
12
|
+
<property name="visible">True</property>
|
13
|
+
<property name="label">0 icons - 0 fps</property>
|
14
|
+
</object>
|
15
|
+
<packing>
|
16
|
+
<property name="pack_type">end</property>
|
17
|
+
</packing>
|
18
|
+
</child>
|
19
|
+
<child>
|
20
|
+
<object class="GtkToggleButton" id="changes_allow">
|
21
|
+
<property name="active">False</property>
|
22
|
+
<property name="visible" bind-source="changes_allow" bind-property="active" bind-flags="invert-boolean">True</property>
|
23
|
+
<property name="icon-name">changes-allow</property>
|
24
|
+
<property name="relief">none</property>
|
25
|
+
</object>
|
26
|
+
<packing>
|
27
|
+
<property name="pack_type">end</property>
|
28
|
+
</packing>
|
29
|
+
</child>
|
30
|
+
<child>
|
31
|
+
<object class="GtkToggleButton" id="changes_prevent">
|
32
|
+
<property name="active" bind-source="changes_allow" bind-property="active" bind-flags="bidirectional|invert-boolean">True</property>
|
33
|
+
<property name="visible" bind-source="changes_prevent" bind-property="active" bind-flags="invert-boolean">False</property>
|
34
|
+
<property name="icon-name">changes-prevent</property>
|
35
|
+
<property name="relief">none</property>
|
36
|
+
</object>
|
37
|
+
<packing>
|
38
|
+
<property name="pack_type">end</property>
|
39
|
+
</packing>
|
40
|
+
</child>
|
41
|
+
</object>
|
42
|
+
</child>
|
43
|
+
<child>
|
44
|
+
<object class="GtkFixed" id="bowl">
|
45
|
+
<property name="visible">True</property>
|
46
|
+
</object>
|
47
|
+
</child>
|
48
|
+
</object>
|
49
|
+
</interface>
|
File without changes
|
File without changes
|
data/sample/gtk-demo/glarea.rb
CHANGED
@@ -24,9 +24,9 @@ class GlareaDemo
|
|
24
24
|
@window.screen = main_window.screen
|
25
25
|
@window.title = "OpenGL Area"
|
26
26
|
@window.set_default_size(400, 600)
|
27
|
-
@window.border_width = 12
|
28
27
|
|
29
28
|
box = Gtk::Box.new(:vertical, false)
|
29
|
+
box.margin = 12
|
30
30
|
box.spacing = 6
|
31
31
|
@window.add(box)
|
32
32
|
|
@@ -42,7 +42,7 @@ class GlareaDemo
|
|
42
42
|
widget.make_current
|
43
43
|
unless widget.error
|
44
44
|
init_buffers
|
45
|
-
@program, @mvp_location = init_shaders
|
45
|
+
@program, @mvp_location = init_shaders(widget)
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -110,9 +110,18 @@ class GlareaDemo
|
|
110
110
|
end
|
111
111
|
|
112
112
|
# Initialize shaders and link them into a programm
|
113
|
-
def init_shaders
|
114
|
-
|
115
|
-
|
113
|
+
def init_shaders(widget)
|
114
|
+
context = widget.context
|
115
|
+
|
116
|
+
if context.use_es?
|
117
|
+
vertex_path = "/glarea/glarea-gles.vs.glsl"
|
118
|
+
fragment_path = "/glarea/glarea-gles.fs.glsl"
|
119
|
+
else
|
120
|
+
vertex_path = "/glarea/glarea-gl.vs.glsl"
|
121
|
+
fragment_path = "/glarea/glarea-gl.fs.glsl"
|
122
|
+
end
|
123
|
+
src_vertex = Gio::Resources.lookup_data(vertex_path, 0)
|
124
|
+
src_fragment = Gio::Resources.lookup_data(fragment_path, 0)
|
116
125
|
vertex = create_shader(GL_VERTEX_SHADER, src_vertex)
|
117
126
|
return [0, nil] if vertex.zero?
|
118
127
|
fragment = create_shader(GL_FRAGMENT_SHADER, src_fragment)
|
@@ -160,7 +169,7 @@ class GlareaDemo
|
|
160
169
|
info_log = " " * (len + 1)
|
161
170
|
glGetShaderInfoLog(shader, len, nil, info_log)
|
162
171
|
type_name = type == GL_VERTEX_SHADER ? "vertex" : "fragment"
|
163
|
-
STDERR.puts "Compile failure in #{type_name}:\n#{info_log}
|
172
|
+
STDERR.puts "Compile failure in #{type_name}:\n#{info_log}"
|
164
173
|
return 0
|
165
174
|
end
|
166
175
|
shader
|
data/sample/gtk-demo/images.rb
CHANGED
@@ -1,197 +1,180 @@
|
|
1
|
-
# Copyright (c)
|
1
|
+
# Copyright (c) 2017 Ruby-GNOME2 Project Team
|
2
2
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
3
|
#
|
4
|
-
# $Id: images.rb,v 1.5 2006/04/08 12:30:03 mutoh Exp $
|
5
4
|
=begin
|
6
|
-
=
|
5
|
+
= Images
|
7
6
|
|
8
|
-
|
9
|
-
Typically, you load an image into a
|
7
|
+
GtkImage is used to display an image; the image can be in a number of formats.
|
8
|
+
Typically, you load an image into a GdkPixbuf, then display the pixbuf.
|
10
9
|
|
11
|
-
This demo code shows some of the more obscure cases, in the simple
|
12
|
-
case a call to
|
10
|
+
This demo code shows some of the more obscure cases, in the simple
|
11
|
+
case a call to gtk_image_new_from_file() is all you need.
|
13
12
|
|
14
|
-
If you want to put image data in your program as a
|
15
|
-
use the make-inline-pixbuf program that comes with GTK+.
|
16
|
-
This way you won't need to depend on loading external files, your
|
17
|
-
application binary can be self-contained.
|
13
|
+
If you want to put image data in your program as a C variable,
|
14
|
+
use the make-inline-pixbuf program that comes with GTK+.
|
15
|
+
This way you won't need to depend on loading external files, your
|
16
|
+
application binary can be self-contained.
|
18
17
|
=end
|
19
|
-
require 'common'
|
20
|
-
|
21
|
-
module Demo
|
22
|
-
class Images < BasicWindow
|
23
|
-
def initialize
|
24
|
-
@pixbuf_loader = nil
|
25
|
-
@load_timeout = 0
|
26
|
-
@image_stream = nil
|
27
|
-
|
28
|
-
super('Images')
|
29
|
-
signal_connect('destroy') do
|
30
|
-
cleanup_callback
|
31
|
-
end
|
32
|
-
|
33
|
-
self.border_width = 8
|
34
|
-
|
35
|
-
vbox = Gtk::VBox.new(false, 8)
|
36
|
-
vbox.border_width = 8
|
37
|
-
add(vbox)
|
38
|
-
|
39
|
-
label = Gtk::Label.new
|
40
|
-
label.set_markup('<u>Image loaded from a file</u>')
|
41
|
-
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
42
|
-
|
43
|
-
frame = Gtk::Frame.new
|
44
|
-
frame.shadow_type = :in
|
45
|
-
|
46
|
-
# The alignment keeps the frame from growing when users resize
|
47
|
-
# the window
|
48
|
-
align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
|
49
|
-
align.add(frame)
|
50
|
-
vbox.pack_start(align, :expand => false, :fill => false, :padding => 0)
|
51
|
-
|
52
|
-
# demo_find_file looks in the the current directory first,
|
53
|
-
# so you can run gtk-demo without installing GTK, then looks
|
54
|
-
# in the location where the file is installed.
|
55
|
-
pixbuf = nil
|
56
|
-
begin
|
57
|
-
filename = Demo.find_file('gtk-logo-rgb.gif')
|
58
|
-
pixbuf = Gdk::Pixbuf.new(filename)
|
59
|
-
rescue
|
60
|
-
# This code shows off error handling. You can just use
|
61
|
-
# Gtk::Image.new instead if you don't want to report
|
62
|
-
# errors to the user. If the file doesn't load when using
|
63
|
-
# Gtk::Image.new, a 'missing image' icon will
|
64
|
-
# be displayed instead.
|
65
|
-
dialog = Gtk::MessageDialog.new(self,
|
66
|
-
Gtk::Dialog::DESTROY_WITH_PARENT,
|
67
|
-
Gtk::MessageDialog::ERROR,
|
68
|
-
Gtk::MessageDialog::BUTTONS_CLOSE,
|
69
|
-
"Unable to open image file 'gtk-logo-rgb.gif': #{$1}")
|
70
|
-
|
71
|
-
dialog.signal_connect('response') do |widget, data|
|
72
|
-
widget.destroy
|
73
|
-
end
|
74
|
-
dialog.show
|
75
|
-
end
|
76
|
-
|
77
|
-
image = Gtk::Image.new(pixbuf)
|
78
|
-
frame.add(image)
|
79
|
-
|
80
|
-
|
81
|
-
# Animation
|
82
|
-
label = Gtk::Label.new
|
83
|
-
label.set_markup('<u>Animation loaded from a file</u>')
|
84
|
-
vbox.pack_start(label, :expand => false, :fill => false, :padding => 0)
|
85
|
-
|
86
|
-
frame = Gtk::Frame.new
|
87
|
-
frame.shadow_type = :in
|
88
|
-
|
89
|
-
# The alignment keeps the frame from growing when users resize
|
90
|
-
# the window
|
91
|
-
align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
|
92
|
-
align.add(frame)
|
93
|
-
vbox.pack_start(align, :expand => false, :fill => false, :padding => 0)
|
94
|
-
|
95
|
-
filename = Demo.find_file('floppybuddy.gif')
|
96
|
-
image = Gtk::Image.new(filename)
|
97
|
-
frame.add(image)
|
98
18
|
|
19
|
+
require "thread"
|
99
20
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
# The alignment keeps the frame from growing when users resize
|
109
|
-
# the window
|
110
|
-
align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
|
111
|
-
align.add(frame)
|
112
|
-
vbox.pack_start(align, :expand => false, :fill => false, :padding => 0)
|
113
|
-
|
114
|
-
# Create an empty image for now; the progressive loader
|
115
|
-
# will create the pixbuf and fill it in.
|
116
|
-
image = Gtk::Image.new
|
117
|
-
frame.add(image)
|
118
|
-
|
119
|
-
start_progressive_loading(image)
|
120
|
-
|
121
|
-
# Sensitivity control
|
122
|
-
button = Gtk::ToggleButton.new('_Insensitive', true)
|
123
|
-
vbox.pack_start(button, :expand => false, :fill => false, :padding => 0)
|
124
|
-
|
125
|
-
button.signal_connect('toggled') do |widget|
|
126
|
-
vbox.children.each do |widget|
|
127
|
-
if widget != button
|
128
|
-
widget.sensitive = ! button.active?
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
21
|
+
class ImagesDemo
|
22
|
+
def initialize(main_window)
|
23
|
+
@window = Gtk::Window.new(:toplevel)
|
24
|
+
@window.screen = main_window.screen
|
25
|
+
@window.title = "Images"
|
26
|
+
@window.signal_connect "destroy" do
|
27
|
+
GLib::Source.remove(@load_timeout) if @load_timeout
|
28
|
+
@pixbuf_loader.close
|
132
29
|
end
|
133
30
|
|
134
|
-
|
135
|
-
|
136
|
-
|
31
|
+
@vbox = Gtk::Box.new(:vertical, 8)
|
32
|
+
@vbox.margin = 16
|
33
|
+
@window.add(@vbox)
|
34
|
+
|
35
|
+
frame = generate_frame("<u>Image loaded from a file </u>")
|
36
|
+
image = Gtk::Image.new(:icon_name => "gtk3-demo", :size => :dialog)
|
37
|
+
frame.add(image)
|
38
|
+
|
39
|
+
# Animation
|
40
|
+
frame = generate_frame("<u>Animation loaded from a file</u>")
|
41
|
+
image = Gtk::Image.new(:resource => "/images/floppybuddy.gif")
|
42
|
+
frame.add(image)
|
43
|
+
|
44
|
+
# Symbolic icon
|
45
|
+
frame = generate_frame("<u>Symbolic themed icon</u>")
|
46
|
+
gicon = Gio::ThemedIcon.new("battery-caution-charging-symbolic")
|
47
|
+
image = Gtk::Image.new(:icon => gicon, :size => :dialog)
|
48
|
+
frame.add(image)
|
49
|
+
|
50
|
+
# Progressive
|
51
|
+
frame = generate_frame("<u>Progressive image loading</u>")
|
52
|
+
|
53
|
+
# Create an empty image for now; the progressive loader
|
54
|
+
# will create the pixbuf and fill it in.
|
55
|
+
image = Gtk::Image.new
|
56
|
+
frame.add(image)
|
57
|
+
start_progressive_loading(image)
|
58
|
+
|
59
|
+
# Sensitivity control
|
60
|
+
button = Gtk::ToggleButton.new(:label => "_Insensitive",
|
61
|
+
:use_underline => true)
|
62
|
+
@vbox.pack_start(button)
|
63
|
+
button.signal_connect "toggled" do |toggle|
|
64
|
+
@vbox.children.each do |child|
|
65
|
+
child.sensitive = !toggle.active? if child.class != Gtk::ToggleButton
|
137
66
|
end
|
138
67
|
end
|
68
|
+
end
|
139
69
|
|
140
|
-
|
141
|
-
|
142
|
-
|
70
|
+
def run
|
71
|
+
if !@window.visible?
|
72
|
+
@window.show_all
|
73
|
+
else
|
74
|
+
@window.destroy
|
75
|
+
end
|
76
|
+
@window
|
77
|
+
end
|
143
78
|
|
144
|
-
|
79
|
+
private
|
80
|
+
|
81
|
+
def start_progressive_loading(image)
|
82
|
+
# This is obviously totally contrived (we slow down loading
|
83
|
+
# on purpose to show how incremental loading works).
|
84
|
+
# The real purpose of incremental loading is the case where
|
85
|
+
# you are reading data from a slow source such as the network.
|
86
|
+
# The timeout simply simulates a slow data source by inserting
|
87
|
+
# pauses in the reading process.
|
88
|
+
image_stream = nil
|
89
|
+
pixbuf_loader = nil
|
90
|
+
@load_timeout = GLib::Timeout.add(150) do
|
91
|
+
if image_stream
|
92
|
+
begin
|
93
|
+
buf = image_stream.read(256)
|
94
|
+
rescue => error
|
95
|
+
buf = ""
|
96
|
+
show_dialog_on_error("Failure reading image file 'alphatest.png': \
|
97
|
+
#{error.message}")
|
98
|
+
end
|
145
99
|
|
146
|
-
if
|
147
|
-
|
148
|
-
|
100
|
+
if buf.empty?
|
101
|
+
# Errors can happen on close, e.g. if the image
|
102
|
+
# file was truncated we'll know on close that
|
103
|
+
# it was incomplete.
|
104
|
+
begin
|
105
|
+
image_stream.close
|
106
|
+
rescue => error
|
107
|
+
show_dialog_on_error("Failed to load image: #{error.message}")
|
108
|
+
end
|
149
109
|
|
150
|
-
|
151
|
-
|
110
|
+
begin
|
111
|
+
pixbuf_loader.close
|
112
|
+
rescue => error
|
113
|
+
show_dialog_on_error("Failed to load image: #{error.message}")
|
114
|
+
end
|
115
|
+
GLib::Source::REMOVE
|
116
|
+
else
|
117
|
+
begin
|
118
|
+
pixbuf_loader.write(buf)
|
119
|
+
rescue => error
|
120
|
+
show_dialog_on_error("Failed to load image: #{error.message}")
|
121
|
+
end
|
122
|
+
GLib::Source::CONTINUE
|
152
123
|
end
|
153
124
|
else
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
@pixbuf_loader.close
|
159
|
-
@pixbuf_loader = nil
|
125
|
+
begin
|
126
|
+
image_stream = Gio::Resources.open_stream("/images/alphatest.png")
|
127
|
+
rescue => error
|
128
|
+
show_dialog_on_error(error.message)
|
160
129
|
end
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
@pixbuf_loader.signal_connect('area_prepared') do |loader|
|
130
|
+
pixbuf_loader.close if pixbuf_loader
|
131
|
+
pixbuf_loader = GdkPixbuf::PixbufLoader.new
|
132
|
+
pixbuf_loader.signal_connect "area-prepared" do |loader|
|
165
133
|
pixbuf = loader.pixbuf
|
166
|
-
|
167
|
-
|
168
|
-
# isn't filled in yet.
|
169
|
-
pixbuf.fill!(0xaaaaaaff)
|
170
|
-
|
171
|
-
image.pixbuf = pixbuf
|
134
|
+
pixbuf.fill(0xaaaaaaff)
|
135
|
+
image.from_pixbuf = pixbuf
|
172
136
|
end
|
173
137
|
|
174
|
-
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
image.
|
138
|
+
pixbuf_loader.signal_connect "area-updated" do
|
139
|
+
# progressive_updated_callback
|
140
|
+
# We know the pixbuf inside the GtkImage has changed, but the image
|
141
|
+
# itself doesn't know this; so give it a hint by setting the pixbuf
|
142
|
+
# again. Queuing a redraw used to be sufficient, but nowadays
|
143
|
+
# GtkImage uses GtkIconHelper which caches the pixbuf state and will
|
144
|
+
# just redraw from the cache.
|
145
|
+
pixbuf = image.pixbuf
|
146
|
+
image.from_pixbuf = pixbuf
|
182
147
|
end
|
148
|
+
GLib::Source::CONTINUE
|
183
149
|
end
|
184
|
-
|
185
|
-
# leave timeout installed
|
186
|
-
return true
|
187
150
|
end
|
151
|
+
source = GLib::MainContext.default.find_source(@load_timeout)
|
152
|
+
source.name = "[gtk+] progressive_timeout"
|
153
|
+
end
|
188
154
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
155
|
+
def show_dialog_on_error(message)
|
156
|
+
dialog = Gtk::MessageDialog.new(:parent => @window,
|
157
|
+
:flags => :destroy_with_parent,
|
158
|
+
:type => :error, :buttons => :close,
|
159
|
+
:message => message)
|
160
|
+
dialog.modal = true
|
161
|
+
dialog.present
|
162
|
+
dialog.signal_connect("response") { |w| w.destroy }
|
163
|
+
GLib::Source.remove(@load_timeout)
|
164
|
+
@load_timeout = nil
|
165
|
+
false
|
166
|
+
end
|
167
|
+
|
168
|
+
def generate_frame(title)
|
169
|
+
label = Gtk::Label.new
|
170
|
+
label.markup = title
|
171
|
+
@vbox.pack_start(label)
|
172
|
+
|
173
|
+
frame = Gtk::Frame.new
|
174
|
+
frame.shadow_type = :in
|
175
|
+
frame.halign = :center
|
176
|
+
frame.valign = :center
|
177
|
+
@vbox.pack_start(frame)
|
178
|
+
frame
|
196
179
|
end
|
197
180
|
end
|