[ontv] New status icon frontend
- From: Olof Kindgren <olki src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ontv] New status icon frontend
- Date: Tue, 20 Apr 2010 19:15:16 +0000 (UTC)
commit 3491f501207d66104329805a99bc141a26d07c10
Author: Olof Kindgren <olki src gnome org>
Date: Sat Apr 17 20:44:40 2010 +0200
New status icon frontend
The preferred way of launching OnTV is now via a status icon.
This will (hopefully) work on any platform that implements the
notification area. The panel applet is still available.
.gitignore | 7 +++
bin/Makefile.am | 10 +++-
bin/ontv.in | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++
data/Makefile.am | 2 +-
data/status_icon.ui | 50 +++++++++++++++++++++++
5 files changed, 177 insertions(+), 4 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 4baab3d..f1655f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,8 @@ aclocal.m4
autom4te.cache
bin/Makefile
bin/Makefile.in
+bin/ontv
+bin/ontv-applet
config.guess
config.h
config.h.in
@@ -12,6 +14,11 @@ config.log
config.status
config.sub
configure
+data/90-ontv.xml
+data/GNOME_OnTVApplet.server
+data/GNOME_OnTVApplet.server.in
+data/ontv.schemas
+data/ontv.schemas.in
Makefile
Makefile.in
images/Makefile
diff --git a/bin/Makefile.am b/bin/Makefile.am
index 888ce24..83c1006 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -1,11 +1,15 @@
libexec_SCRIPTS = ontv-applet
-bin_SCRIPTS = ontv-dbus
+bin_SCRIPTS = ontv ontv-dbus
-ontv_in_file = ontv-applet.in
+ontv_applet_in_file = ontv-applet.in
+ontv_in_file = ontv.in
-$(libexec_SCRIPTS): $(ontv_in_file)
+$(libexec_SCRIPTS): $(ontv_applet_in_file)
sed -e "s|\ PYTHONDIR\@|$(pythondir)|" < $< > $@
chmod a+x $(libexec_SCRIPTS)
+ontv: $(ontv_in_file)
+ sed -e "s|\ PYTHONDIR\@|$(pythondir)|" < $< > $@
+
DISTCLEANFILES = $(libexec_SCRIPTS)
EXTRA_DIST = $(ontv_in_file)
diff --git a/bin/ontv.in b/bin/ontv.in
new file mode 100644
index 0000000..f59c062
--- /dev/null
+++ b/bin/ontv.in
@@ -0,0 +1,112 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2010 Olof Kindgren <olki src gnome org>
+
+# 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 pygtk
+pygtk.require('2.0')
+import gtk
+
+import sys
+import os.path
+PYTHON_DIR = "@PYTHONDIR@"
+sys.path.insert(0, os.path.abspath(PYTHON_DIR))
+
+from gettext import gettext as _
+from ontv import DATA_DIR
+from ontv.ontv_core import OnTVCore
+import ontv.gui
+from optparse import OptionParser
+
+
+class OnTVStatusIcon:
+
+ def __init__(self, configure = False, debug = False):
+
+ self.ontv_core = OnTVCore(configure, debug, self.cb_status)
+
+ self.builder = gtk.Builder()
+ ui_file = os.path.join(DATA_DIR, "status_icon.ui")
+ self.builder.add_from_file(ui_file)
+ self.builder.connect_signals(self)
+
+ self.statusIcon = self.builder.get_object("status_icon")
+
+ #Why won't Glade do this?
+ menu = self.builder.get_object("popup_menu")
+ self.statusIcon.connect('popup-menu', self.popup_menu_cb, menu)
+
+ def update_listings(self, widget):
+ self.ontv_core.update_listings()
+
+ def show_preferences(self, widget):
+ self.ontv_core.show_preferences_dialog()
+
+ def show_about(self,widget):
+ self.ontv_core.show_about_dialog()
+
+ def show_program_window(self,widget):
+ self.ontv_core.set_program_window_position(self.get_docking_data())
+ self.ontv_core.toggle_program_window()
+
+ def get_docking_data(self):
+
+ #FIXME: Size not correct on first view
+ screen, pos, ori = self.statusIcon.get_geometry()
+ w,h = self.ontv_core.get_program_window_size()
+ if pos[0]+w < gtk.gdk.screen_width():
+ x = pos[0]
+ else:
+ x = gtk.gdk.screen_width()-w
+ y = pos[1] + pos[3]
+ return (x, y, gtk.gdk.GRAVITY_NORTH_EAST)
+
+ #FIXME: Move to left/up if menu doesn't fit
+
+ def quit_cb(self, widget, data = None):
+ gtk.main_quit()
+
+ def cb_status(self, msg):
+ if msg:
+ self.statusIcon.set_tooltip(msg)
+
+ def run(self):
+ gtk.gdk.threads_init()
+ self.ontv_core.run()
+ gtk.main()
+
+ def popup_menu_cb(self, widget, button, time, data = None):
+ if button == 3:
+ if data:
+ data.show_all()
+ data.popup(None, None, gtk.status_icon_position_menu,
+ 3, time, self.statusIcon)
+
+if __name__ == "__main__":
+ parser = OptionParser()
+ parser.add_option("-c", "--configure",
+ action="store_true",
+ help=_("run XMLTV assistant on startup"))
+ parser.add_option("-d", "--debug",
+ action="store_true",
+ help=_("enable debug messages"))
+
+ (options, args) = parser.parse_args()
+ ontv_status_icon = OnTVStatusIcon(options.configure, options.debug)
+ ontv_status_icon.run()
diff --git a/data/Makefile.am b/data/Makefile.am
index 0ab47ef..e6e86f7 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -19,7 +19,7 @@ $(server_in_files): $(server_in_files:.server.in=.server.in.in)
@INTLTOOL_SERVER_RULE@
gladedir = $(datadir)/ontv
-glade_DATA = dialogs.ui
+glade_DATA = dialogs.ui status_icon.ui
uidir = $(datadir)/gnome-2.0/ui
ui_DATA = GNOME_OnTVApplet.xml
diff --git a/data/status_icon.ui b/data/status_icon.ui
new file mode 100644
index 0000000..7549133
--- /dev/null
+++ b/data/status_icon.ui
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkStatusIcon" id="status_icon">
+ <property name="icon_name">ontv</property>
+ <property name="has_tooltip">True</property>
+ <signal name="popup_menu" handler="popup_menu_cb" object="popup_menu"/>
+ <signal name="activate" handler="show_program_window" after="yes"/>
+ </object>
+ <object class="GtkMenu" id="popup_menu">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkMenuItem" id="item_update">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Update TV Listings</property>
+ <signal name="activate" handler="update_listings"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkSeparatorMenuItem" id="item_sep">
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="item_preferences">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Preferences</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="show_preferences"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="item_about">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">About</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="show_about"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuItem" id="item_exit">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Exit</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="quit_cb"/>
+ </object>
+ </child>
+ </object>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]