File: list_toggle_select_mode_cmd.e

package info (click to toggle)
egtk 0.3.6-8
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,984 kB
  • ctags: 5,256
  • sloc: ansic: 2,320; sh: 273; makefile: 234
file content (65 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (3)
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
class LIST_TOGGLE_SELECT_MODE_CMD

inherit

	MENU_ITEM_CMD
		redefine
			parent
		end
			
	GTK_SELECTIONMODE_ENUM

creation

	make

feature

	list: GTK_LIST
			-- a gtk_list

	clist: GTK_CLIST
			-- a gtk_clist

	make (a_list: GTK_CONTAINER) is
			-- this command will work on a GTK_LIST or a GTK_CLIST
		do
			-- It actually would be better if GTK_LIST and GTK_CLIST
			-- had a common ancestor that had the set_selection_mode 
			-- deferred routine. The this code would avoid the "?="
			list ?= a_list
			if list = Void then
				clist ?= a_list
			end
		ensure
			valid_list: (clist /= Void) or (list /= Void)
		end

	parent: GTK_RADIO_MENU_ITEM

	execute is
		local
			selection_mode: INTEGER
		do
			if parent.mapped then
				inspect item_index
				when 1 then
					selection_mode := Gtk_selection_single
				when 2 then
					selection_mode := Gtk_selection_browse
				when 3 then
					selection_mode := Gtk_selection_multiple
				when 4 then
					selection_mode := Gtk_selection_extended
				end
				-- set selection mode on the list or clist. One of 
				-- these must not be void
				if list /= Void then
					list.set_selection_mode (selection_mode)
				else
					clist.set_selection_mode (selection_mode)
				end
			end
		end
			
end