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
    def on_preferences(self):
        """Preferences event handler (:class:`dialogs.PreferencesDialog`) """

        data = PreferencesDialog(self).data

        if data is not None:
            max_file_history_changed = \
                self.settings.max_file_history != data['max_file_history']

            # Dialog has been approved --> Store data to settings
            for key in data:
                if key == "signature_key" and not data[key]:
                    data[key] = genkey()
                self.settings.__setattr__(key, data[key])

            # Immediately adjust file history in menu
            if max_file_history_changed:
                self.menuBar().file_menu.history_submenu.update()
Ejemplo n.º 3
0
    def on_preferences(self, event):
        """Creates and shows :class:`dialogs.PreferencesDialog` to edit the
        configuration parameters.

        :param event: Event entailed execution of the callback
        :type event: :class:`wx.CommandEvent` with type :const:`wx.EVT_MENU`

        """
        dialog = PreferencesDialog(player=self)
        if dialog.ShowModal() == wx.ID_OK:
            wx.PostEvent(
                self,
                ev.ConfigUpdate(params=dialog.get_preferences(),
                                apply_updated=True))
            self._filters = dialog.get_filters()
            self.app.dump_filters(self._filters)
        dialog.Destroy()
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def preferences_menu_item_activate(self, menu_item):
     """Show the preferences dialog."""
     pd = PreferencesDialog(self.config)
     pd.dialog.show()
Ejemplo n.º 6
0
class ObjectsPathPage(PathPage):
    def __init__(self):
        super().__init__()

        self.setTitle("Objects Path (optional)")
        self.setSubTitle("Choose the folder containing object folders")

        self.requireFinish = False
        self.isValidPathMethod = isValidObjectsPath

        path = setting('ObjPath')
        if path:
            self.pathLineEdit.setText(path)


ThemesTab = PreferencesDialog.getThemesTab(QtWidgets.QWizardPage)


class ThemesPage(ThemesTab):
    def __init__(self):
        super().__init__()

        self.setTitle("Set the theme (optional)")
        self.setSubTitle(
            "Can be changed later from Miyamoto! Preferences\nYou have to launch the editor for the theme to apply"
        )

        self.NonWinStyle.currentIndexChanged.connect(self.setStyle)
        self.setStyle()

    def setStyle(self):