gtk3 3.0.8-x64-mingw32 → 3.0.9-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/ext/gtk3/rb-gtk3.c +17 -0
  3. data/lib/2.2/gtk3.so +0 -0
  4. data/lib/2.3/gtk3.so +0 -0
  5. data/lib/gtk3/container.rb +0 -7
  6. data/lib/gtk3/deprecated.rb +3 -3
  7. data/lib/gtk3/image.rb +7 -7
  8. data/lib/gtk3/loader.rb +11 -5
  9. data/lib/gtk3/text-buffer.rb +33 -12
  10. data/lib/gtk3/text-view.rb +53 -0
  11. data/lib/gtk3/tree-model.rb +5 -0
  12. data/lib/gtk3/tree-view.rb +25 -0
  13. data/lib/gtk3/widget.rb +0 -5
  14. data/sample/gtk-demo/TODO +10 -6
  15. data/sample/gtk-demo/application.ui +93 -70
  16. data/sample/gtk-demo/appmenu.ui +19 -0
  17. data/sample/gtk-demo/assistant.rb +1 -0
  18. data/sample/gtk-demo/css_accordion.css +8 -8
  19. data/sample/gtk-demo/css_accordion.rb +2 -2
  20. data/sample/gtk-demo/css_basics.css +1 -1
  21. data/sample/gtk-demo/css_basics.rb +2 -2
  22. data/sample/gtk-demo/css_multiplebgs.rb +2 -2
  23. data/sample/gtk-demo/css_pixbufs.css +2 -2
  24. data/sample/gtk-demo/css_pixbufs.rb +2 -2
  25. data/sample/gtk-demo/css_shadows.css +5 -5
  26. data/sample/gtk-demo/css_shadows.rb +2 -2
  27. data/sample/gtk-demo/cssview.css +5 -5
  28. data/sample/gtk-demo/data/16x16/gtk3-demo-symbolic.symbolic.png +0 -0
  29. data/sample/gtk-demo/data/16x16/gtk3-demo.png +0 -0
  30. data/sample/gtk-demo/data/22x22/gtk3-demo-symbolic.symbolic.png +0 -0
  31. data/sample/gtk-demo/data/22x22/gtk3-demo.png +0 -0
  32. data/sample/gtk-demo/data/24x24/gtk3-demo-symbolic.symbolic.png +0 -0
  33. data/sample/gtk-demo/data/24x24/gtk3-demo.png +0 -0
  34. data/sample/gtk-demo/data/256x256/gtk3-demo-symbolic.symbolic.png +0 -0
  35. data/sample/gtk-demo/data/256x256/gtk3-demo.png +0 -0
  36. data/sample/gtk-demo/data/32x32/gtk3-demo-symbolic.symbolic.png +0 -0
  37. data/sample/gtk-demo/data/32x32/gtk3-demo.png +0 -0
  38. data/sample/gtk-demo/data/48x48/gtk3-demo-symbolic.symbolic.png +0 -0
  39. data/sample/gtk-demo/data/48x48/gtk3-demo.png +0 -0
  40. data/sample/gtk-demo/data/512x512/gtk3-demo-symbolic.symbolic.png +0 -0
  41. data/sample/gtk-demo/data/512x512/gtk3-demo.png +0 -0
  42. data/sample/gtk-demo/data/source.svg +2886 -0
  43. data/sample/gtk-demo/data/symbolic-source.svg +29 -0
  44. data/sample/gtk-demo/demo.gresource.xml +16 -5
  45. data/sample/gtk-demo/demo.ui +1 -0
  46. data/sample/gtk-demo/font_features.rb +1 -1
  47. data/sample/gtk-demo/main.rb +2 -2
  48. data/sample/gtk-demo/main.ui +18 -36
  49. data/sample/gtk-demo/markup.rb +53 -8
  50. data/sample/gtk-demo/markup.txt +2 -2
  51. data/sample/gtk-demo/org.gtk.Demo.gschema.xml +9 -0
  52. data/sample/gtk-demo/pixbufs.rb +105 -145
  53. data/sample/gtk-demo/reset.css +1 -58
  54. data/sample/gtk-demo/rotated_text.rb +119 -55
  55. data/sample/gtk-demo/shortcuts-boxes.ui +167 -0
  56. data/sample/gtk-demo/shortcuts-builder.ui +547 -0
  57. data/sample/gtk-demo/shortcuts-clocks.ui +166 -0
  58. data/sample/gtk-demo/shortcuts-gedit.ui +172 -0
  59. data/sample/gtk-demo/shortcuts.ui +65 -0
  60. data/sample/gtk-demo/stack.ui +5 -5
  61. data/sample/gtk-demo/textscroll.rb +106 -0
  62. data/sample/gtk-demo/theming.ui +58 -22
  63. data/sample/gtk-demo/theming_style_classes.rb +5 -4
  64. data/sample/gtk-demo/transparent.rb +143 -0
  65. data/sample/misc/aboutdialog.rb +1 -1
  66. data/sample/misc/bindings.rb +36 -15
  67. data/sample/misc/combobox.rb +1 -1
  68. data/sample/misc/dnd.rb +3 -3
  69. data/sample/misc/icons-theme-viewer.rb +1 -1
  70. data/sample/misc/iconview.rb +2 -2
  71. data/sample/misc/textbuffer-serialize.rb +18 -14
  72. data/sample/misc/to-drawable.rb +2 -2
  73. data/sample/misc/tooltips.rb +1 -0
  74. data/sample/misc/treeview.rb +1 -1
  75. data/sample/tutorial/README.md +18 -18
  76. data/test/test-gtk-clipboard.rb +1 -1
  77. data/test/test-gtk-combo-box.rb +2 -2
  78. data/test/test-gtk-icon-view.rb +2 -2
  79. data/test/test-gtk-image.rb +1 -1
  80. data/test/test-gtk-list-store.rb +9 -3
  81. data/test/test-gtk-text-view.rb +64 -0
  82. data/test/test-gtk-tree-path.rb +1 -3
  83. data/test/test-gtk-tree-view.rb +97 -0
  84. data/test/test-gtk-window.rb +2 -2
  85. data/test/test-pango-context.rb +56 -0
  86. metadata +46 -19
