Added properties dialog, config file support for gPodderLib, http and ftp proxy support!
git-svn-id: svn://svn.berlios.de/gpodder@25 b0d088ad-0a06-0410-aad2-9ed5178a7e87
This commit is contained in:
parent
1da6e986ad
commit
27b36c4605
|
@ -1,3 +1,7 @@
|
|||
Mon, 09 Jan 2006 00:13:10 +0100 <thp@perli.net>
|
||||
+ Added gPodder Properties dialog with http/ftp proxy settings
|
||||
+ Added very basic config file support to gPodderLib, for proxy
|
||||
|
||||
Son Dez 25 10:07:19 CET 2005 <thp@perli.net>
|
||||
* Fixed "add channel" dialog "OK" button handling (works again)
|
||||
|
||||
|
|
9
TODO
9
TODO
|
@ -7,9 +7,8 @@
|
|||
* generate a Debian package (for Debian Sarge & Ubuntu Breezy)
|
||||
|
||||
* add downloaded feeds tab
|
||||
* implement properties dialog
|
||||
* properties: set http proxy or use gnome's proxy setting
|
||||
(suggested by alabrosse.ext@rd.francetelecom.fr)
|
||||
|
||||
|
||||
|
||||
== 0.6 / non-release-cricital ==
|
||||
|
||||
|
@ -19,6 +18,10 @@
|
|||
* check if threads deleted from download status
|
||||
list make the gui freeze and why and FIX ;)
|
||||
|
||||
* (properties: set http proxy) --> done
|
||||
---> or use gnome's proxy setting <---
|
||||
(suggested by alabrosse.ext@rd.francetelecom.fr)
|
||||
|
||||
* sort view
|
||||
* improve error handler
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
# PLEASE DO NOT CHANGE FORMAT OF __version__ LINE (Makefile reads this)
|
||||
|
||||
__author__ = "Thomas Perl <thp@perli.net>"
|
||||
__version__ = "0.5-svn"
|
||||
__date__ = "2005-12-08"
|
||||
__copyright__ = "Copyright (c) 2005 %s. All rights reserved." %__author__
|
||||
__version__ = "0.5-svn_pro"
|
||||
__date__ = "2006-01-09"
|
||||
__copyright__ = "Copyright (c) 2005-2006 %s. All rights reserved." % __author__
|
||||
__licence__ = "GPL"
|
||||
|
||||
import sys,os
|
||||
|
|
|
@ -1109,4 +1109,213 @@ For now, have a look into <b>~/.config/gpodder/downloads</b>.</prope
|
|||
</child>
|
||||
</widget>
|
||||
|
||||
<widget class="GtkWindow" id="gPodderProperties">
|
||||
<property name="visible">True</property>
|
||||
<property name="title" translatable="yes">gPodder Properties</property>
|
||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="modal">False</property>
|
||||
<property name="resizable">True</property>
|
||||
<property name="destroy_with_parent">False</property>
|
||||
<property name="decorated">True</property>
|
||||
<property name="skip_taskbar_hint">False</property>
|
||||
<property name="skip_pager_hint">False</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<signal name="destroy" handler="on_gPodderProperties_destroy" last_modification_time="Sun, 08 Jan 2006 22:49:35 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="vBoxMain">
|
||||
<property name="border_width">10</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">10</property>
|
||||
|
||||
<child>
|
||||
<widget class="GtkTable" id="propertiesTable">
|
||||
<property name="visible">True</property>
|
||||
<property name="n_rows">3</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="label13">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">HTTP Proxy:</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>
|
||||
</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="GtkLabel" id="label14">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">FTP Proxy:</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>
|
||||
</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="GtkEntry" id="httpProxy">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</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="GtkEntry" id="ftpProxy">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="editable">True</property>
|
||||
<property name="visibility">True</property>
|
||||
<property name="max_length">0</property>
|
||||
<property name="text" translatable="yes"></property>
|
||||
<property name="has_frame">True</property>
|
||||
<property name="invisible_char">*</property>
|
||||
<property name="activates_default">False</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="label15">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">If you want to use a HTTP or FTP Proxy Server,
|
||||
you can use the usual format of the environment variables:
|
||||
|
||||
<b>http://username:password@proxy_host:proxy_port/</b></property>
|
||||
<property name="use_underline">False</property>
|
||||
<property name="use_markup">True</property>
|
||||
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||
<property name="wrap">True</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>
|
||||
</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>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkHBox" id="hBoxButtomButtons">
|
||||
<property name="visible">True</property>
|
||||
<property name="homogeneous">False</property>
|
||||
<property name="spacing">5</property>
|
||||
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="btnOK">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-ok</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_btnOK_clicked" last_modification_time="Sun, 08 Jan 2006 22:51:12 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkButton" id="btnCancel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="label">gtk-cancel</property>
|
||||
<property name="use_stock">True</property>
|
||||
<property name="relief">GTK_RELIEF_NORMAL</property>
|
||||
<property name="focus_on_click">True</property>
|
||||
<signal name="clicked" handler="on_btnCancel_clicked" last_modification_time="Sun, 08 Jan 2006 22:51:55 GMT"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="padding">0</property>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
||||
</glade-interface>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Python module src/gpodder/gpodder.py
|
||||
# Autogenerated from gpodder.glade
|
||||
# Generated on Thu Dec 8 20:37:43 2005
|
||||
# Generated on Mon Jan 9 00:51:18 2006
|
||||
|
||||
# Warning: Do not modify any context comment such as #--
|
||||
# They are required to keep user's code
|
||||
|
@ -44,8 +44,8 @@ import libgpodder
|
|||
app_name = "gpodder"
|
||||
app_version = "unknown" # will be set in main() call
|
||||
app_authors = [ "Thomas Perl <thp@perli.net>", "Peter Hoffmann <tosh@cs.tu-berlin.de>" ]
|
||||
app_copyright = "Copyright (c) 2005 Thomas Perl"
|
||||
app_website = "http://www.perli.net/projekte/gpodder/"
|
||||
app_copyright = "Copyright (c) 2005-2006 Thomas Perl"
|
||||
app_website = "http://perli.net/projekte/gpodder/"
|
||||
|
||||
#glade_dir = "../data"
|
||||
glade_dir = "/usr/share/gpodder/"
|
||||
|
@ -250,7 +250,8 @@ class Gpodder(SimpleGladeApp):
|
|||
def on_itemPreferences_activate(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_itemPreferences_activate called with self.%s" % widget.get_name()
|
||||
self.not_implemented( "the preferences dialog")
|
||||
#self.not_implemented( "the preferences dialog")
|
||||
Gpodderproperties()
|
||||
#-- Gpodder.on_itemPreferences_activate }
|
||||
|
||||
#-- Gpodder.on_itemAddChannel_activate {
|
||||
|
@ -559,16 +560,62 @@ class Gpodderchannel(SimpleGladeApp):
|
|||
#-- Gpodderchannel.on_btnCancel_clicked }
|
||||
|
||||
|
||||
class Gpodderproperties(SimpleGladeApp):
|
||||
def __init__(self, path="gpodder.glade",
|
||||
root="gPodderProperties",
|
||||
domain=app_name, **kwargs):
|
||||
path = os.path.join(glade_dir, path)
|
||||
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
||||
|
||||
#-- Gpodderproperties.new {
|
||||
def new(self):
|
||||
if libgpodder.isDebugging():
|
||||
print "A new %s has been created" % self.__class__.__name__
|
||||
gl = gPodderLib()
|
||||
self.httpProxy.set_text( gl.http_proxy)
|
||||
self.ftpProxy.set_text( gl.ftp_proxy)
|
||||
#-- Gpodderproperties.new }
|
||||
|
||||
#-- Gpodderproperties custom methods {
|
||||
# Write your own methods here
|
||||
#-- Gpodderproperties custom methods }
|
||||
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy {
|
||||
def on_gPodderProperties_destroy(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_gPodderProperties_destroy called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy }
|
||||
|
||||
#-- Gpodderproperties.on_btnOK_clicked {
|
||||
def on_btnOK_clicked(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_btnOK_clicked called with self.%s" % widget.get_name()
|
||||
gl = gPodderLib()
|
||||
gl.http_proxy = self.httpProxy.get_text()
|
||||
gl.ftp_proxy = self.ftpProxy.get_text()
|
||||
gl.propertiesChanged()
|
||||
self.gPodderProperties.destroy()
|
||||
#-- Gpodderproperties.on_btnOK_clicked }
|
||||
|
||||
#-- Gpodderproperties.on_btnCancel_clicked {
|
||||
def on_btnCancel_clicked(self, widget, *args):
|
||||
if libgpodder.isDebugging():
|
||||
print "on_btnCancel_clicked called with self.%s" % widget.get_name()
|
||||
self.gPodderProperties.destroy()
|
||||
#-- Gpodderproperties.on_btnCancel_clicked }
|
||||
|
||||
|
||||
#-- main {
|
||||
|
||||
def main( __version__ = None):
|
||||
global app_version
|
||||
|
||||
|
||||
gtk.gdk.threads_init()
|
||||
app_version = __version__
|
||||
g_podder = Gpodder()
|
||||
#g_podder_status = Gpodderstatus()
|
||||
#g_podder_channel = Gpodderchannel()
|
||||
#g_podder_properties = Gpodderproperties()
|
||||
|
||||
g_podder.set_icon()
|
||||
g_podder.run()
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
# Python module src/gpodder/gpodder.py
|
||||
# Autogenerated from gpodder.glade
|
||||
# Generated on Thu Dec 8 20:37:43 2005
|
||||
# Generated on Mon Jan 9 00:51:18 2006
|
||||
|
||||
# Warning: Do not modify any context comment such as #--
|
||||
# They are required to keep user's code
|
||||
|
@ -168,12 +168,46 @@ class Gpodderchannel(SimpleGladeApp):
|
|||
#-- Gpodderchannel.on_btnCancel_clicked }
|
||||
|
||||
|
||||
class Gpodderproperties(SimpleGladeApp):
|
||||
|
||||
def __init__(self, path="gpodder.glade",
|
||||
root="gPodderProperties",
|
||||
domain=app_name, **kwargs):
|
||||
path = os.path.join(glade_dir, path)
|
||||
SimpleGladeApp.__init__(self, path, root, domain, **kwargs)
|
||||
|
||||
#-- Gpodderproperties.new {
|
||||
def new(self):
|
||||
print "A new %s has been created" % self.__class__.__name__
|
||||
#-- Gpodderproperties.new }
|
||||
|
||||
#-- Gpodderproperties custom methods {
|
||||
# Write your own methods here
|
||||
#-- Gpodderproperties custom methods }
|
||||
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy {
|
||||
def on_gPodderProperties_destroy(self, widget, *args):
|
||||
print "on_gPodderProperties_destroy called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_gPodderProperties_destroy }
|
||||
|
||||
#-- Gpodderproperties.on_btnOK_clicked {
|
||||
def on_btnOK_clicked(self, widget, *args):
|
||||
print "on_btnOK_clicked called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_btnOK_clicked }
|
||||
|
||||
#-- Gpodderproperties.on_btnCancel_clicked {
|
||||
def on_btnCancel_clicked(self, widget, *args):
|
||||
print "on_btnCancel_clicked called with self.%s" % widget.get_name()
|
||||
#-- Gpodderproperties.on_btnCancel_clicked }
|
||||
|
||||
|
||||
#-- main {
|
||||
|
||||
def main():
|
||||
g_podder = Gpodder()
|
||||
g_podder_status = Gpodderstatus()
|
||||
g_podder_channel = Gpodderchannel()
|
||||
g_podder_properties = Gpodderproperties()
|
||||
|
||||
g_podder.run()
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ from os.path import basename
|
|||
from os.path import exists
|
||||
from os.path import dirname
|
||||
from os import mkdir
|
||||
from os import environ
|
||||
from threading import Event
|
||||
|
||||
from libpodcasts import configChannel
|
||||
|
@ -37,6 +38,8 @@ class gPodderLib( object):
|
|||
gpodderdir = ""
|
||||
downloaddir = ""
|
||||
cachedir = ""
|
||||
http_proxy = ""
|
||||
ftp_proxy = ""
|
||||
|
||||
def __init__( self):
|
||||
self.gpodderdir = expanduser( "~/.config/gpodder/")
|
||||
|
@ -45,6 +48,15 @@ class gPodderLib( object):
|
|||
self.createIfNecessary( self.downloaddir)
|
||||
self.cachedir = self.gpodderdir + "cache/"
|
||||
self.createIfNecessary( self.cachedir)
|
||||
try:
|
||||
self.http_proxy = environ['http_proxy']
|
||||
except:
|
||||
self.http_proxy = ''
|
||||
try:
|
||||
self.ftp_proxy = environ['ftp_proxy']
|
||||
except:
|
||||
self.ftp_proxy = ''
|
||||
self.loadConfig()
|
||||
|
||||
def createIfNecessary( self, path):
|
||||
#TODO: recursive mkdir all parent directories
|
||||
|
@ -59,7 +71,7 @@ class gPodderLib( object):
|
|||
mkdir( path)
|
||||
|
||||
def getConfigFilename( self):
|
||||
return self.gpodderdir + "gpodder.conf.xml"
|
||||
return self.gpodderdir + "gpodder.conf"
|
||||
|
||||
def getChannelsFilename( self):
|
||||
return self.gpodderdir + "channels.xml"
|
||||
|
@ -69,6 +81,34 @@ class gPodderLib( object):
|
|||
self.createIfNecessary( savedir)
|
||||
|
||||
return savedir
|
||||
|
||||
def propertiesChanged( self):
|
||||
# set new environment variables for subprocesses to use
|
||||
environ['http_proxy'] = self.http_proxy
|
||||
environ['ftp_proxy'] = self.ftp_proxy
|
||||
# save settings for next startup
|
||||
self.saveConfig()
|
||||
|
||||
def saveConfig( self):
|
||||
fn = self.getConfigFilename()
|
||||
fp = open( fn, "w")
|
||||
fp.write( self.http_proxy + "\n")
|
||||
fp.write( self.ftp_proxy + "\n")
|
||||
fp.close()
|
||||
|
||||
def loadConfig( self):
|
||||
try:
|
||||
fn = self.getConfigFilename()
|
||||
fp = open( fn, "r")
|
||||
http = fp.readline()
|
||||
ftp = fp.readline()
|
||||
if http != "" and ftp != "":
|
||||
self.http_proxy = strip( http)
|
||||
self.ftp_proxy = strip( ftp)
|
||||
fp.close()
|
||||
except:
|
||||
# TODO: well, well..
|
||||
None
|
||||
|
||||
def getChannelCacheFile( self, filename):
|
||||
return self.cachedir + filename + ".xml"
|
||||
|
|
|
@ -77,6 +77,9 @@ class downloadThread( object):
|
|||
|
||||
while process.poll() == -1:
|
||||
msg = stderr.readline( 80)
|
||||
# the next two lines might fix some lockup problems
|
||||
if msg == "":
|
||||
break
|
||||
if libgpodder.isDebugging():
|
||||
print msg
|
||||
msg = msg.strip()
|
||||
|
|
Loading…
Reference in New Issue