This file is indexed.

/usr/share/arm/util/gtkTools.py is in tor-arm 1.4.5.0-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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
"""
Helper module for getting Gtk+ theme colors.
"""

import gobject
import gtk

COLOR_MAP = {
  'normal' : ('fg', gtk.STATE_NORMAL),
  'active' : ('fg', gtk.STATE_ACTIVE),
  'insensitive' : ('fg', gtk.STATE_INSENSITIVE),
}

class Theme:
  def __init__(self):
    self.colors = {}

    widget = gtk.Button()

    for (key, (prop, state)) in COLOR_MAP.items():
      self.colors[key] = getattr(widget.style, prop)[state]

class ListWrapper(object):
  def __init__(self, container, model=None):
    self.container = []
    self.model = model

    for value in container:
      self.append(value)

  def append(self, value):
    self.container.append(value)
    gobject.idle_add(self._model_append, value)

  def empty(self):
    self.container = []
    gobject.idle_add(self._model_clear)

  def __str__(self):
    return str(self.container)

  def __repr__(self):
    return str(self.container)

  def __len__(self):
    return len(self.container)

  def __iadd__(self, other):
    for value in other:
      self.append(value)

  def __delitem__(self, key):
    del self.container[key]

    gobject.idle_add(self._model_del, key)

  def __getitem__(self, key):
    return self.container[key]

  def __setitem__(self, key, value):
    self.container[key] = value

    gobject.idle_add(self._model_set, key, value)

  def _model_append(self, value):
    if not self.model:
      return

    row = self._create_row_from_value(value)
    self.model.append(row)

  def _model_clear(self):
    if not self.model:
      return

    self.model.clear()

  def _model_del(self, key):
    if not self.model:
      return

    treeIter = self.model.get_iter(key)
    self.model.remove(treeIter)

  def _model_set(self, key, value):
    if not self.model:
      return

    row = self._create_row_from_value(value)
    self.model[key] = row

  def _create_row_from_value(self, value):
    raise NotImplementedError("Subclass must implement abstract method")

class TreeWrapper(ListWrapper):
  def _model_append(self, value):
    if not self.model:
      return

    row = self._create_row_from_value(value)
    self.model.append(None, row)

def response_to_dialog(entry, dialog, response):
  dialog.response(response)

def input_size(prompt, default=None):
  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_QUESTION,
      gtk.BUTTONS_OK_CANCEL,
      None)

  dialog.set_markup(prompt)

  hBox = gtk.HBox()

  dialog.vbox.pack_end(hBox, True, True, 0)

  spinButton = gtk.SpinButton(None)
  spinButton.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)

  spinButton.set_increments(1, 10)
  spinButton.set_range(0, 1024)

  hBox.pack_start(spinButton, True, True, 0)

  comboBox = gtk.combo_box_new_text()

  comboBox.append_text("B")
  comboBox.append_text("KB")
  comboBox.append_text("MB")
  comboBox.append_text("GB")
  comboBox.append_text("TB")
  comboBox.append_text("PB")

  hBox.pack_end(comboBox, False, False, 0)

  if default:
    value, units = default.split()

    spinButton.set_value(float(value))

    model = comboBox.get_model()
    modelUnits = [row[0] for row in model]
    index = modelUnits.index(units)
    comboBox.set_active(index)

  dialog.show_all()
  response = dialog.run()

  value = spinButton.get_value_as_int()

  model = comboBox.get_model()
  active = comboBox.get_active()
  (units,) = model[active]

  dialog.destroy()

  return "%d %s" % (value, units) if response == gtk.RESPONSE_OK else None

def input_time(prompt, default=None):
  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_QUESTION,
      gtk.BUTTONS_OK_CANCEL,
      None)

  dialog.set_markup(prompt)

  hBox = gtk.HBox()

  dialog.vbox.pack_end(hBox, True, True, 0)

  spinButton = gtk.SpinButton(None)
  spinButton.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)

  spinButton.set_increments(1, 10)
  spinButton.set_range(0, 1024)

  hBox.pack_start(spinButton, True, True, 0)

  comboBox = gtk.combo_box_new_text()

  comboBox.append_text("seconds")
  comboBox.append_text("minutes")
  comboBox.append_text("hours")
  comboBox.append_text("days")

  hBox.pack_end(comboBox, False, False, 0)

  if default:
    if default[-1:] != 's':
      default = default + 's'

    value, units = default.split()

    spinButton.set_value(float(value))

    model = comboBox.get_model()
    modelUnits = [row[0] for row in model]
    index = modelUnits.index(units)
    comboBox.set_active(index)

  dialog.show_all()
  response = dialog.run()

  value = spinButton.get_value_as_int()

  model = comboBox.get_model()
  active = comboBox.get_active()
  (units,) = model[active]

  dialog.destroy()

  return "%d %s" % (value, units) if response == gtk.RESPONSE_OK else None

