[ontv] Move gtk specific code out from ontv_core.py
- From: Olof Kindgren <olki src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ontv] Move gtk specific code out from ontv_core.py
- Date: Fri, 14 Jan 2011 18:38:26 +0000 (UTC)
commit ca1424a268f1cbfe5bd9cb2ba0c75115bfdc0cd3
Author: Olof Kindgren <olki src gnome org>
Date: Fri Jan 14 19:33:59 2011 +0100
Move gtk specific code out from ontv_core.py
Now all gtk related things are moved out from ontv_core.py. This
is a step towards making OnTV eaiser to port to other graphical
toolkits
ontv/dialogs.py | 10 ++++++++++
ontv/ontv_core.py | 30 ++++++------------------------
ontv/window.py | 16 ++++++++++++++++
3 files changed, 32 insertions(+), 24 deletions(-)
---
diff --git a/ontv/dialogs.py b/ontv/dialogs.py
index 5173ea5..f423959 100644
--- a/ontv/dialogs.py
+++ b/ontv/dialogs.py
@@ -45,6 +45,16 @@ COL_PIXBUF = 1
COL_ISDIR = 2
COL_TITLE = 3
+class AboutDialog:
+ def __init__(self):
+ builder = gtk.Builder()
+ builder.add_from_file(gui.about_dialog_ui_file)
+ ad = builder.get_object("about_dialog")
+ ad.set_name(NAME)
+ ad.set_version(VERSION)
+ ad.connect("response", lambda d, r: d.destroy())
+ ad.show()
+
class ChannelDialog:
def __init__(self, channel, pd):
self.channel = channel
diff --git a/ontv/ontv_core.py b/ontv/ontv_core.py
index f6bcda7..9e48221 100644
--- a/ontv/ontv_core.py
+++ b/ontv/ontv_core.py
@@ -21,8 +21,6 @@
import os.path
from gettext import gettext as _
-import gtk
-
import dbus
import dbus.mainloop.glib
@@ -30,7 +28,7 @@ import gui
from assistant import XMLTVAssistant
from config import Configuration
from dbus_service import DBusService
-from dialogs import PreferencesDialog, SearchDialog
+from dialogs import AboutDialog, PreferencesDialog, SearchDialog
from reminders import Reminders
from window import ProgramWindow
from xmltv_file import XMLTVFile
@@ -69,13 +67,7 @@ class OnTVCore:
self.xmltvfile.download()
def show_about_dialog(self):
- builder = gtk.Builder()
- builder.add_from_file(gui.about_dialog_ui_file)
- ad = builder.get_object("about_dialog")
- ad.set_name(NAME)
- ad.set_version(VERSION)
- ad.connect("response", lambda d, r: d.destroy())
- ad.show()
+ AboutDialog()
def show_preferences_dialog(self):
self.pd.show()
@@ -84,21 +76,11 @@ class OnTVCore:
self.sd.show()
def toggle_program_window(self):
- visible = True
- if self.pw.props.visible:
- self.pw.hide()
- visible = False
+ visible = self.pw.is_visible()
+ if visible:
+ self.pw.hide_window()
else:
- self.pw.position_window(self.window_position)
- self.pw.stick()
- self.pw.show_all()
- self.pw.grab_focus()
-
- if not self.config.display_current_programs:
- self.pw.cpt.hide()
- if not self.config.display_upcoming_programs:
- self.pw.upt.hide()
-
+ self.pw.show_window(self.window_position)
return visible
def __get_running_instance(self):
diff --git a/ontv/window.py b/ontv/window.py
index 86ec42d..df2abc0 100644
--- a/ontv/window.py
+++ b/ontv/window.py
@@ -308,6 +308,9 @@ class ProgramWindow(gtk.Window):
self.config = Configuration()
+ def is_visible(self):
+ return self.props.visible
+
def __xmltvfile_loading_done(self, xmltvfile, listings):
if listings:
self.cpt.listings = listings
@@ -325,6 +328,19 @@ class ProgramWindow(gtk.Window):
(w, h) = self.size_request()
return (w, h)
+ def hide_window(self):
+ self.hide()
+
+ def show_window(self, window_position):
+ self.position_window(window_position)
+ self.stick()
+ self.show_all()
+ self.grab_focus()
+ if not self.config.display_current_programs:
+ self.cpt.hide()
+ if not self.config.display_upcoming_programs:
+ self.upt.hide()
+
def position_window(self, window_position):
(x, y, gravity) = window_position
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]