Skip to content

Commit

Permalink
Scale trayicon since Gtk+ don't scale it
Browse files Browse the repository at this point in the history
  • Loading branch information
mozbugbox committed May 11, 2016
1 parent 7684df5 commit 2306fad
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions plugins/trayicon.py
Expand Up @@ -23,7 +23,8 @@
gi.require_version('Peas', '1.0')
gi.require_version('PeasGtk', '1.0')
gi.require_version('Liferea', '3.0')
from gi.repository import GObject, Peas, PeasGtk, Gtk, Liferea, Gdk
from gi.repository import GObject, Peas, PeasGtk, Gtk, Liferea
from gi.repository import Gdk, GdkPixbuf
import cairo
from collections import namedtuple

Expand Down Expand Up @@ -94,6 +95,7 @@ def do_activate(self):
self.staticon.set_from_pixbuf(Liferea.icon_create_from_file("unread.png"))
self.staticon.connect("activate", self.trayicon_click)
self.staticon.connect("popup_menu", self.trayicon_popup)
self.staticon.connect("size-changed", self.trayicon_size_changed)
self.staticon.set_visible(True)

self.menu = Gtk.Menu()
Expand Down Expand Up @@ -155,18 +157,29 @@ def show_new_count(self, new_count):
self.staticon.props.pixbuf = pix
return pix

def feedlist_new_items_cb(self, feedlist, new_count=-1):
def feedlist_new_items_cb(self, feedlist=None, new_count=-1):
if new_count < 0:
if feedlist is None:
feedlist = self.shell.props.feed_list
new_count = feedlist.get_new_item_count()
if new_count > 0:
double_figure = min(99, new_count) # show max 2 digit
pix = self.show_new_count(double_figure)
else:
pix = self.read_pix

icon_size = self.staticon.props.size
if pix.props.height < icon_size:
pix = pix.scale_simple(icon_size, icon_size,
GdkPixbuf.InterpType.HYPER)

if self.staticon.props.pixbuf != pix:
self.staticon.props.pixbuf = pix

def trayicon_size_changed(self, widget, size):
self.feedlist_new_items_cb()
return True

def do_deactivate(self):
self.staticon.set_visible(False)
self.window.disconnect(self.minimize_to_tray_delete_handler)
Expand Down

0 comments on commit 2306fad

Please sign in to comment.