deskbar-applet r2334 - in trunk: . deskbar/core deskbar/ui/cuemiac



Author: sebp
Date: Sun Aug 17 16:38:32 2008
New Revision: 2334
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=2334&view=rev

Log:
2008-08-17  Sebastian PÃlsterl  <sebp cvs gnome org>

    * deskbar/core/DeskbarHistory.py:
    Renamed old remove method to remove_index.
    Added remove_and_save method.
    Overridden gtk.ListStore.remove that history is
    marked as empty when last item has been removed.
    
    * deskbar/ui/cuemiac/CuemiacAlignedWindow.py:
    Added adjust_popup_size method
    
    * deskbar/ui/cuemiac/CuemiacHistory.py:
    Remove selected item when Delete button is pressed


Modified:
   trunk/ChangeLog
   trunk/deskbar/core/DeskbarHistory.py
   trunk/deskbar/ui/cuemiac/CuemiacAlignedWindow.py
   trunk/deskbar/ui/cuemiac/CuemiacHistory.py

Modified: trunk/deskbar/core/DeskbarHistory.py
==============================================================================
--- trunk/deskbar/core/DeskbarHistory.py	(original)
+++ trunk/deskbar/core/DeskbarHistory.py	Sun Aug 17 16:38:32 2008
@@ -42,7 +42,7 @@
     
     __gsignals__ = {
         "cleared" :        (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
-        "action-added" :   (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [str, gobject.TYPE_PYOBJECT]),
+        "action-added" :   (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [str, gobject.TYPE_PYOBJECT]), 
     }
     __instance = None
     (COL_TIME, COL_TEXT, COL_ACTION) = range(3)
@@ -190,11 +190,11 @@
         for idx, val in enumerate(self):
             htime, htext, haction = val
             if isinstance(haction, EmptyHistoryAction):
-                self.remove (idx)
+                self.remove_index (idx)
                 continue
                 
             if (action.get_hash() == haction.get_hash() and action.__class__.__name__ == haction.__class__.__name__):
-                self.remove (idx)
+                self.remove_index (idx)
                 break
                 
         timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
@@ -204,12 +204,21 @@
         self.reset()
         self.save()
         
-    def remove(self, index):
-        gtk.ListStore.remove (self, self.get_iter_from_string (str(index)))
+    def remove(self, aiter):
+        gtk.ListStore.remove(self, aiter)
+        if len(self) == 0:
+            self.clear()
+        
+    def remove_index(self, index):
+        self.remove (self.get_iter_from_string (str(index)))
+    
+    def remove_and_save(self, aiter):
+        self.remove(aiter)
+        self.save()
     
     def __remove_too_many(self):
         while len(self) > self.__max_history_items:
-            self.remove (len(self) - 1)
+            self.remove_index (len(self) - 1)
     
     def up(self):
         """

Modified: trunk/deskbar/ui/cuemiac/CuemiacAlignedWindow.py
==============================================================================
--- trunk/deskbar/ui/cuemiac/CuemiacAlignedWindow.py	(original)
+++ trunk/deskbar/ui/cuemiac/CuemiacAlignedWindow.py	Sun Aug 17 16:38:32 2008
@@ -45,6 +45,15 @@
         # Update position, cause the size might have changed for the window
         self.update_position ()
     
+    def adjust_popup_size(self):
+         w, h = self.widgetToAlignWith.size_request ()
+         
+         # add border width
+         w += 1
+         h += 1
+         
+         self.resize(w, h)
+    
     def update_position (self):
         """
         Calculates the position and moves the window to it.

Modified: trunk/deskbar/ui/cuemiac/CuemiacHistory.py
==============================================================================
--- trunk/deskbar/ui/cuemiac/CuemiacHistory.py	(original)
+++ trunk/deskbar/ui/cuemiac/CuemiacHistory.py	Sun Aug 17 16:38:32 2008
@@ -17,6 +17,7 @@
         
         self.connect ("row-activated", lambda w,p,c: self.__on_activated())
         self.connect ("button-press-event", lambda w,e: self.__on_activated())
+        self.connect ("key-press-event", self.__on_key_press_event)
         self.set_property ("headers-visible", False)
         self.set_property ("hover-selection", True)
         
@@ -68,6 +69,13 @@
             
         return False
     
+    def __on_key_press_event(self, widget, event): 
+        if event.keyval == gtk.keysyms.Delete:
+            model, aiter = self.get_selection().get_selected()
+            if aiter != None:
+                model.remove_and_save(aiter)
+                return True
+    
 class CuemiacHistoryPopup (CuemiacAlignedWindow) :
     
     def __init__ (self, widget_to_align_with, applet, history_view):
@@ -81,12 +89,17 @@
         self.applet = applet
         self.window_group = None
         self.view = history_view
-            
-        self.add (self.view)
+        
         self.connect('enter-notify-event', self.on_view_enter)
         self.connect('motion-notify-event', self.on_view_motion)
         self.connect('button-press-event', self.on_view_button_press)
         self.connect ("key-press-event", self.on_key_press_event)
+            
+        self.add (self.view)
+        self.view.get_model().connect("row-deleted", self.on_row_deleted)
+     
+    def on_row_deleted(self, model, path):
+        self.adjust_popup_size()
      
     def on_view_button_press (self, widget, event):
         self.popdown()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]