This file is indexed.

/usr/share/pyshared/menueditor/MenuTreeModel.py is in edubuntu-menueditor 1.3.5-0ubuntu2.

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
# -*- coding: utf-8 -*-
### BEGIN LICENSE
# Copyright (C) 2009 <Marc Gariépy> <mgariepy@revolutionlinux.com> Révolution Linux
#This program is free software: you can redistribute it and/or modify it 
#under the terms of the GNU General Public License version 3  or (at your option) 
#any later version, as published by the Free Software Foundation.
#
#This program is distributed in the hope that it will be useful, but 
#WITHOUT ANY WARRANTY; without even the implied warranties of 
#MERCHANTABILITY, SATISFACTORY QUALITY, 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, see <http://www.gnu.org/licenses/>.
### END LICENSE

import os
import os.path
import sys, gtk
import gmenu

def lookup_system_menu_file (menu_file):
    conf_dirs = None
    if os.environ.has_key ("XDG_CONFIG_DIRS"):
        conf_dirs = os.environ["XDG_CONFIG_DIRS"]
    if not conf_dirs:
        conf_dirs = "/etc/xdg"

    for conf_dir in conf_dirs.split (":"):
        menu_file_path = os.path.join (conf_dir, "menus", menu_file)
        if os.path.isfile (menu_file_path):
            return menu_file_path

    return None

def load_icon_from_path (icon_path):
    if os.path.isfile (icon_path):
        try:
            return gtk.gdk.pixbuf_new_from_file_at_size (icon_path, 24, 24)
        except:
            pass
    return None

def load_icon_from_data_dirs (icon_value):
    data_dirs = None
    if os.environ.has_key ("XDG_DATA_DIRS"):
        data_dirs = os.environ["XDG_DATA_DIRS"]
    if not data_dirs:
        data_dirs = "/usr/local/share/:/usr/share/"

    for data_dir in data_dirs.split (":"):
        retval = load_icon_from_path (os.path.join (data_dir, "pixmaps", icon_value))
        if retval:
            return retval
        retval = load_icon_from_path (os.path.join (data_dir, "icons", icon_value))
        if retval:
            return retval

    return None

def load_icon (icon_theme, icon_value):
    if not icon_value:
        return

    if os.path.isabs (icon_value):
        icon = load_icon_from_path (icon_value)
        if icon:
            return icon
        icon_name = os.path.basename (icon_value)
    else:
        icon_name = icon_value

    if icon_name.endswith (".png"):
        icon_name = icon_name[:-len (".png")]
    elif icon_name.endswith (".xpm"):
        icon_name = icon_name[:-len (".xpm")]
    elif icon_name.endswith (".svg"):
        icon_name = icon_name[:-len (".svg")]

    try:
        return icon_theme.load_icon (icon_name, 24, 0)
    except:
        return load_icon_from_data_dirs (icon_value)

class MenuTreeModel(gtk.TreeStore):
    (
        COLUMN_IS_ENTRY,
        COLUMN_ID,
        COLUMN_NAME,
        COLUMN_ICON,
        COLUMN_ICON_NAME,
        COLUMN_MENU_FILE,
        COLUMN_SYSTEM_VISIBLE,
        COLUMN_USER_VISIBLE,
        COLUMN_USER_ADDED,
        COLUMN_COMMENT
    ) = range (10)

    def __init__(self, menu_files):
        gtk.TreeStore.__init__ (self, bool, str, str, gtk.gdk.Pixbuf, str, \
                                str, bool, bool, bool, str)

        self.entries_list_iter = None

        self.icon_theme = gtk.icon_theme_get_default ()

        if (len (menu_files) < 1):
            menu_files = ["applications.menu", "settings.menu"]

        for menu_file in menu_files:
            tree = gmenu.lookup_tree (menu_file, gmenu.FLAGS_INCLUDE_EXCLUDED)
            tree.sort_key = gmenu.SORT_DISPLAY_NAME
            self.__append_directory (tree.root, None, False, menu_file)

            system_file = lookup_system_menu_file (menu_file)
            if system_file:
                system_tree = gmenu.lookup_tree (system_file, gmenu.FLAGS_INCLUDE_EXCLUDED)

                system_tree.sort_key = gmenu.SORT_DISPLAY_NAME
                self.__append_directory (system_tree.root, None, True, menu_file)

    def __append_directory (self, directory, parent_iter, system, menu_file):
        if not directory:
            return

        iter = self.iter_children (parent_iter)
        while iter:
            if self[iter][self.COLUMN_ID] == directory.menu_id:
                break
            iter = self.iter_next (iter)

        if not iter:
            iter = self.append (parent_iter)

            self[iter][self.COLUMN_IS_ENTRY]   = False
            self[iter][self.COLUMN_ID]         = directory.menu_id
            self[iter][self.COLUMN_NAME]       = directory.name
            self[iter][self.COLUMN_ICON]       = load_icon (self.icon_theme, directory.icon)
            self[iter][self.COLUMN_ICON_NAME]  = directory.icon
            self[iter][self.COLUMN_USER_ADDED] = False
            self[iter][self.COLUMN_COMMENT]    = directory.comment

            if not menu_file is None:
                self[iter][self.COLUMN_MENU_FILE] = menu_file

        if system:
            self[iter][self.COLUMN_SYSTEM_VISIBLE] = True
        else:
            self[iter][self.COLUMN_USER_VISIBLE]   = True

        for child_item in directory.contents:
            if isinstance (child_item, gmenu.Directory):
                self.__append_directory (child_item, iter, system, None)

            if not isinstance (child_item, gmenu.Entry):
                continue

            child_iter = self.iter_children (iter)
            while child_iter:
                if child_item.type == gmenu.TYPE_ENTRY and \
                   self[child_iter][self.COLUMN_IS_ENTRY] and \
                   self[child_iter][self.COLUMN_ID] == child_item.desktop_file_id:
                        break
                child_iter = self.iter_next (child_iter)

            if not child_iter:
                child_iter = self.append (iter)
                self[child_iter][self.COLUMN_IS_ENTRY] = True
                self[child_iter][self.COLUMN_ID]       = child_item.desktop_file_id
                self[child_iter][self.COLUMN_NAME]     = child_item.display_name
                self[child_iter][self.COLUMN_ICON]     = load_icon (self.icon_theme,
                                                                    child_item.icon)
                self[child_iter][self.COLUMN_ICON_NAME]  = child_item.icon
                self[child_iter][self.COLUMN_USER_ADDED] = False
                self[child_iter][self.COLUMN_COMMENT] = child_item.comment

            if system:
                self[child_iter][self.COLUMN_SYSTEM_VISIBLE] = not child_item.is_excluded
            else:
                self[child_iter][self.COLUMN_USER_VISIBLE]   = not child_item.is_excluded