support for custom episode list colors
git-svn-id: svn://svn.berlios.de/gpodder/trunk@244 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
0bdebc95df
commit
3f66dfcf63
|
@ -1,3 +1,11 @@
|
|||
Sun, 28 Jan 2007 10:20:26 +0100 <thp@perli.net>
|
||||
* src/gpodder/libipodsync.py: Fixed a small encoding warning
|
||||
* data/gpodder.glade: Added color chooser tab in preferences
|
||||
* src/gpodder/libgpodder.py: Added support for loading/saving
|
||||
episode list color values + default values
|
||||
* src/gpodder/libpodcasts.py: Added support for color config
|
||||
* src/gpodder/gpodder.py: Added support for episode list colors
|
||||
|
||||
Sun, 28 Jan 2007 09:21:47 +0100 <thp@perli.net>
|
||||
* src/gpodder/libipodsync.py: Added mediatype flag for iPod nano
|
||||
as suggested by José Luis Fustel (dr_psy terra.es) - thanks!
|
||||
|
|
|
@ -2150,6 +2150,245 @@
|
|||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table6">
|
||||
<property name="border_width">10</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">6</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="row_spacing">5</property>
|
||||
<property name="column_spacing">5</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label57">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Download in progress:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorDownloading">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="title" translatable="yes">Color for podcasts currently being downloaded</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">1</property>
|
||||
<property name="bottom_attach">2</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label56">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Default color:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorDefault">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="title" translatable="yes">Default color for episodes list</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">0</property>
|
||||
<property name="bottom_attach">1</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label59">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Downloaded episodes:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label58">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Deleted episodes:</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">0</property>
|
||||
<property name="right_attach">1</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorDownloaded">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="title" translatable="yes">Color for downloaded podcasts</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">2</property>
|
||||
<property name="bottom_attach">3</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkColorButton" id="colorDeleted">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_alpha">False</property>
|
||||
<property name="title" translatable="yes">Color for already downloaded but deleted podcasts</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="btnRevertToDefault">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label" translatable="yes">Revert to default colors</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_btnRevertToDefault_clicked" last_modification_time="Sun, 28 Jan 2007 09:12:05 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">5</property>
|
||||
<property name="bottom_attach">6</property>
|
||||
<property name="x_options">fill</property>
|
||||
<property name="y_options"></property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="tab_expand">False</property>
|
||||
<property name="tab_fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkLabel" id="label55">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Colors</property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">False</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">False</property>
|
||||
<property name="selectable">False</property>
|
||||
<property name="xalign">0.5</property>
|
||||
<property name="yalign">0.5</property>
|
||||
<property name="xpad">0</property>
|
||||
<property name="ypad">0</property>
|
||||
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||
<property name="width_chars">-1</property>
|
||||
<property name="single_line_mode">False</property>
|
||||
<property name="angle">0</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="type">tab</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="table5">
|
||||
<property name="border_width">10</property>
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
import os
|
||||
import gtk
|
||||
import gtk.gdk
|
||||
import gobject
|
||||
import pango
|
||||
import sys
|
||||
|
@ -539,6 +540,7 @@ class Gpodder(SimpleGladeApp):
|
|||
def on_itemPreferences_activate(self, widget, *args):
|
||||
prop = Gpodderproperties()
|
||||
prop.set_uar( self.user_apps_reader)
|
||||
prop.set_callback_finished( self.updateTreeView)
|
||||
#-- Gpodder.on_itemPreferences_activate }
|
||||
|
||||
#-- Gpodder.on_itemAddChannel_activate {
|
||||
|
@ -930,6 +932,7 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
|
||||
#-- Gpodderproperties.new {
|
||||
def new(self):
|
||||
self.callback_finished = None
|
||||
gl = gPodderLib()
|
||||
self.httpProxy.set_text( gl.http_proxy)
|
||||
self.ftpProxy.set_text( gl.ftp_proxy)
|
||||
|
@ -941,6 +944,8 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
if gl.downloaddir:
|
||||
self.chooserDownloadTo.set_filename( gl.downloaddir)
|
||||
self.updateonstartup.set_active(gl.update_on_startup)
|
||||
# colors
|
||||
self.reload_colors()
|
||||
# device type
|
||||
self.comboboxDeviceType.set_active( 0)
|
||||
if gl.device_type == 'ipod':
|
||||
|
@ -963,6 +968,22 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
#-- Gpodderproperties.new }
|
||||
|
||||
#-- Gpodderproperties custom methods {
|
||||
def on_btnRevertToDefault_clicked( self, widget, *args):
|
||||
gl = gPodderLib()
|
||||
gl.set_default_colors()
|
||||
self.reload_colors()
|
||||
|
||||
def reload_colors( self):
|
||||
gl = gPodderLib()
|
||||
try:
|
||||
self.colorDefault.set_color( gtk.gdk.color_parse( gl.colors['default']))
|
||||
self.colorDownloading.set_color( gtk.gdk.color_parse( gl.colors['downloading']))
|
||||
self.colorDownloaded.set_color( gtk.gdk.color_parse( gl.colors['downloaded']))
|
||||
self.colorDeleted.set_color( gtk.gdk.color_parse( gl.colors['deleted']))
|
||||
except:
|
||||
log( '(gPodderProperties) Could not parse color strings.')
|
||||
|
||||
|
||||
def update_mountpoint( self, ipod):
|
||||
if ipod == None or ipod.mount_point == None:
|
||||
self.iPodMountpoint.set_label( '')
|
||||
|
@ -974,6 +995,9 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
# try to activate an item
|
||||
index = self.find_active()
|
||||
self.comboPlayerApp.set_active( index)
|
||||
|
||||
def set_callback_finished( self, cb):
|
||||
self.callback_finished = cb
|
||||
# end set_uar
|
||||
|
||||
def find_active( self):
|
||||
|
@ -1087,6 +1111,13 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
gl.ipod_mount = self.iPodMountpoint.get_label()
|
||||
gl.mp3_player_folder = self.filesystemMountpoint.get_label()
|
||||
gl.opml_url = self.opmlURL.get_text()
|
||||
try:
|
||||
gl.set_color( 'default', self.colorDefault.get_color())
|
||||
gl.set_color( 'downloading', self.colorDownloading.get_color())
|
||||
gl.set_color( 'downloaded', self.colorDownloaded.get_color())
|
||||
gl.set_color( 'deleted', self.colorDeleted.get_color())
|
||||
except:
|
||||
log('(gPodderProperties) Could not parse and save color values.')
|
||||
|
||||
if gl.downloaddir != self.chooserDownloadTo.get_filename():
|
||||
new_download_dir = self.chooserDownloadTo.get_filename()
|
||||
|
@ -1150,6 +1181,8 @@ class Gpodderproperties(SimpleGladeApp):
|
|||
else:
|
||||
gl.removeDesktopSymlink()
|
||||
self.gPodderProperties.destroy()
|
||||
if self.callback_finished:
|
||||
self.callback_finished()
|
||||
#-- Gpodderproperties.on_btnOK_clicked }
|
||||
|
||||
#-- Gpodderproperties.on_btnCancel_clicked {
|
||||
|
|
|
@ -75,6 +75,15 @@ from ConfigParser import ConfigParser
|
|||
|
||||
from xml.sax import saxutils
|
||||
|
||||
|
||||
# default colors for episodes list
|
||||
default_colors = {
|
||||
'default': '#FFFFFF',
|
||||
'downloading': '#FFBC99',
|
||||
'downloaded': '#99FF99',
|
||||
'deleted': '#DDFFCC',
|
||||
}
|
||||
|
||||
# global recursive lock for thread exclusion
|
||||
globalLock = threading.RLock()
|
||||
|
||||
|
@ -101,6 +110,8 @@ class gPodderLibClass( object):
|
|||
gpodderconf_section = 'gpodder-conf-1'
|
||||
|
||||
def __init__( self):
|
||||
global default_colors
|
||||
|
||||
self.gpodderdir = expanduser( "~/.config/gpodder/")
|
||||
self.createIfNecessary( self.gpodderdir)
|
||||
self.__download_dir = None
|
||||
|
@ -122,6 +133,9 @@ class gPodderLibClass( object):
|
|||
self.desktop_link = _("gPodder downloads")
|
||||
self.device_type = None
|
||||
self.mp3_player_folder = ""
|
||||
self.colors = {}
|
||||
for key in default_colors.keys():
|
||||
self.colors[key] = default_colors[key]
|
||||
self.__download_history = DownloadHistory( self.get_download_history_filename())
|
||||
self.loadConfig()
|
||||
|
||||
|
@ -154,6 +168,15 @@ class gPodderLibClass( object):
|
|||
# save settings for next startup
|
||||
self.saveConfig()
|
||||
|
||||
def set_color( self, key, value):
|
||||
# calculate hex value from gtk.gdk.Color object
|
||||
self.colors[key] = '#%02x%02x%02x' % ( value.red*256/65536, value.green*256/65536, value.blue*256/65536, )
|
||||
|
||||
def set_default_colors( self):
|
||||
global default_colors
|
||||
for key in default_colors.keys():
|
||||
self.colors[key] = default_colors[key]
|
||||
|
||||
def clean_up_downloads( self):
|
||||
# Clean up temporary files left behind by old gPodder versions
|
||||
temporary_files = glob( '%s/*/.tmp-*' % ( self.downloaddir, ))
|
||||
|
@ -185,6 +208,8 @@ class gPodderLibClass( object):
|
|||
self.write_to_parser( parser, 'download_dir', self.downloaddir)
|
||||
self.write_to_parser( parser, 'device_type', self.device_type)
|
||||
self.write_to_parser( parser, 'mp3_player_folder', self.mp3_player_folder)
|
||||
for color in self.colors.keys():
|
||||
self.write_to_parser( parser, 'color_' + color, self.colors[color])
|
||||
fn = self.getConfigFilename()
|
||||
fp = open( fn, "w")
|
||||
parser.write( fp)
|
||||
|
@ -254,6 +279,8 @@ class gPodderLibClass( object):
|
|||
log( 'write_to_parser: could not write config (option=%s, value=%s)', option, value)
|
||||
|
||||
def loadConfig( self):
|
||||
global default_colors
|
||||
|
||||
was_oldstyle = False
|
||||
try:
|
||||
fn = self.getConfigFilename()
|
||||
|
@ -279,6 +306,8 @@ class gPodderLibClass( object):
|
|||
self.downloaddir = self.get_from_parser( parser, 'download_dir', expanduser('~/gpodder-downloads'))
|
||||
self.device_type = self.get_from_parser( parser, 'device_type', 'none')
|
||||
self.mp3_player_folder = self.get_from_parser( parser, 'mp3_player_folder', '/media/usbdisk')
|
||||
for color in self.colors.keys():
|
||||
self.colors[color] = self.get_from_parser( parser, 'color_'+color, default_colors[color])
|
||||
else:
|
||||
log( 'config file %s has no section %s', fn, gpodderconf_section)
|
||||
if not self.proxy_use_environment:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# gPodder (a media aggregator / podcast client)
|
||||
|
|
|
@ -204,16 +204,17 @@ class podcastChannel(ListType):
|
|||
being downloaded and False otherwise.
|
||||
"""
|
||||
new_model = gtk.ListStore( gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING)
|
||||
gl = libgpodder.gPodderLib()
|
||||
|
||||
for item in self.get_all_episodes():
|
||||
if self.is_downloaded( item) and want_color:
|
||||
background_color = '#99FF99'
|
||||
background_color = gl.colors['downloaded']
|
||||
elif downloading_callback and downloading_callback( item.url) and want_color:
|
||||
background_color = '#FFBC99'
|
||||
background_color = gl.colors['downloading']
|
||||
elif libgpodder.gPodderLib().history_is_downloaded( item.url) and want_color:
|
||||
background_color = '#DDFFCC'
|
||||
background_color = gl.colors['deleted']
|
||||
else:
|
||||
background_color = '#FFFFFF'
|
||||
background_color = gl.colors['default']
|
||||
new_iter = new_model.append()
|
||||
new_model.set( new_iter, 0, item.url)
|
||||
new_model.set( new_iter, 1, item.title)
|
||||
|
|
Loading…
Reference in New Issue