@@ -0,0 +1,29 @@
1
+ <?xml version='1.0' encoding='UTF-8' standalone='no'?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg xmlns:cc='http://creativecommons.org/ns#' xmlns:dc='http://purl.org/dc/elements/1.1/' sodipodi:docname='gtk3-demo-symbolic.svg' height='16.000015' id='svg7384' xmlns:inkscape='http://www.inkscape.org/namespaces/inkscape' xmlns:osb='http://www.openswatchbook.org/uri/2009/osb' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:sodipodi='http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd' xmlns:svg='http://www.w3.org/2000/svg' inkscape:version='0.48.5 r10040' version='1.1' width='16' xmlns='http://www.w3.org/2000/svg'>
5
+ <metadata id='metadata90'>
6
+ <rdf:RDF>
7
+ <cc:Work rdf:about=''>
8
+ <dc:format>image/svg+xml</dc:format>
9
+ <dc:type rdf:resource='http://purl.org/dc/dcmitype/StillImage'/>
10
+ <dc:title>Gnome Symbolic Icon Theme</dc:title>
11
+ </cc:Work>
12
+ </rdf:RDF>
13
+ </metadata>
14
+ <sodipodi:namedview inkscape:bbox-paths='true' bordercolor='#666666' borderopacity='1' inkscape:current-layer='layer9' inkscape:cx='-12.5126' inkscape:cy='-0.73412416' gridtolerance='10' inkscape:guide-bbox='true' guidetolerance='10' id='namedview88' inkscape:object-nodes='false' inkscape:object-paths='false' objecttolerance='10' pagecolor='#555753' inkscape:pageopacity='1' inkscape:pageshadow='2' showborder='false' showgrid='false' showguides='true' inkscape:snap-bbox='true' inkscape:snap-bbox-midpoints='false' inkscape:snap-global='true' inkscape:snap-grids='true' inkscape:snap-nodes='true' inkscape:snap-others='false' inkscape:snap-to-guides='true' inkscape:window-height='1375' inkscape:window-maximized='1' inkscape:window-width='2560' inkscape:window-x='0' inkscape:window-y='27' inkscape:zoom='5.6568542'>
15
+ <inkscape:grid empspacing='2' enabled='true' id='grid4866' originx='-182.99998px' originy='-251.99998px' snapvisiblegridlinesonly='true' spacingx='1px' spacingy='1px' type='xygrid' visible='true'/>
16
+ </sodipodi:namedview>
17
+ <title id='title9167'>Gnome Symbolic Icon Theme</title>
18
+ <defs id='defs7386'>
19
+ <linearGradient id='linearGradient7212' osb:paint='solid'>
20
+ <stop id='stop7214' offset='0' style='stop-color:#000000;stop-opacity:1;'/>
21
+ </linearGradient>
22
+ </defs>
23
+ <g inkscape:groupmode='layer' id='layer9' inkscape:label='apps' style='display:inline' transform='translate(-424.00018,35)'>
24
+
25
+ <rect height='8.0000048' id='rect7866' style='opacity:0.3;color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='matrix(0.83205029,0.5547002,0,1,0,0)' width='7.2111053' x='510.78668' y='-314.33347'/>
26
+ <rect height='8.0000086' id='rect7868' style='opacity:0.5;color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new' transform='matrix(-0.86824295,0.49613928,0,1,0,0)' width='8.0622425' x='-505.61908' y='219.8575'/>
27
+ <path inkscape:connector-curvature='0' d='m 431.53145,-28 -5.875,-3.65625 6.8125,-3.34375 6.03125,3 z' id='path7870' sodipodi:nodetypes='ccccc' style='color:#000000;fill:#bebebe;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.39999998;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:new'/>
28
+ </g>
29
+ </svg>
@@ -2,11 +2,13 @@
2
2
  <gresources>
