def drawRect_(self, rect): rect = NSInsetRect(self.bounds(), 1.5, 1.5) if not self.conferencing: NSColor.whiteColor().set() path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) path.fill() if self.conferencing: if self.draggedOut: NSColor.whiteColor().set() else: # bgcolor for conference area NSColor.colorWithDeviceRed_green_blue_alpha_( 196 / 255.0, 230 / 255.0, 254 / 255.0, 1.0).set() border = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) border.setLineWidth_(1) border.fill() NSColor.grayColor().set() border.stroke() # hack: if we're the 1st item, draw the border around all conferenced boxes subviews = self.superview().subviews() if subviews.objectAtIndex_(0) == self: # first in conference list rect.size.height += 5 rect.origin.y -= 5 path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) else: prev = None last = True for view in subviews: if prev == self: last = not view.conferencing break prev = view # last in conference list if last: rect.size.height += 5 path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) else: rect.origin.y -= 5 rect.size.height += 10 path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) if self.selected or self.highlighted: path.setLineWidth_(3) else: path.setLineWidth_(1) if self.highlighted: NSColor.orangeColor().set() else: NSColor.grayColor().set() if self.selected or self.highlighted: path.stroke() elif self.highlighted: path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) path.setLineWidth_(3) NSColor.orangeColor().set() path.stroke() elif self.selected: path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) path.setLineWidth_(3) NSColor.grayColor().set() path.stroke() else: path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_( rect, 5.0, 5.0) path.setLineWidth_(1) NSColor.grayColor().set() path.stroke()
def __init__(self, sessionController): self.notification_center = NotificationCenter() self.notification_center.add_observer(self, name='CFGSettingsObjectDidChange') self.sessionController = None self.audio_stream = None self.video_stream = None self.chat_stream = None self.add_session(sessionController) self.add_audio_stream() self.add_video_stream() self.add_chat_stream() self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_(1.0, self, "updateTimer:", None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSModalPanelRunLoopMode) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode) NSBundle.loadNibNamed_owner_("SessionInfoPanel", self) sessionBoxTitle = NSAttributedString.alloc().initWithString_attributes_(NSLocalizedString("SIP Session", "Label"), NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.sessionBox.setTitle_(sessionBoxTitle) audioBoxTitle = NSAttributedString.alloc().initWithString_attributes_(NSLocalizedString("Audio Stream", "Label"), NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.audioBox.setTitle_(audioBoxTitle) videoBoxTitle = NSAttributedString.alloc().initWithString_attributes_(NSLocalizedString("Video Stream", "Label"), NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.videoBox.setTitle_(videoBoxTitle) chatBoxTitle = NSAttributedString.alloc().initWithString_attributes_(NSLocalizedString("Chat Stream", "Label"), NSDictionary.dictionaryWithObject_forKey_(NSColor.orangeColor(), NSForegroundColorAttributeName)) self.chatBox.setTitle_(chatBoxTitle) settings = SIPSimpleSettings() self.audio_rtt_graph.setLineWidth_(1.0) self.audio_rtt_graph.setLineSpacing_(1.0) self.audio_rtt_graph.setAboveLimit_(settings.gui.rtt_threshold) # if higher show red color self.audio_rtt_graph.setMinimumHeigth_(settings.gui.rtt_threshold) self.audio_packet_loss_graph.setLineWidth_(1.0) self.audio_packet_loss_graph.setLineSpacing_(1.0) self.audio_packet_loss_graph.setAboveLimit_(3) # if higher than 3% show red color self.audio_packet_loss_graph.setLineColor_(NSColor.greenColor()) self.audio_packet_loss_graph.setMinimumHeigth_(5) self.rx_speed_graph.setLineWidth_(1.0) self.rx_speed_graph.setLineSpacing_(0.0) self.rx_speed_graph.setLineColor_(NSColor.greenColor()) self.rx_speed_graph.setMinimumHeigth_(100000) self.rx_speed_graph.setAboveLimit_(120000) self.tx_speed_graph.setLineWidth_(1.0) self.tx_speed_graph.setLineSpacing_(0.0) self.tx_speed_graph.setLineColor_(NSColor.blueColor()) self.tx_speed_graph.setMinimumHeigth_(100000) self.tx_speed_graph.setAboveLimit_(120000) self.video_rx_speed_graph.setLineWidth_(1.0) self.video_rx_speed_graph.setLineSpacing_(0.0) self.video_rx_speed_graph.setLineColor_(NSColor.greenColor()) self.video_rx_speed_graph.setMinimumHeigth_(100000) self.video_rx_speed_graph.setAboveLimit_(1200000) self.video_tx_speed_graph.setLineWidth_(1.0) self.video_tx_speed_graph.setLineSpacing_(0.0) self.video_tx_speed_graph.setLineColor_(NSColor.blueColor()) self.video_tx_speed_graph.setMinimumHeigth_(100000) self.video_tx_speed_graph.setAboveLimit_(1200000) self.resetSession() self.updatePanelValues()
def __init__(self, sessionController): self.notification_center = NotificationCenter() self.notification_center.add_observer( self, name='CFGSettingsObjectDidChange') self.sessionController = None self.audio_stream = None self.video_stream = None self.chat_stream = None self.add_session(sessionController) self.add_audio_stream() self.add_video_stream() self.add_chat_stream() self.timer = NSTimer.timerWithTimeInterval_target_selector_userInfo_repeats_( 1.0, self, "updateTimer:", None, True) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSModalPanelRunLoopMode) NSRunLoop.currentRunLoop().addTimer_forMode_(self.timer, NSDefaultRunLoopMode) NSBundle.loadNibNamed_owner_("SessionInfoPanel", self) sessionBoxTitle = NSAttributedString.alloc( ).initWithString_attributes_( NSLocalizedString("SIP Session", "Label"), NSDictionary.dictionaryWithObject_forKey_( NSColor.orangeColor(), NSForegroundColorAttributeName)) self.sessionBox.setTitle_(sessionBoxTitle) audioBoxTitle = NSAttributedString.alloc().initWithString_attributes_( NSLocalizedString("Audio Stream", "Label"), NSDictionary.dictionaryWithObject_forKey_( NSColor.orangeColor(), NSForegroundColorAttributeName)) self.audioBox.setTitle_(audioBoxTitle) videoBoxTitle = NSAttributedString.alloc().initWithString_attributes_( NSLocalizedString("Video Stream", "Label"), NSDictionary.dictionaryWithObject_forKey_( NSColor.orangeColor(), NSForegroundColorAttributeName)) self.videoBox.setTitle_(videoBoxTitle) chatBoxTitle = NSAttributedString.alloc().initWithString_attributes_( NSLocalizedString("Chat Stream", "Label"), NSDictionary.dictionaryWithObject_forKey_( NSColor.orangeColor(), NSForegroundColorAttributeName)) self.chatBox.setTitle_(chatBoxTitle) settings = SIPSimpleSettings() self.audio_rtt_graph.setLineWidth_(1.0) self.audio_rtt_graph.setLineSpacing_(1.0) self.audio_rtt_graph.setAboveLimit_( settings.gui.rtt_threshold) # if higher show red color self.audio_rtt_graph.setMinimumHeigth_(settings.gui.rtt_threshold) self.audio_packet_loss_rx_graph.setLineWidth_(1.0) self.audio_packet_loss_rx_graph.setLineSpacing_(1.0) self.audio_packet_loss_rx_graph.setAboveLimit_( 3) # if higher than 3% show red color self.audio_packet_loss_rx_graph.setLineColor_(NSColor.greenColor()) self.audio_packet_loss_rx_graph.setMinimumHeigth_(5) self.audio_packet_loss_tx_graph.setLineWidth_(1.0) self.audio_packet_loss_tx_graph.setLineSpacing_(1.0) self.audio_packet_loss_tx_graph.setAboveLimit_( 3) # if higher than 3% show red color self.audio_packet_loss_tx_graph.setLineColor_(NSColor.greenColor()) self.audio_packet_loss_tx_graph.setMinimumHeigth_(5) self.rx_speed_graph.setLineWidth_(1.0) self.rx_speed_graph.setLineSpacing_(0.0) self.rx_speed_graph.setLineColor_(NSColor.greenColor()) self.rx_speed_graph.setMinimumHeigth_(100000) self.rx_speed_graph.setAboveLimit_(120000) self.tx_speed_graph.setLineWidth_(1.0) self.tx_speed_graph.setLineSpacing_(0.0) self.tx_speed_graph.setLineColor_(NSColor.blueColor()) self.tx_speed_graph.setMinimumHeigth_(100000) self.tx_speed_graph.setAboveLimit_(120000) self.video_rx_speed_graph.setLineWidth_(1.0) self.video_rx_speed_graph.setLineSpacing_(0.0) self.video_rx_speed_graph.setLineColor_(NSColor.greenColor()) self.video_rx_speed_graph.setMinimumHeigth_(100000) self.video_rx_speed_graph.setAboveLimit_(99999999) self.video_tx_speed_graph.setLineWidth_(1.0) self.video_tx_speed_graph.setLineSpacing_(0.0) self.video_tx_speed_graph.setLineColor_(NSColor.blueColor()) self.video_tx_speed_graph.setMinimumHeigth_(100000) self.video_tx_speed_graph.setAboveLimit_(99999999) self.resetSession() self.updatePanelValues()
def drawRect_(self, rect): rect = NSInsetRect(self.bounds(), 1.5, 1.5) if not self.conferencing: NSColor.whiteColor().set() path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) path.fill() if self.conferencing: if self.draggedOut: NSColor.whiteColor().set() else: # bgcolor for conference area NSColor.colorWithDeviceRed_green_blue_alpha_(196/255.0, 230/255.0, 254/255.0, 1.0).set() border = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) border.setLineWidth_(1) border.fill() NSColor.grayColor().set() border.stroke() # hack: if we're the 1st item, draw the border around all conferenced boxes subviews = self.superview().subviews() if subviews.objectAtIndex_(0) == self: # first in conference list rect.size.height += 5 rect.origin.y -= 5 path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) else: prev = None last = True for view in subviews: if prev == self: last = not view.conferencing break prev = view # last in conference list if last: rect.size.height += 5 path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) else: rect.origin.y -= 5 rect.size.height += 10 path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) if self.selected or self.highlighted: path.setLineWidth_(3) else: path.setLineWidth_(1) if self.highlighted: NSColor.orangeColor().set() else: NSColor.grayColor().set() if self.selected or self.highlighted: path.stroke() elif self.highlighted: path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) path.setLineWidth_(3) NSColor.orangeColor().set() path.stroke() elif self.selected: path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) path.setLineWidth_(3) NSColor.grayColor().set() path.stroke() else: path = NSBezierPath.bezierPathWithRoundedRect_xRadius_yRadius_(rect, 5.0, 5.0) path.setLineWidth_(1) NSColor.grayColor().set() path.stroke()