1
1
#!/usr/bin/env python
3
# Copyright (C) 2007 Christian Dywan <christian at twotoasts dot de>
3
# Copyright (C) 2007-2008 Christian Dywan <christian at twotoasts dot de>
5
5
# This program is free software; you can redistribute it and/or
6
6
# modify it under the terms of the GNU General Public License
7
7
# as published by the Free Software Foundation; either version 2
8
8
# of the License, or (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
10
# See the file COPYING for the full license text.
134
127
def __init__(self):
135
128
"""Create the main window."""
137
self.openwrappers = ['gnome-open', 'exo-open', 'xdg-open']
138
# Guess default fileman
139
if os.environ.get('DESKTOP_SESSION', os.environ.get('GDMSESSION', ''))[:4] == 'xfce':
130
# Check for a desktop environment
131
desktop = os.environ.get('DESKTOP_SESSION', os.environ.get('GDMSESSION', ''))
132
if desktop[:4] == 'xfce':
133
# We assume this is Xfce4
140
134
default_fileman = 'Thunar'
141
135
self.open_wrapper = 'exo-open'
136
elif desktop[:5] == 'gnome':
137
# We assume this is Gnome
143
138
default_fileman = 'Nautilus'
139
self.open_wrapper = 'gnome-open'
141
# Unknown desktop? Just see what we have then
142
# Guess suitable fileman
143
commands = ['Nautilus', 'Thunar', 'konqueror']
145
for path in os.environ.get('PATH', '/usr/bin').split(os.pathsep):
146
for command in commands:
147
if os.path.exists(os.path.join(path, command)):
148
default_fileman = command
150
commands = ['gnome-open', 'exo-open', 'xdg-open']
144
151
self.open_wrapper = ''
145
152
# Guess suitable file open wrapper
146
153
for path in os.environ.get('PATH', '/usr/bin').split(os.pathsep):
147
for wrapper in self.openwrappers:
148
if os.path.exists(os.path.join(path, wrapper)):
149
self.open_wrapper = wrapper
154
for command in commands:
155
if os.path.exists(os.path.join(path, command)):
156
self.open_wrapper = command
152
159
# Parse command line options
188
195
print '(The default is "open".)'
198
if not self.options.fileman:
199
print 'Warning: No file manager was found or specified.'
191
201
# Prepare i18n using gettext
193
203
locale.setlocale(locale.LC_ALL, '')
480
490
if self.options.debug: print 'Debug:', msg
481
491
self.get_error_dialog(('Error: Could not open the file %s.'
482
492
% filename), self.window_search)
483
print 'Note: The wrapper was %s.' % self.open_wrapper
493
print '* The wrapper was %s.' % self.open_wrapper
494
print '* The filemanager was %s.' % self.options.fileman
495
print 'Hint: Check wether the wrapper and filemanager exist.'
484
496
except Exception, msg:
485
497
if self.options.debug: print 'Debug:', msg
486
498
self.get_error_dialog(('Error: Could not access the file %s.'
498
510
folder = os.path.expanduser(folder)
499
511
method_name = [method, 'locate'][method=='slocate']
501
'find': (method, '', '%s ' + folder + ' -ignore_readdir_race -noleaf',
513
'find': (method, '', '%s "' + folder + '" -ignore_readdir_race -noleaf',
502
514
'-wholename', '-iwholename', '', 1, 1, 0, 0, 0),
503
515
'locate': (method, '', '%s', '', '-i', '-n %i' % limit,