Ticket #176: nicotine_show_notification.diff

File nicotine_show_notification.diff, 6.4 kB (added by code@…, 18 months ago)

Add libnotify support to nicotine+

  • nicotine+-1.2.7.1/pynicotine/config.py

    diff -Naur --exclude='*.pyc' -x '*.bak' /home/fito/bin/nicotine+-1.2.7.1/pynicotine/config.py nicotine+-1.2.7.1/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.7.1/pynicotine/gtkgui/nicotine-settings.glade

    diff -Naur --exclude='*.pyc' -x '*.bak' /home/fito/bin/nicotine+-1.2.7.1/pynicotine/gtkgui/nicotine-settings.glade nicotine+-1.2.7.1/pynicotine/gtkgui/nicotine-settings.glade
    old new  
    84818481          <property name="spacing">10</property> 
    84828482 
    84838483          <child> 
     8484            <widget class="GtkCheckButton" id="notificationtogglebutton"> 
     8485              <property name="visible">True</property> 
     8486              <property name="can_focus">True</property> 
     8487              <property name="label" translatable="yes">Show notification when a file is downloaded</property> 
     8488              <property name="use_underline">True</property> 
     8489              <property name="relief">GTK_RELIEF_NORMAL</property> 
     8490              <property name="focus_on_click">True</property> 
     8491              <property name="active">False</property> 
     8492              <property name="inconsistent">False</property> 
     8493              <property name="draw_indicator">True</property> 
     8494            </widget> 
     8495            <packing> 
     8496              <property name="padding">0</property> 
     8497              <property name="expand">False</property> 
     8498              <property name="fill">False</property> 
     8499            </packing> 
     8500          </child> 
     8501 
     8502          <child> 
    84848503            <widget class="GtkVBox" id="vbox87"> 
    84858504              <property name="visible">True</property> 
    84868505              <property name="homogeneous">False</property> 
     
    86318650            </widget> 
    86328651            <packing> 
    86338652              <property name="padding">0</property> 
    8634               <property name="expand">False</property> 
     8653              <property name="expand">True</property> 
    86358654              <property name="fill">True</property> 
    86368655            </packing> 
    86378656          </child> 
  • nicotine+-1.2.7.1/pynicotine/gtkgui/settings_glade.py

    diff -Naur --exclude='*.pyc' -x '*.bak' /home/fito/bin/nicotine+-1.2.7.1/pynicotine/gtkgui/settings_glade.py nicotine+-1.2.7.1/pynicotine/gtkgui/settings_glade.py
    old new  
    33983398        self.vbox87 = gtk.VBox(False, 0) 
    33993399        self.vbox87.show() 
    34003400        self.vbox87.set_spacing(0) 
     3401         
     3402        self.ShowNotification = gtk.CheckButton() 
     3403        self.ShowNotification.set_active(False) 
     3404        self.ShowNotification.set_label(_("Show notification after download")) 
     3405        self.ShowNotification.show() 
     3406        self.vbox87.pack_start(self.ShowNotification, False, False, 0) 
    34013407 
    34023408        self.label214 = gtk.Label(_("Run command after download finishes ($ for filename):")) 
    34033409        self.label214.set_alignment(0, 0.5) 
  • nicotine+-1.2.7.1/pynicotine/gtkgui/settingswindow.py

    diff -Naur --exclude='*.pyc' -x '*.bak' /home/fito/bin/nicotine+-1.2.7.1/pynicotine/gtkgui/settingswindow.py nicotine+-1.2.7.1/pynicotine/gtkgui/settingswindow.py
    old new  
    10331033         
    10341034        def SetSettings(self, config): 
    10351035                transfers = config["transfers"] 
     1036                if transfers["shownotification"] is not None: 
     1037                        self.ShowNotification.set_active(transfers["shownotification"]) 
    10361038                if transfers["afterfinish"] is not None: 
    10371039                        self.AfterDownload.set_text(transfers["afterfinish"]) 
    10381040                if transfers["afterfolder"] is not None: 
     
    10401042                if config["players"]["default"] is not None: 
    10411043                        self.audioPlayerCombo.child.set_text(config["players"]["default"]) 
    10421044                        self.audioPlayerCombo.append_text( config["players"]["default"] )  
     1045 
    10431046        def GetSettings(self): 
    10441047                return { 
    10451048                        "transfers": { 
     1049                                "shownotification" : self.ShowNotification.get_active(), 
    10461050                                "afterfinish": self.AfterDownload.get_text(), 
    10471051                                "afterfolder": self.AfterFolder.get_text(), 
    10481052                                 
  • nicotine+-1.2.7.1/pynicotine/transfers.py

    diff -Naur --exclude='*.pyc' -x '*.bak' /home/fito/bin/nicotine+-1.2.7.1/pynicotine/transfers.py nicotine+-1.2.7.1/pynicotine/transfers.py
    old new  
    2222from utils import _ 
    2323from gtkgui.utils import recode2 
    2424 
     25 
    2526class Transfer: 
    2627        """ This class holds information about a single transfer. """ 
    2728        def __init__(self, conn = None, user = None, filename = None, path = None, status = None, req=None, size = None, file = None, starttime = None, offset = None, currentbytes = None, speed = None,timeelapsed = None, timeleft = None, timequeued = None, transfertimer = None, requestconn = None, modifier = None, place = 0): 
     
    105106                                self.geoip = _GeoIP.new(_GeoIP.GEOIP_STANDARD) 
    106107                        except: 
    107108                                self.geoip = None 
     109                                 
     110                                 
     111                try: 
     112                        import pynotify 
     113                        pynotify.init("Nicotine+") 
     114                        self.pynotify = pynotify 
     115                except ImportError: 
     116                        self.pynotify = None 
     117 
    108118  
    109119        def setTransferPanels(self, downloads, uploads): 
    110120                self.downloadspanel = downloads 
     
    762772                                        self.eventprocessor.sendNumSharedFoldersFiles() 
    763773                                        self.SaveDownloads() 
    764774                                        self.downloadspanel.update(i) 
     775                                        if self.eventprocessor.config.sections["transfers"]["shownotification"] and self.pynotify != None: 
     776                                                n = self.pynotify.Notification("Nicotine+", _("%s downloaded" % newname)) 
     777                                                n.set_icon_from_pixbuf(self.eventprocessor.frame.images["nicotinen"]) 
     778                                                try: n.attach_to_widget(self.eventprocessor.frame.trayicon) 
     779                                                except: pass 
     780                                                n.show() 
     781                                                 
    765782                                        if self.eventprocessor.config.sections["transfers"]["afterfinish"]: 
    766783                                                command = self.eventprocessor.config.sections["transfers"]["afterfinish"].replace("$", utils.escapeCommand(newname)) 
    767784                                                os.system(command)