r6867 - in bigboard/trunk: . bigboard/stocks/apps bigboard/stocks/search



Author: hp
Date: 2007-11-02 15:00:08 -0500 (Fri, 02 Nov 2007)
New Revision: 6867

Modified:
   bigboard/trunk/bigboard/stocks/apps/AppsStock.py
   bigboard/trunk/bigboard/stocks/apps/apps.py
   bigboard/trunk/bigboard/stocks/search/SearchStock.py
   bigboard/trunk/main.py
Log:
unpopout sidebar when launching an app or choosing a search result

Modified: bigboard/trunk/bigboard/stocks/apps/AppsStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/AppsStock.py	2007-11-02 19:31:27 UTC (rev 6866)
+++ bigboard/trunk/bigboard/stocks/apps/AppsStock.py	2007-11-02 20:00:08 UTC (rev 6867)
@@ -83,6 +83,7 @@
         self.__repo.connect('my-pinned-apps-changed', self.__on_my_pinned_apps_changed)
         self.__repo.connect('my-top-apps-changed', self.__on_my_top_apps_changed)
         self.__repo.connect('global-top-apps-changed', self.__on_global_top_apps_changed)
+        self.__repo.connect('app-launched', self.__on_app_launched)
 
         self.__sync()
 
@@ -118,6 +119,9 @@
         _logger.debug("app size changed")  
         self.__sync()
 
+    def __on_app_launched(self, repo, app):
+        self._panel.action_taken()
+
     def __on_more_button(self):
         _logger.debug("more!")
         if self.__app_browser is None:

Modified: bigboard/trunk/bigboard/stocks/apps/apps.py
===================================================================
--- bigboard/trunk/bigboard/stocks/apps/apps.py	2007-11-02 19:31:27 UTC (rev 6866)
+++ bigboard/trunk/bigboard/stocks/apps/apps.py	2007-11-02 20:00:08 UTC (rev 6867)
@@ -161,12 +161,16 @@
     def recheck_installed(self):
         old_installed = self.__desktop_entry is not None
         self.__desktop_entry = self.__lookup_desktop()
-            
-    def launch(self):
+
+    ## called only by apps repo
+    def _do_launch(self):
         if self.__desktop_entry:
             self.__desktop_entry.launch([])
         else:
             global_mugshot.get_mugshot().install_application(self.__resource.id, self.__resource.packageNames, self.__resource.desktopNames)            
+    
+    def launch(self):
+        get_apps_repo().launch(self)        
 
     def __str__(self):
         return "<App:%s,local:%d,usageCount:%s>" % (self.get_name(), self.is_local(), self.get_usage_count())
@@ -256,7 +260,8 @@
         "my-pinned-apps-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
         "my-top-apps-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
         "global-top-apps-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
-        "local-apps-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
+        "local-apps-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,)),
+        "app-launched" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_PYOBJECT,))
         }
     def __init__(self, *args, **kwargs):
         super(AppsRepo, self).__init__(*args, **kwargs)        
@@ -440,6 +445,10 @@
             
         self.emit("local-apps-changed", self.__local_apps.itervalues())
 
+    def launch(self, app):
+        app._do_launch()
+        self.emit('app-launched', app)
+
     def get_app_for_resource(self, app_resource):
         if not self.__ddm_apps.has_key(app_resource.id):
             ad = apps_directory.get_app_directory()

Modified: bigboard/trunk/bigboard/stocks/search/SearchStock.py
===================================================================
--- bigboard/trunk/bigboard/stocks/search/SearchStock.py	2007-11-02 19:31:27 UTC (rev 6866)
+++ bigboard/trunk/bigboard/stocks/search/SearchStock.py	2007-11-02 20:00:08 UTC (rev 6867)
@@ -46,8 +46,12 @@
         else:
             _logger.debug("ignoring old async set_query")
 
-class ResultsView(search.SearchConsumer):
-
+class ResultsView(gobject.GObject, search.SearchConsumer):
+    __gsignals__ = {
+        ## this signal is used to autohide the sidebar when a result is selected
+        "match-selected" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+    }
+    
     RESULT_TYPE_MAX = 4
     
     def __init__(self, *args, **kwargs):
@@ -123,6 +127,7 @@
         iter = model.get_iter(path)
         result = model.get_value(iter, 0)
         if result:
+            self.emit('match-selected')
             result._on_activated()
             
     def __update_showing(self):
@@ -262,6 +267,11 @@
         logging.error("failed to load image for '%s': %s", url, exc)  #FIXME queue retry                
 
 class SearchEntry(gtk.Entry):
+    __gsignals__ = {
+        ## this signal is used to autohide the sidebar when a result is selected
+        "match-selected" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+    }
+    
     def __init__(self, *args, **kwargs):
         super(SearchEntry,self).__init__(*args, **kwargs)
 
