deskbar-applet r1827 - in trunk: . deskbar/ui deskbar/ui/cuemiac



Author: sebp
Date: Thu Jan 10 22:22:02 2008
New Revision: 1827
URL: http://svn.gnome.org/viewvc/deskbar-applet?rev=1827&view=rev

Log:
Re-added LingeringSelectionWindow for CuemiacTreeView and CuemiacActionsTreeView

Added:
   trunk/deskbar/ui/cuemiac/LingeringSelectionWindow.py
Modified:
   trunk/ChangeLog
   trunk/deskbar/ui/CuemiacWindowView.py
   trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py
   trunk/deskbar/ui/cuemiac/CuemiacTreeView.py
   trunk/deskbar/ui/cuemiac/Makefile.am

Modified: trunk/deskbar/ui/CuemiacWindowView.py
==============================================================================
--- trunk/deskbar/ui/CuemiacWindowView.py	(original)
+++ trunk/deskbar/ui/CuemiacWindowView.py	Thu Jan 10 22:22:02 2008
@@ -11,6 +11,7 @@
 from deskbar.ui.cuemiac.CuemiacItems import CuemiacCategory
 from deskbar.ui.cuemiac.CuemiacHistory import CuemiacHistoryView
 from deskbar.ui.cuemiac.CuemiacActionsTreeView import CuemiacActionsTreeView, CuemiacActionsModel
