~ubuntu-branches/ubuntu/maverick/awn-extras-applets/maverick

« back to all changes in this revision

Viewing changes to applets/unmaintained/stacks/stacks_backend_plugger.py

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-08-29 14:29:52 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: james.westby@ubuntu.com-20100829142952-rhvuetyms9bv5uu7
Tags: upstream-0.4.0+bzr1372
ImportĀ upstreamĀ versionĀ 0.4.0+bzr1372

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
 
3
 
# Copyright (c) 2007 Timon ter Braak
4
 
#
5
 
# This library is free software; you can redistribute it and/or
6
 
# modify it under the terms of the GNU Lesser General Public
7
 
# License as published by the Free Software Foundation; either
8
 
# version 2 of the License, or (at your option) any later version.
9
 
#
10
 
# This library 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 GNU
13
 
# Lesser General Public License for more details.
14
 
#
15
 
# You should have received a copy of the GNU Lesser General Public
16
 
# License along with this library; if not, write to the
17
 
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18
 
# Boston, MA 02111-1307, USA.
19
 
 
20
 
import gtk
21
 
import gnomevfs
22
 
from awn.extras import _
23
 
from desktopagnostic.config import GROUP_DEFAULT
24
 
from stacks_backend_folder import *
25
 
from stacks_vfs import VfsUri, Monitor
26
 
 
27
 
class PluggerBackend(FolderBackend):
28
 
 
29
 
    def _eject_cb(self, *args, **kargs):
30
 
        return
31
 
 
32
 
    def _unmount_cb(self, widget):
33
 
        for volume in gnomevfs.VolumeMonitor().get_mounted_volumes():
34
 
             hudi = volume.get_hal_udi()
35
 
             if hudi is not None:
36
 
                hal,sep,vid = hudi.rpartition(os.sep)
37
 
                if not cmp(vid, self.applet.uid):
38
 
                    volume.unmount(self._eject_cb)
39
 
 
40
 
    def _hide_cb(self, widget):
41
 
        #self.applet.gconf_client.set_bool(self.applet.gconf_path + "/hide_volume", True)
42
 
        self.applet.destroy()
43
 
 
44
 
    def get_type(self):
45
 
        return BACKEND_TYPE_PLUGGER
46
 
 
47
 
    def get_title(self):
48
 
        title = self.applet.client.get_string(GROUP_DEFAULT, "title")
49
 
        if title and len(title) > 0:
50
 
            return title
51
 
        else:
52
 
            return _("Mounted Volume")
53
 
 
54
 
    def get_menu_items(self):
55
 
        items = FolderBackend.get_menu_items(self)
56
 
        unmount_item = gtk.MenuItem(label=_("Unmount Volume"))
57
 
        unmount_item.connect_object("activate", self._unmount_cb, self)
58
 
        items.append(unmount_item)
59
 
        hide_item = gtk.MenuItem(label=_("Hide Volume"))
60
 
        hide_item.connect_object("activate", self._hide_cb, self)
61
 
        items.append(hide_item)
62
 
        return items