Ticket #161: privatechat.py.diff
| File privatechat.py.diff, 5.0 kB (added by gallows, 19 months ago) |
|---|
-
privatechat.py
old new 177 177 f.close() 178 178 s = d.split("\n") 179 179 for l in s[-8:-1]: 180 AppendLine(self.ChatScroll, l + "\n", self.tag_hilite, "", username=self.user, usertag=self.tag_ username)180 AppendLine(self.ChatScroll, l + "\n", self.tag_hilite, "", username=self.user, usertag=self.tag_hilite) 181 181 except IOError, e: 182 182 pass 183 183 … … 251 251 252 252 253 253 def SendMessage(self, text): 254 254 255 255 if text[:4] == "/me ": 256 256 line = "* %s %s" % (self.frame.np.config.sections["server"]["login"], text[4:]) 257 257 tag = self.tag_me … … 262 262 else: 263 263 line = text 264 264 tag = self.tag_local 265 266 my_username = self.frame.np.config.sections["server"]["login"] 267 if text[:4] == "/me ": 268 AppendLine(self.ChatScroll, self.frame.np.decode(line, self.encoding), tag, "%c", username=my_username, usertag=self.tag_me) 269 else: 270 AppendLine(self.ChatScroll, '[' + my_username + "] " + self.frame.np.decode(line, self.encoding), tag, "%c", username=my_username, usertag=self.tag_my_username) 265 271 266 AppendLine(self.ChatScroll, self.frame.np.decode(line, self.encoding), tag, "%c", username=self.user, usertag=self.tag_username)267 272 if self.Log.get_active(): 268 self.logfile = WriteLog(self.logfile, self.frame.np.config.sections["logging"]["logsdir"], self.user, line)273 self.logfile = WriteLog(self.logfile, self.frame.np.config.sections["logging"]["logsdir"], self.user, '[' + my_username + "] " + line) 269 274 270 275 if self.PeerPrivateMessages.get_active(): 271 276 # not in the soulseek protocol … … 273 278 else: 274 279 self.frame.np.queue.put(slskmessages.MessageUser(self.user, text)) 275 280 CMDS = ["/alias ", "/unalias ", "/whois ", "/browse ", "/ip ", "/pm ", "/msg ", "/search ", "/usearch ", "/rsearch ", 276 "/bsearch ", "/add ", "/buddy ", "/rem ", "/unbuddy ", "/ban ", "/ignore ", "/unban ", "/unignore ", "/clear", "/quit", "/rescan", "/nsa", "/info", "/ctcpversion" ]281 "/bsearch ", "/add ", "/buddy ", "/rem ", "/unbuddy ", "/ban ", "/ignore ", "/unban ", "/unignore ", "/clear", "/quit", "/rescan", "/nsa", "/info", "/ctcpversion", "/join"] 277 282 278 283 def OnEnter(self, widget): 279 284 text = self.frame.np.encode(widget.get_text(), self.encoding) … … 375 380 self.SendMessage(np) 376 381 elif cmd == "/rescan": 377 382 self.frame.OnRescan() 383 elif cmd in ["/join", "/j"]: 384 self.frame.np.queue.put(slskmessages.JoinRoom(args)) 378 385 elif cmd and cmd[:1] == "/" and cmd != "/me" and cmd[:2] != "//": 379 386 self.frame.logMessage(_("Command %s is not recognized") % text) 380 387 return … … 417 424 statuscolor = "useroffline" 418 425 419 426 self.tag_username = self.makecolour(buffer, statuscolor) 427 if self.frame.away: 428 self.tag_my_username = self.makecolour(buffer, "useraway") 429 else: 430 self.tag_my_username = self.makecolour(buffer, "useronline") 431 420 432 usernamestyle = self.frame.np.config.sections["ui"]["usernamestyle"] 421 433 if usernamestyle == "bold": 422 434 self.tag_username.set_property("weight", pango.WEIGHT_BOLD) 435 self.tag_my_username.set_property("weight", pango.WEIGHT_BOLD) 423 436 else: 424 437 self.tag_username.set_property("weight", pango.WEIGHT_NORMAL) 438 self.tag_my_username.set_property("weight", pango.WEIGHT_NORMAL) 425 439 if usernamestyle == "italic": 426 440 self.tag_username.set_property("style", pango.STYLE_ITALIC) 441 self.tag_my_username.set_property("style", pango.STYLE_ITALIC) 427 442 else: 428 443 self.tag_username.set_property("style", pango.STYLE_NORMAL) 444 self.tag_my_username.set_property("style", pango.STYLE_NORMAL) 429 445 if usernamestyle == "underline": 430 446 self.tag_username.set_property("underline", pango.UNDERLINE_SINGLE) 447 self.tag_my_username.set_property("underline", pango.UNDERLINE_SINGLE) 431 448 else: 432 449 self.tag_username.set_property("underline", pango.UNDERLINE_NONE) 450 self.tag_my_username.set_property("underline", pango.UNDERLINE_NONE) 451 433 452 self.frame.SetTextBG(self.ChatScroll) 434 453 self.frame.SetTextBG(self.ChatLine) 435 454 … … 472 491 self.changecolour(self.tag_hilite, "chathilite") 473 492 color = self.getUserStatusColor(self.status) 474 493 self.changecolour(self.tag_username, color) 494 475 495 self.frame.SetTextBG(self.ChatScroll) 476 496 self.frame.SetTextBG(self.ChatLine) 497 498 if self.frame.away: 499 self.changecolour(self.tag_my_username, "useraway") 500 else: 501 self.changecolour(self.tag_my_username, "useronline") 477 502 478 503 def getUserStatusColor(self, status): 479 504 if status == 1: … … 488 513 if status == self.status: 489 514 return 490 515 491 492 516 self.status = status 493 517 494 518 color = self.getUserStatusColor(self.status) 495 519 496 520 self.changecolour(self.tag_username, color) 497 521 498 522 #line = "* " + ["User %s is offline", "User %s is away", "User %s is online"][status] % self.user 499 523 #AppendLine(self.ChatScroll, line, self.tag_hilite, "%c") 500 524 … … 530 554 widget.insert_text(completion, ix) 531 555 widget.set_position(ix + len(completion)) 532 556 widget.emit_stop_by_name("key_press_event") 557 533 558 return True 534 559 535 560 def OnLogToggled(self, widget):
