Exemplo n.º 1
0
    def focus(self):
        if self.loaded:
            return
        self.loaded = True
        print "Loading callsigns..."

        def set_ucall(calls):
            self.editor_ucall.set_callsigns(calls)
            self.editor_ucall.connect("changed", self.__cs_changed)

        def set_rcall(calls):
            self.editor_rcall.set_callsigns(calls)
            self.editor_rcall.connect("changed", self.__cs_changed)

        def set_mcall(calls):
            self.editor_mcall.set_callsigns(calls)
            self.editor_mcall.connect("changed", self.__cs_changed)

        job = common.RadioJob(set_ucall, "get_urcall_list")
        job.set_desc(_("Downloading URCALL list"))
        self.rthread.submit(job)

        job = common.RadioJob(set_rcall, "get_repeater_call_list")
        job.set_desc(_("Downloading RPTCALL list"))
        self.rthread.submit(job)

        job = common.RadioJob(set_mcall, "get_mycall_list")
        job.set_desc(_("Downloading MYCALL list"))
        self.rthread.submit(job)
Exemplo n.º 2
0
    def _index_edited_cb(self, rend, path, new):
        loc, = self._store.get(self._store.get_iter(path), self.C_LOC)

        def refresh_memory(*args):
            self.refresh_memory(loc)

        def set_index(mappings, memory):
            self.emit("changed")
            # Step 2: Set the index
            job = common.RadioJob(refresh_memory, "set_memory_index", memory,
                                  mappings[0], int(new))
            job.set_target(self._model)
            job.set_desc(
                _("Setting index "
                  "for memory {num}").format(num=memory.number))
            self.rthread.submit(job)

        def get_mapping(memory):
            # Step 1: Get the first/only mapping
            job = common.RadioJob(set_index, "get_memory_mappings", memory)
            job.set_cb_args(memory)
            job.set_target(self._model)
            job.set_desc(
                _("Getting {type} for "
                  "memory {num}").format(type=self._type, num=memory.number))
            self.rthread.submit(job)

        # Step 0: Get the memory
        job = common.RadioJob(get_mapping, "get_memory", loc)
        job.set_desc(_("Getting memory {num}").format(num=loc))
        self.rthread.submit(job)
Exemplo n.º 3
0
 def get_mapping(memory):
     # Step 1: Get the first/only mapping
     job = common.RadioJob(set_index, "get_memory_mappings", memory)
     job.set_cb_args(memory)
     job.set_target(self._model)
     job.set_desc(
         _("Getting {type} for "
           "memory {num}").format(type=self._type, num=memory.number))
     self.rthread.submit(job)
Exemplo n.º 4
0
 def do_mapping_adjustment(memory):
     # Step 1: Do the mapping add/remove
     job = common.RadioJob(do_mapping_index, fn, memory, mapping)
     job.set_target(self._model)
     job.set_cb_args(memory)
     job.set_desc(
         _("Updating mapping information "
           "for memory {num}").format(num=memory.number))
     self.rthread.submit(job)
Exemplo n.º 5
0
 def set_index(mappings, memory):
     self.emit("changed")
     # Step 2: Set the index
     job = common.RadioJob(refresh_memory, "set_memory_index", memory,
                           mappings[0], int(new))
     job.set_target(self._model)
     job.set_desc(
         _("Setting index "
           "for memory {num}").format(num=memory.number))
     self.rthread.submit(job)
Exemplo n.º 6
0
    def __cs_changed(self, cse):
        job = None

        print "Callsigns: %s" % cse.get_callsigns()
        if cse == self.editor_ucall:
            job = common.RadioJob(None, "set_urcall_list", cse.get_callsigns())
            print "Set urcall"
        elif cse == self.editor_rcall:
            job = common.RadioJob(None, "set_repeater_call_list",
                                  cse.get_callsigns())
            print "Set rcall"
        elif cse == self.editor_mcall:
            job = common.RadioJob(None, "set_mycall_list", cse.get_callsigns())

        if job:
            print "Submitting job to update call lists"
            self.rthread.submit(job)

        self.emit("changed")
