This file is indexed.

/usr/share/pyshared/gvbmod/advancededitor.py is in gvb 1.2.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# GVB - a GTK+/GNOME vibrations simulator
#
# Copyright (C) 2008 Pietro Battiston
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import gtk
import gobject

from gvbmod import drawers, dispositions, points

from scipy import array 	#Just until I find a "revert order" method for arrays...

param_names = ['lenght', 'shift', 'wavelenght', 'fase', 'amplitude', 'centering']
int_params = ['lenght', 'shift', 'wavelenght', 'fase']
rule_names = ['prod', 'sum', 'max', 'min']

reflect = -1
label = -2
rules = -3
rules_hbox = -4
drawer = -5

DIMS = [1,2]

def reflect_matrix(matrix):
	n = matrix.shape[0]
	return array([matrix[n - 1 - i ] for i in range(n) ])

class AdvancedEditor():
	def __init__(self, caller, xml, old_points, shape):
		self.caller = caller
		self.dim = len(shape)
		self.points = None
		self.ready = False
		self.skipped_one = False
		self.xml = xml

		self.window = xml.get_object('advanced editor')
		self.for_good = True

		self.widgets = {}
		for dim in DIMS:
			self.widgets[dim] = {}
			self.widgets[dim]['waveform'] = xml.get_object('editor waveform combo '+str(dim))
#			print self.widgets
			self.combo_model=gtk.ListStore(str,str)
			for waveform in dispositions.waveforms:
#				print "appended", waveform
				self.combo_model.append([_(waveform), waveform])
			self.widgets[dim]['waveform'].set_model(self.combo_model)
			self.widgets[dim]['waveform'].set_active(0)
#			print "combo:", self.combo_form, self.combo_form.get_active()

			self.widgets[dim][reflect] = xml.get_object('editor reflect check '+str(dim))
			self.widgets[dim][label] = xml.get_object('editor label '+str(dim))

			for name in param_names:
				self.widgets[dim][name] = xml.get_object('editor '+name+' scale '+str(dim))

		self.widgets[drawer] = xml.get_object('editor combo drawer')
		self.widgets[rules]=[]
		self.widgets[rules_hbox] = xml.get_object('editor rules hbox')

		for rule in rule_names:
			self.widgets[rules].append(xml.get_object('editor rule '+rule))


		self.invert_check = xml.get_object('editor invert check')
		self.add_check = xml.get_object('editor addto check')
		
		for dim in DIMS:
			for widget in self.widgets[dim]:
				if type(self.widgets[dim][widget]) == gtk.ComboBox:
					self.widgets[dim][widget].connect('changed', self.update)
				elif type(self.widgets[dim][widget]) == gtk.CheckButton:
					self.widgets[dim][widget].connect('toggled', self.update)
				elif type(self.widgets[dim][widget]) == gtk.HScale:
					self.widgets[dim][widget].connect('change-value', self.update)
		
		for widget in  [self.invert_check, self.add_check] + self.widgets[rules]:
			widget.connect('toggled', self.update)
		
		self.go(old_points, shape)


	def go(self, old_points, shape):			
#		print "shape:", shape
		self.old_points = old_points
		self.shape = shape
		self.dim = len(shape)

#		self.drawer=drawers.drawers[self.dim][self.widgets[drawer].get_active_text()]

		for dim in range(1, self.dim+1):
			if self.points == None  or len(self.points.shape) < dim or self.points.shape[dim-1] != shape[dim-1]:
				#If number of points or dimension changed since last editor call (or if this is the first call)...
				self.widgets[dim]['lenght'].set_adjustment(gtk.Adjustment(shape[0], 3, shape[0], 4, 10))
				self.widgets[dim]['shift'].set_adjustment(gtk.Adjustment(0, 0, shape[0], 4, 10))
				self.widgets[dim]['wavelenght'].set_adjustment(gtk.Adjustment(shape[0], 5, shape[0]*3, 4, 10))
#				print "reset"

		for dim in DIMS:
			useful = not (dim > self.dim)
			for widget in self.widgets[dim]:
				self.widgets[dim][widget].set_sensitive(useful)

		self.widgets[rules_hbox].set_sensitive(bool(self.dim-1))

		#If dimension is changing with this editor call, we cannot add
		self.add_check.set_sensitive(old_points.shape == shape)
#			print "reset"


		
		self.points = points.Points(self.shape, None, 'flat', None, drawers.Drawer(self.xml.get_object('editor drawing'), self.xml.get_object('editor combo drawer')))
#		print "reconfigure"

		gobject.timeout_add(10, self.update)

		resp = self.window.run()
		while True:
			self.response(None, resp)
			if resp == 2:
				resp = self.window.run()
			else:
				break


	def update(self, arg=None, arg2=None, arg3=None):
#		print arg, arg2, arg3
		if arg in self.widgets[rules]:		#The radiobuttons always send 2 signals: one for the toggled and one for the untoggled
			if self.skipped_one:
				self.skipped_one = False
			else:
				self.skipped_one = True
				return

		params = []
		for dim in range(1, self.dim+1):
			selected_iter = self.widgets[dim]['waveform'].get_active_iter()
			liststore = self.widgets[dim]['waveform'].get_model()
			params=params + [liststore.get(selected_iter, 1)[0]]
			params_dim = [self.widgets[dim][widget].get_value() for widget in param_names]
#			print params_dim
			for index in range(len(int_params)):
				params_dim[index]=int(params_dim[index])

			params = params + params_dim

		#Get selected rule:
		params.append(rule_names[ [rule.get_active() for rule in self.widgets[rules]].index(True)]) #FIXME (ugly)
#		print params
		self.new_disp = dispositions.waveformer[self.dim](self.shape, *params)


		if self.dim == 1:
			if self.widgets[1][reflect].get_active():
				self.new_disp = reflect_matrix(self.new_disp)
		else:
			if self.widgets[2][reflect].get_active():
				self.new_disp = reflect_matrix(self.new_disp)
			if self.widgets[1][reflect].get_active():
				self.new_disp = reflect_matrix(self.new_disp.transpose()).transpose()


		if self.invert_check.get_active():
			self.new_disp = self.new_disp * -1
		if self.add_check.get_active():
			self.points.reconfigure(pos = self.old_points.pos + self.new_disp)
		else:
			self.points.reconfigure(pos = self.new_disp)
		self.ready = True
#		self.draw()


	def set_defaults(self):
		defaults = [self.shape[0], 0, self.shape[0], 0, 1, .5]

		for dim in range(1, self.dim+1):
			self.widgets[dim]['waveform'].set_active(0)
			for index in range(len(param_names)):
				self.widgets[dim][param_names[index]].set_value(defaults[index])
			self.widgets[dim][reflect].set_active(False)

		self.widgets[rules][0].set_active(True)
		self.invert_check.set_active(False)
		self.add_check.set_active(False)
		self.update()


	def response(self, button, response):
		if response == 2:
			self.set_defaults()
			return

		if response == 1:
			self.caller.editor_save(self.points)

		self.window.hide()