File: demo-paned.lua

package info (click to toggle)
lua-lgi 0.9.2-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,388 kB
  • sloc: ansic: 5,082; makefile: 169; sh: 31
file content (166 lines) | stat: -rw-r--r-- 3,705 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
return function(parent, dir)

local lgi = require 'lgi'
local Gtk = lgi.Gtk

local window = Gtk.Window {
   title = "Panes",
   Gtk.Box {
      orientation = 'VERTICAL',
      Gtk.Paned {
	 orientation = 'VERTICAL',
	 Gtk.Paned {
	    id = 'paned_top',
	    orientation = 'HORIZONTAL',
	    Gtk.Frame {
	       id = 'paned_left',
	       shadow_type = 'IN',
	       height_request = 60,
	       width_request = 60,
	       Gtk.Button {
		  label = "_Hi there",
		  use_underline = true,
	       },
	    },
	    Gtk.Frame {
	       id = 'paned_right',
	       shadow_type = 'IN',
	       height_request = 80,
	       width_request = 60,
	    },
	 },
	 Gtk.Frame {
	    id = 'paned_bottom',
	    shadow_type = 'IN',
	    height_request = 60,
	    width_request = 80,
	 },
      },
      Gtk.Frame {
	 label = "Horizontal",
	 border_width = 4,
	 Gtk.Grid {
	    {
	       left_attach = 0, top_attach = 0,
	       Gtk.Label { label = "Left" },
	    },
	    {
	       left_attach = 0, top_attach = 1,
	       Gtk.CheckButton {
		  id = 'resize_left',
		  label = "_Resize",
		  use_underline = true,
	       },
	    },
	    {
	       left_attach = 0, top_attach = 2,
	       Gtk.CheckButton {
		  id = 'shrink_left',
		  label = "_Shrink",
		  use_underline = true,
	       },
	    },
	    {
	       left_attach = 1, top_attach = 0,
	       Gtk.Label { label = "Right" },
	    },
	    {
	       left_attach = 1, top_attach = 1,
	       Gtk.CheckButton {
		  id = 'resize_right',
		  label = "_Resize",
		  use_underline = true,
	       },
	    },
	    {
	       left_attach = 1, top_attach = 2,
	       Gtk.CheckButton {
		  id = 'shrink_right',
		  label = "_Shrink",
		  use_underline = true,
	       },
	    },
	 },
      },
      Gtk.Frame {
	 label = "Vertical",
	 border_width = 4,
	 Gtk.Grid {
	    {
	       left_attach = 0, top_attach = 0,
	       Gtk.Label { label = "Top" },
	    },
	    {
	       left_attach = 0, top_attach = 1,
	       Gtk.CheckButton {
		  id = 'resize_top',
		  label = "_Resize",
		  use_underline = true,
	       },
	    },
	    {
	       left_attach = 0, top_attach = 2,
	       Gtk.CheckButton {
		  id = 'shrink_top',
		  label = "_Shrink",
		  use_underline = true,
	       },
	    },
	    {
	       left_attach = 1, top_attach = 0,
	       Gtk.Label { label = "Bottom" },
	    },
	    {
	       left_attach = 1, top_attach = 1,
	       Gtk.CheckButton {
		  id = 'resize_bottom',
		  label = "_Resize",
		  use_underline = true,
	       },
	    },
	    {
	       left_attach = 1, top_attach = 2,
	       Gtk.CheckButton {
		  id = 'shrink_bottom',
		  label = "_Shrink",
		  use_underline = true,
	       },
	    },
	 },
      },
   },
}

-- Connect servicing routines for all toggles.
for _, pos in ipairs { 'left', 'right', 'top', 'bottom' } do
   local child = window.child['paned_' .. pos]
   local paned = child.parent

   local resize = window.child['resize_' .. pos]
   resize.active = paned.property[child].resize
   function resize:on_clicked()
      paned.property[child].resize = self.active
   end

   local shrink = window.child['shrink_' .. pos]
   shrink.active = paned.property[child].shrink
   function shrink:on_clicked()
      paned.property[child].shrink = self.active
   end
end

window:show_all()
return window
end,

"Paned Widgets",

table.concat {
   [[The Gtk.Paned widget divide its content area into two panes ]],
   [[with a divider in between that the user can adjust. A separate ]],
   [[child is placed into each pane.
]],
   [[There are a number of options that can be set for each pane. ]],
   [[This test contains both a horizontal and a vertical widget, ]],
   [[and allows you to adjust the options for each side of each widget.]],
}