def __init__(self, config): wtree = gtk.glade.XML(config.ship_obj_fn("ui/mainwindow.glade"), "mainwindow", "D-RATS") MainWindowElement.__init__(self, wtree, config, "") self.__window = self._wtree.get_widget("mainwindow") self._tabs = self._wtree.get_widget("main_tabs") self._tabs.connect("switch-page", self._tab_switched) self.tabs = {} self.__last_status = 0 self.tabs["chat"] = ChatTab(wtree, config) self.tabs["messages"] = MessagesTab(wtree, config) self.tabs["event"] = EventTab(wtree, config) self.tabs["files"] = FilesTab(wtree, config) self.tabs["stations"] = StationsList(wtree, config) for label, tab in self.tabs.items(): tab.connect("notice", self._maybe_blink, label) self._current_tab = "messages" ic = "incomingcolor" cpr = "Copyright 2012 Dan Smith (KK7DS)" self.tabs["chat"]._display_line("D-RATS v%s" % DRATS_VERSION, True, ic) self.tabs["chat"]._display_line(cpr, True, ic) self.tabs["chat"]._display_line("", True) self.__window.connect("destroy", self._destroy) self.__window.connect("delete_event", self._delete) self.__window.connect("focus-in-event", self._got_focus) self._connect_menu_items(self.__window) h = self._config.getint("state", "main_size_x") w = self._config.getint("state", "main_size_y") if self._config.getboolean("state", "main_maximized"): self.__window.maximize() self.__window.set_default_size(h, w) else: self.__window.resize(h, w) try: import gtkmacintegration mbar = self._wtree.get_widget("menubar1") mbar.hide() gtkmacintegration.gtk_mac_menu_set_menu_bar(mbar) gtkmacintegration.gtk_mac_menu_set_global_key_handler_enabled(False) print "Enabled OSX menubar integration" except ImportError: pass self.__window.show() gobject.timeout_add(3000, self.__update_status)
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()