All episodes: Sort by date, show podcast (bug 921)
[gpodder.git] / src / gpodder / launcher.py
blob84ff3fc75e7348aa45cf170915c470f08968252d
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
5 # gPodder - A media aggregator and podcast client
6 # Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
8 # gPodder is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
13 # gPodder is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 """Win32 Launcher script for gPodder
24 This is only used for the Win32 version of gPodder
25 and will set up the environment to find all files
26 and then start up the gPodder GUI.
28 Thomas Perl <thpinfo.com>; 2009-05-09
29 """
31 import sys
32 import os
33 import os.path
34 import platform
36 import gettext
38 if __name__ == '__main__':
39 prefix = os.path.abspath(os.path.normpath('.'))
40 data_dir = os.path.join(prefix, 'data')
42 locale_dir = os.path.join(data_dir, 'locale')
43 ui_folder = os.path.join(data_dir, 'ui')
44 credits_file = os.path.join(data_dir, 'credits.txt')
45 images_folder = os.path.join(data_dir, 'images')
46 icon_file = os.path.join(data_dir, 'gpodder.svg')
48 # Set up the path to translation files
49 gettext.bindtextdomain('gpodder', locale_dir)
51 import gpodder
53 if not gpodder.win32:
54 print >>sys.stderr, 'This launcher is only for Win32.'
55 sys.exit(1)
57 # Enable i18n for gPodder translations
58 _ = gpodder.gettext
60 # Set up paths to folder with GtkBuilder files and gpodder.svg
61 gpodder.ui_folders.append(ui_folder)
62 gpodder.ui_folders.append(os.path.join(ui_folder, 'desktop'))
63 gpodder.icon_file = icon_file
64 gpodder.credits_file = credits_file
65 gpodder.images_folder = images_folder
66 gpodder.ui.desktop = True
68 # Portable version support
69 if (os.path.exists('downloads') and os.path.exists('config')) or \
70 not os.path.exists(os.path.expanduser('~/.config/gpodder')):
71 home = os.path.join(os.getcwd(), 'config')
72 if not os.path.exists(home):
73 os.mkdir(home)
74 gpodder.home = home
75 gpodder.subscription_file = os.path.join(home, 'channels.opml')
76 gpodder.config_file = os.path.join(home, 'gpodder.conf')
77 gpodder.database_file = os.path.join(home, 'database.sqlite')
78 download_dir = os.path.join(os.getcwd(), 'downloads')
79 os.environ['GPODDER_DOWNLOAD_DIR'] = download_dir
81 from gpodder import gui
83 class options(object):
84 subscribe = None
86 gui.main(options)