Debian Codegraph @

peas-demo/plugins/luahello/luahello.lua

raw
1 --
2 -- Copyright (C) 2014 - Garrett Regier
3 --
4 -- libpeas is free software; you can redistribute it and/or
5 -- modify it under the terms of the GNU Lesser General Public
6 -- License as published by the Free Software Foundation; either
7 -- version 2.1 of the License, or (at your option) any later version.
8 --
9 -- libpeas is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 -- Lesser General Public License for more details.
13 --
14 -- You should have received a copy of the GNU Lesser General Public
15 -- License along with this library; if not, write to the Free Software
16 -- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 local lgi = require 'lgi'
19
20 local GObject = lgi.GObject
21 local Gtk = lgi.Gtk
22 local Peas = lgi.Peas
23 local PeasGtk = lgi.PeasGtk
24
25
26 local LuaHelloPlugin = GObject.Object:derive('LuaHelloPlugin', {
27 Peas.Activatable
28 })
29
30 LuaHelloPlugin._property.object =
31 GObject.ParamSpecObject('object', 'object', 'object',
32 GObject.Object._gtype,
33 { GObject.ParamFlags.READABLE,
34 GObject.ParamFlags.WRITABLE })
35
36 function LuaHelloPlugin:do_activate()
37 local window = self.priv.object
38 print('LuaHelloPlugin:do_activate', tostring(window))
39 self.priv.label = Gtk.Label.new('Lua Says Hello!')
40 self.priv.label:show()
41 window:get_child():pack_start(self.priv.label, true, true, 0)
42 end
43
44 function LuaHelloPlugin:do_deactivate()
45 local window = self.priv.object
46 print('LuaHelloPlugin:do_deactivate', tostring(window))
47 window:get_child():remove(self.priv.label)
48 self.priv.label:destroy()
49 end
50
51 function LuaHelloPlugin:do_update_state()
52 local window = self.priv.object
53 print('LuaHelloPlugin:do_update_state', tostring(window))
54 end
55
56
57 local LuaHelloConfigurable = GObject.Object:derive('LuaHelloConfigurable', {
58 PeasGtk.Configurable
59 })
60
61 function LuaHelloConfigurable:do_create_configure_widget()
62 return Gtk.Label.new('Lua Hello configure widget')
63 end
64
65 return { LuaHelloPlugin, LuaHelloConfigurable }
66
67 -- ex:set ts=4 et sw=4 ai: