ontv r472 - in trunk: bin ontv



Author: johans
Date: Fri Nov  7 16:49:37 2008
New Revision: 472
URL: http://svn.gnome.org/viewvc/ontv?rev=472&view=rev

Log:


Added:
   trunk/ontv/main.py
Modified:
   trunk/bin/Makefile.am
   trunk/bin/ontv.in

Modified: trunk/bin/Makefile.am
==============================================================================
--- trunk/bin/Makefile.am	(original)
+++ trunk/bin/Makefile.am	Fri Nov  7 16:49:37 2008
@@ -4,6 +4,7 @@
 
 $(libexec_SCRIPTS): $(ontv_in_file)
 	sed -e "s|\ PYTHONDIR\@|$(pythondir)|" < $< > $@
+	chmod a+x $(libexec_SCRIPTS)
 
 DISTCLEANFILES = $(libexec_SCRIPTS)
 EXTRA_DIST = $(ontv_in_file)

Modified: trunk/bin/ontv.in
==============================================================================
--- trunk/bin/ontv.in	(original)
+++ trunk/bin/ontv.in	Fri Nov  7 16:49:37 2008
@@ -20,11 +20,20 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import sys
+import os.path
 
 PYTHON_DIR = "@PYTHONDIR@"
 
-if PYTHON_DIR not in sys.path:
-    sys.path.insert(0, PYTHON_DIR)
+# Try to determine if we run from source or install and fix path accordingly
+def _check(path):
+    return os.path.exists(path) and os.path.isdir(path) and \
+           os.path.isfile(path + "/AUTHORS")
+
+name = os.path.join(os.path.dirname(__file__), "..")
+if _check(name):
+    sys.path.insert(0, os.path.abspath(name))
+elif PYTHON_DIR not in sys.path:
+    sys.path.insert(0, os.path.abspath(PYTHON_DIR))
 
 from ontv import main
 

Added: trunk/ontv/main.py
==============================================================================
--- (empty file)
+++ trunk/ontv/main.py	Fri Nov  7 16:49:37 2008
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2004-2008 Johan Svedberg <johan svedberg com>
+
+# This file is part of OnTV.
+
+# OnTV 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 2 of the License, or
+# (at your option) any later version.
+
+# OnTV 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 OnTV; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+import getopt
+import gettext
+import locale
+import sys
+from gettext import gettext as _
+
+import pygtk
+pygtk.require("2.0")
+import gtk
+import gnome
+import gnomeapplet
+
+import gui
+from applet import OnTVApplet
+from ontv import NAME, VERSION, LOCALE_DIR
+
+def main():
+    gettext.bindtextdomain(NAME.lower(), LOCALE_DIR)
+    gettext.textdomain(NAME.lower())
+
+    locale.bindtextdomain(NAME.lower(), LOCALE_DIR)
+    locale.textdomain(NAME.lower())
+
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], "cdhw", ["configure", "debug",
+                                                          "help", "window"])
+    except getopt.GetoptError:
+        opts = []
+        args = sys.argv[1:]
+
+    configure = debug = standalone = False
+    for o, a in opts:
+        if o in ("-c", "--configure"):
+            configure = True
+        elif o in ("-d", "--debug"):
+            debug = True
+        elif o in ("-h", "--help"):
+            print_usage()
+        elif o in ("-w", "--window"):
+            standalone = True
+
+    gnome.init(NAME, VERSION)
+    gtk.gdk.threads_init()
+    gtk.window_set_default_icon_list(*gui.get_icon_list([16,22,24,32,48]))
+
+    if standalone:
+        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
+        window.set_title(NAME)
+        window.props.allow_grow = False
+        gtk.window_set_default_icon_list(*gui.get_icon_list([16, 22, 24, 32,
+                                                             48]))
+        window.connect("destroy", gtk.main_quit)
+        applet = gnomeapplet.Applet()
+        applet_factory(applet, None, configure, debug, True)
+        applet.reparent(window)
+        window.show_all()
+        gtk.main()
+    else:
+        activate_factory(debug)
+
+def print_usage():
+    print _("Usage: %s [OPTIONS]...") % (sys.argv[0])
+    print ""
+    print _("OPTIONS:")
+    print "  -c, --configure	%s" % (_("run XMLTV assistant on startup"))
+    print "  -d, --debug		%s" % (_("enable debug messages"))
+    print "  -h, --help		%s" % (_("show this help message and exit"))
+    print "  -w, --window		%s" % (_("run OnTV in a standalone window (for testing purposes)"))
+
+    sys.exit()
+
+def applet_factory(applet, iid=None, configure=False, debug=False,
+                   standalone=False):
+    ontvapplet = OnTVApplet(applet, configure, debug, standalone)
+    ontvapplet.run()
+    return True
+
+def activate_factory(configure=False, debug=False):
+    gnomeapplet.bonobo_factory("OAFIID:GNOME_OnTVApplet_Factory",
+                               gnomeapplet.Applet.__gtype__, NAME, VERSION,
+                               applet_factory, (configure, debug,))
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]