3
3
  <gresource prefix="/ui">
4
4
  <file preprocess="xml-stripblanks">main.ui</file>
5
+ <file preprocess="xml-stripblanks">appmenu.ui</file>
5
6
  </gresource>
6
- <gresource prefix="/application">
7
+ <!-- <gresource prefix="/application_demo">
8
+ <file>application.c</file>
7
9
  <file>application.ui</file>
8
10
  <file>menus.ui</file>
9
- </gresource>
11
+ </gresource>-->
10
12
  <gresource prefix="/builder">
11
13
  <file>demo.ui</file>
12
14
  </gresource>
@@ -91,6 +93,13 @@
91
93
  <gresource prefix="/stack">
92
94
  <file>stack.ui</file>
93
95
  </gresource>
96
+ <gresource prefix="/shortcuts">
97
+ <file>shortcuts.ui</file>
98
+ <file>shortcuts-builder.ui</file>
99
+ <file>shortcuts-gedit.ui</file>
100
+ <file>shortcuts-clocks.ui</file>
101
+ <file>shortcuts-boxes.ui</file>
102
+ </gresource>
94
103
  <gresource prefix="/revealer">
95
104
  <file>revealer.ui</file>
96
105
  </gresource>
@@ -110,8 +119,8 @@
110
119
  <file>gnu-keys.png</file>
111
120
  </gresource>
112
121
  <gresource prefix="/sources">
113
- <!-- <file>application.rb</file>
114
- <file>assistant.rb</file>
122
+ <!-- <file>application_demo.rb</file>
123
+ <file>assistant.rb</file>
115
124
  <file>builder.rb</file>
116
125
  <file>button_box.rb</file>
117
126
  <file>changedisplay.rb</file>
@@ -133,6 +142,7 @@
133
142
  <file>expander.rb</file>
134
143
  <file>filtermodel.rb</file>
135
144
  <file>flowbox.rb</file>
145
+ <file>foreigndrawing.rb</file>
136
146
  <file>font_features.rb</file>
137
147
  <file>gestures.rb</file>
138
148
  <file>glarea.rb</file>
@@ -163,6 +173,7 @@
163
173
  <file>scale.rb</file>
164
174
  <file>search_entry.rb</file>
165
175
  <file>search_entry2.rb</file>
176
+ <file>shortcuts.rb</file>
166
177
  <file>sizegroup.rb</file>
167
178
  <file>sidebar.rb</file>
168
179
  <file>stack.rb</file>
@@ -191,7 +202,7 @@
191
202
  <file>glarea-fragment.glsl</file>
192
203
  <file>glarea-vertex.glsl</file>
193
204
  </gresource>
194
- <gresource prefix="/font-features">
205
+ <gresource prefix="/font_features">
195
206
  <file>font-features.ui</file>
196
207
  </gresource>
197
208
  <gresource prefix="/spinbutton">
@@ -78,6 +78,7 @@
78
78
  <property name="visible">1</property>
79
79
  <property name="label" translatable="yes">Save _As</property>
80
80
  <property name="use-underline">1</property>
81
+ <accelerator key="s" modifiers="primary | shift-mask" signal="activate"/>
81
82
  </object>
82
83
  </child>
83
84
  <child>
@@ -10,7 +10,7 @@
10
10
  =end
11
11
  module FontFeaturesDemo
12
12
  def self.run_demo(main_window)
13
- builder = Gtk::Builder.new(:resource => "/font-features/font-features.ui")
13
+ builder = Gtk::Builder.new(:resource => "/font_features/font-features.ui")
14
14
  window = builder["window"]
