This file is indexed.

/usr/share/pyshared/pyrenamer/pyrenamer_prefs.py is in pyrenamer 0.6.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
# -*- coding: utf-8 -*-

"""
Copyright (C) 2006-2008 Adolfo González Blázquez <code@infinicode.org>

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 2
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

If you find any bugs or have any suggestions email: code@infinicode.org
"""

try:
    import pygtk
    pygtk.require('2.0')
except:
      print "PyGtk 2.0 or later required for this app to run"
      raise SystemExit

try:
    import gtk
    import gtk.glade
    import gobject
except:
    raise SystemExit

try:
    import gconf
    HAS_GCONF = True
except:
    HAS_GCONF = False

from os import path as ospath

import pyrenamer_globals as pyrenamerglob

from gettext import gettext as _

class PyrenamerPrefs:

    def __init__(self, main):

        self.main = main

        self.gconf_path = '/apps/' + pyrenamerglob.name
        self.gconf_root_dir = self.gconf_path + '/root_dir'
        self.gconf_active_dir = self.gconf_path + '/active_dir'
        self.gconf_window_maximized = self.gconf_path + '/window_maximized'
        self.gconf_pane_position = self.gconf_path + '/pane_position'
        self.gconf_window_width = self.gconf_path + '/window_width'
        self.gconf_window_height = self.gconf_path + '/window_height'
        self.gconf_window_posx = self.gconf_path + '/window_posx'
        self.gconf_window_posy = self.gconf_path + '/window_posy'
        self.gconf_options_shown = self.gconf_path + '/options_shown'
        self.gconf_filedir = self.gconf_path + '/filedir'
        self.gconf_keepext = self.gconf_path + '/keepext'
        self.gconf_autopreview  = self.gconf_path + '/autopreview'


    def create_preferences_dialog(self):
        """ Create Preferences dialog and connect signals """

        # Create the window
        self.preferences_tree = gtk.glade.XML(pyrenamerglob.gladefile, "prefs_window")

        # Get text entries and buttons
        self.prefs_window = self.preferences_tree.get_widget('prefs_window')
        self.prefs_entry_root = self.preferences_tree.get_widget('prefs_entry_root')
        self.prefs_entry_active = self.preferences_tree.get_widget('prefs_entry_active')
        self.prefs_browse_root = self.preferences_tree.get_widget('prefs_browse_root')
        self.prefs_browse_active = self.preferences_tree.get_widget('prefs_browse_active')
        self.prefs_close = self.preferences_tree.get_widget('prefs_close')

        # Signals
        signals = {
                   "on_prefs_browse_root_clicked": self.on_prefs_browse_root_clicked,
                   "on_prefs_browse_active_clicked": self.on_prefs_browse_active_clicked,
                   "on_prefs_close_clicked": self.on_prefs_close_clicked,
                   "on_prefs_window_destroy": self.on_prefs_destroy,
                   }
        self.preferences_tree.signal_autoconnect(signals)

        # Fill the panel with gconf values or actual values (if gconf is empty)
        client = gconf.client_get_default()
        root_dir = client.get_string(self.gconf_root_dir)
        if root_dir == (None or ''): root_dir = self.main.root_dir
        active_dir = client.get_string(self.gconf_active_dir)
        if active_dir == (None or ''): active_dir = self.main.active_dir
        self.prefs_entry_root.set_text(root_dir)
        self.prefs_entry_active.set_text(active_dir)

        # Set prefs window icon
        self.prefs_window.set_icon_from_file(pyrenamerglob.icon)


    def on_prefs_browse_root_clicked(self, widget):
        """ Browse root clicked """
        f = gtk.FileChooserDialog(_('Select root directory'),
                                  self.prefs_window,
                                  gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                  (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                   gtk.STOCK_OK, gtk.RESPONSE_ACCEPT),
                                   )
        f.set_current_folder(self.prefs_entry_root.get_text())
        response = f.run()
        if response == gtk.RESPONSE_ACCEPT:
            self.prefs_entry_root.set_text(f.get_filename())
        elif response == gtk.RESPONSE_REJECT:
            pass
        f.destroy()


    def on_prefs_browse_active_clicked(self, widget):
        """ Browse active clicked """
        f = gtk.FileChooserDialog(_('Select active directory'),
                                  self.prefs_window,
                                  gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER,
                                  (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                                   gtk.STOCK_OK, gtk.RESPONSE_ACCEPT),
                                   )
        f.set_current_folder(self.prefs_entry_active.get_text())
        response = f.run()
        if response == gtk.RESPONSE_ACCEPT:
            self.prefs_entry_active.set_text(f.get_filename())
        elif response == gtk.RESPONSE_REJECT:
            pass
        f.destroy()


    def on_prefs_close_clicked(self, widget):
        """ Prefs close button clicked """

        root = self.prefs_entry_root.get_text()
        active = self.prefs_entry_active.get_text()
        if root != "" and active != "":
            if not self.check_root_dir(root):
                self.display_error_dialog(_("\nThe root directory is not valid!\nPlease select another directory."))
                self.prefs_entry_root.set_text('/')
            elif not self.check_active_dir(root, active):
                self.main.display_error_dialog(_("\nThe active directory is not valid!\nPlease select another directory."))
                self.prefs_entry_active.set_text(root)
            else:
                self.main.root_dir = root
                self.main.active_dir = active
                self.prefs_window.destroy()
                self.preferences_save_dirs()
        else:
            self.main.display_error_dialog(_("\nPlease set both directories!"))
            if root == '': self.prefs_entry_root.set_text(self.main.root_dir)
            if active == '': self.prefs_entry_active.set_text(self.main.active_dir)


    def on_prefs_destroy(self, widget):
        """ Prefs window destroyed """

        root = self.prefs_entry_root.get_text()
        active = self.prefs_entry_active.get_text()
        if root != "" and active != "":
            if not self.check_root_dir(root):
                self.main.display_error_dialog(_("\nThe root directory is not valid!\nPlease select another directory."))
                self.create_preferences_dialog()
                self.prefs_entry_root.set_text('/')
            elif not self.check_active_dir(root, active):
                self.main.display_error_dialog(_("\nThe active directory is not valid!\nPlease select another directory."))
                self.create_preferences_dialog()
                self.prefs_entry_active.set_text(root)
            else:
                self.main.root_dir = root
                self.main.active_dir = active
                self.prefs_window.destroy()
                self.preferences_save_dirs()
        else:
            self.main.display_error_dialog(_("\nPlease set both directories!"))
            self.create_preferences_dialog()
            if root == '': self.prefs_entry_root.set_text(self.main.root_dir)
            if active == '': self.prefs_entry_active.set_text(self.main.active_dir)


    def on_add_recursive_toggled(self, widget):
        """ Reload current dir, but with Recursive flag enabled """
        self.main.dir_reload_current()

    def on_filedir_combo_changed(self, combo):
        filedir = combo.get_active()
        self.main.filedir = filedir
        self.main.dir_reload_current()

    def on_extensions_check_toggled(self, check):
        self.main.keepext = check.get_active()

    def on_autopreview_check_toggled(self, check):
        self.main.autopreview = check.get_active()

    def check_root_dir(self, root):
        """ Checks if the root dir is correct """
        return ospath.isdir(ospath.abspath(root))


    def check_active_dir(self, root, active):
        """ Checks if active dir is correct """
        root = ospath.abspath(root)
        active = ospath.abspath(active)
        return ospath.isdir(active) and (root in active)


    def preferences_save(self):
        """ Width and height are saved on the configure_event callback for main_window """
        client = gconf.client_get_default()
        client.set_int(self.gconf_pane_position, self.main.pane_position)
        client.set_bool(self.gconf_window_maximized, self.main.window_maximized)
        client.set_int(self.gconf_window_width, self.main.window_width)
        client.set_int(self.gconf_window_height, self.main.window_height)
        client.set_int(self.gconf_window_posx, self.main.window_posx)
        client.set_int(self.gconf_window_posy, self.main.window_posy)
        client.set_bool(self.gconf_options_shown, self.main.options_shown)
        client.set_int(self.gconf_filedir, self.main.filedir)
        client.set_bool(self.gconf_keepext, self.main.keepext)
        client.set_bool(self.gconf_autopreview, self.main.autopreview)


    def preferences_save_dirs(self):
        """ Save default directories """
        client = gconf.client_get_default()
        client.set_string(self.gconf_root_dir, self.main.root_dir)
        client.set_string(self.gconf_active_dir, self.main.active_dir)

    def preferences_read(self):
        """ The name says it all... """
        client = gconf.client_get_default()

        root_dir = client.get_string(self.gconf_root_dir)
        if root_dir != None and root_dir != '': self.main.root_dir = root_dir

        active_dir = client.get_string(self.gconf_active_dir)
        if active_dir != None and active_dir != '': self.main.active_dir = active_dir

        pane_position = client.get_int(self.gconf_pane_position)
        if pane_position != None: self.main.pane_position = pane_position

        maximized = client.get_bool(self.gconf_window_maximized)
        if maximized != None: self.main.window_maximized = maximized

        width = client.get_int(self.gconf_window_width)
        height = client.get_int(self.gconf_window_height)
        if width != None and height != None:
            self.main.window_width = width
            self.main.window_height = height

        posx = client.get_int(self.gconf_window_posx)
        posy = client.get_int(self.gconf_window_posy)
        if posx != None and posy != None:
            self.main.window_posx = posx
            self.main.window_posy = posy

        options_shown = client.get_bool(self.gconf_options_shown)
        if options_shown != None: self.main.options_shown = options_shown

        filedir = client.get_int(self.gconf_filedir)
        if filedir != None: self.main.filedir = filedir

        keepext = client.get_bool(self.gconf_keepext)
        if keepext != None: self.main.keepext = keepext

        autopreview = client.get_bool(self.gconf_autopreview)
        if autopreview != None: self.main.autopreview = autopreview