Remove tray icon support
Stop whining. We'll replace that with another mechanism (appindicator, etc..) in the future.
This commit is contained in:
parent
3a595b721c
commit
a198ecc400
5 changed files with 2 additions and 245 deletions
|
@ -160,16 +160,6 @@
|
|||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="checkbutton_show_tray_icon">
|
||||
<property name="label" translatable="yes">Show icon in system tray</property>
|
||||
<property name="visible">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="tab-label" translatable="yes">General</property>
|
||||
|
|
|
@ -87,9 +87,6 @@ gPodderSettings = {
|
|||
# YouTube
|
||||
'youtube_preferred_fmt_id': 18,
|
||||
|
||||
# Tray icon
|
||||
'display_tray_icon': False,
|
||||
|
||||
# Misc
|
||||
'paned_position': 200,
|
||||
'rotation_mode': 0,
|
||||
|
|
|
@ -92,7 +92,6 @@ class gPodderPreferences(BuilderWidget):
|
|||
self.combo_video_player_app.set_active(index)
|
||||
|
||||
self._config.connect_gtk_togglebutton('enable_notifications', self.checkbutton_enable_notifications)
|
||||
self._config.connect_gtk_togglebutton('display_tray_icon', self.checkbutton_show_tray_icon)
|
||||
|
||||
self.update_interval_presets = [0, 10, 30, 60, 2*60, 6*60, 12*60]
|
||||
adjustment_update_interval = self.hscale_update_interval.get_adjustment()
|
||||
|
|
|
@ -1,186 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# gPodder - A media aggregator and podcast client
|
||||
# Copyright (c) 2005-2011 Thomas Perl and the gPodder Team
|
||||
#
|
||||
# gPodder is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# gPodder is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
|
||||
# trayicon.py -- Tray icon and notification support
|
||||
# Jérôme Chabod (JCH) <jerome.chabod@ifrance.com> 2007-12-20
|
||||
|
||||
|
||||
import gtk
|
||||
|
||||
import gpodder
|
||||
from gpodder.liblogger import log
|
||||
|
||||
_ = gpodder.gettext
|
||||
N_ = gpodder.ngettext
|
||||
|
||||
from gpodder.gtkui import draw
|
||||
|
||||
class GPodderStatusIcon(gtk.StatusIcon):
|
||||
""" this class display a status icon in the system tray
|
||||
this icon serves to show or hide gPodder, notify dowload status
|
||||
and provide a popupmenu for quick acces to some
|
||||
gPodder functionalities
|
||||
|
||||
author: Jérôme Chabod <jerome.chabod at ifrance.com>
|
||||
"""
|
||||
|
||||
DEFAULT_TOOLTIP = _('gPodder media aggregator')
|
||||
|
||||
# status: they are displayed as tooltip and add a small icon to the main icon
|
||||
STATUS_DOWNLOAD_IN_PROGRESS = (_('Downloading episodes'), gtk.STOCK_GO_DOWN)
|
||||
STATUS_UPDATING_FEED_CACHE = (_('Looking for new episodes'), gtk.STOCK_REFRESH)
|
||||
STATUS_SYNCHRONIZING = (_('Synchronizing to player'), 'multimedia-player')
|
||||
STATUS_DELETING = (_('Cleaning files'), gtk.STOCK_DELETE)
|
||||
|
||||
def __init__(self, gp, icon_filename, config):
|
||||
gtk.StatusIcon.__init__(self)
|
||||
log('Creating tray icon', sender=self)
|
||||
|
||||
self._config = config
|
||||
self.__gpodder = gp
|
||||
self.__icon_cache = {}
|
||||
self.__icon_filename = icon_filename
|
||||
self.__current_icon = -1
|
||||
|
||||
# try getting the icon
|
||||
try:
|
||||
self.__icon = gtk.gdk.pixbuf_new_from_file(self.__icon_filename)
|
||||
except Exception, exc:
|
||||
log('Warning: Cannot load gPodder icon, will use the default icon (%s)', exc, sender=self)
|
||||
self.__icon = gtk.icon_theme_get_default().load_icon(gtk.STOCK_DIALOG_QUESTION, 30, 30)
|
||||
|
||||
# Reset trayicon (default icon, default tooltip)
|
||||
self.__current_pixbuf = None
|
||||
self.__last_ratio = 1.0
|
||||
self.set_status()
|
||||
|
||||
menu = self.__create_context_menu()
|
||||
self.connect('activate', self.__on_left_click)
|
||||
self.connect('popup-menu', self.__on_right_click, menu)
|
||||
|
||||
self.set_visible(True)
|
||||
|
||||
def __create_context_menu(self):
|
||||
# build and connect the popup menu
|
||||
menu = gtk.Menu()
|
||||
menuItem = gtk.ImageMenuItem(_("Check for new episodes"))
|
||||
menuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU))
|
||||
menuItem.connect('activate', self.__gpodder.on_itemUpdate_activate)
|
||||
menu.append(menuItem)
|
||||
|
||||
menuItem = gtk.ImageMenuItem(_("Download all new episodes"))
|
||||
menuItem.set_image(gtk.image_new_from_stock(gtk.STOCK_GO_DOWN, gtk.ICON_SIZE_MENU))
|
||||
menuItem.connect('activate', self.__gpodder.on_itemDownloadAllNew_activate)
|
||||
menu.append(menuItem)
|
||||
|
||||
menuItem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
|
||||
menuItem.connect('activate', self.__gpodder.on_itemPreferences_activate)
|
||||
menu.append(menuItem)
|
||||
|
||||
menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
|
||||
menuItem.connect('activate', self.__gpodder.on_itemAbout_activate)
|
||||
menu.append(menuItem)
|
||||
menu.append( gtk.SeparatorMenuItem())
|
||||
|
||||
menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT)
|
||||
menuItem.connect('activate', self.__on_exit_callback)
|
||||
menu.append(menuItem)
|
||||
|
||||
return menu
|
||||
|
||||
def __on_exit_callback(self, widget, *args):
|
||||
self.__gpodder.close_gpodder()
|
||||
|
||||
def __on_right_click(self, widget, button=None, time=0, data=None):
|
||||
"""Open popup menu on right-click
|
||||
"""
|
||||
if data is not None:
|
||||
data.show_all()
|
||||
data.popup(None, None, None, 3, time)
|
||||
|
||||
def __on_left_click(self, widget, data=None):
|
||||
"""Hide/unhide gPodder on left-click
|
||||
"""
|
||||
if self.__gpodder.is_iconified():
|
||||
self.__gpodder.uniconify_main_window()
|
||||
else:
|
||||
if not self.__gpodder.gPodder.is_active():
|
||||
self.__gpodder.gPodder.present()
|
||||
else:
|
||||
self.__gpodder.iconify_main_window()
|
||||
|
||||
def __get_status_icon(self, icon):
|
||||
if icon in self.__icon_cache:
|
||||
return self.__icon_cache[icon]
|
||||
|
||||
try:
|
||||
new_icon = self.__icon.copy()
|
||||
emblem = gtk.icon_theme_get_default().load_icon(icon, int(new_icon.get_width()/1.5), 0)
|
||||
(width, height) = (emblem.get_width(), emblem.get_height())
|
||||
xpos = new_icon.get_width()-width
|
||||
ypos = new_icon.get_height()-height
|
||||
emblem.composite(new_icon, xpos, ypos, width, height, xpos, ypos, 1, 1, gtk.gdk.INTERP_BILINEAR, 255)
|
||||
self.__icon_cache[icon] = new_icon
|
||||
return new_icon
|
||||
except Exception, exc:
|
||||
pass
|
||||
|
||||
log('Warning: Cannot create status icon: %s', icon, sender=self)
|
||||
return self.__icon
|
||||
|
||||
def set_status(self, status=None, tooltip=None):
|
||||
if status is None:
|
||||
if tooltip is None:
|
||||
tooltip = self.DEFAULT_TOOLTIP
|
||||
else:
|
||||
tooltip = 'gPodder - %s' % tooltip
|
||||
if self.__current_icon is not None:
|
||||
self.__current_pixbuf = self.__icon
|
||||
self.set_from_pixbuf(self.__current_pixbuf)
|
||||
self.__current_icon = None
|
||||
else:
|
||||
(status_tooltip, icon) = status
|
||||
if tooltip is None:
|
||||
tooltip = 'gPodder - %s' % status_tooltip
|
||||
else:
|
||||
tooltip = 'gPodder - %s' % tooltip
|
||||
if self.__current_icon != icon:
|
||||
self.__current_pixbuf = self.__get_status_icon(icon)
|
||||
self.set_from_pixbuf(self.__current_pixbuf)
|
||||
self.__current_icon = icon
|
||||
self.set_tooltip(tooltip)
|
||||
|
||||
def draw_progress_bar(self, ratio):
|
||||
"""
|
||||
Draw a progress bar on top of this tray icon.
|
||||
The ratio parameter should be a value from 0 to 1.
|
||||
"""
|
||||
|
||||
# Only update in 3-percent-steps to save some resources
|
||||
if abs(ratio-self.__last_ratio) < 0.03 and ratio > self.__last_ratio:
|
||||
return
|
||||
|
||||
icon = self.__current_pixbuf.copy()
|
||||
progressbar = draw.progressbar_pixbuf(icon.get_width(), icon.get_height(), ratio)
|
||||
progressbar.composite(icon, 0, 0, icon.get_width(), icon.get_height(), 0, 0, 1, 1, gtk.gdk.INTERP_NEAREST, 255)
|
||||
|
||||
self.set_from_pixbuf(icon)
|
||||
self.__last_ratio = ratio
|
||||
|
|
@ -103,13 +103,6 @@ if gpodder.ui.desktop:
|
|||
from gpodder.gtkui.desktop.episodeselector import gPodderEpisodeSelector
|
||||
from gpodder.gtkui.desktop.podcastdirectory import gPodderPodcastDirectory
|
||||
from gpodder.gtkui.interface.progress import ProgressIndicator
|
||||
try:
|
||||
from gpodder.gtkui.desktop.trayicon import GPodderStatusIcon
|
||||
have_trayicon = True
|
||||
except Exception, exc:
|
||||
log('Warning: Could not import gpodder.trayicon.', traceback=True)
|
||||
log('Warning: This probably means your PyGTK installation is too old!')
|
||||
have_trayicon = False
|
||||
elif gpodder.ui.fremantle:
|
||||
from gpodder.gtkui.frmntl.model import DownloadStatusModel
|
||||
from gpodder.gtkui.frmntl.model import EpisodeListModel
|
||||
|
@ -123,7 +116,6 @@ elif gpodder.ui.fremantle:
|
|||
from gpodder.gtkui.frmntl.downloads import gPodderDownloads
|
||||
from gpodder.gtkui.frmntl.progress import ProgressIndicator
|
||||
from gpodder.gtkui.frmntl.widgets import FancyProgressBar
|
||||
have_trayicon = False
|
||||
|
||||
from gpodder.gtkui.frmntl.portrait import FremantleRotation
|
||||
from gpodder.gtkui.frmntl.mafw import MafwPlaybackMonitor
|
||||
|
@ -241,7 +233,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
self.preferences_dialog = None
|
||||
self.config.add_observer(self.on_config_changed)
|
||||
|
||||
self.tray_icon = None
|
||||
self.episode_shownotes_window = None
|
||||
self.new_episodes_window = None
|
||||
|
||||
|
@ -275,7 +266,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
self.download_queue_manager = download.DownloadQueueManager(self.config)
|
||||
|
||||
if gpodder.ui.desktop:
|
||||
self.show_hide_tray_icon()
|
||||
self.itemShowAllEpisodes.set_active(self.config.podcast_list_view_all)
|
||||
self.itemShowToolbar.set_active(self.config.show_toolbar)
|
||||
self.itemShowDescription.set_active(self.config.episode_list_descriptions)
|
||||
|
@ -1320,14 +1310,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
percentage = 0.0
|
||||
total_speed = util.format_filesize(total_speed)
|
||||
title[1] += ' (%d%%, %s/s)' % (percentage, total_speed)
|
||||
if self.tray_icon is not None:
|
||||
# Update the tray icon status and progress bar
|
||||
self.tray_icon.set_status(self.tray_icon.STATUS_DOWNLOAD_IN_PROGRESS, title[1])
|
||||
self.tray_icon.draw_progress_bar(percentage/100.)
|
||||
else:
|
||||
if self.tray_icon is not None:
|
||||
# Update the tray icon status
|
||||
self.tray_icon.set_status()
|
||||
if gpodder.ui.desktop:
|
||||
self.downloads_finished(self.download_tasks_seen)
|
||||
log('All downloads have finished.', sender=self)
|
||||
|
@ -1721,10 +1704,7 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
return True
|
||||
|
||||
def on_itemClose_activate(self, widget):
|
||||
if self.tray_icon is not None:
|
||||
self.iconify_main_window()
|
||||
else:
|
||||
self.on_gPodder_delete_event(widget)
|
||||
self.on_gPodder_delete_event(widget)
|
||||
|
||||
def cover_file_removed(self, channel_url):
|
||||
"""
|
||||
|
@ -2672,9 +2652,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
self.show_message(_('No new episodes. Please check for new episodes later.'))
|
||||
return
|
||||
|
||||
if self.tray_icon:
|
||||
self.tray_icon.set_status()
|
||||
|
||||
if self.feed_cache_update_cancelled:
|
||||
# The user decided to abort the feed update
|
||||
self.show_update_feeds_buttons()
|
||||
|
@ -2742,8 +2719,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
d = {'podcast': channel.title, 'position': updated+1, 'total': total}
|
||||
progression = _('Updated %(podcast)s (%(position)d/%(total)d)') % d
|
||||
self.pbFeedUpdate.set_text(progression)
|
||||
if self.tray_icon:
|
||||
self.tray_icon.set_status(self.tray_icon.STATUS_UPDATING_FEED_CACHE, progression)
|
||||
self.pbFeedUpdate.set_fraction(float(updated+1)/float(total))
|
||||
util.idle_add(update_progress)
|
||||
|
||||
|
@ -2799,9 +2774,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
self.itemUpdate.set_sensitive(False)
|
||||
self.itemUpdateChannel.set_sensitive(False)
|
||||
|
||||
if self.tray_icon:
|
||||
self.tray_icon.set_status(self.tray_icon.STATUS_UPDATING_FEED_CACHE)
|
||||
|
||||
self.feed_cache_update_cancelled = False
|
||||
self.btnCancelFeedUpdate.show()
|
||||
self.btnCancelFeedUpdate.set_sensitive(True)
|
||||
|
@ -2856,9 +2828,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
"""
|
||||
self.gPodder.hide()
|
||||
|
||||
if self.tray_icon is not None:
|
||||
self.tray_icon.set_visible(False)
|
||||
|
||||
# Notify all tasks to to carry out any clean-up actions
|
||||
self.download_status_model.tell_all_tasks_to_quit()
|
||||
|
||||
|
@ -3196,17 +3165,6 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
"""This will be called after the sync process is finished"""
|
||||
self.db.commit()
|
||||
|
||||
def show_hide_tray_icon(self):
|
||||
if self.config.display_tray_icon and have_trayicon and self.tray_icon is None:
|
||||
self.tray_icon = GPodderStatusIcon(self, gpodder.icon_file, self.config)
|
||||
elif not self.config.display_tray_icon and self.tray_icon is not None:
|
||||
self.tray_icon.set_visible(False)
|
||||
del self.tray_icon
|
||||
self.tray_icon = None
|
||||
|
||||
if self.tray_icon:
|
||||
self.tray_icon.set_visible(True)
|
||||
|
||||
def on_itemShowAllEpisodes_activate(self, widget):
|
||||
self.config.podcast_list_view_all = widget.get_active()
|
||||
|
||||
|
@ -3249,9 +3207,8 @@ class gPodder(BuilderWidget, dbus.service.Object):
|
|||
if self.config.podcast_list_hide_boring and not gpodder.ui.fremantle:
|
||||
self.podcast_list_model.set_view_mode(self.config.episode_list_view_mode)
|
||||
|
||||
def properties_closed( self):
|
||||
def properties_closed(self):
|
||||
self.preferences_dialog = None
|
||||
self.show_hide_tray_icon()
|
||||
|
||||
def on_itemPreferences_activate(self, widget, *args):
|
||||
self.preferences_dialog = gPodderPreferences(self.main_window, \
|
||||
|
|
Loading…
Reference in a new issue