def set_status(self, msg): sb = self._wtree.get_widget("statusbar") cb = self._wtree.get_widget("callbar") self.__last_status = time.time() id = sb.get_context_id("default") sb.pop(id) sb.push(id, msg) call = self._config.get("user", "callsign") self.__window.set_title("D-RATS: %s" % call) cb.pop(0) cb.push(0, call) if __name__ == "__main__": wtree = gtk.glade.XML("ui/mainwindow.glade", "mainwindow") from d_rats import config conf = config.DratsConfig(None) def test(chat, station, msg): print(f"{station}->{msg}") chat = ChatTab(wtree, conf) chat.connect("user-sent-message", test) msgs = MessagesTab(wtree, conf) gtk.main()
def __init__(self, **args): self.handlers = { "status": self.__status, "user-stop-session": self.__user_stop_session, "user-cancel-session": self.__user_cancel_session, "user-send-form": self.__user_send_form, "user-send-file": self.__user_send_file, "rpc-send-form": self.__user_send_form, "rpc-send-file": self.__user_send_file, "user-send-chat": self.__user_send_chat, "incoming-chat-message": self.__incoming_chat_message, "outgoing-chat-message": self.__outgoing_chat_message, "get-station-list": self.__get_station_list, "get-message-list": self.__get_message_list, "submit-rpc-job": self.__submit_rpc_job, "event": self.__event, "notice": False, "config-changed": self.__config_changed, "show-map-station": self.__show_map_station, "ping-station": self.__ping_station, "ping-station-echo": self.__ping_station_echo, "ping-request": self.__ping_request, "ping-response": self.__ping_response, "incoming-gps-fix": self.__incoming_gps_fix, "station-status": self.__station_status, "get-current-status": self.__get_current_status, "get-current-position": self.__get_current_position, "session-status-update": self.__session_status_update, "session-started": self.__session_started, "session-ended": self.__session_ended, "file-received": self.__file_received, "form-received": self.__form_received, "file-sent": self.__file_sent, "form-sent": self.__form_sent, "get-chat-port": self.__get_chat_port, "trigger-msg-router": self.__trigger_msg_router, "register-object": self.__register_object, } global MAINAPP MAINAPP = self self.comm = None self.sm = {} self.seen_callsigns = CallList() self.position = None self.mail_threads = {} self.__unused_pipes = {} self.__pipes = {} self.pop3srv = None self.config = config.DratsConfig(self) self._refresh_lang() self._announce_self() message = _("Since this is your first time running D-RATS, " + "you will be taken directly to the configuration " + "dialog. At a minimum, put your callsign in the " + "box and click 'Save'. You will be connected to " + "the ratflector initially for testing.") while self.config.get("user", "callsign") == "": d = gtk.MessageDialog(buttons=gtk.BUTTONS_OK) d.set_markup(message) d.run() d.destroy() if not self.config.show(): raise Exception("User canceled configuration") message = _("You must enter a callsign to continue") self.gps = self._static_gps() self.map = mapdisplay.MapWindow(self.config) self.map.set_title("D-RATS Map Window") self.map.connect("reload-sources", lambda m: self._load_map_overlays()) self.__connect_object(self.map) pos = self.get_position() self.map.set_center(pos.latitude, pos.longitude) self.map.set_zoom(14) self.__map_point = None self.mainwindow = mainwindow.MainWindow(self.config) self.__connect_object(self.mainwindow) for tab in self.mainwindow.tabs.values(): self.__connect_object(tab) self.refresh_config() self._load_map_overlays() if self.config.getboolean("prefs", "dosignon") and self.chat_session: msg = self.config.get("prefs", "signon") status = station_status.STATUS_ONLINE for port in self.sm.keys(): self.chat_session(port).advertise_status(status, msg) gobject.timeout_add(3000, self._refresh_location)