Ticket #176: nicotine_show_notification_128.diff

File nicotine_show_notification_128.diff, 4.1 kB (added by code@…, 18 months ago)

Add libnotify support to nicotine+

  • nicotine+-1.2.8/pynicotine/config.py

    diff -Naur --exclude='*.pyc' -x '*.bak' -x 'trayicon*' /home/fito/nicotine+-1.2.8/pynicotine/config.py nicotine+-1.2.8/pynicotine/config.py
    old new  
    5050\ 
    5151"transfers":{"downloaddir":None,"sharedownloaddir":1,"shared":None, "buddyshared": [],\ 
    5252"uploadbandwidth":10, "uselimit":0,"uploadlimit":150, "preferfriends":0, \ 
    53 "useupslots":0, "uploadslots":2, "incompletedir":"", "afterfinish":"", \ 
     53"useupslots":0, "uploadslots":2, "incompletedir":"", "shownotification":0, "afterfinish":"", \ 
    5454"afterfolder":"", "lock":1, "fifoqueue": 0, "usecustomban":0, "limitby":1, \ 
    5555"customban":"Banned, don't bother retrying","queuelimit":100,"friendsonly":0, \ 
    5656"friendsnolimits":0, "enablebuddyshares": 0, "enabletransferbuttons": 1, \ 
  • nicotine+-1.2.8/pynicotine/gtkgui/settings_glade.py

    diff -Naur --exclude='*.pyc' -x '*.bak' -x 'trayicon*' /home/fito/nicotine+-1.2.8/pynicotine/gtkgui/settings_glade.py nicotine+-1.2.8/pynicotine/gtkgui/settings_glade.py
    old new  
    32273227        self.label214.show() 
    32283228        self.vbox96.pack_start(self.label214, False, False, 0) 
    32293229 
     3230        self.ShowNotification = gtk.CheckButton() 
     3231        self.ShowNotification.set_active(False) 
     3232        self.ShowNotification.set_label(_("Show notification after download")) 
     3233        self.ShowNotification.show() 
     3234        self.vbox96.pack_start(self.ShowNotification, False, False, 0) 
     3235 
    32303236        self.AfterDownload = gtk.Entry() 
    32313237        self.AfterDownload.set_size_request(313, -1) 
    32323238        self.AfterDownload.set_text("") 
  • nicotine+-1.2.8/pynicotine/gtkgui/settingswindow.py

    diff -Naur --exclude='*.pyc' -x '*.bak' -x 'trayicon*' /home/fito/nicotine+-1.2.8/pynicotine/gtkgui/settingswindow.py nicotine+-1.2.8/pynicotine/gtkgui/settingswindow.py
    old new  
    11391139        def SetSettings(self, config): 
    11401140                 
    11411141                transfers = config["transfers"] 
     1142                if transfers["shownotification"] is not None:  
     1143                        self.ShowNotification.set_active(transfers["shownotification"]) 
    11421144                if transfers["afterfinish"] is not None: 
    11431145                        self.AfterDownload.set_text(transfers["afterfinish"]) 
    11441146                if transfers["afterfolder"] is not None: 
     
    11501152        def GetSettings(self): 
    11511153                return { 
    11521154                        "transfers": { 
     1155                                "shownotification" : self.ShowNotification.get_active(), 
    11531156                                "afterfinish": self.AfterDownload.get_text(), 
    11541157                                "afterfolder": self.AfterFolder.get_text(), 
    11551158                                 
  • nicotine+-1.2.8/pynicotine/transfers.py

    diff -Naur --exclude='*.pyc' -x '*.bak' -x 'trayicon*' /home/fito/nicotine+-1.2.8/pynicotine/transfers.py nicotine+-1.2.8/pynicotine/transfers.py
    old new  
    111111                                self.geoip = _GeoIP.new(_GeoIP.GEOIP_STANDARD) 
    112112                        except: 
    113113                                self.geoip = None 
     114                                 
     115                try: 
     116                        import pynotify 
     117                        pynotify.init("Nicotine+") 
     118                        self.pynotify = pynotify 
     119                except ImportError: 
     120                        self.pynotify = None 
    114121  
    115122        def setTransferPanels(self, downloads, uploads): 
    116123                self.downloadspanel = downloads 
     
    772779                                        self.eventprocessor.sendNumSharedFoldersFiles() 
    773780                                        self.SaveDownloads() 
    774781                                        self.downloadspanel.update(i) 
     782                                        if self.eventprocessor.config.sections["transfers"]["shownotification"] and self.pynotify != None: 
     783                                                n = self.pynotify.Notification("Nicotine+", _("%s downloaded" % newname)) 
     784                                                n.set_icon_from_pixbuf(self.eventprocessor.frame.images["n"]) 
     785                                                try: n.attach_to_status_icon(self.eventprocessor.frame.TrayApp.trayicon_module) 
     786                                                except:  
     787                                                        try: n.attach_to_widget(self.eventprocessor.frame.TrayApp.trayicon_module) 
     788                                                        except: pass 
     789                                                n.show() 
    775790                                        if self.eventprocessor.config.sections["transfers"]["afterfinish"]: 
    776791                                                command = self.eventprocessor.config.sections["transfers"]["afterfinish"].replace("$", utils.escapeCommand(newname)) 
    777792                                                os.system(command)