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
Exemple #2
0
 def init_enigma2_flags(self, flags):
     f_flags = list(filter(lambda x: x.startswith("f:"), flags))
     if f_flags:
         value = int(f_flags[0][2:])
         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))
Exemple #3
0
def set_hide(services, model, paths):
    col_num = 5
    hide = has_locked_hide(model, paths, col_num)

    for path in paths:
        itr = model.get_iter(path)
        model.set_value(itr, col_num, None if hide else HIDE_ICON)
        flags = [*model.get_value(itr, 0).split(",")]
        index, flag = None, None
        for i, fl in enumerate(flags):
            if fl.startswith("f:"):
                index = i
                flag = fl
                break

        value = int(flag[2:]) if flag else 0

        if not hide:
            if Flag.is_hide(value):
                continue  # skip if already hidden
            value += Flag.HIDE.value
        else:
            if not Flag.is_hide(value):
                continue  # skip if already allowed to show
            value -= Flag.HIDE.value

        if value == 0 and index is not None:
            del flags[index]
        else:
            value = "f:{:02d}".format(value)
            if index is not None:
                flags[index] = value
            else:
                flags.append(value)

        model.set_value(itr, 0, (",".join(reversed(sorted(flags)))))
        fav_id = model.get_value(itr, 18)
        srv = services.get(fav_id, None)
        if srv:
            services[fav_id] = srv._replace(hide=None if hide else HIDE_ICON)
Exemple #4
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()
            except Exception as e:
                print(e)
                show_dialog(DialogType.ERROR,
                            transient=self._dialog,
                            text="Error getting transponder parameters!")
            else:
                if self._transponder_services_iters:
                    self.update_transponder_services(transponder)
        # service
        service = self.get_service(fav_id, data_id, transponder)
        old_fav_id = self._old_service.fav_id
        if old_fav_id != fav_id:
            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 flags:
            f_flags = list(
                filter(lambda x: x.startswith("f:"), flags.split(",")))
            if f_flags and Flag.is_new(int(f_flags[0][2:])):
                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