15
15
  label = builder["label"]
16
16
  settings = builder["settings"]
@@ -438,7 +438,7 @@ class Demo < Gtk::Application
438
438
  def fontify(start_iter = @source_buffer.start_iter,
439
439
  end_iter = @source_buffer.end_iter)
440
440
  str = @source_buffer.get_text(start_iter, end_iter, true)
441
- tokenizer = RubyTokonizer.new
441
+ tokenizer = RubyTokenizer.new
442
442
  tokenizer.tokenize(str, start_iter.offset) do |tag, start, last|
443
443
  @source_buffer.apply_tag(tag.to_s,
444
444
  @source_buffer.get_iter_at(:offset => start),
@@ -446,7 +446,7 @@ class Demo < Gtk::Application
446
446
  end
447
447
  end
448
448
 
449
- class RubyTokonizer
449
+ class RubyTokenizer
450
450
  RESERVED_WORDS = %w(begin end module class def if then else
451
451
  while unless do case when require yield)
452
452
  RESERVED_WORDS_PATTERN = Regexp.compile(/(^|\s+)(#{RESERVED_WORDS.collect do |pat| Regexp.quote(pat) end.join("|")})(\s+|$)/)
@@ -1,31 +1,12 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <interface>
3
3
  <!-- interface-requires gtk+ 3.10 -->
4
- <menu id="appmenu">
5
- <section>
6
- <item>
7
- <attribute name="label" translatable="yes">About</attribute>
8
- <attribute name="action">app.about</attribute>
9
- </item>
10
- </section>
11
- <section>
12
- <item>
13
- <attribute name="label" translatable="yes">_Quit</attribute>
14
- <attribute name="action">app.quit</attribute>
15
- <attribute name="accel">&lt;Primary&gt;q</attribute>
16
- </item>
17
- </section>
18
- </menu>
19
4
  <object class="GtkTreeStore" id="treestore">
20
5
  <columns>
21
- <!-- column-name NAME
22
- <column type="gchararray"/> -->
23
6
  <!-- column-name TITLE -->
24
7
  <column type="gchararray"/>
25
8
  <!-- column-name FILENAME -->
26
9
  <column type="gchararray"/>
27
- <!-- column-name FUNC
28
- <column type="gpointer"/> -->
29
10
  <!-- column-name STYLE -->
30
11
  <column type="gint"/>
31
12
  </columns>
@@ -41,7 +22,7 @@
41
22
  <property name="visible">1</property>
42
23
  <property name="show-close-button">1</property>
43
24
  <child>
44
- <object class="GtkButton" id="run_button">
25
+ <object class="GtkButton">
45
26
  <property name="visible">1</property>
46
27
  <property name="valign">center</property>
47
28
  <property name="can_focus">1</property>
@@ -50,7 +31,7 @@
50
31
  <class name="text-button"/>
51
32
  </style>
52
33
  <child>
53
- <object class="GtkLabel" id="run_label">
34
+ <object class="GtkLabel">
54
35
  <property name="visible">1</property>
55
36
  <property name="label" translatable="yes">Run</property>
56
37
  </object>
@@ -60,21 +41,18 @@
60
41
  </object>
61
42
  </child>
62
43
  <child>
63
- <object class="GtkBox" id="box1">
44
+ <object class="GtkBox">
64
45
  <property name="visible">1</property>
65
46
  <child>
66
47
  <object class="GtkFrame">
67
48
  <property name="visible">1</property>
68
49
  <child>
69
- <object class="GtkScrolledWindow" id="scrolledwindow">
50
+ <object class="GtkScrolledWindow">
70
51
  <property name="width_request">120</property>
71
52
  <property name="visible">1</property>
72
53
  <property name="can_focus">1</property>
73
54
  <property name="hscrollbar_policy">never</property>
74
55
  <property name="min_content_width">150</property>
75
- <style>
76
- <class name="sidebar"/>
77
- </style>
78
56
  <child>
79
57
  <object class="GtkTreeView" id="treeview">
80
58
  <property name="visible">1</property>
@@ -87,15 +65,19 @@
87
65
  </object>
88
66
  </child>
89
67
  <child>
90
- <object class="GtkTreeViewColumn" id="treeviewcolumn0">
91
- <property name="title" translatable="yes">column</property>
68
+ <object class="GtkTreeViewColumn">
92
69
  <child>
93
- <object class="GtkCellRendererText" id="cellrenderertext0"/>
70
+ <object class="GtkCellRendererText"/>
94
71
  <attributes>
95
72
  <attribute name="style">2</attribute>
96
73
  <attribute name="text">0</attribute>
97
74
  </attributes>
98
75
  </child>
76
+ <child>
77
+ <object class="GtkCellRendererText">
78
+ <property name="text"> </property>
79
+ </object>
80
+ </child>
99
81
  </object>
100
82
  </child>
101
83
  </object>
@@ -112,7 +94,7 @@
112
94
  <property name="enable_popup">1</property>
113
95
  <property name="show_border">0</property>
114
96
  <child>
115
- <object class="GtkScrolledWindow" id="info-scrolledwindow">
97
+ <object class="GtkScrolledWindow">
116
98
  <property name="visible">1</property>
117
99
  <property name="can_focus">1</property>
118
100
  <child>
@@ -121,8 +103,8 @@
121
103
  <property name="can_focus">1</property>
122
104
  <property name="left-margin">20</property>
123
105
  <property name="right-margin">20</property>
124
- <!-- TODO <property name="top-margin">20</property>
125
- <property name="bottom-margin">20</property>-->
106
+ <property name="top-margin">20</property>
107
+ <property name="bottom-margin">20</property>
126
108
  <property name="pixels_above_lines">2</property>
127
109
  <property name="pixels_below_lines">2</property>
128
110
  <property name="editable">0</property>
@@ -136,7 +118,7 @@
136
118
  </packing>
137
119
  </child>
138
120
  <child type="tab">
139
- <object class="GtkLabel" id="label1">
121
+ <object class="GtkLabel">
140
122
  <property name="visible">1</property>
141
123
  <property name="label" translatable="yes">_Info</property>
142
124
  <property name="use_underline">1</property>
@@ -156,8 +138,8 @@
156
138
  <property name="can_focus">1</property>
157
139
  <property name="left-margin">20</property>
158
140
  <property name="right-margin">20</property>
159
- <!-- TODO <property name="top-margin">20</property>
160
- <property name="bottom-margin">20</property> -->
141
+ <property name="top-margin">20</property>
142
+ <property name="bottom-margin">20</property>
161
143
  <property name="editable">0</property>
162
144
  <property name="cursor_visible">0</property>
163
145
  </object>
@@ -169,7 +151,7 @@
169
151
  </packing>
170
152
  </child>
171
153
  <child type="tab">
172
- <object class="GtkLabel" id="label2">
154
+ <object class="GtkLabel">
173
155
  <property name="visible">1</property>
174
156
  <property name="label" translatable="yes">Source</property>
175
157
  </object>
@@ -17,25 +17,70 @@ module MarkupDemo
17
17
  window.screen = main_window.screen
18
18
  window.set_default_size(450, 450)
19
19
 
20
- window.set_title("Markup")
20
+ stack = Gtk::Stack.new
21
+ stack.show
22
+ window.add(stack)
23
+
24
+ show_source = Gtk::CheckButton.new("Source")
25
+ show_source.valign = :center
26
+
27
+ header = Gtk::HeaderBar.new
28
+ header.pack_start(show_source)
29
+ header.show_close_button = true
30
+ header.show_all
31
+ window.titlebar = header
32
+
33
+ window.title = "Markup"
21
34
 
22
35
  view = Gtk::TextView.new
23
- view.set_wrap_mode(:word)
24
- view.set_left_margin(10)
25
- view.set_right_margin(10)
36
+ view.wrap_mode = :word
37
+ view.left_margin = 10
38
+ view.right_margin = 10
26
39
 
27
40
  sw = Gtk::ScrolledWindow.new(nil, nil)
28
- sw.set_policy(:never, :automatic)
41
+ sw.set_policy(:automatic, :automatic)
29
42
 
30
- window.add(sw)
31
43
  sw.add(view)
44
+ sw.show_all
45
+
46
+ stack.add_named(sw, "formatted")
47
+
48
+ view2 = Gtk::TextView.new
49
+ view2.wrap_mode = :word
50
+ view2.left_margin = 10
51
+ view2.right_margin = 10
52
+
53
+ sw = Gtk::ScrolledWindow.new(nil, nil)
54
+ sw.set_policy(:automatic, :automatic)
55
+
56
+ sw.add(view2)
57
+ sw.show_all
58
+
59
+ stack.add_named(sw, "source")
32
60
 
33
61
  markup = Gio::Resources.lookup_data("/markup/markup.txt", 0)
34
-
62
+
63
+ show_source.signal_connect "toggled" do |button|
64
+ if button.active?
65
+ stack.visible_child_name = "source"
66
+ else
67
+ buffer = view2.buffer
68
+ markup = buffer.get_text(buffer.start_iter,
69
+ buffer.end_iter,
70
+ false)
71
+ buffer = view.buffer
72
+ buffer.insert_markup(buffer.start_iter, markup, -1)
73
+ stack.visible_child_name = "formatted"
74
+ end
75
+ end
76
+
35
77
  buffer = view.buffer
36
78
  buffer.insert_markup(buffer.start_iter, markup, -1)
37
79
 
38
- sw.show_all
80
+ buffer = view2.buffer
81
+ buffer.insert(buffer.start_iter, markup)
82
+
83
+ stack.show
39
84
 
40
85
  if !window.visible?
41
86
  window.show_all
@@ -1,9 +1,9 @@
1
1
 
2
2
  Text sizes: <span size="xx-small">tiny</span> <span size="x-small">very small</span> <span size="small">small</span> <span size="medium">normal</span> <span size="large">large</span> <span size="x-large">very large</span> <span size="xx-large">huge</span>
3
3
 
4
- Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</span>rs</span>
4
+ Text <span color="gray">c<span color="green">o</span>l<span color="tomato">o</span>rs</span> and <span background="pink">backgrounds</span>
5
5
 
6
- Colorful <span underline="low" underline-color="blue"><span underline="double" underline-color="red">under</span>lines</span>
6
+ Colorful <span underline="low" underline-color="blue"><span underline="double" underline-color="red">under</span>lines</span> and <span background="pink"><span underline="error">mo</span><span underline="error" underline-color="green">re</span></span>
7
7
 
8
8
  Colorful <span strikethrough="true" strikethrough-color="magenta">strikethroughs</span>
9
9
 
@@ -12,6 +12,15 @@
12
12
  <key name='color' enum='org.gtk.Demo.Color'>
13
13
  <default>'red'</default>
14
14
  </key>
15
+ <key name='window-size' type='(ii)'>
16
+ <default>(-1, -1)</default>
17
+ </key>
18
+ <key name='maximized' type='b'>
19
+ <default>false</default>
20
+ </key>
21
+ <key name='fullscreen' type='b'>
22
+ <default>false</default>
23
+ </key>
15
24
  </schema>
16
25
 
17
26
  </schemalist>
@@ -1,167 +1,127 @@
1
- # Copyright (c) 2003-2014 Ruby-GNOME2 Project Team
1
+ # Copyright (c) 2016 Ruby-GNOME2 Project Team
2
2
  # This program is licenced under the same licence as Ruby-GNOME2.
3
3
  #
4
- # $Id: pixbufs.rb,v 1.5 2005/02/12 23:02:43 kzys Exp $
5
4
  =begin
6
- = Pixbufs
5
+ = Pixbufs
7
6
 
8
- A Gdk::Pixbuf represents an image, normally in RGB or RGBA format.
9
- Pixbufs are normally used to load files from disk and perform
10
- image scaling.
7
+ A GdkPixbuf represents an image, normally in RGB or RGBA format.
8
+ Pixbufs are normally used to load files from disk and perform
9
+ image scaling.
11
10
 
12
- This demo is not all that educational, but looks cool. It was written
13
- by Extreme Pixbuf Hacker Federico Mena Quintero. It also shows
14
- off how to use Gtk::DrawingArea to do a simple animation.
11
+ This demo is not all that educational, but looks cool. It was written
12
+ by Extreme Pixbuf Hacker Federico Mena Quintero. It also shows
13
+ off how to use GtkDrawingArea to do a simple animation.
15
14
 
16
- Look at the Image demo for additional pixbuf usage examples.
15
+ Look at the Image demo for additional pixbuf usage examples.
17
16
  =end
18
-
19
- require "common"
20
-
21
- module Demo
22
- class Pixbufs < BasicWindow
23
- FRAME_DELAY = 50
24
-
25
- BACKGROUND_NAME = "background.jpg"
26
-
27
- IMAGE_NAMES = [
28
- "apple-red.png",
29
- "gnome-applets.png",
30
- "gnome-calendar.png",
31
- "gnome-foot.png",
32
- "gnome-gmush.png",
33
- "gnome-gimp.png",
34
- "gnome-gsame.png",
35
- "gnu-keys.png",
36
- "ruby-gnome2-logo.png",
37
- ]
38
-
39
- CYCLE_LEN = 60
40
- def initialize
41
- super("Pixbufs")
42
- set_resizable(false)
43
-
44
- @background = nil
45
- @frame = nil
46
- @frame_num = 0
47
- @images = []
48
-
49
- begin
50
- load_pixbufs
51
-
52
- set_size_request(@background.width, @background.height)
53
-
54
- @frame = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB,
55
- false, 8,
56
- @background.width, @background.height)
57
-
58
- @da = Gtk::DrawingArea.new
59
-
60
- @da.signal_connect("draw") do |w, e|
61
- draw_cb(w, e)
62
- end
63
-
64
- add(@da)
65
-
66
- timeout_id = GLib::Timeout.add(FRAME_DELAY) do
67
- timeout
68
- end
69
- signal_connect("destroy") do
70
- GLib::Source.remove(timeout_id)
71
- end
72
- rescue
73
- message = "Failed to load an image: #{$!.message}"
74
- dialog = Gtk::MessageDialog.new(:parent => self,
75
- :flags => :destroy_with_parent,
76
- :type => :error,
77
- :buttons_type => :close,
78
- :message => message)
79
-
80
- dialog.signal_connect("response") do
81
- dialog.destroy
82
- end
83
-
84
- dialog.show
85
- end
17
+ module PixbufsDemo
18
+ IMAGES_NAMES = %w(/pixbufs/apple-red.png /pixbufs/gnome-applets.png
19
+ /pixbufs/gnome-calendar.png /pixbufs/gnome-foot.png
20
+ /pixbufs/gnome-gmush.png /pixbufs/gnome-gimp.png
21
+ /pixbufs/gnome-gsame.png /pixbufs/gnu-keys.png)
22
+ N_IMAGES = IMAGES_NAMES.size
23
+ BACKGROUND_NAME = "/pixbufs/background.jpg"
24
+ CYCLE_TIME = 3_000_000
25
+
26
+ def self.run_demo(main_window)
27
+ window = Gtk::Window.new(:toplevel)
28
+ window.screen = main_window.screen
29
+ window.resizable = false
30
+
31
+ background_pixbuf = load_pixbuf(window, BACKGROUND_NAME)
32
+ other_pixbufs = []
33
+ IMAGES_NAMES.each do |img|
34
+ other_pixbufs << load_pixbuf(window, img)
86
35
  end
87
36
 
88
- def load_pixbufs
89
- # Loads the images for the demo
37
+ width = background_pixbuf.width
38
+ height = background_pixbuf.height
39
+ window.set_size_request(width, height)
90
40
 
91
- if @background
92
- return # already loaded earlier
93
- end
41
+ frame = GdkPixbuf::Pixbuf.new(:colorspace => :rgb,
42
+ :has_alpha => false,
43
+ :bits_per_sample => 8,
44
+ :width => width, :height => height)
94
45
 
95
- # demo_find_file() looks in the the current directory first,
96
- # so you can run gtk-demo without installing GTK, then looks
97
- # in the location where the file is installed.
98
- #
99
- filename = Demo.find_file(BACKGROUND_NAME)
100
- @background = Gdk::Pixbuf.new(filename)
46
+ da = Gtk::DrawingArea.new
47
+ da.signal_connect "draw" do |_widget, cr|
48
+ cr.set_source_pixbuf(frame, 0, 0)
49
+ cr.paint
50
+ true
51
+ end
52
+ window.add(da)
53
+ start_time = 0
54
+ da.add_tick_callback do |_widget, frame_clock|
55
+ background_pixbuf.copy_area(0, 0, width, height, frame, 0, 0)
56
+ start_time = frame_clock.frame_time if start_time == 0
57
+ current_time = frame_clock.frame_time
58
+ f = ((current_time - start_time) % CYCLE_TIME) / Float(CYCLE_TIME)
59
+ xmid = width / 2
60
+ ymid = height / 2
61
+ radius = [xmid, ymid].min / 2
62
+ N_IMAGES.times do |i|
63
+ ang = 2 * Math::PI * i / N_IMAGES - f * 2 * Math::PI
64
+ iw = other_pixbufs[i].width
65
+ ih = other_pixbufs[i].height
66
+
67
+ r = radius + (radius / 3) * Math.sin(f * 2 * Math::PI)
68
+
69
+ xpos = (xmid + r * Math.cos(ang) - iw / 2 + 0.5).floor
70
+ ypos = (ymid + r * Math.sin(ang) - ih / 2 + 0.5).floor
71
+ k = (i & 1) ? Math.sin(f * 2 * Math::PI) : Math.cos(f * 2 * Math::PI)
72
+ k = 2.0 * k * k
73
+ k = [0.25, k].max
74
+
75
+ r1 = Gdk::Rectangle.new(xpos, ypos, iw * k, iw * k)
76
+ r2 = Gdk::Rectangle.new(0, 0, width, height)
101
77
 
102
- IMAGE_NAMES.each_with_index do |basename, i|
103
- filename = Demo.find_file(basename)
78
+ dest = r1.intersect(r2)
79
+ next unless dest
80
+ frame.composite!(other_pixbufs[i], dest.x, dest.y, dest.width,
81
+ dest.height, xpos, ypos, k, k,
82
+ :nearest,
83
+ if (i & 1) == 1
84
+ [
85
+ 127, (255 * Math.sin(f * 2.0 * Math::PI)).abs
86
+ ].max
87
+ else
88
+ [
89
+ 127, (255 * Math.cos(f * 2.0 * Math::PI)).abs
90
+ ].max
91
+ end)
104
92
 
105
- @images[i] = Gdk::Pixbuf.new(filename)
106
93
  end
94
+ da.queue_draw
95
+ GLib::Source::CONTINUE
107
96
  end
108
97
 
109
- def draw_cb(widget, cairo_context)
110
- cairo_context.set_source_pixbuf(@frame)
111
- cairo_context.paint
112
- true
98
+ if !window.visible?
99
+ window.show_all
100
+ else
101
+ window.destroy
113
102
  end
103
+ window
104
+ end
114
105
 
115
- # Timeout handler to regenerate the frame
116
- def timeout
117
- @background.copy_area(0, 0, @background.width, @background.height,
118
- @frame, 0, 0)
119
-
120
- f = Float(@frame_num % CYCLE_LEN) / CYCLE_LEN;
121
-
122
- xmid = @background.width / 2.0
123
- ymid = @background.height / 2.0
124
-
125
- radius = [xmid, ymid].min / 2.0
126
-
127
- @images.each_with_index do |image, i|
128
- ang = 2.0 * Math::PI * Float(i) / IMAGE_NAMES.length - f * 2.0 * Math::PI
129
-
130
- r = radius + (radius / 3.0) * Math.sin(f * 2.0 * Math::PI)
131
-
132
- xpos = (xmid + r * Math.cos(ang) - image.width / 2.0 + 0.5).floor
133
- ypos = (ymid + r * Math.sin(ang) - image.height / 2.0 + 0.5).floor
134
-
135
- k = if (i & 1) == 1
136
- Math.sin(f * 2.0 * Math::PI)
137
- else
138
- Math.cos(f * 2.0 * Math::PI)
139
- end
140
- k = [0.25, 2.0 * k * k].max
141
-
142
- r1 = Gdk::Rectangle.new(xpos, ypos, image.width * k, image.height * k)
143
- r2 = Gdk::Rectangle.new(0, 0, @background.width, @background.height)
106
+ def self.show_message_dialog_on(window, error)
107
+ message = "Failed to load an image: #{error.message}"
108
+ dialog = Gtk::MessageDialog.new(:parent => window,
109
+ :flags => :destroy_with_parent,
110
+ :type => :error,
111
+ :buttons => :close,
112
+ :message => message)
113
+ dialog.signal_connect("response", &:destroy)
114
+ dialog.show
115
+ end
144
116
 
145
- dest = r1.intersect(r2)
146
- if dest
147
- @frame.composite!(image, dest.x, dest.y, dest.width, dest.height,
148
- xpos, ypos, k, k, Gdk::Pixbuf::INTERP_NEAREST,
149
- if (i & 1) == 1
150
- [
151
- 127,
152
- (255 * Math.sin(f * 2.0 * Math::PI)).abs,
153
- ].max
154
- else
155
- [
156
- 127,
157
- (255 * Math.cos(f * 2.0 * Math::PI)).abs,
158
- ].max
159
- end)
160
- end
161
- end
162
- @da.queue_draw
163
- @frame_num += 1
164
- true
117
+ def self.load_pixbuf(window, image_name)
118
+ begin
119
+ # Is it OK? should we implement gdk_pixbuf_new_from_resource instead?
120
+ #Gtk::Image.new(:resource => image_name).pixbuf
121
+ GdkPixbuf::Pixbuf.new(:resource => image_name)
122
+ rescue StandardError => e
123
+ show_message_dialog_on(window, e)
124
+ window.destroy
165
125
  end
166
126
  end
167
127
  end