@@ -276,6 +286,8 @@
         self.__results_window.add(vbox)
         
         self.__results_view = ResultsView()
+        self.__results_view.connect('match-selected', lambda obj: self.emit('match-selected'))
+        
         treeview = self.__results_view.get_widget()
         frame = gtk.Frame()
         frame.add(treeview)
@@ -368,9 +380,7 @@
     
 class SearchStock(Stock):
     """Search.  It's what's for dinner."""
-    __gsignals__ = {
-        "match-selected" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
-    }    
+
     def __init__(self, *args, **kwargs):
         super(SearchStock,self).__init__(*args, **kwargs)
         
@@ -381,6 +391,9 @@
         self.__box.append(self.__widget)
         self.__empty_box = CanvasVBox()
 
+        ## notify the main panel when a search result is chosen
+        self.__entry.connect('match-selected', lambda obj: self._panel.action_taken())
+
     def get_content(self, size):
         return size == self.SIZE_BULL and self.__box or self.__empty_box
 

Modified: bigboard/trunk/main.py
===================================================================
--- bigboard/trunk/main.py	2007-11-02 19:31:27 UTC (rev 6866)
+++ bigboard/trunk/main.py	2007-11-02 20:00:08 UTC (rev 6867)
@@ -443,7 +443,6 @@
         gobject.idle_add(self.__sync_listing)
         
         self.__self_stock.connect('info-loaded', lambda *args: self.__initial_appearance())
-        self.__search_stock.connect('match-selected', self.__on_search_match_selected)
 
         ## visible=True means we never hide, visible=False means we "autohide" and popout
         ## when the hotkey or applet is used
@@ -472,8 +471,8 @@
     @log_except()
     def __idle_show_we_exist(self):
         _logger.debug("showing we exist")
-        self.__handle_activation()
-        self.__handle_deactivation()
+        self.__enter_popped_out_state()
+        self.__leave_popped_out_state()
 
     @log_except()
     def __on_focus(self):
@@ -521,14 +520,12 @@
         
     def __get_size(self):
         return Stock.SIZE_BULL
-    
+
+    ## If the user performs an action such as launching an app,
+    ## that should close a popped-out sidebar, call this
     def action_taken(self):
-        _logger.debug("action taken")           
-        self.__handle_deactivation(immediate=True)
-    
-    @log_except()
-    def __on_search_match_selected(self, search):
-        self.action_taken()        
+        _logger.debug("action taken")
+        self.__leave_popped_out_state(immediate=True)
         
     @log_except()
     def _toggle_size(self):
@@ -571,7 +568,7 @@
     ## is always popped out, i.e. self.__popped_out should be True always.
 
     ## Shows the sidebar
-    def __handle_activation(self):
+    def __enter_popped_out_state(self):
         if not self.__popped_out:
             _logger.debug("popping out")
             self._dw.show()
@@ -582,11 +579,11 @@
             self.EmitPoppedOutChanged()
 
     ## Hides the sidebar, possibly after a delay, only if visible mode is False
-    def __handle_deactivation(self, immediate=False):
+    def __leave_popped_out_state(self, immediate=False):
         vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
         if self.__popped_out and not vis and self.__autohide_id == 0:
             _logger.debug("enqueued autohide timeout")            
-            self.__autohide_id = gobject.timeout_add(immediate and 1 or 1500, self.__idle_do_hide)        
+            self.__autohide_id = gobject.timeout_add(immediate and 1 or 1500, self.__idle_do_hide) 
             
     @log_except()
     def __idle_do_hide(self):
@@ -613,9 +610,9 @@
     def __sync_visible_mode(self, *args):
         vis = gconf.client_get_default().get_bool(GCONF_PREFIX + 'visible')
         if vis and not self.__popped_out:
-            self.__handle_activation()
+            self.__enter_popped_out_state()
         elif not vis:
-            self.__handle_deactivation()
+            self.__leave_popped_out_state()
             if not gconf.client_get_default().get_bool(GCONF_PREFIX + 'first_time_minimize_seen'):
                 dialog = FirstTimeMinimizeDialog(True)
                 dialog.show_all()
@@ -629,7 +626,7 @@
     def __do_popout(self, xtimestamp):
         if not self.__popped_out:
             _logger.debug("popout requested")
-            self.__handle_activation()
+            self.__enter_popped_out_state()
 
         ## focus even if we were already shown
         self._dw.present_with_time(xtimestamp)
@@ -638,8 +635,8 @@
     ## Hides the sidebar, only if not in visible mode
     def __do_unpopout(self):
         if self.__popped_out:
-            _logger.debug("unpopout requested")            
-            self.__handle_deactivation(True)
+            _logger.debug("unpopout requested")
+            self.__leave_popped_out_state(True)
 
     def toggle_popout(self, xtimestamp):
         if self.__popped_out:



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