Skip to content

Commit 3133643

Browse files
committed
Fix samples formatting, get them working
Also deletes mxwidgets.lua because Mx is dead, and deletes repobrowser.lua because of a GTK+ 3 override bug that I don't care about fixing.
1 parent fd2760e commit 3133643

17 files changed

Lines changed: 1147 additions & 1400 deletions

samples/cairo.lua

Lines changed: 202 additions & 203 deletions
Large diffs are not rendered by default.

samples/clutterdemo.lua

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
-- Basic clutter demo.
55
--
66

7-
local lgi = require('lgi')
8-
local Clutter = lgi.require('Clutter', '1.0')
9-
local GObject = lgi.require('GObject', '2.0')
10-
local Gio = lgi.require('Gio', '2.0')
7+
local LuaGObject = require('LuaGObject')
8+
local Clutter = LuaGObject.require('Clutter', '1.0')
9+
local GObject = LuaGObject.require('GObject', '2.0')
10+
local Gio = LuaGObject.require('Gio', '2.0')
1111

12-
local app = Gio.Application { application_id = 'org.lgi.samples.Clutter' }
12+
local app = Gio.Application { application_id = 'org.LuaGObject.samples.Clutter' }
1313

1414
local stage = Clutter.Stage.get_default()
1515
stage.color = Clutter.Color(0, 0, 0, 255)
@@ -19,49 +19,47 @@ stage.title = 'LGI Clutter Demo'
1919

2020
local rects = {}
2121
for i = 1, 6 do
22-
rects[i] = Clutter.Rectangle {
23-
color = Clutter.Color(
24-
256 / 6 * ((i - 1) % 6),
25-
256 / 6 * ((i + 3) % 6),
26-
256 / 6 * ((-i + 8) % 6),
27-
128),
28-
width = 100, height = 100,
29-
fixed_x = 200, fixed_y = 200,
30-
anchor_x = 128, anchor_y = 64,
31-
reactive = true,
32-
on_button_press_event = function(rect) rect:raise_top() return true end,
33-
}
34-
stage:add_actor(rects[i])
35-
rects[i]:show()
22+
rects[i] = Clutter.Rectangle {
23+
color = Clutter.Color(
24+
256 / 6 * ((i - 1) % 6),
25+
256 / 6 * ((i + 3) % 6),
26+
256 / 6 * ((-i + 8) % 6),
27+
128),
28+
width = 100, height = 100,
29+
fixed_x = 200, fixed_y = 200,
30+
anchor_x = 128, anchor_y = 64,
31+
reactive = true,
32+
on_button_press_event = function(rect) rect:raise_top() return true end,
33+
}
34+
stage:add_actor(rects[i])
35+
rects[i]:show()
3636
end
3737

3838
local timeline = Clutter.Timeline { duration = 60, loop = true }
3939
local rotation, rotation_delta = 0, 0.01
4040
local scale, scale_delta = 1, 0.001
4141
function timeline:on_new_frame(frame_num)
42-
rotation = rotation + rotation_delta
43-
scale = scale + scale_delta
44-
if scale > 2 or scale < 1 then scale_delta = -scale_delta end
45-
for i = 1, #rects do
46-
rects[i]:set_rotation(Clutter.RotateAxis.Z_AXIS, rotation * (#rects - i),
47-
0, 0, 0)
48-
rects[i]:set_scale(scale, 3 - scale)
49-
end
42+
rotation = rotation + rotation_delta
43+
scale = scale + scale_delta
44+
if scale > 2 or scale < 1 then scale_delta = -scale_delta end
45+
for i = 1, #rects do
46+
rects[i]:set_rotation(Clutter.RotateAxis.Z_AXIS, rotation * (#rects - i), 0, 0, 0)
47+
rects[i]:set_scale(scale, 3 - scale)
48+
end
5049

51-
-- A bug in clutter? If following line is not present, stage stops
52-
-- redrawing itself after a while...
53-
stage:queue_redraw()
50+
-- A bug in clutter? If following line is not present, stage stops redrawing itself after a while...
51+
stage:queue_redraw()
5452
end
5553

5654
function stage:on_button_press_event(event)
57-
app:release()
58-
return true
55+
app:release()
56+
return true
5957
end
6058

6159
function app:on_activate()
62-
self:hold()
63-
stage:show()
64-
timeline:start()
60+
self:hold()
61+
stage:show()
62+
timeline:start()
6563
end
6664

6765
return app:run { arg[0], ... }

0 commit comments

Comments
 (0)