Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Small updates of samples

  • Loading branch information...
commit 31324348c3635b968588ce9dcc6a7796e9a4beef 1 parent 4960d87
@pavouk authored
View
0  samples/clutterdemo.lua 100644 → 100755
File mode changed
View
2  samples/gtkclipboard.lua
@@ -4,7 +4,7 @@
-- http://live.gnome.org/Vala/GTKSample#Clipboard
local lgi = require 'lgi'
-local Gtk = lgi.Gtk
+local Gtk = lgi.require('Gtk', '3.0')
local Gdk = lgi.Gdk
local app = Gtk.Application { application_id = 'org.lgi.samples.gtkclipboard' }
View
4 samples/gtkconsole.lua
@@ -7,8 +7,8 @@
--
local lgi = require 'lgi'
-local Gtk = lgi.Gtk
-local Vte = lgi.Vte
+local Gtk = lgi.require('Gtk', '3.0')
+local Vte = lgi.require('Vte', '2.90')
-- Simple readline implementation with asynchronous interface.
local ReadLine = {}
View
55 samples/gtklistview.lua
@@ -1,55 +0,0 @@
-#! /usr/bin/env lua
-
---
--- Listview demo.
---
-
-local lgi = require('lgi')
-local Gtk = lgi.require('Gtk', '3.0')
-local GObject = lgi.require('GObject', '2.0')
-
--- Create and populate ListStore model.
-local model = Gtk.ListStore.new { GObject.Type.STRING, GObject.Type.BOOLEAN }
-for _, row in ipairs { { 'GObject', true }, { 'Gtk+', true },
- { 'GStreamer', false } } do
- local iter = model:append()
- model.values[iter] = row
-end
-
--- Create rendereres for columns, attach signals to them.
-local name_renderer = Gtk.CellRendererText { editable = true }
-function name_renderer:on_edited(path, new_text)
- model.values[path][0] = new_text
-end
-
-local check_renderer = Gtk.CellRendererToggle()
-function check_renderer:on_toggled(path)
- local row = model.values[path]
- row[1] = not row[1]
-end
-
--- Create the application.
-local app = Gtk.Application { application_id = 'org.lgi.demo.gtklistview' }
-function app:on_activate()
- -- Create treeview and columns.
- local treeview = Gtk.TreeView {
- model = model,
- columns = {
- Gtk.TreeViewColumn {
- title = 'Component', clickable = true, resizable = true,
- expand = true,
- cell = { name_renderer, { [0] = Gtk.CellRendererText.text } } },
- Gtk.TreeViewColumn {
- title = 'LGI Support', align = 0.5,
- cell = { check_renderer, { [1] = Gtk.CellRendererToggle.active } } }
- }
- }
-
- -- Create window with treeview in it.
- local window = Gtk.Window {
- title = 'LGI ListView demo', application = self, child = treeview
- }
- window:show_all()
-end
-
-return app:run { arg[0], ... }
View
16 samples/gtkpad.lua
@@ -11,16 +11,19 @@
--]]--------------------------------------------------------------------------
local lgi = require 'lgi'
-local Gtk = lgi.Gtk
+local Gtk = lgi.require('Gtk', '3.0')
local Gio = lgi.Gio
-local function new_editor(app, file)
+local app = Gtk.Application.new('org.lgi.GtkPad',
+ Gio.ApplicationFlags.HANDLES_OPEN)
+
+function app:new_editor(file)
local contents = file and file:load_contents()
local window = Gtk.Window {
type = Gtk.WindowType.TOPLEVEL,
default_width = 400,
default_height = 300,
- application = app,
+ application = self,
title = file and file:get_parse_name() or '<Untitled>',
child = Gtk.ScrolledWindow {
child = Gtk.TextView {
@@ -34,15 +37,12 @@ local function new_editor(app, file)
return window
end
-local app = Gtk.Application.new('org.lgi.GtkPad',
- Gio.ApplicationFlags.HANDLES_OPEN)
-
function app:on_activate()
- new_editor(self)
+ self:new_editor()
end
function app:on_open(files)
- for i = 1, #files do new_editor(self, files[i]) end
+ for i = 1, #files do self:new_editor(files[i]) end
end
return app:run {arg[0], ...}
Please sign in to comment.
Something went wrong with that request. Please try again.