def input_int(prompt, default=None, csvResponse=False):
  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_QUESTION,
      gtk.BUTTONS_OK_CANCEL,
      None)

  dialog.set_markup(prompt)

  spinButton = gtk.SpinButton(None)
  spinButton.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)

  spinButton.set_increments(1, 10)
  spinButton.set_range(0, 65535)

  dialog.vbox.pack_end(spinButton, True, True, 0)

  if default:
    spinButton.set_value(float(default))

  dialog.show_all()
  response = dialog.run()

  value = spinButton.get_value_as_int()

  dialog.destroy()

  return "%d" % (value) if response == gtk.RESPONSE_OK else None

def input_string(prompt, default=None):
  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_QUESTION,
      gtk.BUTTONS_OK_CANCEL,
      None)

  dialog.set_markup(prompt)

  entry = gtk.Entry()
  entry.connect('activate', response_to_dialog, dialog, gtk.RESPONSE_OK)

  dialog.vbox.pack_end(entry, True, True, 0)

  if default:
    entry.set_text(default)

  dialog.show_all()
  response = dialog.run()

  text = entry.get_text()
  dialog.destroy()

  return text if response == gtk.RESPONSE_OK else None

def input_list(prompt, default, csv=False):
  def on_add_button_clicked(widget, listStore):
    newValue = input_string("Enter new value:")

    if newValue:
      row = (newValue,)
      listStore.append(row)

  def on_delete_button_clicked(widget, treeView):
    selection = treeView.get_selection()
    model, selectionIter = selection.get_selected()

    if (selectionIter):
      model.remove(selectionIter)

  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_QUESTION,
      gtk.BUTTONS_OK_CANCEL,
      None)

  dialog.set_markup(prompt)

  hBox = gtk.HBox()

  dialog.vbox.pack_start(hBox, False, False, 0)

  addButton = gtk.Button(stock=gtk.STOCK_ADD)

  hBox.pack_start(addButton, False, False, 0)

  deleteButton = gtk.Button(stock=gtk.STOCK_DELETE)

  hBox.pack_start(deleteButton, False, False, 0)

  scrolledWindow = gtk.ScrolledWindow()

  dialog.vbox.pack_end(scrolledWindow, True, True, 0)

  listStore = gtk.ListStore(str)
  treeView = gtk.TreeView(listStore)
  treeViewColumn = gtk.TreeViewColumn("Value")
  cellRenderer = gtk.CellRendererText()

  treeViewColumn.pack_start(cellRenderer, True)
  treeViewColumn.add_attribute(cellRenderer, 'text', 0)
  treeView.append_column(treeViewColumn)

  scrolledWindow.add(treeView)

  addButton.connect('clicked', on_add_button_clicked, listStore)
  deleteButton.connect('clicked', on_delete_button_clicked, treeView)

  separator = "," if csv else " "
  if default:
    for value in default.split(separator):
      row = (value,)
      listStore.append(row)

  dialog.show_all()
  response = dialog.run()

  dialog.destroy()

  if not response == gtk.RESPONSE_OK:
    return

  return None if len(listStore) == 0 else separator.join([row[0] for row in listStore])

def input_bool(prompt, default=None):
  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_QUESTION,
      gtk.BUTTONS_OK_CANCEL,
      None)

  dialog.set_markup(prompt)

  hbox = gtk.HBox()
  buttonTrue = gtk.RadioButton(None, "True")
  buttonFalse = gtk.RadioButton(buttonTrue, "False")
  hbox.pack_start(buttonTrue, True, True, 0)
  hbox.pack_start(buttonFalse, True, True, 0)

  dialog.vbox.pack_end(hbox, True, True, 0)

  if not default == None:
    if default == 'True':
      buttonTrue.set_active(True)
    elif default == 'False':
      buttonFalse.set_active(True)

  dialog.show_all()
  response = dialog.run()

  choice = None

  if buttonTrue.get_active():
    choice = True
  elif buttonFalse.get_active():
    choice = False

  dialog.destroy()

  return choice if response == gtk.RESPONSE_OK else None

def input_dir(prompt, default):
  dialog = gtk.FileChooserDialog(prompt,
                               None,
                               gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                gtk.STOCK_OPEN, gtk.RESPONSE_OK))
  dialog.set_default_response(gtk.RESPONSE_OK)

  if default:
    dialog.set_filename(default)

  dialog.show_all()
  response = dialog.run()

  filename = dialog.get_filename()

  dialog.destroy()

  return filename if response == gtk.RESPONSE_OK else None

def input_filename(prompt, default):
  dialog = gtk.FileChooserDialog(prompt,
                               None,
                               gtk.FILE_CHOOSER_ACTION_SAVE,
                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                gtk.STOCK_OPEN, gtk.RESPONSE_OK))
  dialog.set_default_response(gtk.RESPONSE_OK)

  if default:
    dialog.set_filename(default)

  dialog.show_all()
  response = dialog.run()

  filename = dialog.get_filename()

  dialog.destroy()

  return filename if response == gtk.RESPONSE_OK else None

def showError(msg):
  dialog = gtk.MessageDialog(None,
      gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
      gtk.MESSAGE_ERROR,
      gtk.BUTTONS_OK,
      msg)

  dialog.run()
  dialog.destroy()