+from deskbar.ui.cuemiac.LingeringSelectionWindow import LingeringSelectionWindow
 
 class CuemiacWindowView(deskbar.interfaces.View, gtk.Window):
     """
@@ -104,6 +105,8 @@
         self.cview.connect ("row-collapsed", self._controller.on_category_collapsed, self.treeview_model)
         self.cview.show()
         
+        LingeringSelectionWindow (self.cview)
+        
         self.scrolled_results = gtk.ScrolledWindow ()
         self.scrolled_results.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
         self.scrolled_results.set_shadow_type(gtk.SHADOW_IN)
@@ -119,6 +122,8 @@
         self.aview.connect ("go-back", self.__on_go_back)
         self.aview.show()
         
+        LingeringSelectionWindow (self.aview)
+        
         self.scrolled_actions = gtk.ScrolledWindow()
         self.scrolled_actions.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
         self.scrolled_actions.set_shadow_type(gtk.SHADOW_IN)
@@ -144,6 +149,9 @@
         self.results_box.pack_start(self.scrolled_results)
         self.results_box.pack_start(self.actions_box)
         self.vbox_main.pack_start(self.results_box)
+   
+    def __on_row_act(self, view, path, column):
+        print "======================"
     
     def clear_all(self):
         deskbar.interfaces.View.clear_all(self)

Modified: trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py
==============================================================================
--- trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py	(original)
+++ trunk/deskbar/ui/cuemiac/CuemiacActionsTreeView.py	Thu Jan 10 22:22:02 2008
@@ -36,12 +36,12 @@
         cell_icon.set_property("xpad", 10)
         cell_text = gtk.CellRendererText()
         cell_text.set_property ("ellipsize", pango.ELLIPSIZE_END)
-        col = gtk.TreeViewColumn("Actions")
-        col.pack_start(cell_icon, expand=False)
-        col.add_attribute(cell_icon, "pixbuf", model.ICON_COL)
-        col.pack_start(cell_text)
-        col.add_attribute(cell_text, "markup", model.LABEL_COL)
-        self.append_column(col)
+        self._column = gtk.TreeViewColumn("Actions")
+        self._column.pack_start(cell_icon, expand=False)
+        self._column.add_attribute(cell_icon, "pixbuf", model.ICON_COL)
+        self._column.pack_start(cell_text)
+        self._column.add_attribute(cell_text, "markup", model.LABEL_COL)
+        self.append_column(self._column)
         
     def __on_button_press_event (self, treeview, event):
         path_ctx = self.get_path_at_pos (int(event.x), int(event.y))
@@ -51,6 +51,7 @@
             action = model[model.get_iter(path)][model.ACTION_COL]
             qstring = model[model.get_iter(path)][model.QUERY_COL]
             
+            self.emit("row-activated", path, self._column)
             self.emit ("action-selected", qstring, action, event)
             
     def __on_key_press_event(self, treeview, event):

Modified: trunk/deskbar/ui/cuemiac/CuemiacTreeView.py
==============================================================================
--- trunk/deskbar/ui/cuemiac/CuemiacTreeView.py	(original)
+++ trunk/deskbar/ui/cuemiac/CuemiacTreeView.py	Thu Jan 10 22:22:02 2008
@@ -262,12 +262,12 @@
         hit_title.connect("do-action-activated", self.__on_do_action_activated)
         hit_title.set_property ("ellipsize", pango.ELLIPSIZE_END)
        
-        hits = gtk.TreeViewColumn ("Hits")
-        hits.pack_start (icon, expand=False)
-        hits.pack_start (hit_title)
-        hits.set_cell_data_func(hit_title, self.__get_match_title_for_cell)            
-        hits.set_cell_data_func(icon, self.__get_match_icon_for_cell)
-        self.append_column (hits)
+        self._hits_column = gtk.TreeViewColumn ("Hits")
+        self._hits_column.pack_start (icon, expand=False)
+        self._hits_column.pack_start (hit_title)
+        self._hits_column.set_cell_data_func(hit_title, self.__get_match_title_for_cell)            
+        self._hits_column.set_cell_data_func(icon, self.__get_match_icon_for_cell)
+        self.append_column (self._hits_column)
         
         #self.set_reorderable(True)
         # FIXME: Make it so that categories *only* can be reordered by dragging
@@ -411,6 +411,8 @@
         match = model[iter][model.MATCHES]
         qstring = model[iter][model.QUERY]
         
+        # Used by LingeringSelectionWindow
+        self.emit("row-activated", path, self._hits_column)
         self.emit("do-default-action", qstring, match, event)
 
     def __on_activated (self, treeview, path, col, event=None):

Added: trunk/deskbar/ui/cuemiac/LingeringSelectionWindow.py
==============================================================================
--- (empty file)
+++ trunk/deskbar/ui/cuemiac/LingeringSelectionWindow.py	Thu Jan 10 22:22:02 2008
@@ -0,0 +1,64 @@
+import gtk, gobject
+
+class LingeringSelectionWindow (gtk.Window):
+	"""
+	Leave an imprint on the screen of the selected row in a treeview
+	when it is activated.
+	This is mainly used when the window containing the treeview is
+	hidden on the same activation.
+	"""
+	def __init__ (self, view):
+		"""
+		Just create the LingeringSelectionWindow passing the treeview
+		to manage in the constructor and everything will be taken care of.
+		"""
+		gtk.Window.__init__ (self, gtk.WINDOW_POPUP)
+		
+		self.linger_time = 1000 # Linger for one second
+		
+		self.set_focus_on_map (False)
+				
+		view.connect ("row-activated", self._on_view_activated)
+		
+	def _on_view_activated (self, view, path, column):
+		# Check if this row has children, if it does
+		# do nothing
+		model = view.get_model()
+		if model.iter_has_child (model.get_iter(path)) :
+			"linger block"
+			return
+			
+		pixmap = view.create_row_drag_icon (path)
+		if pixmap == None:
+			self.hide()
+			return
+			
+		image = gtk.Image()
+		image.set_from_pixmap (pixmap, None)
+		
+		if self.get_child() :
+			self.remove (self.get_child())
+			
+		self.add (image)
+		self._update_position (view, path, column)
+		self._linger ()
+		
+	def _update_position (self, view, path, column):
+		"""
+		Move the window to the activated paths position
+		"""
+		ox, oy = view.window.get_origin ()
+		area = view.get_background_area (path, column)
+		x, y = view.tree_to_widget_coords (area.x, area.y)
+		self.move (x + ox, y + oy)
+		self.resize (area.width, area.height)
+		
+	def _linger (self):
+		"""
+		Display for a short while
+		"""
+		self.show_all ()
+		gobject.timeout_add (self.linger_time, self.hide)
+		
+		
+			

Modified: trunk/deskbar/ui/cuemiac/Makefile.am
==============================================================================
--- trunk/deskbar/ui/cuemiac/Makefile.am	(original)
+++ trunk/deskbar/ui/cuemiac/Makefile.am	Thu Jan 10 22:22:02 2008
@@ -7,4 +7,5 @@
 	CuemiacHistory.py \
 	CuemiacItems.py \
 	CuemiacModel.py \
-	CuemiacTreeView.py
\ No newline at end of file
+	CuemiacTreeView.py \
+	LingeringSelectionWindow.py
\ No newline at end of file



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