Ejemplo n.º 1
0
    def __init__(self, configure, debug, cb_status):

        self.configure = configure
        self.debug = debug
        self.config = Configuration(self.debug)

        self.xmltvfile = XMLTVFile(self.config)
        self.cb_status = cb_status
        self.reminders = Reminders(self.config)
        if os.path.exists(self.reminders.file):
            self.reminders = self.reminders.load()

        self.pw = ProgramWindow(self.xmltvfile)
        self.sd = SearchDialog(self.xmltvfile, self.reminders)
        self.pd = PreferencesDialog(self.config, self.xmltvfile,
                                    self.reminders, self.pw, self.sd)

        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        remote_object = self.__get_running_instance()

        if remote_object:
            print "OnTV is already running"
            exit()
        else:
            DBusService(self)
Ejemplo n.º 2
0
class OnTVCore:
    """Entry point for OnTV backend"""

    def __init__(self, configure, debug, cb_status):

        self.configure = configure
        self.debug = debug
        self.config = Configuration(self.debug)

        self.xmltvfile = XMLTVFile(self.config)
        self.cb_status = cb_status
        self.reminders = Reminders(self.config)
        if os.path.exists(self.reminders.file):
            self.reminders = self.reminders.load()

        self.pw = ProgramWindow(self.xmltvfile)
        self.sd = SearchDialog(self.xmltvfile, self.reminders)
        self.pd = PreferencesDialog(self.config, self.xmltvfile,
                                    self.reminders, self.pw, self.sd)

        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        remote_object = self.__get_running_instance()

        if remote_object:
            print "OnTV is already running"
            exit()
        else:
            DBusService(self)

    def update_listings(self):
        self.xmltvfile.download()

    def show_about_dialog(self):
        AboutDialog()

    def show_preferences_dialog(self):
        self.pd.show()

    def show_search_dialog(self):
        self.sd.show()

    def toggle_program_window(self):
        visible = self.pw.is_visible()
        if visible:
            self.pw.hide_window()
        else:
            self.pw.show_window(self.window_position)
        return visible

    def __get_running_instance(self):
        session_bus = dbus.SessionBus()
        dbus_object = session_bus.get_object('org.freedesktop.DBus',
                                     '/org/freedesktop/DBus')
        dbus_iface = dbus.Interface(dbus_object, 'org.freedesktop.DBus')
        services = dbus_iface.ListNames()
        if "org.gnome.OnTV" in services:
            return session_bus.get_object("org.gnome.OnTV","/DBusService")
        return False

    def run(self):
        if self.configure or self.config.grabber_command == '':
            xmltv_assistant = XMLTVAssistant(self.config, self.xmltvfile)
            xmltv_assistant.show()
        else:
            self.xmltvfile.connect("downloading", self.__xmltvfile_activity,
                                   _("Downloading TV Listings..."))
            self.xmltvfile.connect("downloading-done",
                                   self.__xmltvfile_downloading_done)
            self.xmltvfile.connect("sorting", self.__xmltvfile_activity,
                                   _("Sorting TV Listings..."))
            self.xmltvfile.connect("sorting-done",
                                   self.__xmltvfile_sorting_done)
            self.xmltvfile.connect("loading", self.__xmltvfile_activity,
                                   _("Loading TV Listings..."))
            self.xmltvfile.connect("loading-done",
                                   self.__xmltvfile_loading_done)
            self.xmltvfile.load()

    def __xmltvfile_activity(self, xmltvfile, activity):
        self.cb_status(activity)

    def __xmltvfile_downloading_done(self, xmltvfile, pid, condition):
        self.cb_status("")
        self.xmltvfile.sort()

    def __xmltvfile_sorting_done(self, xmltvfile, pid, condition):
        self.cb_status("")
        self.xmltvfile.load()

    def __xmltvfile_loading_done(self, xmltvfile, listings):
        self.cb_status("")

    def get_program_window_size(self):
        return self.pw.get_window_size()

    def set_program_window_position(self, window_position):
        self.window_position = window_position