deskbar-applet r2253 - in trunk: . deskbar/core deskbar/ui
- From: sebp svn gnome org
- To: svn-commits-list gnome org
- Subject: deskbar-applet r2253 - in trunk: . deskbar/core deskbar/ui
- Date: Mon, 21 Jul 2008 16:52:02 +0000 (UTC)
Author: sebp
Date: Mon Jul 21 16:52:02 2008
New Revision: 2253
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2253&view=rev
Log:
2008-07-21 Sebastian PÃlsterl <sebp cvs gnome org>
* deskbar/core/DeskbarHistory.py:
Added action-added signal.
* deskbar/ui/DeskbarStatusIcon.py:
Added history submenu.
Modified:
trunk/ChangeLog
trunk/deskbar/core/DeskbarHistory.py
trunk/deskbar/ui/DeskbarStatusIcon.py
Modified: trunk/deskbar/core/DeskbarHistory.py
==============================================================================
--- trunk/deskbar/core/DeskbarHistory.py (original)
+++ trunk/deskbar/core/DeskbarHistory.py Mon Jul 21 16:52:02 2008
@@ -41,7 +41,8 @@
"""
__gsignals__ = {
- "cleared" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ "cleared" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ "action-added" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [str, gobject.TYPE_PYOBJECT]),
}
__instance = None
(COL_TIME, COL_TEXT, COL_ACTION) = range(3)
@@ -106,9 +107,9 @@
Clear the history
"""
gtk.ListStore.clear(self)
- self.append("", "", EmptyHistoryAction())
self._index = -1
self.emit("cleared")
+ self.append("", "", EmptyHistoryAction())
def load (self):
"""
@@ -159,6 +160,7 @@
"""
*Do not* use this method. Always use L{add}.
"""
+ self.emit('action-added', text, action)
self.append_method (self, (timestamp, text, action))
def prepend (self, timestamp, text, action):
Modified: trunk/deskbar/ui/DeskbarStatusIcon.py
==============================================================================
--- trunk/deskbar/ui/DeskbarStatusIcon.py (original)
+++ trunk/deskbar/ui/DeskbarStatusIcon.py Mon Jul 21 16:52:02 2008
@@ -1,4 +1,6 @@
from deskbar.ui.AbstractCuemiacDeskbarIcon import AbstractCuemiacDeskbarIcon
+from deskbar.core.Categories import CATEGORIES
+from deskbar.core.DeskbarHistory import EmptyHistoryAction
from gettext import gettext as _
from os.path import join
import deskbar
@@ -11,7 +13,7 @@
class Item (gtk.ImageMenuItem):
- def __init__(self, label, stock_id):
+ def __init__(self, label, stock_id=None, pixbuf=None):
gtk.ImageMenuItem.__init__ (self)
self.box = gtk.HBox (False, 3)
@@ -19,11 +21,16 @@
self.add(self.box)
self.image = gtk.Image ()
- self.image.set_from_stock (stock_id, gtk.ICON_SIZE_MENU)
+ if stock_id != None:
+ self.image.set_from_stock (stock_id, gtk.ICON_SIZE_MENU)
+ elif isinstance(pixbuf, gtk.gdk.Pixbuf):
+ self.image.set_from_pixbuf(pixbuf)
+
self.image.show()
self.box.pack_start (self.image, False, False, 0)
- self.label = gtk.Label (label)
+ self.label = gtk.Label ()
+ self.label.set_markup(label)
self.label.show()
self.alignment = gtk.Alignment ()
@@ -31,9 +38,50 @@
self.alignment.show()
self.box.pack_start (self.alignment)
+ class HistoryMenu (gtk.Menu):
+
+ def __init__(self, controller):
+ gtk.Menu.__init__(self)
+ self.__controller = controller
+ self.__is_empty = True
+
+ def add_action(self, text, action):
+ if isinstance(action, EmptyHistoryAction):
+ menuItem = DeskbarPopupMenu.Item (_("<i>Empty</i>"),
+ pixbuf=CATEGORIES["history"]["icon"])
+ self.__is_empty = True
+ else:
+ if self.__is_empty:
+ self.clear()
+
+ text = action.get_verb () % action.get_escaped_name(text)
+ # We only want to display the first line of text
+ # E.g. some beagle-live actions display a snippet in the second line
+ text = text.split("\n")[0]
+
+ menuItem = DeskbarPopupMenu.Item (text, pixbuf=action.get_pixbuf())
+ menuItem.connect ("activate", self.__controller.on_history_match_selected, text, action)
+
+ self.__is_empty = False
+
+ self.append(menuItem)
+
+ def clear(self):
+ for w in self:
+ self.remove(w)
+
def __init__(self, controller):
gtk.Menu.__init__ (self)
+ menuItem = DeskbarPopupMenu.Item (_("History"),
+ pixbuf=CATEGORIES["history"]["icon"])
+ self.append(menuItem)
+
+ self.historymenu = DeskbarPopupMenu.HistoryMenu(controller)
+ menuItem.set_submenu(self.historymenu)
+
+ self.append(gtk.SeparatorMenuItem())
+
menuItem = DeskbarPopupMenu.Item (_("Clear History"), gtk.STOCK_CLEAR)
menuItem.connect ("activate", controller.on_clear_history)
self.append(menuItem)
@@ -50,7 +98,7 @@
menuItem.connect ("activate", controller.on_show_about)
self.append(menuItem)
- self.append(gtk.MenuItem())
+ self.append(gtk.SeparatorMenuItem())
menuItem = DeskbarPopupMenu.Item (_("Quit"), gtk.STOCK_QUIT)
menuItem.connect ("activate", lambda w: gtk.main_quit())
@@ -72,8 +120,12 @@
self._setup_mvc()
self.setup_menu()
- self._on_size_changed(self, self.get_size())
+ history = self._core.get_history()
+ history.connect("action-added", lambda w, t, a: self._menu.historymenu.add_action(t, a))
+ history.connect("cleared", lambda w: self._menu.historymenu.clear())
+ self._on_size_changed(self, self.get_size())
+
def on_loaded(self, sender):
AbstractCuemiacDeskbarIcon.on_loaded (self, sender)
self.set_visible (True)
@@ -105,4 +157,5 @@
raise NotImplementedError
def setup_menu(self):
- self._menu = DeskbarPopupMenu (self._controller)
\ No newline at end of file
+ self._menu = DeskbarPopupMenu (self._controller)
+
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]