This file is indexed.

/usr/share/cinnamon/cinnamon-looking-glass/page_inspect.py is in cinnamon-common 3.6.7-8ubuntu1.

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
from __future__ import print_function

import pageutils
from gi.repository import Gtk

lookingGlassProxy = None
melangeApp = None


class InspectView(pageutils.BaseListView):

    def __init__(self, parent):
        self.parent = parent
        store = Gtk.ListStore(str, str, str, str, str)
        pageutils.BaseListView.__init__(self, store)

        self.createTextColumn(0, "Name")
        self.createTextColumn(1, "Type")
        self.createTextColumn(2, "Value")

        self.popup = Gtk.Menu()
        self.insertCommand = Gtk.MenuItem("Insert into command entry")
        self.insertCommand.connect("activate", self.onInsertCommand)
        self.popup.append(self.insertCommand)
        self.popup.show_all()

        self.treeView.connect("button-press-event", self.onButtonPressEvent)
        self.treeView.connect("row-activated", self.onRowActivated)

    def onButtonPressEvent(self, treeview, event):
        x = int(event.x)
        y = int(event.y)
        pthinfo = treeview.get_path_at_pos(x, y)
        if pthinfo is not None and event.button == 3:
            path, col, cellx, celly = pthinfo
            self.selectedPath = path
            treeview.grab_focus()
            treeview.set_cursor(path, col, 0)
            self.popup.popup(None, None, None, None, event.button, event.time)
            return True

    def onInsertCommand(self, widget):
        treeIter = self.store.get_iter(self.selectedPath)
        objType = self.store.get_value(treeIter, 1)
        objPath = self.store.get_value(treeIter, 4)
        if objType == "function":
            objPath += "()"
        Gtk.Entry.do_insert_at_cursor(melangeApp.commandline, objPath)
        melangeApp.commandline.grab_focus_without_selecting()

    def onRowActivated(self, treeview, path, view_column):
        treeIter = self.store.get_iter(path)
        name = self.store.get_value(treeIter, 0)
        objType = self.store.get_value(treeIter, 1)
        value = self.store.get_value(treeIter, 3)
        path = self.store.get_value(treeIter, 4)

        self.parent.updateInspector(path, objType, name, value, True)

    def setInspectionData(self, path, data):
        self.store.clear()
        for item in data:
            self.store.append([item["name"], item["type"], item["shortValue"], item["value"], path + "['" + item["name"] + "']"])


class ModulePage(pageutils.WindowAndActionBars):

    def __init__(self, parent):
        self.view = InspectView(self)
        pageutils.WindowAndActionBars.__init__(self, self.view)
        self.parent = parent

        self.back = pageutils.ImageButton("back")
        self.back.set_tooltip_text("Go back")
        self.back.set_sensitive(False)
        self.back.connect("clicked", self.onBackButton)
        self.addToLeftBar(self.back, 1)

        self.insert = pageutils.ImageButton("insert-object")
        self.insert.set_tooltip_text("Insert into results")
        self.insert.set_sensitive(False)
        self.insert.connect("clicked", self.onInsertButton)
        self.addToLeftBar(self.insert, 1)

        self.addToBottomBar(Gtk.Label("Path:"), 2)
        self.pathLabel = Gtk.Label("<No selection done yet>")
        self.addToBottomBar(self.pathLabel, 2)

        self.addToBottomBar(Gtk.Label("; Type:"), 2)
        self.typeLabel = Gtk.Label("")
        self.addToBottomBar(self.typeLabel, 2)
        self.addToBottomBar(Gtk.Label("; Name:"), 2)
        self.nameLabel = Gtk.Label("")
        self.addToBottomBar(self.nameLabel, 2)

        self.currentInspection = None
        self.stack = []
        lookingGlassProxy.addStatusChangeCallback(self.onStatusChange)

    def onStatusChange(self, online):
        if online:
            self.clear()

    def clear(self):
        self.pathLabel.set_text("<No selection done yet>")
        self.typeLabel.set_text("")
        self.nameLabel.set_text("")
        self.view.store.clear()

    def onInsertButton(self, widget):
        if len(self.stack) > 0:
            path, objType, name, value = self.currentInspection
            lookingGlassProxy.AddResult(path)

    def onBackButton(self, widget):
        self.popInspectionElement()

    def popInspectionElement(self):
        if len(self.stack) > 0:
            self.updateInspector(*self.stack.pop())

        sensitive = len(self.stack) > 0
        self.back.set_sensitive(sensitive)
        self.insert.set_sensitive(sensitive)

    def pushInspectionElement(self):
        if self.currentInspection is not None:
            self.stack.append(self.currentInspection)
            self.back.set_sensitive(True)
            self.insert.set_sensitive(True)

    def updateInspector(self, path, objType, name, value, pushToStack=False):
        if objType == "object":
            if pushToStack:
                self.pushInspectionElement()

            self.currentInspection = (path, objType, name, value)

            self.pathLabel.set_text(path)
            self.typeLabel.set_text(objType)
            self.nameLabel.set_text(name)

            melangeApp.activatePage("inspect")
            success, data = lookingGlassProxy.Inspect(path)
            if success:
                try:
                    self.view.setInspectionData(path, data)
                except Exception as e:
                    print(e)
                    self.view.store.clear()
            else:
                self.view.store.clear()
        elif objType == "undefined":
            pageutils.ResultTextDialog("Value for '" + name + "'", "Value is <undefined>")
        else:
            pageutils.ResultTextDialog("Value for " + objType + " '" + name + "'", value)

    def inspectElement(self, path, objType, name, value):
        del self.stack[:]
        self.currentInspection = None
        self.back.set_sensitive(False)
        self.insert.set_sensitive(False)
        self.updateInspector(path, objType, name, value)