Ticket #2010: titlebar.patch

File titlebar.patch, 3.8 KB (added by phil, 13 years ago)

Here's a patch for gktui and webui.

  • deluge/common.py

    diff -ruN deluge-1.3.3/deluge/common.py deluge-1.3.3-dev/deluge/common.py
    old new  
    319319    fspeed_gb = fspeed_mb / 1024.0
    320320    return "%.1f %s" % (fspeed_gb, _("GiB/s"))
    321321
     322def fspeedtitle(bps):
     323    fspeed_kb = bps / 1024.0
     324    if fspeed_kb < 1024:
     325        return "%.1f%s" % (fspeed_kb, _("K"))
     326    fspeed_mb = fspeed_kb / 1024.0
     327    if fspeed_mb < 1024:
     328        return "%.1f%s" % (fspeed_mb, _("M"))
     329    fspeed_gb = fspeed_mb / 1024.0
     330    return "%.1f%s" % (fspeed_gb, _("G"))
     331
    322332def fpeer(num_peers, total_peers):
    323333    """
    324334    Formats a string to show 'num_peers' ('total_peers')
  • deluge/ui/gtkui/mainwindow.py

    diff -ruN deluge-1.3.3/deluge/ui/gtkui/mainwindow.py deluge-1.3.3-dev/deluge/ui/gtkui/mainwindow.py
    old new  
    230230    def update(self):
    231231        # Update the window title
    232232        def _on_get_session_status(status):
    233             download_rate = deluge.common.fspeed(status["download_rate"])
    234             upload_rate = deluge.common.fspeed(status["upload_rate"])
    235             self.window.set_title("Deluge - %s %s %s %s" % (_("Down:"), download_rate, _("Up:"), upload_rate))
     233            download_rate = deluge.common.fspeedtitle(status["payload_download_rate"])
     234            upload_rate = deluge.common.fspeedtitle(status["payload_upload_rate"])
     235            self.window.set_title("%s%s %s%s - Deluge" % (_("D:"), download_rate, _("U:"), upload_rate))
    236236        if self.config["show_rate_in_title"]:
    237             client.core.get_session_status(["download_rate", "upload_rate"]).addCallback(_on_get_session_status)
     237            client.core.get_session_status(["payload_download_rate", "payload_upload_rate"]).addCallback(_on_get_session_status)
    238238
    239239    def _on_set_show_rate_in_title(self, key, value):
    240240        if value:
  • deluge/ui/web/js/deluge-all/Formatters.js

    diff -ruN deluge-1.3.3/deluge/ui/web/js/deluge-all/Formatters.js deluge-1.3.3-dev/deluge/ui/web/js/deluge-all/Formatters.js
    old new  
    9292                return (!bytes && !showZero) ? '' : fsize(bytes, showZero) + '/s';
    9393        },
    9494       
     95        speedtitle: function(bytes, showZero) {
     96                if (!bytes && !showZero) return '';
     97                bytes = bytes / 1024.0;
     98       
     99                if (bytes < 1024) { return bytes.toFixed(1)  + 'K'; }
     100                else { bytes = bytes / 1024; }
     101       
     102                if (bytes < 1024) { return bytes.toFixed(1)  + 'M'; }
     103                else { bytes = bytes / 1024; }
     104       
     105                return bytes.toFixed(1) + 'G'
     106        },
     107
    95108        /**
    96109         * Formats a string to show time in a human readable form.
    97110         *
     
    150163}
    151164var fsize = Deluge.Formatters.size;
    152165var fspeed = Deluge.Formatters.speed;
     166var fspeedtitle = Deluge.Formatters.speedtitle;
    153167var ftime = Deluge.Formatters.timeRemaining;
    154168var fdate = Deluge.Formatters.date;
    155169var fplain = Deluge.Formatters.plain;
  • deluge/ui/web/js/deluge-all/UI.js

    diff -ruN deluge-1.3.3/deluge/ui/web/js/deluge-all/UI.js deluge-1.3.3-dev/deluge/ui/web/js/deluge-all/UI.js
    old new  
    169169
    170170                if (deluge.config.show_session_speed) {
    171171                        document.title = this.originalTitle +
    172                                 ' (Down: ' + fspeed(data['stats'].download_rate, true) +
    173                                 ' Up: ' + fspeed(data['stats'].upload_rate, true) + ')';
     172                                ' (D:' + fspeedtitle(data['stats'].download_rate, true) +
     173                                ' U:' + fspeedtitle(data['stats'].upload_rate, true) + ')';
    174174                }
    175175                if (Ext.areObjectsEqual(this.filters, this.oldFilters)) {
    176176                        deluge.torrents.update(data['torrents']);