Exemplo n.º 7
0
    def prime(self):
        # NOTE: this is only called to prime new CSV files, so assume
        # only one memory editor for now
        mem = chirp_common.Memory()
        mem.freq = 146010000

        def cb(*args):
            gobject.idle_add(self.editors["memedit0"].prefill)

        job = common.RadioJob(cb, "set_memory", mem)
        job.set_desc(_("Priming memory"))
        self.rthread.submit(job)
Exemplo n.º 8
0
    def mapping_changed(self, listw, key):
        def cb(*args):
            self.emit("changed")

        name = self.listw.get_item(key)[2]
        mapping, oldname = self.mappings[self._keys.index(key)]

        def trigger_changed(*args):
            self.emit("changed")

        job = common.RadioJob(trigger_changed, "set_name", name)
        job.set_target(mapping)
        job.set_desc(_("Setting name on %s") % self._type.lower())
        self.rthread.submit(job)

        return True
Exemplo n.º 9
0
        def do_mapping_index(result, memory):
            if isinstance(result, Exception):
                common.show_error(
                    "Failed to add {mem} to mapping: {err}".format(
                        mem=memory.number, err=str(result)),
                    parent=self.editorset.parent_window)
                return
            self.emit("changed")
            # Step 3: Set the memory's mapping index (maybe)
            if not is_indexed or index is None:
                return do_refresh_memory()

            job = common.RadioJob(do_refresh_memory, "set_memory_index",
                                  memory, mapping, index)
            job.set_target(self._model)
            job.set_desc(
                _("Updating {type} index "
                  "for memory {num}").format(type=self._type,
                                             num=memory.number))
            self.rthread.submit(job)
Exemplo n.º 10
0
    def _toggled_cb(self, rend, path, colnum):
        try:
            if not rend.get_sensitive():
                return
        except AttributeError:
            # support PyGTK < 2.22
            iter = self._store.get_iter(path)
            if not self._store.get(iter, self.C_FILLED)[0]:
                return

        # The mapping index is the column number, minus the 3 label columns
        mapping, name = self.mappings[colnum - len(self._cols)]
        loc, = self._store.get(self._store.get_iter(path), self.C_LOC)

        is_indexed = isinstance(self._model,
                                chirp_common.MappingModelIndexInterface)

        if rend.get_active():
            # Changing from True to False
            fn = "remove_memory_from_mapping"
            index = None
        else:
            # Changing from False to True
            fn = "add_memory_to_mapping"
            if is_indexed:
                index = self._get_next_mapping_index(colnum - len(self._cols))
            else:
                index = None

        def do_refresh_memory(*args):
            # Step 2: Update our notion of the memory's mapping information
            self.refresh_memory(loc)

        def do_mapping_index(result, memory):
            if isinstance(result, Exception):
                common.show_error(
                    "Failed to add {mem} to mapping: {err}".format(
                        mem=memory.number, err=str(result)),
                    parent=self.editorset.parent_window)
                return
            self.emit("changed")
            # Step 3: Set the memory's mapping index (maybe)
            if not is_indexed or index is None:
                return do_refresh_memory()

            job = common.RadioJob(do_refresh_memory, "set_memory_index",
                                  memory, mapping, index)
            job.set_target(self._model)
            job.set_desc(
                _("Updating {type} index "
                  "for memory {num}").format(type=self._type,
                                             num=memory.number))
            self.rthread.submit(job)

        def do_mapping_adjustment(memory):
            # Step 1: Do the mapping add/remove
            job = common.RadioJob(do_mapping_index, fn, memory, mapping)
            job.set_target(self._model)
            job.set_cb_args(memory)
            job.set_desc(
                _("Updating mapping information "
                  "for memory {num}").format(num=memory.number))
            self.rthread.submit(job)

        # Step 0: Fetch the memory
        job = common.RadioJob(do_mapping_adjustment, "get_memory", loc)
        job.set_desc(_("Getting memory {num}").format(num=loc))
        self.rthread.submit(job)