Instantly share code, notes, and snippets.
Created
June 14, 2009 12:23
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save jezdez/129656 to your computer and use it in GitHub Desktop.
This is a plugin for Colloquy (trunk/nightly) that creates a status menu bar item with some helpful entries.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import objc | |
from Foundation import * | |
from AppKit import * | |
from sys import * | |
# the NSStatusItem we'll create | |
statusItem = 0 | |
inactiveIcon = 0 | |
activeIcon = 0 | |
isActive = 0 | |
myApp = 0 | |
# called on load and reload | |
def load( scriptFilePath ): | |
global statusItem, inactiveIcon, activeIcon, myApp | |
myApp = NSApplication.sharedApplication() | |
# create a new NSStatusItem | |
thickness = NSStatusBar.systemStatusBar().thickness() | |
statusItem = NSStatusBar.systemStatusBar().statusItemWithLength_(thickness) | |
statusItem.setToolTip_("Colloquy Status") | |
statusItem.setHighlightMode_(1) | |
bundle = NSBundle.mainBundle() | |
path = bundle.pathForImageResource_("newHighlightMessage.png") | |
activeIcon = NSImage.alloc().initWithContentsOfFile_(path) | |
path = bundle.pathForImageResource_("newMessage.png") | |
inactiveIcon = NSImage.alloc().initWithContentsOfFile_(path) | |
statusItem.setImage_(inactiveIcon) | |
menu = NSMenu.alloc().init() | |
# # Sync event is bound to sync_ method | |
# menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Bring to front', 'arrangeInFront:', '') | |
# menu.addItem_(menuitem) | |
# Default event | |
menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( | |
u'Buddy List', 'showBuddyList:', '') | |
menu.addItem_(menuitem) | |
menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( | |
u'New Connection…', 'newConnection:', '') | |
menu.addItem_(menuitem) | |
menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( | |
u'Join Chat Room…', 'joinRoom:', '') | |
menu.addItem_(menuitem) | |
seperator = NSMenuItem.separatorItem() | |
menu.addItem_(seperator) | |
menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( | |
u'Preferences…', 'showPreferences:', '') | |
menu.addItem_(menuitem) | |
menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_( | |
u'Quit Colloquy…', 'terminate:', '') | |
menu.addItem_(menuitem) | |
# Bind it to the status item | |
statusItem.setMenu_(menu) | |
# called on unload and relead | |
def unload(): | |
global statusItem | |
if statusItem != 0: | |
statusItem.statusBar().removeStatusItem_(statusItem) | |
# return an array of NSMenuItems that should be dispalyed for 'item' associated with 'view' | |
def contextualMenuItems( item, view ): | |
global inactiveIcon, myApp | |
if inactiveIcon != 0 and myApp.isActive(): | |
statusItem.setImage_(inactiveIcon) | |
# return an array of toolbar item identifier strings that can be associated with 'view' | |
def toolbarItemIdentifiers( view ): | |
pass | |
# return an NSToolbarItem for 'identifier' associated with 'view' | |
def toolbarItem( identifier, view, willBeInserted ): | |
pass | |
# perform the action associated with 'toolbarItem' for 'view' | |
def handleClickedToolbarItem( toolbarItem, view ): | |
pass | |
# process the command and return true if you handle it or False to pass on to another plugin | |
def processUserCommand( command, arguments, connection, view ): | |
# return true if the command was handled or to prevent other plugins or Colloquy from handling it | |
return False | |
# handle a ctcp request and return true if you handle it or False to pass on to another plugin | |
def processSubcodeRequest( command, arguments, user ): | |
# return true if the command was handled or to prevent other plugins or Colloquy from handling it | |
return False | |
# handle a ctcp reply and return true if you handle it or False to pass on to another plugin | |
def processSubcodeReply( command, arguments, user ): | |
# return true if the command was handled or to prevent other plugins or Colloquy from handling it | |
return False | |
# called when 'connection' connects | |
def connected(connection): | |
pass | |
# called when 'connection' is disconnecting | |
def disconnecting( connection ): | |
pass | |
# perform a notification | |
def performNotification( identifier, context, preferences ): | |
pass | |
# called when an unhandled URL scheme is clicked in 'view' | |
def handleClickedLink( url, view ): | |
# return true if the link was handled or to prevent other plugins or Colloquy from handling it | |
return False | |
# called for each incoming message, the message is mutable | |
def processIncomingMessage( message, view ): | |
global activeIcon | |
if activeIcon != 0: | |
statusItem.setImage_(activeIcon) | |
# called for each outgoing message, the message is mutable | |
def processOutgoingMessage( message, view ): | |
pass | |
# called when a member joins 'room' | |
def memberJoined( member, room ): | |
pass | |
# called when a member parts 'room' | |
def memberParted( member, room, reason ): | |
pass | |
# called when a member is kicked from 'room' for 'reason' | |
def memberKicked( member, room, by, reason ): | |
pass | |
# called when the local user joins 'room' | |
def joinedRoom( room ): | |
pass | |
# called when the local user is parting 'room' | |
def partingFromRoom( room ): | |
pass | |
# called when the local user is kicked from 'room' for 'reason' | |
def kickedFromRoom( room, by, reason ): | |
pass | |
# called when the topic changes in 'room' by 'user' | |
def topicChanged( topic, room, user ): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment