gtk3 2.2.0-x86-mingw32 → 2.2.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/extconf.rb +3 -2
  3. data/ext/gtk3/rbgtk-color-button.c +7 -1
  4. data/ext/gtk3/rbgtk-dialog.c +26 -6
  5. data/ext/gtk3/rbgtk-image.c +1 -0
  6. data/ext/gtk3/rbgtk-selection-data.c +4 -5
  7. data/ext/gtk3/rbgtk-stack-switcher.c +41 -0
  8. data/ext/gtk3/rbgtk-window.c +8 -0
  9. data/ext/gtk3/rbgtk.c +158 -0
  10. data/ext/gtk3/rbgtk3.h +33 -0
  11. data/ext/gtk3/rbgtk3conversions.h +60 -1
  12. data/ext/gtk3/rbgtk3private.h +1 -1
  13. data/lib/2.0/gtk3.so +0 -0
  14. data/lib/gtk3.rb +1 -0
  15. data/sample/gtk-demo/cairo-arc-negative.rb +1 -1
  16. data/sample/gtk-demo/cairo-arc.rb +1 -1
  17. data/sample/gtk-demo/cairo-clip-image.rb +6 -6
  18. data/sample/gtk-demo/cairo-clip-rectangle.rb +2 -2
  19. data/sample/gtk-demo/cairo-curve-rectangle.rb +2 -2
  20. data/sample/gtk-demo/cairo-curve-to.rb +2 -2
  21. data/sample/gtk-demo/cairo-dash.rb +1 -1
  22. data/sample/gtk-demo/cairo-fill-and-stroke.rb +1 -1
  23. data/sample/gtk-demo/cairo-fill-and-stroke2.rb +2 -2
  24. data/sample/gtk-demo/cairo-gradient.rb +1 -1
  25. data/sample/gtk-demo/cairo-image-pattern.rb +5 -5
  26. data/sample/gtk-demo/cairo-image.rb +4 -4
  27. data/sample/gtk-demo/cairo-line-cap.rb +8 -8
  28. data/sample/gtk-demo/cairo-line-join.rb +3 -3
  29. data/sample/gtk-demo/cairo-long-lines.rb +3 -3
  30. data/sample/gtk-demo/cairo-pattern-fill.rb +11 -11
  31. data/sample/gtk-demo/cairo-self-intersect.rb +2 -2
  32. data/sample/gtk-demo/cairo-text-align-center.rb +4 -4
  33. data/sample/gtk-demo/cairo-text-extents.rb +5 -5
  34. data/sample/gtk-demo/cairo-text.rb +3 -3
  35. data/sample/gtk-demo/common.rb +0 -1
  36. data/sample/gtk-demo/dialog.rb +23 -23
  37. data/sample/gtk-demo/drawingarea.rb +5 -1
  38. data/sample/gtk-demo/editable_cells.rb +28 -28
  39. data/sample/gtk-demo/entry_completion.rb +3 -3
  40. data/sample/gtk-demo/images.rb +75 -75
  41. data/sample/gtk-demo/item_factory.rb +40 -40
  42. data/sample/gtk-demo/list_store.rb +13 -13
  43. data/sample/gtk-demo/menus.rb +34 -34
  44. data/sample/gtk-demo/panes.rb +28 -28
  45. data/sample/gtk-demo/rotated_text.rb +41 -53
  46. data/sample/gtk-demo/sizegroup.rb +17 -17
  47. data/sample/gtk-demo/spinner.rb +1 -1
  48. data/sample/gtk-demo/textview.rb +137 -137
  49. data/sample/gtk-demo/theming.ui +319 -0
  50. data/sample/gtk-demo/theming_style_classes.rb +48 -0
  51. data/sample/gtk-demo/tree_store.rb +127 -127
  52. data/sample/misc/assistant.rb +6 -66
  53. data/sample/misc/bindings.rb +22 -32
  54. data/sample/misc/button.rb +8 -5
  55. data/sample/misc/buttonbox.rb +2 -2
  56. data/sample/misc/checkbutton.rb +4 -1
  57. data/sample/misc/colorselection.rb +7 -10
  58. data/sample/misc/combo_check.rb +34 -26
  59. data/sample/misc/combobox.rb +10 -11
  60. data/sample/misc/cursor.rb +3 -1
  61. data/sample/misc/dialog.rb +12 -12
  62. data/sample/misc/dialog2.rb +13 -16
  63. data/sample/misc/drawing.rb +40 -21
  64. data/sample/misc/statusicon.rb +28 -45
  65. data/sample/misc/threads.rb +16 -18
  66. data/sample/misc/tree_progress.rb +10 -12
  67. data/test/run-test.rb +17 -9
  68. data/test/test_gtk_search_bar.rb +1 -1
  69. data/test/test_gtk_stack_switcher.rb +30 -0
  70. metadata +26 -24
  71. data/lib/1.9/gtk3.so +0 -0
  72. data/lib/2.1/gtk3.so +0 -0
@@ -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
- '<main>', accel_group)
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
- puts "ItemFactory: activated \"#{Gtk::ItemFactory.path_from_widget(widget)}\""
25
+ puts "ItemFactory: activated \"#{Gtk::ItemFactory.path_from_widget(widget)}\""
26
26
  end
27
27
  menu_items = [
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],
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
- quit
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
- iter = store.append
76
- bug.each_with_index do |value, index|
77
- iter[index] = value
78
- end
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
- fixed_toggled(treeview.model, path)
87
+ fixed_toggled(treeview.model, path)
88
88
  end
89
89
 
