def _snd_msg(self, button, fn=None): if not fn: try: sel = self._messages.get_selected_messages() except TypeError: return if len(sel) > 1: print("FIXME: Warn about multiple send") return fn = sel[0] recip = self._messages.current_info.get_msg_recip(fn) if not msgrouting.msg_lock(fn): display_error(_("Unable to send: message in use by another task")) return stations = [] ports = self.emit("get-station-list") for slist in list(ports.values()): stations += slist if recip in stations: stations.remove(recip) stations.insert(0, recip) station, port = prompt_for_station(stations, self._config) if not station: msgrouting.msg_unlock(fn) return self.emit("user-send-form", station, port, fn, "foo")
def _mh(self, _action, store, iter, view): action = _action.get_name() if action == "delete": info = self.get_folder(self._get_folder_by_iter(store, iter)) try: info.delete_self() except OSError as e: display_error("Unable to delete folder: %s" % e) return store.remove(iter) elif action == "create": store.insert(iter, 0, ("New Folder", self.folder_pixbuf)) parent = self.get_folder(self._get_folder_by_iter(store, iter)) self._create_folder(parent, "New Folder") elif action == "rename": info = self.get_folder(self._get_folder_by_iter(store, iter)) new_text = prompt_for_string("Rename folder `%s' to:" % info.name(), orig=info.name()) if not new_text: return elif new_text == info.name(): return try: info.rename(new_text) except Exception as e: display_error("Unable to rename: %s" % e) return store.set(iter, 0, new_text)
def _folder_rename(self, render, path, new_text, store): iter = store.get_iter(path) orig = store.get(iter, 0)[0] if orig == new_text: return elif orig in BASE_FOLDERS: return info = self.get_folder(self._get_folder_by_iter(store, iter)) try: info.rename(new_text) except Exception as e: display_error("Unable to rename: %s" % e) return store.set(iter, 0, new_text)
def _bcast_file(self, but, dest): dir = self._config.get("prefs", "download_dir") fn = self._config.platform.gui_open_file(dir) if not fn: return try: f = file(fn) except Exception as e: display_error(_("Unable to open file %s: %s") % (fn, e)) return data = f.read() f.close() if len(data) > (2 << 12): display_error(_("File is too large to send (>8KB)")) return port = dest.get_active_text() self.emit("user-send-chat", "CQCQCQ", port, "\r\n" + data, False)
def open_msg(self, filename, editable, cb=None, cbdata=None): if not msgrouting.msg_lock(filename): display_error(_("Unable to open: message in use by another task")) return Gtk.RESPONSE_CANCEL parent = self._wtree.get_widget("mainwindow") form = formgui.FormDialog(_("Form"), filename, parent=parent) form.configure(self._config) def form_done(dlg, response, info): saveable_actions = [ formgui.RESPONSE_SAVE, formgui.RESPONSE_SEND, formgui.RESPONSE_SEND_VIA, ] dlg.hide() dlg.update_dst() msgrouting.msg_unlock(filename) if response in saveable_actions: print(("Saving to %s" % filename)) dlg.save_to(filename) else: print("Not saving") dlg.destroy() self.refresh(filename) if cb: cb(response, cbdata) if response == formgui.RESPONSE_SEND: self.move_message(info, filename, _("Outbox")) elif response == formgui.RESPONSE_SEND_VIA: fn = self.move_message(info, filename, _("Outbox")) self.emit("prompt-send-form", fn) elif response == formgui.RESPONSE_REPLY: self.emit("reply-form", filename) elif response == formgui.RESPONSE_DELETE: self.emit("delete-form", filename) form.build_gui(editable) form.show() form.connect("response", form_done, self.current_info)
def _query_user(self, button): while True: d = inputdialog.TextInputDialog(title=_("Query User")) d.label.set_text(_("Enter station:")) r = d.run() text = d.text.get_text() d.destroy() if not text: return elif r != Gtk.RESPONSE_OK: return if text.startswith("@"): text = text[1:] if re.match("^[A-z0-9_-]+$", text): self._build_filter("@" + text.upper()) self._save_filters() break display_error(_("Station must be a plain " + "alphanumeric string"))
def _join_channel(self, button): while True: d = inputdialog.TextInputDialog(title=_("Join Channel")) d.label.set_text(_("Enter channel name:")) r = d.run() text = d.text.get_text() d.destroy() if not text: return elif r != Gtk.RESPONSE_OK: return if text.startswith("#"): text = text[1:] if re.match("^[A-z0-9_-]+$", text): self._build_filter("#" + text) self._save_filters() break display_error( _("Channel names must be a single-word " + "alphanumeric string"))
def runner(*args, **kwargs): try: f(*args, **kwargs) except Exception as err: log_exception() main_common.display_error(f"{_('An error occurred: ')}{err}")
def runner(*args, **kwargs): try: f(*args, **kwargs) except Exception, e: log_exception() main_common.display_error(_("An error occurred: ") + str(e))