Fix #311 add tooltips to statusbar items

This commit is contained in:
Andrew Resch 2008-07-02 01:29:04 +00:00
parent 5f1de26f58
commit 34354a25d5
1 changed files with 20 additions and 14 deletions

View File

@ -101,6 +101,7 @@ class StatusBar(component.Component):
component.Component.__init__(self, "StatusBar", interval=3000) component.Component.__init__(self, "StatusBar", interval=3000)
self.window = component.get("MainWindow") self.window = component.get("MainWindow")
self.statusbar = self.window.main_glade.get_widget("statusbar") self.statusbar = self.window.main_glade.get_widget("statusbar")
self.tooltips = gtk.Tooltips()
self.config = ConfigManager("gtkui.conf") self.config = ConfigManager("gtkui.conf")
# Status variables that are updated via callback # Status variables that are updated via callback
@ -138,23 +139,26 @@ class StatusBar(component.Component):
def start(self): def start(self):
# Add in images and labels # Add in images and labels
self.remove_item(self.not_connected_item) self.remove_item(self.not_connected_item)
self.connections_item = StatusBarItem(
self.connections_item = self.add_item(
stock=gtk.STOCK_NETWORK, stock=gtk.STOCK_NETWORK,
callback=self._on_connection_item_clicked) callback=self._on_connection_item_clicked,
self.hbox.pack_start( tooltip="Connections")
self.connections_item.get_eventbox(), expand=False, fill=False)
self.download_item = StatusBarItem( self.download_item = self.add_item(
image=deluge.common.get_pixmap("downloading16.png"), image=deluge.common.get_pixmap("downloading16.png"),
callback=self._on_download_item_clicked) callback=self._on_download_item_clicked,
self.hbox.pack_start( tooltip="Download Speed")
self.download_item.get_eventbox(), expand=False, fill=False)
self.upload_item = StatusBarItem( self.upload_item = self.add_item(
image=deluge.common.get_pixmap("seeding16.png"), image=deluge.common.get_pixmap("seeding16.png"),
callback=self._on_upload_item_clicked) callback=self._on_upload_item_clicked,
self.hbox.pack_start( tooltip="Upload Speed")
self.upload_item.get_eventbox(), expand=False, fill=False)
self.dht_item = StatusBarItem( self.dht_item = StatusBarItem(
image=deluge.common.get_pixmap("dht16.png")) image=deluge.common.get_pixmap("dht16.png"))
self.tooltips.set_tip(self.dht_item.get_eventbox(), "DHT Nodes")
self.health_item = self.add_item( self.health_item = self.add_item(
stock=gtk.STOCK_DIALOG_ERROR, stock=gtk.STOCK_DIALOG_ERROR,
text=_("No Incoming Connections!"), text=_("No Incoming Connections!"),
@ -198,11 +202,13 @@ class StatusBar(component.Component):
self.hbox.pack_start( self.hbox.pack_start(
self.not_connected_item.get_eventbox(), expand=False, fill=False) self.not_connected_item.get_eventbox(), expand=False, fill=False)
def add_item(self, image=None, stock=None, text=None, callback=None): def add_item(self, image=None, stock=None, text=None, callback=None, tooltip=None):
"""Adds an item to the status bar""" """Adds an item to the status bar"""
# The return tuple.. we return whatever widgets we add # The return tuple.. we return whatever widgets we add
item = StatusBarItem(image, stock, text, callback) item = StatusBarItem(image, stock, text, callback)
self.hbox.pack_start(item.get_eventbox(), expand=False, fill=False) self.hbox.pack_start(item.get_eventbox(), expand=False, fill=False)
if tooltip:
self.tooltips.set_tip(item.get_eventbox(), tooltip)
return item return item
def remove_item(self, item): def remove_item(self, item):