| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | import gtk |
|---|
| 17 | import systray |
|---|
| 18 | |
|---|
| 19 | from common import gajim |
|---|
| 20 | from common import helpers |
|---|
| 21 | |
|---|
| 22 | class StatusIcon(systray.Systray): |
|---|
| 23 | '''Class for the notification area icon''' |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | def __init__(self): |
|---|
| 30 | systray.Systray.__init__(self) |
|---|
| 31 | self.status_icon = None |
|---|
| 32 | |
|---|
| 33 | def show_icon(self): |
|---|
| 34 | if not self.status_icon: |
|---|
| 35 | self.status_icon = gtk.StatusIcon() |
|---|
| 36 | self.status_icon.connect('activate', self.on_status_icon_left_clicked) |
|---|
| 37 | self.status_icon.connect('popup-menu', |
|---|
| 38 | self.on_status_icon_right_clicked) |
|---|
| 39 | |
|---|
| 40 | self.set_img() |
|---|
| 41 | self.status_icon.props.visible = True |
|---|
| 42 | |
|---|
| 43 | def on_status_icon_right_clicked(self, widget, event_button, event_time): |
|---|
| 44 | self.make_menu(event_button, event_time) |
|---|
| 45 | |
|---|
| 46 | def hide_icon(self): |
|---|
| 47 | self.status_icon.props.visible = False |
|---|
| 48 | |
|---|
| 49 | def on_status_icon_left_clicked(self, widget): |
|---|
| 50 | self.on_left_click() |
|---|
| 51 | |
|---|
| 52 | def set_img(self): |
|---|
| 53 | '''apart from image, we also update tooltip text here''' |
|---|
| 54 | if not gajim.interface.systray_enabled: |
|---|
| 55 | return |
|---|
| 56 | text = helpers.get_notification_icon_tooltip_text() |
|---|
| 57 | self.status_icon.set_tooltip(text) |
|---|
| 58 | if gajim.events.get_nb_systray_events(): |
|---|
| 59 | state = 'message' |
|---|
| 60 | self.status_icon.props.blinking = True |
|---|
| 61 | else: |
|---|
| 62 | state = self.status |
|---|
| 63 | self.status_icon.props.blinking = False |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | image = gajim.interface.roster.jabber_state_images['16'][state] |
|---|
| 67 | if image.get_storage_type() == gtk.IMAGE_PIXBUF: |
|---|
| 68 | self.status_icon.props.pixbuf = image.get_pixbuf() |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | |
|---|