Exemplo n.º 1
0
    def __init__(self):
        ItemSource.__init__(self,
                            name=_("Devices & Media"),
                            icon="gnome-dev-removable-usb",
                            uri="source://Devices",
                            filter_by_date=False)
        
        self.add_bluetooth = Item(name=_("Add Bluetooth..."),
                                  comment=_("Access a wireless device"),
                                  icon="stock_bluetooth",
                                  special=True)
        self.add_bluetooth.do_open = lambda: self._add_bluetooth()

        self.cd_burner = Item(name=_("Create CD/DVD..."),
                              comment=_("Burn files onto a CD or DVD disk"),
                              icon="gnome-dev-cdrom",
                              special=True)
        self.cd_burner.do_open = \
            lambda: launcher.launch_command("nautilus --no-desktop burn:///")

        self.vol_monitor = gnomevfs.VolumeMonitor()
        self.vol_monitor.connect("drive_connected", lambda v, d: self.emit("reload"))
        self.vol_monitor.connect("drive_disconnected", lambda v, d: self.emit("reload"))
        self.vol_monitor.connect("volume_mounted", lambda v, d: self.emit("reload"))
        self.vol_monitor.connect("volume_unmounted", lambda v, d: self.emit("reload"))
Exemplo n.º 2
0
    def __init__(self, drive = None, uri = None):
        assert drive or uri, "Invalid arguments passed to DriveItem.__init__"

        if not drive and uri:
            for drive in gnomevfs.VolumeMonitor().get_connected_drives():
                if drive.get_activation_uri() == uri:
                    break
            else:
                raise ValueError, "Cannot find drive to match URI '%s'" % uri

        uri = drive.get_activation_uri()
        if not uri:
            for volume in drive.get_mounted_volumes():
                if volume.is_user_visible():
                    # FIXME: Using the first volume URI for a device is
                    #        broken. There could be multiple, though I don't
                    #        know under what circumstances this would happen.
                    uri = volume.get_activation_uri()
                    break
            else:
                raise ValueError, "Cannot find URI to open for drive '%s'" % \
                      drive.get_display_name()

        Item.__init__(self,
                      uri=uri,
                      timestamp=0,
                      mimetype="x-gimmie/drive",
                      icon=drive.get_icon())
        self.drive = drive
Exemplo n.º 3
0
    def __init__(self, node):
        self.account_name = node.getAttribute("account")
        self.proto = node.getAttribute("proto")
        self.screenname = node.getElementsByTagName(
            "name")[0].childNodes[0].data
        try:
            self.alias = node.getElementsByTagName(
                "alias")[0].childNodes[0].data
        except IndexError:
            self.alias = ""

        self.buddy_icon = None

        icondir = os.path.expanduser("~/.gaim/icons")

        for setting in node.getElementsByTagName("setting"):
            if setting.getAttribute("name") == "buddy_icon":
                path = setting.childNodes[0].data
                if os.path.split(path)[0] == "":
                    path = os.path.join(icondir, path)
                if os.path.exists(path):
                    self.buddy_icon = path
                break

        Item.__init__(self,
                      uri="aim:goim?screenname=\"%s\"" % self.screenname,
                      mimetype="gaim/buddy")

        self.idle_time = None
Exemplo n.º 4
0
 def __init__(self, uri="trash:///"):
     Item.__init__(self,
                   name=_("Trash"),
                   uri=uri,
                   icon="gnome-fs-trash-full",
                   mimetype="x-directory/normal")
     trash_monitor.connect("count-changed", lambda mon: self.emit("reload"))
Exemplo n.º 5
0
 def populate_popup(self, menu):
     Item.populate_popup(self, menu)
     
     props = gtk.ImageMenuItem (gtk.STOCK_PROPERTIES)
     props.connect("activate", lambda w: self._open_properties())
     props.show()
     menu.append(props)
Exemplo n.º 6
0
    def __init__(self, uri):
        assert uri.startswith(
            "aim:"), "Pidgin buddy URI does not begin with aim:"
        Item.__init__(self, uri=uri, mimetype="purple/buddy")

        pidgin_reader.connect("reload", lambda r, u: self._find_buddy(u), uri)
        self._find_buddy(uri)
Exemplo n.º 7
0
 def __init__(self, printer):
     Item.__init__(self, mimetype="x-gimmie/printer")
     
     printer.connect("is_default_changed", lambda *args: self.emit("reload"))
     printer.connect("attributes_changed", lambda *args: self.emit("reload"))
     
     self.printer = printer
     self.add_tag("Printer")
Exemplo n.º 8
0
 def get_items_uncached(self):
     self.recent_items = {}
     for info in self.recent_model.get_list():
         item = Item(uri=info.get_uri(),
                     mimetype=info.get_mime_type(),
                     timestamp=info.get_timestamp(),
                     tags=info.get_groups())
         self.recent_items[item.get_uri()] = item
         yield item
Exemplo n.º 9
0
    def __init__(self, buddy, win):
        Item.__init__(self,
                      uri=buddy.get_uri(),
                      timestamp=buddy.get_timestamp(),
                      icon=None)
        self.buddy = buddy
        self.win = win

        # Listen for hint changes.
        self.win.connect("state-changed", self._win_state_changed)
Exemplo n.º 10
0
 def __getattribute__(self, name):
     try:
         if hasattr(gobject.GObject, name) or name == "pin":
             # Allow connect et al. to reach this gobject
             return Item.__getattribute__(self, name)
         else:
             # Avoid infinite recursion accessing pidgin_buddy
             pidgin_buddy = Item.__getattribute__(self, "pidgin_buddy")
             return getattr(pidgin_buddy, name)
     except AttributeError:
         return Item.__getattribute__(self, name)
Exemplo n.º 11
0
    def populate_popup(self, menu):
        Item.populate_popup(self, menu)

        sep = gtk.SeparatorMenuItem()
        sep.show()
        menu.append(sep)

        empty = gtk.MenuItem(_("_Empty Trash"), use_underline=True)
        empty.set_sensitive(not trash_monitor.is_empty())
        empty.connect("activate", lambda w: self.do_empty())
        empty.show()
        menu.append(empty)
Exemplo n.º 12
0
    def populate_popup(self, menu):
        Item.populate_popup(self, menu)

        # FIXME: Add mount/unmount toggle?  Need to track nautilus.

        eject = gtk.MenuItem(_("_Eject"), use_underline=True)
        if hasattr(self.drive, "needs_eject"):
            # NOTE: PyGTK doesn't bind this yet.  See bug #419225.
            eject.set_sensitive(self.drive.needs_eject())
        eject.connect("activate", lambda w: self.eject())
        eject.show()
        menu.append(eject)
Exemplo n.º 13
0
 def get_icon(self, icon_size):
     # FIXME: accept icon?
     if trash_monitor.is_empty():
         self.icon = "gnome-fs-trash-empty"
     else:
         self.icon = "gnome-fs-trash-full"
     return Item.get_icon(self, icon_size)
Exemplo n.º 14
0
    def __init__(self, node):
        self.account_name = node.getAttribute("account")
        self.proto = node.getAttribute("proto")

        # Getting the Screenname
        try:
            try:
                self.screenname = node.getElementsByTagName(
                    "component")[0].childNodes[0].data
            except IndexError:
                self.screenname = node.getElementsByTagName(
                    "name")[0].childNodes[0].data
        except IndexError:
            self.screenname = ""

        # Getting the Alias
        try:
            self.alias = node.getElementsByTagName(
                "alias")[0].childNodes[0].data
        except IndexError:
            try:
                account = pidgin_dbus.PurpleAccountsFindAny(
                    self.account_name, self.proto)
                buddy = pidgin_dbus.PurpleFindBuddy(account, self.screenname)
                self.alias = pidgin_dbus.PurpleBuddyGetAlias(buddy)
            except dbus.DBusException:
                self.alias = ""

        self.buddy_icon = None

        icondir = os.path.expanduser("~/.purple/icons")

        for setting in node.getElementsByTagName("setting"):
            if setting.getAttribute("name") == "buddy_icon":
                path = setting.childNodes[0].data
                if os.path.split(path)[0] == "":
                    path = os.path.join(icondir, path)
                if os.path.exists(path):
                    self.buddy_icon = path
                break

        Item.__init__(self,
                      uri="aim:goim?screenname=\"%s\"" % self.screenname,
                      mimetype="purple/buddy")

        self.idle_time = None
Exemplo n.º 15
0
 def get_items_uncached(self):
     for info in self.recent_manager.get_items():
         if not info.get_private_hint():
             yield Item(name=info.get_display_name(),
                        uri=info.get_uri(),
                        mimetype=info.get_mime_type(),
                        timestamp=info.get_modified(),
                        tags=info.get_groups())
Exemplo n.º 16
0
    def __init__(self, app_group, item=None):
        assert app_group, "WnckClassGroup app_group cannot be None"

        if item:
            Item.__init__(self,
                          uri=item.get_uri(),
                          timestamp=item.get_timestamp(),
                          mimetype=item.get_mimetype())
        else:
            Item.__init__(self,
                          uri="win-group://%s" % app_group.get_name(),
                          mimetype="x-unknown")

        self.item = item
        self.app_group = app_group

        # Listen for hint changes.
        for win in app_group.get_windows():
            win.connect("state-changed", self._win_state_changed)
Exemplo n.º 17
0
    def add(self, uri, mimetype, groups=None, timestamp=None):
        assert uri, "Must specify recent URI"
        assert mimetype, "Must specify recent URI's mimetype"

        if not timestamp:
            timestamp = int(time.time())
        recent_item = Item(uri=uri,
                           mimetype=mimetype,
                           tags=groups,
                           timestamp=timestamp)
        self.add_item(recent_item)
Exemplo n.º 18
0
    def __init__(self):
        ItemSource.__init__(self,
                            name=_("Nearby Computers"),
                            icon=gtk.STOCK_NETWORK,
                            uri="source://Network",
                            filter_by_date=False)

        self.connect_to = Item(name=_("Connect to..."),
                               comment=_("Access a computer on the network"),
                               icon=gtk.STOCK_CONNECT,
                               special=True)
        self.connect_to.do_open = lambda: self._connect_to()

        self.smb = Item(name=_("Windows Network"),
                        comment=_("Browse nearby Windows computers"),
                        icon=gtk.STOCK_NETWORK,
                        special=True)
        self.smb.do_open = lambda: launcher.launch_command("nautilus smb://")

        self.vol_monitor = gnomevfs.VolumeMonitor()
        self.vol_monitor.connect("volume_mounted", lambda v, d: self.emit("reload"))
        self.vol_monitor.connect("volume_unmounted", lambda v, d: self.emit("reload"))
Exemplo n.º 19
0
    def get_item(self, uri):
        # Usually, we're given a file path, but maybe not always
        if uri[0] == '/':
            uri = 'file://' + uri

        try:
            info = self.recent_manager.lookup_item(uri)
            return Item(name=info.get_display_name(),
                        uri=info.get_uri(),
                        mimetype=info.get_mime_type(),
                        timestamp=info.get_modified(),
                        tags=info.get_groups())
        except gobject.GError:
            raise KeyError, uri
Exemplo n.º 20
0
    def __init__(self):
        ItemSource.__init__(self,
                            name=_("Printers"),
                            icon=gtk.STOCK_PRINT,
                            uri="source://Printers",
                            filter_by_date=False)

        self.add_printer = Item(name=_("Add Printer..."),
                                comment=_("Setup attached or networked printer"),
                                icon="gnome-dev-printer-new",
                                special=True)
        self.add_printer.do_open = lambda: launcher.launch_command("gnome-cups-add")

        if gnomecups:
            gnomecups.new_printer_notify_add(lambda *args: self.emit("reload"))
            gnomecups.printer_removed_notify_add(lambda *args: self.emit("reload"))
Exemplo n.º 21
0
 def __init__(self, volume):
     Item.__init__(self,
                   name=volume.get_display_name(),
                   uri=volume.get_activation_uri(),
                   mimetype="x-directory/normal",
                   icon=volume.get_icon())
Exemplo n.º 22
0
 def get_timestamp(self):
     return max(self.get_seen_timestamp(), self.get_modified_timestamp(),
                Item.get_timestamp(self))
Exemplo n.º 23
0
 def __init__(self, uri, timestamp=0, icon=None):
     Item.__init__(self, uri=uri, timestamp=timestamp, icon=icon)
     self.vfs_info = None
     self.vfs_info_job_id = None