~ubuntu-branches/ubuntu/trusty/catfish/trusty

« back to all changes in this revision

Viewing changes to catfish.py

  • Committer: Bazaar Package Importer
  • Author(s): Python Applications Team, Marco Rodrigues, Sandro Tosi, Savvas Radević, Piotr Ożarowski
  • Date: 2009-01-13 19:04:56 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090113190456-fukbnmg09h28ptd0
Tags: 0.3.2-1
[ Marco Rodrigues ]
* New upstream version (0.3.1)
  + Closes LP: #316674
* Bump to Standards-Version 3.8.0.
  + Add README.source.

[ Sandro Tosi ]
* debian/watch
  - updated to reflect new upstream website
* debian/control
  - Homepage field updated
* debian/copyright
  - updated upstream location
* debian/control
  - switch Vcs-Browser field to viewsvn

[ Savvas Radević ]
* 10Fix_makefile.dpatch updated to follow upstream changes

[ Piotr Ożarowski ]
* New upstream version (0.3.2)
  + Closes: #511492
* Updated the copyright years in debian/copyright
* Updated catfish.svg link in debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
2
2
 
3
 
# Copyright (C) 2007 Christian Dywan <christian at twotoasts dot de>
 
3
# Copyright (C) 2007-2008 Christian Dywan <christian at twotoasts dot de>
4
4
#
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.
9
9
#
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.
14
 
#
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.
18
11
 
19
12
import sys
20
13
 
41
34
    print 'Warning: The optional module %s is missing.' % str(msg).split()[-1]
42
35
 
43
36
app_name = 'catfish'
44
 
app_version = '0.3'
 
37
app_version = '0.3.2'
45
38
 
46
39
_ = gettext.gettext # i18n shortcut
47
40
 
134
127
    def __init__(self):
135
128
        """Create the main window."""
136
129
 
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'
142
 
        else:
 
136
        elif desktop[:5] == 'gnome':
 
137
            # We assume this is Gnome
143
138
            default_fileman = 'Nautilus'
 
139
            self.open_wrapper = 'gnome-open'
 
140
        else:
 
141
            # Unknown desktop? Just see what we have then
 
142
            # Guess suitable fileman
 
143
            commands = ['Nautilus', 'Thunar', 'konqueror']
 
144
            default_fileman = ''
 
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
 
149
                        break
 
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
150
157
                        break
151
158
 
152
159
        # Parse command line options
188
195
            print '(The default is "open".)'
189
196
            sys.exit(1)
190
197
 
 
198
        if not self.options.fileman:
 
199
            print 'Warning: No file manager was found or specified.'
 
200
 
191
201
        # Prepare i18n using gettext
192
202
        try:
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']
500
512
        methods = {
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,
504
516
                1, 0, 1, 0, 0),