Exemplo n.º 1
0
    def on_edit(self):
        """ Edit current service.  """
        fav_id, data_id = self.get_srv_data()
        # Transponder
        transponder = self._old_service.transponder
        if self._tr_edit_switch.get_active():
            try:
                if self._tr_type is TrType.Satellite:
                    transponder = self.get_satellite_transponder_data()
                elif self._tr_type is TrType.Terrestrial:
                    transponder = self.get_terrestrial_transponder_data()
                elif self._tr_type is TrType.Cable:
                    transponder = self.get_cable_transponder_data()
                elif self._tr_type is TrType.ATSC:
                    transponder = self.get_atsc_transponder_data()
            except Exception as e:
                log("Edit service error: {}".format(e))
                show_dialog(DialogType.ERROR,
                            transient=self._dialog,
                            text="Error getting transponder parameters!")
            else:
                if self._transponder_services_iters:
                    self.update_transponder_services(transponder,
                                                     self.get_sat_position())
        # Service
        service = self.get_service(fav_id, data_id, transponder)
        old_fav_id = self._old_service.fav_id
        if old_fav_id != fav_id:
            if fav_id in self._services:
                msg = "{}\n\n\t{}".format(
                    "A similar service is already in this list!",
                    "Are you sure?")
                if show_dialog(DialogType.QUESTION,
                               transient=self._dialog,
                               text=msg) != Gtk.ResponseType.OK:
                    return False
            self.update_bouquets(fav_id, old_fav_id)

        self._services[fav_id] = service

        if self._old_service.picon_id != service.picon_id:
            self.update_picon_name(self._old_service.picon_id,
                                   service.picon_id)

        flags = service.flags_cas
        extra_data = {Column.SRV_TOOLTIP: None, Column.SRV_BACKGROUND: None}
        if self._s_type is SettingsType.ENIGMA_2 and flags:
            f_flags = list(
                filter(lambda x: x.startswith("f:"), flags.split(",")))
            if f_flags and Flag.is_new(Flag.parse(f_flags[0])):
                extra_data[Column.SRV_BACKGROUND] = self._new_color

        self._current_model.set(self._current_itr, extra_data)
        self._current_model.set(self._current_itr,
                                {i: v
                                 for i, v in enumerate(service)})
        self.update_fav_view(self._old_service, service)
        self._old_service = service
        return True
Exemplo n.º 2
0
 def init_enigma2_flags(self, flags):
     f_flags = list(filter(lambda x: x.startswith("f:"), flags))
     if f_flags:
         value = Flag.parse(f_flags[0])
         self._keep_check_button.set_active(Flag.is_keep(value))
         self._hide_check_button.set_active(Flag.is_hide(value))
         self._use_pids_check_button.set_active(Flag.is_pids(value))
         self._new_check_button.set_active(Flag.is_new(value))