90
90
  column = Gtk::TreeViewColumn.new('Fixed?',
91
- renderer,
92
- 'active' => COLUMN_FIXED)
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
- renderer,
103
- 'text' => COLUMN_NUMBER)
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
- renderer,
111
- 'text' => COLUMN_SEVERITY)
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
- renderer,
119
- 'text' => COLUMN_DESCRIPTION)
118
+ renderer,
119
+ 'text' => COLUMN_DESCRIPTION)
120
120
  column.set_sort_column_id(COLUMN_DESCRIPTION)
121
121
  treeview.append_column(column)
122
122
  end
@@ -83,31 +83,31 @@ module Demo
83
83
  menu.append(menuitem)
84
84
  menuitem.show
85
85
  menuitem.add_accelerator('activate',
86
- accel_group,
87
- Gdk::Keyval::GDK_F1,
88
- 0,
89
- Gtk::ACCEL_VISIBLE)
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
- accel_group,
95
- Gdk::Keyval::GDK_F2,
96
- 0,
97
- Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED)
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
- accel_group,
103
- Gdk::Keyval::GDK_F2,
104
- 0,
105
- Gtk::ACCEL_VISIBLE)
102
+ accel_group,
103
+ Gdk::Keyval::GDK_F2,
104
+ 0,
105
+ Gtk::ACCEL_VISIBLE)
106
106
  menuitem.add_accelerator('activate',
107
- accel_group,
108
- Gdk::Keyval::GDK_F3,
109
- 0,
110
- Gtk::ACCEL_VISIBLE)
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
- quit
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
- return nil
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
- menuitem = Gtk::TearoffMenuItem.new
148
- menu.append(menuitem)
149
- menuitem.show
147
+ menuitem = Gtk::TearoffMenuItem.new
148
+ menu.append(menuitem)
149
+ menuitem.show
150
150
  end
151
151
 
152
152
  5.times do |i|
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
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
@@ -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
- 'Horizontal', 'Left', 'Right'),
58
- :expand => false, :fill => false, :padding => 0)
57
+ 'Horizontal', 'Left', 'Right'),
58
+ :expand => false, :fill => false, :padding => 0)
59
59
 
60
60
  vbox.pack_start(create_pane_options(vpaned,
61
- 'Vertical', 'Top', 'Bottom'),
62
- :expand => false, :fill => false, :padding => 0)
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
- toggle_resize(paned.child1)
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
- toggle_shrink(paned.child1)
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
- toggle_resize(paned.child2)
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
- toggle_shrink(paned.child2)
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
- paned.child1_resize?
114
- else
115
- paned.child2_resize?
116
- end
113
+ paned.child1_resize?
114
+ else
115
+ paned.child2_resize?
116
+ end
117
117
 
118
118
  shrink = if is_child1
119
- paned.child1_shrink?
120
- else
121
- paned.child2_shrink?
122
- end
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
- paned.pack1(child, !resize, shrink)
126
+ paned.pack1(child, !resize, shrink)
127
127
  else
128
- paned.pack2(child, !resize, shrink)
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
- paned.child1_resize?
138
- else
139
- paned.child2_resize?
140
- end
137
+ paned.child1_resize?
138
+ else
139
+ paned.child2_resize?
140
+ end
141
141
 
142
142
  shrink = if is_child1
143
- paned.child1_shrink?
144
- else
145
- paned.child2_shrink?
146
- end
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
- paned.pack1(child, resize, !shrink)
150
+ paned.pack1(child, resize, !shrink)
151
151
  else
152
- paned.pack2(child, resize, !shrink)
152
+ paned.pack2(child, resize, !shrink)
153
153
  end
154
154
  end
155
155
  end
@@ -1,17 +1,13 @@
1
- # Copyright (c) 2005 Ruby-GNOME2 Project Team
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 GDK and Pango to draw rotated and transformed text.
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 'common'
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('Rotated Text')
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.modify_bg(Gtk::STATE_NORMAL, Gdk::Color.new(65535, 65535, 65535))
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("expose_event") do
35
- matrix = Pango::Matrix.new
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
- # Get the default renderer for the screen, and set it up for drawing
38
- renderer = Gdk::PangoRenderer.get_default(drawing_area.screen)
39
- renderer.drawable = drawing_area.window
40
- renderer.gc = style.black_gc
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
- # Set up a transformation matrix so that the user space coordinates for
45
- # the centered square where we draw are [-RADIUS, RADIUS], [-RADIUS, RADIUS]
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
- matrix.translate!(device_radius + (width - 2 * device_radius) / 2.0,
50
- device_radius + (height - 2 * device_radius) / 2.0)
51
- matrix.scale!(device_radius / RADIUS, device_radius / RADIUS)
48
+ layout.text = "Text"
49
+ layout.font_description = Pango::FontDescription.new(FONT)
52
50
 
53
- # Create a PangoLayout, set the font and text
54
- context = Gdk::Pango.context
55
- layout = Pango::Layout.new(context)
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
- # Draw the layout N_WORDS times in a circle
60
- (0...N_WORDS).each do |i|
61
- rotated_matrix = matrix.dup
62
- angle = 360 * i / N_WORDS.to_f
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
- # Gradient from red at angle == 60 to blue at angle == 300
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
- rotated_matrix.rotate!(angle)
70
- context.matrix = rotated_matrix
62
+ # Inform Pango to re-layout the text with the new transformation
63
+ cairo_context.update_pango_layout(layout)
71
64
 
72
- # Inform Pango to re-layout the text with the new transformation matrix
73
- layout.context_changed
74
- width, height = layout.size
75
- renderer.draw_layout(layout, - width / 2, - RADIUS * Pango::SCALE)
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