gtk3 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gtk3/extconf.rb +1 -1
- data/ext/gtk3/rbgtk-color-button.c +7 -1
- data/ext/gtk3/rbgtk-dialog.c +26 -6
- data/ext/gtk3/rbgtk-image.c +1 -0
- data/ext/gtk3/rbgtk-selection-data.c +4 -5
- data/ext/gtk3/rbgtk-stack-switcher.c +41 -0
- data/ext/gtk3/rbgtk-window.c +8 -0
- data/ext/gtk3/rbgtk.c +158 -0
- data/ext/gtk3/rbgtk3.h +33 -0
- data/ext/gtk3/rbgtk3conversions.h +60 -1
- data/ext/gtk3/rbgtk3private.h +1 -1
- data/lib/gtk3.rb +1 -0
- data/sample/gtk-demo/cairo-arc-negative.rb +1 -1
- data/sample/gtk-demo/cairo-arc.rb +1 -1
- data/sample/gtk-demo/cairo-clip-image.rb +6 -6
- data/sample/gtk-demo/cairo-clip-rectangle.rb +2 -2
- data/sample/gtk-demo/cairo-curve-rectangle.rb +2 -2
- data/sample/gtk-demo/cairo-curve-to.rb +2 -2
- data/sample/gtk-demo/cairo-dash.rb +1 -1
- data/sample/gtk-demo/cairo-fill-and-stroke.rb +1 -1
- data/sample/gtk-demo/cairo-fill-and-stroke2.rb +2 -2
- data/sample/gtk-demo/cairo-gradient.rb +1 -1
- data/sample/gtk-demo/cairo-image-pattern.rb +5 -5
- data/sample/gtk-demo/cairo-image.rb +4 -4
- data/sample/gtk-demo/cairo-line-cap.rb +8 -8
- data/sample/gtk-demo/cairo-line-join.rb +3 -3
- data/sample/gtk-demo/cairo-long-lines.rb +3 -3
- data/sample/gtk-demo/cairo-pattern-fill.rb +11 -11
- data/sample/gtk-demo/cairo-self-intersect.rb +2 -2
- data/sample/gtk-demo/cairo-text-align-center.rb +4 -4
- data/sample/gtk-demo/cairo-text-extents.rb +5 -5
- data/sample/gtk-demo/cairo-text.rb +3 -3
- data/sample/gtk-demo/common.rb +0 -1
- data/sample/gtk-demo/dialog.rb +23 -23
- data/sample/gtk-demo/drawingarea.rb +5 -1
- data/sample/gtk-demo/editable_cells.rb +28 -28
- data/sample/gtk-demo/entry_completion.rb +3 -3
- data/sample/gtk-demo/images.rb +75 -75
- data/sample/gtk-demo/item_factory.rb +40 -40
- data/sample/gtk-demo/list_store.rb +13 -13
- data/sample/gtk-demo/menus.rb +34 -34
- data/sample/gtk-demo/panes.rb +28 -28
- data/sample/gtk-demo/rotated_text.rb +41 -53
- data/sample/gtk-demo/sizegroup.rb +17 -17
- data/sample/gtk-demo/spinner.rb +1 -1
- data/sample/gtk-demo/textview.rb +137 -137
- data/sample/gtk-demo/theming.ui +319 -0
- data/sample/gtk-demo/theming_style_classes.rb +48 -0
- data/sample/gtk-demo/tree_store.rb +127 -127
- data/sample/misc/assistant.rb +6 -66
- data/sample/misc/bindings.rb +22 -32
- data/sample/misc/button.rb +8 -5
- data/sample/misc/buttonbox.rb +2 -2
- data/sample/misc/checkbutton.rb +4 -1
- data/sample/misc/colorselection.rb +7 -10
- data/sample/misc/combo_check.rb +34 -26
- data/sample/misc/combobox.rb +10 -11
- data/sample/misc/cursor.rb +3 -1
- data/sample/misc/dialog.rb +12 -12
- data/sample/misc/dialog2.rb +13 -16
- data/sample/misc/drawing.rb +40 -21
- data/sample/misc/statusicon.rb +28 -45
- data/sample/misc/threads.rb +16 -18
- data/sample/misc/tree_progress.rb +10 -12
- data/test/run-test.rb +17 -9
- data/test/test_gtk_search_bar.rb +1 -1
- data/test/test_gtk_stack_switcher.rb +30 -0
- metadata +25 -21
@@ -14,55 +14,55 @@ module Demo
|
|
14
14
|
class ItemFactory < BasicWindow
|
15
15
|
def initialize
|
16
16
|
super('Item Factory')
|
17
|
-
|
17
|
+
|
18
18
|
accel_group = Gtk::AccelGroup.new
|
19
19
|
item_factory = Gtk::ItemFactory.new(Gtk::ItemFactory::TYPE_MENU_BAR,
|
20
|
-
|
21
|
-
|
20
|
+
'<main>', accel_group)
|
21
|
+
|
22
22
|
add_accel_group(accel_group)
|
23
23
|
set_border_width(0)
|
24
24
|
ifactory_cb = proc do |data, widget|
|
25
|
-
|
25
|
+
puts "ItemFactory: activated \"#{Gtk::ItemFactory.path_from_widget(widget)}\""
|
26
26
|
end
|
27
27
|
menu_items = [
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
28
|
+
['/_File'],
|
29
|
+
['/File/tearoff1',
|
30
|
+
'<Tearoff>', nil, nil, ifactory_cb],
|
31
|
+
['/File/_New',
|
32
|
+
'<Item>', '<control>N', nil, ifactory_cb],
|
33
|
+
['/File/_Open',
|
34
|
+
'<Item>', '<control>O', nil, ifactory_cb],
|
35
|
+
['/File/_Save',
|
36
|
+
'<Item>', '<control>S', nil, ifactory_cb],
|
37
|
+
['/File/Save _As...',
|
38
|
+
'<Item>', nil, nil, ifactory_cb],
|
39
|
+
['/File/sep1', '<Separator>'],
|
40
|
+
['/File/_Quit',
|
41
|
+
'<Item>', '<control>Q', nil, ifactory_cb],
|
42
|
+
|
43
|
+
['/_Preferences'],
|
44
|
+
['/_Preferences/_Color'],
|
45
|
+
[ '/_Preferences/Color/_Red',
|
46
|
+
'<RadioItem>', nil, nil, ifactory_cb],
|
47
|
+
['/_Preferences/Color/_Green',
|
48
|
+
'/Preferences/Color/Red', nil, nil, ifactory_cb],
|
49
|
+
['/_Preferences/Color/_Blue',
|
50
|
+
'/Preferences/Color/Red', nil, nil, ifactory_cb],
|
51
|
+
['/_Preferences/_Shape'],
|
52
|
+
['/_Preferences/Shape/_Square',
|
53
|
+
'<RadioItem>', nil, nil, ifactory_cb],
|
54
|
+
[ '/_Preferences/Shape/_Rectangle',
|
55
|
+
'/Preferences/Shape/Square', nil, nil, ifactory_cb],
|
56
|
+
[ '/_Preferences/Shape/_Oval',
|
57
|
+
'/Preferences/Shape/Rectangle', nil, nil, ifactory_cb],
|
58
|
+
|
59
|
+
[ '/_Help', '<LastBranch>'],
|
60
|
+
[ '/Help/_About', '<Item>', nil, nil, ifactory_cb],
|
61
61
|
]
|
62
62
|
item_factory.create_items(menu_items)
|
63
63
|
|
64
64
|
item_factory.get_item('/Preferences/Shape/Oval').set_active(true)
|
65
|
-
|
65
|
+
|
66
66
|
box1 = Gtk::VBox.new(false, 0)
|
67
67
|
add(box1)
|
68
68
|
|
@@ -76,7 +76,7 @@ module Demo
|
|
76
76
|
separator = Gtk::HSeparator.new
|
77
77
|
box1.pack_start(separator)
|
78
78
|
|
79
|
-
|
79
|
+
|
80
80
|
box2 = Gtk::VBox.new(false, 10)
|
81
81
|
box2.set_border_width(10)
|
82
82
|
box1.pack_start(box2, :expand => false, :fill => true, :padding => 0)
|
@@ -84,7 +84,7 @@ module Demo
|
|
84
84
|
button = Gtk::Button.new('close')
|
85
85
|
# TODO: Need signal_connect_swapped?
|
86
86
|
button.signal_connect('clicked') do
|
87
|
-
|
87
|
+
quit
|
88
88
|
end
|
89
89
|
box2.pack_start(button, :expand => true, :fill => true, :padding => 0)
|
90
90
|
button.set_flags(Gtk::Widget::CAN_DEFAULT)
|
@@ -72,10 +72,10 @@ module Demo
|
|
72
72
|
|
73
73
|
# add data to the list store
|
74
74
|
DATA.each do |bug|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
iter = store.append
|
76
|
+
bug.each_with_index do |value, index|
|
77
|
+
iter[index] = value
|
78
|
+
end
|
79
79
|
end
|
80
80
|
return store
|
81
81
|
end
|
@@ -84,12 +84,12 @@ module Demo
|
|
84
84
|
# column for fixed toggles
|
85
85
|
renderer = Gtk::CellRendererToggle.new
|
86
86
|
renderer.signal_connect('toggled') do |cell, path|
|
87
|
-
|
87
|
+
fixed_toggled(treeview.model, path)
|
88
88
|
end
|
89
89
|
|
90
90
|
column = Gtk::TreeViewColumn.new('Fixed?',
|
91
|
-
|
92
|
-
|
91
|
+
renderer,
|
92
|
+
'active' => COLUMN_FIXED)
|
93
93
|
|
94
94
|
# set this column to a fixed sizing (of 50 pixels)
|
95
95
|
column.sizing = Gtk::TreeViewColumn::FIXED
|
@@ -99,24 +99,24 @@ module Demo
|
|
99
99
|
# column for bug numbers
|
100
100
|
renderer = Gtk::CellRendererText.new
|
101
101
|
column = Gtk::TreeViewColumn.new('Bug number',
|
102
|
-
|
103
|
-
|
102
|
+
renderer,
|
103
|
+
'text' => COLUMN_NUMBER)
|
104
104
|
column.set_sort_column_id(COLUMN_NUMBER)
|
105
105
|
treeview.append_column(column)
|
106
106
|
|
107
107
|
# column for severities
|
108
108
|
renderer = Gtk::CellRendererText.new
|
109
109
|
column = Gtk::TreeViewColumn.new('Severity',
|
110
|
-
|
111
|
-
|
110
|
+
renderer,
|
111
|
+
'text' => COLUMN_SEVERITY)
|
112
112
|
column.set_sort_column_id(COLUMN_SEVERITY)
|
113
113
|
treeview.append_column(column)
|
114
114
|
|
115
115
|
# column for description
|
116
116
|
renderer = Gtk::CellRendererText.new
|
117
117
|
column = Gtk::TreeViewColumn.new('Description',
|
118
|
-
|
119
|
-
|
118
|
+
renderer,
|
119
|
+
'text' => COLUMN_DESCRIPTION)
|
120
120
|
column.set_sort_column_id(COLUMN_DESCRIPTION)
|
121
121
|
treeview.append_column(column)
|
122
122
|
end
|
data/sample/gtk-demo/menus.rb
CHANGED
@@ -83,31 +83,31 @@ module Demo
|
|
83
83
|
menu.append(menuitem)
|
84
84
|
menuitem.show
|
85
85
|
menuitem.add_accelerator('activate',
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
accel_group,
|
87
|
+
Gdk::Keyval::GDK_F1,
|
88
|
+
0,
|
89
|
+
Gtk::ACCEL_VISIBLE)
|
90
90
|
menuitem = Gtk::CheckMenuItem.new('Accelerator Locked')
|
91
91
|
menu.append(menuitem)
|
92
92
|
menuitem.show
|
93
93
|
menuitem.add_accelerator('activate',
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
94
|
+
accel_group,
|
95
|
+
Gdk::Keyval::GDK_F2,
|
96
|
+
0,
|
97
|
+
Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED)
|
98
98
|
menuitem = Gtk::CheckMenuItem.new('Accelerators Frozen')
|
99
99
|
menu.append(menuitem)
|
100
100
|
menuitem.show
|
101
101
|
menuitem.add_accelerator('activate',
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
102
|
+
accel_group,
|
103
|
+
Gdk::Keyval::GDK_F2,
|
104
|
+
0,
|
105
|
+
Gtk::ACCEL_VISIBLE)
|
106
106
|
menuitem.add_accelerator('activate',
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
107
|
+
accel_group,
|
108
|
+
Gdk::Keyval::GDK_F3,
|
109
|
+
0,
|
110
|
+
Gtk::ACCEL_VISIBLE)
|
111
111
|
|
112
112
|
optionmenu = Gtk::OptionMenu.new
|
113
113
|
optionmenu.menu = menu
|
@@ -126,7 +126,7 @@ module Demo
|
|
126
126
|
|
127
127
|
button = Gtk::Button.new('close')
|
128
128
|
button.signal_connect('clicked') do
|
129
|
-
|
129
|
+
quit
|
130
130
|
end
|
131
131
|
box2.pack_start(button, :expand => true, :fill => true, :padding => 0)
|
132
132
|
button.flags = Gtk::Widget::CAN_DEFAULT
|
@@ -137,32 +137,32 @@ module Demo
|
|
137
137
|
|
138
138
|
def create_menu (depth, tearoff)
|
139
139
|
if depth < 1
|
140
|
-
|
140
|
+
return nil
|
141
141
|
end
|
142
142
|
|
143
143
|
menu = Gtk::Menu.new
|
144
144
|
group = nil
|
145
145
|
|
146
146
|
if tearoff
|
147
|
-
|
148
|
-
|
149
|
-
|
147
|
+
menuitem = Gtk::TearoffMenuItem.new
|
148
|
+
menu.append(menuitem)
|
149
|
+
menuitem.show
|
150
150
|
end
|
151
151
|
|
152
152
|
5.times do |i|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
153
|
+
buf = sprintf('item %2d - %d', depth, i + 1)
|
154
|
+
menuitem = Gtk::RadioMenuItem.new(buf)
|
155
|
+
group = menuitem.group
|
156
|
+
|
157
|
+
menu.append(menuitem)
|
158
|
+
menuitem.show
|
159
|
+
if i == 3
|
160
|
+
menuitem.sensitive = false
|
161
|
+
end
|
162
|
+
|
163
|
+
if submenu = create_menu(depth - 1, true)
|
164
|
+
menuitem.submenu = submenu
|
165
|
+
end
|
166
166
|
end
|
167
167
|
|
168
168
|
menu.show
|
data/sample/gtk-demo/panes.rb
CHANGED
@@ -54,12 +54,12 @@ module Demo
|
|
54
54
|
# Now create toggle buttons to control sizing
|
55
55
|
|
56
56
|
vbox.pack_start(create_pane_options(hpaned,
|
57
|
-
|
58
|
-
|
57
|
+
'Horizontal', 'Left', 'Right'),
|
58
|
+
:expand => false, :fill => false, :padding => 0)
|
59
59
|
|
60
60
|
vbox.pack_start(create_pane_options(vpaned,
|
61
|
-
|
62
|
-
|
61
|
+
'Vertical', 'Top', 'Bottom'),
|
62
|
+
:expand => false, :fill => false, :padding => 0)
|
63
63
|
end
|
64
64
|
|
65
65
|
def create_pane_options(paned, frame_label, label1, label2)
|
@@ -75,14 +75,14 @@ module Demo
|
|
75
75
|
check_button = Gtk::CheckButton.new('_Resize', true)
|
76
76
|
table.attach_defaults(check_button, 0, 1, 1, 2)
|
77
77
|
check_button.signal_connect('toggled') do
|
78
|
-
|
78
|
+
toggle_resize(paned.child1)
|
79
79
|
end
|
80
80
|
|
81
81
|
check_button = Gtk::CheckButton.new('_Shrink', true)
|
82
82
|
table.attach_defaults(check_button, 0, 1, 2, 3)
|
83
83
|
check_button.active = true
|
84
84
|
check_button.signal_connect('toggled') do
|
85
|
-
|
85
|
+
toggle_shrink(paned.child1)
|
86
86
|
end
|
87
87
|
|
88
88
|
label = Gtk::Label.new(label2)
|
@@ -92,14 +92,14 @@ module Demo
|
|
92
92
|
table.attach_defaults(check_button, 1, 2, 1, 2)
|
93
93
|
check_button.active = true
|
94
94
|
check_button.signal_connect('toggled') do
|
95
|
-
|
95
|
+
toggle_resize(paned.child2)
|
96
96
|
end
|
97
97
|
|
98
98
|
check_button = Gtk::CheckButton.new('_Shrink')
|
99
99
|
table.attach_defaults(check_button, 1, 2, 2, 3)
|
100
100
|
check_button.active = true
|
101
101
|
check_button.signal_connect('toggled') do
|
102
|
-
|
102
|
+
toggle_shrink(paned.child2)
|
103
103
|
end
|
104
104
|
|
105
105
|
return frame
|
@@ -110,22 +110,22 @@ module Demo
|
|
110
110
|
is_child1 = (child == paned.child1)
|
111
111
|
|
112
112
|
resize = if is_child1
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
paned.child1_resize?
|
114
|
+
else
|
115
|
+
paned.child2_resize?
|
116
|
+
end
|
117
117
|
|
118
118
|
shrink = if is_child1
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
119
|
+
paned.child1_shrink?
|
120
|
+
else
|
121
|
+
paned.child2_shrink?
|
122
|
+
end
|
123
123
|
|
124
124
|
child.parent.remove(child)
|
125
125
|
if is_child1
|
126
|
-
|
126
|
+
paned.pack1(child, !resize, shrink)
|
127
127
|
else
|
128
|
-
|
128
|
+
paned.pack2(child, !resize, shrink)
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
@@ -134,22 +134,22 @@ module Demo
|
|
134
134
|
is_child1 = (child == paned.child1)
|
135
135
|
|
136
136
|
resize = if is_child1
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
137
|
+
paned.child1_resize?
|
138
|
+
else
|
139
|
+
paned.child2_resize?
|
140
|
+
end
|
141
141
|
|
142
142
|
shrink = if is_child1
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
143
|
+
paned.child1_shrink?
|
144
|
+
else
|
145
|
+
paned.child2_shrink?
|
146
|
+
end
|
147
147
|
|
148
148
|
child.parent.remove(child)
|
149
149
|
if is_child1
|
150
|
-
|
150
|
+
paned.pack1(child, resize, !shrink)
|
151
151
|
else
|
152
|
-
|
152
|
+
paned.pack2(child, resize, !shrink)
|
153
153
|
end
|
154
154
|
end
|
155
155
|
end
|
@@ -1,17 +1,13 @@
|
|
1
|
-
# Copyright (c) 2005
|
1
|
+
# Copyright (c) 2005-2014 Ruby-GNOME2 Project Team
|
2
2
|
# This program is licenced under the same licence as Ruby-GNOME2.
|
3
3
|
#
|
4
4
|
# $Id: rotated_text.rb,v 1.2 2005/03/05 15:01:16 mutoh Exp $
|
5
5
|
=begin
|
6
6
|
= Rotated Text
|
7
7
|
|
8
|
-
This demo shows how to use
|
9
|
-
The use of Gdk::PangoRenderer in this example is a somewhat advanced technique; most applications can simply use Gdk::Drawable#draw_layout.
|
10
|
-
We use it here mostly because that allows us to work in user coordinates - that is, coordinates prior to the application of the transformation matrix, rather than device coordinates.
|
11
|
-
As of GTK+-2.6, the ability to draw transformed and anti-aliased graphics as shown in this example is only present for text.
|
12
|
-
With GTK+-2.8, a new graphics system called "Cairo" will be introduced that provides these capabilities and many more for all types of graphics.
|
8
|
+
This demo shows how to use Cairo and Pango to draw rotated and transformed text.
|
13
9
|
=end
|
14
|
-
require
|
10
|
+
require "common"
|
15
11
|
|
16
12
|
module Demo
|
17
13
|
class RotatedText < BasicWindow
|
@@ -20,64 +16,56 @@ module Demo
|
|
20
16
|
FONT = "Sans Bold 27"
|
21
17
|
|
22
18
|
def initialize
|
23
|
-
super(
|
24
|
-
|
25
|
-
unless Gtk.check_version?(2, 6, 0)
|
26
|
-
add(Gtk::Label.new("This sample requires GTK+ 2.6.0 or later"))
|
27
|
-
return
|
28
|
-
end
|
19
|
+
super("Rotated Text")
|
29
20
|
|
30
21
|
drawing_area = Gtk::DrawingArea.new
|
31
22
|
add(drawing_area)
|
32
|
-
drawing_area.
|
23
|
+
drawing_area.override_background_color(:normal, Gdk::RGBA.new(1.0,
|
24
|
+
1.0,
|
25
|
+
1.0,
|
26
|
+
0.0))
|
33
27
|
|
34
|
-
drawing_area.signal_connect("
|
35
|
-
|
28
|
+
drawing_area.signal_connect("draw") do |_drawing_area, cairo_context|
|
29
|
+
cairo_context.set_source_rgb(1.0, 1.0, 1.0)
|
30
|
+
cairo_context.paint
|
31
|
+
cairo_context.save do
|
32
|
+
width, height = size
|
33
|
+
cairo_context.scale(width.to_f / (RADIUS * 2),
|
34
|
+
height.to_f / (RADIUS * 2))
|
35
|
+
draw_text(cairo_context)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
36
39
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
width = drawing_area.allocation.width
|
42
|
-
height = drawing_area.allocation.height
|
40
|
+
private
|
41
|
+
def draw_text(cairo_context)
|
42
|
+
# Center coordinates on the middle of the region we are drawing
|
43
|
+
cairo_context.translate(RADIUS, RADIUS)
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
# We first center, then change the scale
|
47
|
-
device_radius = [width, height].min / 2.0
|
45
|
+
# Create a PangoLayout, set the font and text
|
46
|
+
layout = cairo_context.create_pango_layout
|
48
47
|
|
49
|
-
|
50
|
-
|
51
|
-
matrix.scale!(device_radius / RADIUS, device_radius / RADIUS)
|
48
|
+
layout.text = "Text"
|
49
|
+
layout.font_description = Pango::FontDescription.new(FONT)
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
layout.text = "Text"
|
57
|
-
layout.font_description = Pango::FontDescription.new(FONT)
|
51
|
+
# Draw the layout N_WORDS times in a circle
|
52
|
+
N_WORDS.times do |i|
|
53
|
+
angle = (360.0 * i) / N_WORDS
|
58
54
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
55
|
+
cairo_context.save do
|
56
|
+
# Gradient from red at angle == 60 to blue at angle == 240
|
57
|
+
red = (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2
|
58
|
+
cairo_context.set_source_rgb(red, 0.0, 1.0 - red)
|
63
59
|
|
64
|
-
|
65
|
-
red = 65535 * (1 + Math.cos((angle - 60) * Math::PI / 180.0)) / 2
|
66
|
-
color = Gdk::Color.new(red, 0, 65535 - red)
|
67
|
-
renderer.set_override_color(Pango::Renderer::PART_FOREGROUND, color)
|
60
|
+
cairo_context.rotate(angle * Math::PI / 180.0)
|
68
61
|
|
69
|
-
|
70
|
-
|
62
|
+
# Inform Pango to re-layout the text with the new transformation
|
63
|
+
cairo_context.update_pango_layout(layout)
|
71
64
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
77
|
-
# Clean up default renderer, since it is shared
|
78
|
-
renderer.set_override_color(Gdk::PangoRenderer::PART_FOREGROUND, nil)
|
79
|
-
renderer.drawable = nil
|
80
|
-
renderer.gc = nil
|
65
|
+
width, height = layout.size
|
66
|
+
cairo_context.move_to(-(width / Pango::SCALE) / 2, -RADIUS)
|
67
|
+
cairo_context.show_pango_layout(layout)
|
68
|
+
end
|
81
69
|
end
|
82
70
|
end
|
83
71
|
end
|