def _create_actions_view(self):
     """
     Sets:
         * self.actions_box
         * self.actions_model
         * self.aview
         * self.scrolled_actions
     """
     self.actions_box = gtk.VBox(spacing=3)
     
     self.actions_model = CuemiacActionsModel()
     self.aview = CuemiacActionsTreeView(self.actions_model)
     self.aview.connect ("action-selected", self._controller.on_action_selected)
     self.aview.connect ("go-back", self._on_go_back)
     
     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)
     self.scrolled_actions.add(self.aview)
     self.actions_box.pack_start(self.scrolled_actions)
     
     buttonbox = gtk.HButtonBox()
     buttonbox.set_layout(gtk.BUTTONBOX_START)
     buttonbox.show()
     self.actions_box.pack_start(buttonbox, False)
     
     back_button = gtk.Button(_("Back to Matches"))
     back_button.set_image( gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU) )
     back_button.set_relief(gtk.RELIEF_NONE)
     back_button.connect("clicked", self._on_go_back)
     back_button.show()
     buttonbox.pack_start(back_button, False, False, 0)
Beispiel #2
0
 def __init__(self, controller, model):
     deskbar.interfaces.View.__init__(self, controller, model)
     self._controller.register_view(self)
     self._model.connect("query-ready", lambda s,m: gobject.idle_add(self.append_matches, s, m))
     
     self.default_entry_pixbuf = deskbar.core.Utils.load_icon("deskbar-applet-panel-h.png", width=23, height=14)
     self.entry = CuemiacEntry (self.default_entry_pixbuf)
     self.entry.connect("changed", self._controller.on_query_entry_changed)
     self.entry.connect("activate", self._controller.on_query_entry_activate)
     self.entry.connect("key-press-event", self._controller.on_query_entry_key_press_event)
     self.entry.connect("focus-out-event", self._controller.on_query_focus_out)
     self.entry.show()
     
     # Results TreeView
     self.treeview_model = CuemiacModel ()
     self.treeview_model.connect("category-added", lambda w, c, p: self.cview.expand_row(p, False) )
     
     self.cview = CuemiacTreeView (self.treeview_model)
     self.cview.connect ("match-selected", self._controller.on_match_selected)
     self.cview.connect ("match-selected", self.__on_match_selected)
     self.cview.connect ("do-default-action", self._controller.on_do_default_action)
     self.cview.connect ("do-default-action", self.__on_match_selected)
     self.cview.connect_after ("cursor-changed", self._controller.on_treeview_cursor_changed)
     self.cview.show()
     
     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)
     self.scrolled_results.add(self.cview)
     self.scrolled_results.show()
     
     # Actions TreeView
     self.actions_model = CuemiacActionsModel()
     self.aview = CuemiacActionsTreeView(self.actions_model)
     self.aview.connect ("action-selected", self._controller.on_action_selected)
     self.aview.connect ("go-back", self.__on_go_back)
     self.aview.show()
     
     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)
     self.scrolled_actions.add(self.aview)
     self.scrolled_actions.show()
  
     self._window = gtk.Window(gtk.WINDOW_POPUP)
     self._window.set_size_request(480, 360)
     self._window.set_decorated(False)
     self._window.set_focus_on_map(False)
     self._window.move(210, 10)
     hbox = gtk.VBox(spacing=6)
     self._window.add(Border(hbox))
     hbox.add(self.scrolled_results)
Beispiel #3
0
    def _create_actions_view(self):
        """
        Sets:
            * self.actions_box
            * self.actions_model
            * self.aview
            * self.scrolled_actions
        """
        self.actions_box = gtk.VBox(spacing=3)

        self.actions_model = CuemiacActionsModel()
        self.aview = CuemiacActionsTreeView(self.actions_model)
        self.aview.connect("action-selected",
                           self._controller.on_action_selected)
        self.aview.connect("go-back", self._on_go_back)

        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)
        self.scrolled_actions.add(self.aview)
        self.actions_box.pack_start(self.scrolled_actions)

        buttonbox = gtk.HButtonBox()
        buttonbox.set_layout(gtk.BUTTONBOX_START)
        buttonbox.show()
        self.actions_box.pack_start(buttonbox, False)

        back_button = gtk.Button(_("Back to Matches"))
        back_button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU))
        back_button.set_relief(gtk.RELIEF_NONE)
        back_button.connect("clicked", self._on_go_back)
        back_button.show()
        buttonbox.pack_start(back_button, False, False, 0)
Beispiel #4
0
class EmbedView(deskbar.interfaces.View):
    
    def __init__(self, controller, model):
        deskbar.interfaces.View.__init__(self, controller, model)
        self._controller.register_view(self)
        self._model.connect("query-ready", lambda s,m: gobject.idle_add(self.append_matches, s, m))
        
        self.default_entry_pixbuf = deskbar.core.Utils.load_icon("deskbar-applet-panel-h.png", width=23, height=14)
        self.entry = CuemiacEntry (self.default_entry_pixbuf)
        self.entry.connect("changed", self._controller.on_query_entry_changed)
        self.entry.connect("activate", self._controller.on_query_entry_activate)
        self.entry.connect("key-press-event", self._controller.on_query_entry_key_press_event)
        self.entry.connect("focus-out-event", self._controller.on_query_focus_out)
        self.entry.show()
        
        # Results TreeView
        self.treeview_model = CuemiacModel ()
        self.treeview_model.connect("category-added", lambda w, c, p: self.cview.expand_row(p, False) )
        
        self.cview = CuemiacTreeView (self.treeview_model)
        self.cview.connect ("match-selected", self._controller.on_match_selected)
        self.cview.connect ("match-selected", self.__on_match_selected)
        self.cview.connect ("do-default-action", self._controller.on_do_default_action)
        self.cview.connect ("do-default-action", self.__on_match_selected)
        self.cview.connect_after ("cursor-changed", self._controller.on_treeview_cursor_changed)
        self.cview.show()
        
        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)
        self.scrolled_results.add(self.cview)
        self.scrolled_results.show()
        
        # Actions TreeView
        self.actions_model = CuemiacActionsModel()
        self.aview = CuemiacActionsTreeView(self.actions_model)
        self.aview.connect ("action-selected", self._controller.on_action_selected)
        self.aview.connect ("go-back", self.__on_go_back)
        self.aview.show()
        
        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)
        self.scrolled_actions.add(self.aview)
        self.scrolled_actions.show()
     
        self._window = gtk.Window(gtk.WINDOW_POPUP)
        self._window.set_size_request(480, 360)
        self._window.set_decorated(False)
        self._window.set_focus_on_map(False)
        self._window.move(210, 10)
        hbox = gtk.VBox(spacing=6)
        self._window.add(Border(hbox))
        hbox.add(self.scrolled_results)
        #hbox.add(self.scrolled_actions)

    def __have_cview_selection(self):
        model, iter = self.cview.get_selection().get_selected()
        if iter == None:
            return False
        
        match = model[iter][model.MATCHES]
        if match.__class__ == CuemiacCategory:
            return False

        return True

    def __send_synthetic_focus_in(self):
        focus_in = gtk.gdk.Event(gtk.gdk.FOCUS_CHANGE)
        focus_in.window = self._window.window
        focus_in.in_ = True
        self._window.event(focus_in)

    def focus_results_from_top(self, event):
        self.cview.grab_focus()
        self.__send_synthetic_focus_in()
        self.cview.event(event)
        
    def focus_results_from_bottom(self, event):
        self.cview.grab_focus()
        self.__send_synthetic_focus_in()
        self.cview.event(event)
        
    def forward_key_to_results_tree(self, event):
        _logger.debug("Sending synthetic event to cview")
        self.cview.event(event)
        
    def clear_results(self):
        self.treeview_model.clear()
        self._window.hide()
        
    def clear_actions(self):
        self.actions_model.clear()
    
    def clear_query(self):
        self.entry.set_text("")
        self.update_entry_icon()
     
    def show_results(self):
        self._window.show_all()
    
    def get_entry(self):
        return self.entry
   
    def receive_focus(self, time):
        self.entry.grab_focus()
       
    def display_actions(self, actions, qstring):
        self.actions_model.clear()
        self.actions_model.add_actions(actions, qstring)
        self.aview.grab_focus()
    
    def append_matches (self, sender, matches):
        """
        We suppose that the results belong to the text
        that is currently in the entry
        """
        self.treeview_model.append (matches, self.entry.get_text())
        self.update_entry_icon()
        
    def update_entry_icon (self, icon=None):
        
        if icon == None:
            icon = self.default_entry_pixbuf
            if not (self.cview.get_toplevel().flags() & gtk.MAPPED):
                # The view is hidden, just show default icon
                self.entry.set_icon (icon)
                return
                
            path, column = self.cview.get_cursor ()
        
            if path != None:
                match = self.treeview_model[self.treeview_model.get_iter(path)][self.treeview_model.MATCHES]
                if not isinstance(match, CuemiacCategory):
                    icon=match.get_icon()
                
        self.entry.set_icon (icon)
         
    def __on_go_back(self, treeview):
        self.cview.grab_focus()
        return False

    def __on_match_selected(self, *args):
        self._window.hide()
class AbstractCuemiacView (deskbar.interfaces.View):
    """
    An abstract base class for all cuemiac derived UIs
    
    It creates and packs all necessary widget and connects
    the signals correctly. L{self.vbox_main} contains the actual
    UI.
    
    You still have to implement methods from L{deskbar.interfaces.View}:
        * get_toplevel
        * receive_focus
    """
    
    VBOX_MAIN_SPACING = 12
    VBOX_MAIN_BORDER_WIDTH = 6
    
    def __init__(self, controller, model):
        deskbar.interfaces.View.__init__(self, controller, model)
        self._do_clear = True
        
        self._model.connect("query-ready", lambda s,m: glib.idle_add(self.append_matches, s, m))
        
        # VBox 
        self._create_vbox_main()
        self.vbox_main.show()
        
        self._create_header()
        self.header.show()
        
        # Results TreeView
        self._create_results_treeview()
        self.cview.show()
        self.scrolled_results.show()
        
        # Actions TreeView
        self._create_actions_view()
        self.aview.show()
        self.scrolled_actions.show()
        
    def _create_vbox_main(self):
        """
        Sets self.vbox_main
        """
        self.vbox_main = gtk.VBox(spacing=self.VBOX_MAIN_SPACING)
        self.vbox_main.set_border_width(self.VBOX_MAIN_BORDER_WIDTH)
        
    def _create_cuemiac_entry(self):
        """
        Sets self.entry
        """
        # Search entry
        self.default_entry_pixbuf = deskbar.core.Utils.load_icon("deskbar-applet-panel-h.png", width=23, height=14)
        self.entry = CuemiacEntry (self.default_entry_pixbuf)
        self.entry.connect("changed", self._controller.on_query_entry_changed)
        # Connect this before "go-next/previous" to parse history
        self.entry.connect("key-press-event", self._controller.on_query_entry_key_press_event)
        self.entry.connect("activate", self._controller.on_query_entry_activate)
        self.entry.connect("go-next", lambda e: self._focus_matches_if_visible("top"))
        self.entry.connect("go-previous", lambda e: self._focus_matches_if_visible("bottom"))
        
    def _create_header(self):
        """
        Sets self.entry and self.header
        """
#        self.completion = gtk.EntryCompletion()
#        self.completion.set_model(self._model.get_history())
#        self.completion.set_inline_completion(True)
#        self.completion.set_popup_completion(False)
#        self.completion.set_text_column(1)
        
        self._create_cuemiac_entry()
#        self.entry.get_entry().set_completion(self.completion)
        self.entry.show()
        
        self.header = CuemiacHeader ( self.entry )
    
    def _create_results_treeview(self):
        """
        Sets:
            * self.treeview_model
            * self.cview
            * self.scrolled_results
        """
        self.treeview_model = CuemiacModel ()
        self.treeview_model.connect("category-added", self._controller.on_category_added)
        
        self.cview = CuemiacTreeView (self.treeview_model)
        #self.cview.connect ("key-press-event", self._on_cview_key_press)
        self.cview.connect ("match-selected", self._controller.on_match_selected)
        self.cview.connect ("do-default-action", self._controller.on_do_default_action)
        self.cview.connect ("pressed-up-at-top", lambda s: self.entry.grab_focus())
        self.cview.connect ("pressed-down-at-bottom", lambda s: self.entry.grab_focus())
        self.cview.connect_after ("cursor-changed", self._controller.on_treeview_cursor_changed)
        self.cview.connect ("row-expanded", self._controller.on_category_expanded, self.treeview_model)
        self.cview.connect ("row-collapsed", self._controller.on_category_collapsed, self.treeview_model)
        
        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)
        self.scrolled_results.add(self.cview)
        
    def _create_actions_view(self):
        """
        Sets:
            * self.actions_box
            * self.actions_model
            * self.aview
            * self.scrolled_actions
        """
        self.actions_box = gtk.VBox(spacing=3)
        
        self.actions_model = CuemiacActionsModel()
        self.aview = CuemiacActionsTreeView(self.actions_model)
        self.aview.connect ("action-selected", self._controller.on_action_selected)
        self.aview.connect ("go-back", self._on_go_back)
        
        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)
        self.scrolled_actions.add(self.aview)
        self.actions_box.pack_start(self.scrolled_actions)
        
        buttonbox = gtk.HButtonBox()
        buttonbox.set_layout(gtk.BUTTONBOX_START)
        buttonbox.show()
        self.actions_box.pack_start(buttonbox, False)
        
        back_button = gtk.Button(_("Back to Matches"))
        back_button.set_image( gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU) )
        back_button.set_relief(gtk.RELIEF_NONE)
        back_button.connect("clicked", self._on_go_back)
        back_button.show()
        buttonbox.pack_start(back_button, False, False, 0)
    
    def _focus_matches_if_visible(self, mode):
        if (self.results_box.get_property("visible")):
            if mode == "top":
                self.cview.select_first_item()
            elif mode == "bottom":
                self.cview.select_last_item()
            self.cview.grab_focus()
            return True
        else:
            return False
         
    def _on_go_back(self, widget):
        self._show_matches()
        self.cview.grab_focus()
        return False
        
    def _show_matches(self):
        self.scrolled_results.show()
        self.actions_box.hide()
        
    def _show_actions(self):
        self.scrolled_results.hide()
        self.actions_box.show()
    
    def clear_results(self):
        self.treeview_model.clear()
        
    def clear_actions(self):
        self.actions_model.clear()
        
    def clear_query(self):
        self.entry.set_text("")
        self.entry.set_icon( self.default_entry_pixbuf )
    
    def get_entry(self):
        return self.entry
    
    def set_clear(self):
        """
        Set a flag to clear the list of matches and actions
        as soon as the first result arrives
        """
        self._do_clear = True
        
    def mark_history_empty(self, val):
        pass
    
    def show_results(self):
        self.results_box.show()
        self._show_matches()
    
    def display_actions(self, actions, qstring):
        self.actions_model.clear()
        self._show_actions()
        self.actions_model.add_actions(actions, qstring)
        first_iter = self.actions_model.get_iter_first()
        self.aview.get_selection().select_iter(first_iter)
    
    def set_sensitive (self, active):
        """
        Called when the UI should be in/active because modules are loading
        """
        self.vbox_main.set_sensitive(active)
        if active:
            self.entry.grab_focus()
   
    def update_entry_icon (self, icon=None):
        if icon == None:
            icon = self.default_entry_pixbuf
            if not (self.cview.get_toplevel().flags() & gtk.MAPPED):
                # The view is hidden, just show default icon
                self.entry.set_icon (icon)
                return
                
            path, column = self.cview.get_cursor ()
        
            if path != None and self.entry.get_text() != "":
                match = self.treeview_model[self.treeview_model.get_iter(path)][self.treeview_model.MATCHES]
                if not isinstance(match, CuemiacCategory):
                    icon = match.get_icon()
                
        self.entry.set_icon (icon)
    
    def append_matches (self, sender, matches):
        """
        We suppose that the results belong to the text
        that is currently in the entry
        """
        if self._do_clear:
            self._do_clear = False
            self.clear_results()
            self.clear_actions()
            # Display default icon in entry
            self.update_entry_icon()
        self.treeview_model.append (matches, self.entry.get_text())
Beispiel #6
0
class AbstractCuemiacView(deskbar.interfaces.View):
    """
    An abstract base class for all cuemiac derived UIs
    
    It creates and packs all necessary widget and connects
    the signals correctly. L{self.vbox_main} contains the actual
    UI.
    
    You still have to implement methods from L{deskbar.interfaces.View}:
        * get_toplevel
        * receive_focus
    """

    VBOX_MAIN_SPACING = 12
    VBOX_MAIN_BORDER_WIDTH = 6

    def __init__(self, controller, model):
        deskbar.interfaces.View.__init__(self, controller, model)
        self._do_clear = True

        self._model.connect(
            "query-ready",
            lambda s, m: glib.idle_add(self.append_matches, s, m))

        # VBox
        self._create_vbox_main()
        self.vbox_main.show()

        self._create_header()
        self.header.show()

        # Results TreeView
        self._create_results_treeview()
        self.cview.show()
        self.scrolled_results.show()

        # Actions TreeView
        self._create_actions_view()
        self.aview.show()
        self.scrolled_actions.show()

    def _create_vbox_main(self):
        """
        Sets self.vbox_main
        """
        self.vbox_main = gtk.VBox(spacing=self.VBOX_MAIN_SPACING)
        self.vbox_main.set_border_width(self.VBOX_MAIN_BORDER_WIDTH)

    def _create_cuemiac_entry(self):
        """
        Sets self.entry
        """
        # Search entry
        self.default_entry_pixbuf = deskbar.core.Utils.load_icon(
            "deskbar-applet-panel-h.png", width=23, height=14)
        self.entry = CuemiacEntry(self.default_entry_pixbuf)
        self.entry.connect("changed", self._controller.on_query_entry_changed)
        # Connect this before "go-next/previous" to parse history
        self.entry.connect("key-press-event",
                           self._controller.on_query_entry_key_press_event)
        self.entry.connect("activate",
                           self._controller.on_query_entry_activate)
        self.entry.connect("go-next",
                           lambda e: self._focus_matches_if_visible("top"))
        self.entry.connect("go-previous",
                           lambda e: self._focus_matches_if_visible("bottom"))

    def _create_header(self):
        """
        Sets self.entry and self.header
        """
        #        self.completion = gtk.EntryCompletion()
        #        self.completion.set_model(self._model.get_history())
        #        self.completion.set_inline_completion(True)
        #        self.completion.set_popup_completion(False)
        #        self.completion.set_text_column(1)

        self._create_cuemiac_entry()
        #        self.entry.get_entry().set_completion(self.completion)
        self.entry.show()

        self.header = CuemiacHeader(self.entry)

    def _create_results_treeview(self):
        """
        Sets:
            * self.treeview_model
            * self.cview
            * self.scrolled_results
        """
        self.treeview_model = CuemiacModel()
        self.treeview_model.connect("category-added",
                                    self._controller.on_category_added)

        self.cview = CuemiacTreeView(self.treeview_model)
        #self.cview.connect ("key-press-event", self._on_cview_key_press)
        self.cview.connect("match-selected",
                           self._controller.on_match_selected)
        self.cview.connect("do-default-action",
                           self._controller.on_do_default_action)
        self.cview.connect("pressed-up-at-top",
                           lambda s: self.entry.grab_focus())
        self.cview.connect("pressed-down-at-bottom",
                           lambda s: self.entry.grab_focus())
        self.cview.connect_after("cursor-changed",
                                 self._controller.on_treeview_cursor_changed)
        self.cview.connect("row-expanded",
                           self._controller.on_category_expanded,
                           self.treeview_model)
        self.cview.connect("row-collapsed",
                           self._controller.on_category_collapsed,
                           self.treeview_model)

        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)
        self.scrolled_results.add(self.cview)

    def _create_actions_view(self):
        """
        Sets:
            * self.actions_box
            * self.actions_model
            * self.aview
            * self.scrolled_actions
        """
        self.actions_box = gtk.VBox(spacing=3)

        self.actions_model = CuemiacActionsModel()
        self.aview = CuemiacActionsTreeView(self.actions_model)
        self.aview.connect("action-selected",
                           self._controller.on_action_selected)
        self.aview.connect("go-back", self._on_go_back)

        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)
        self.scrolled_actions.add(self.aview)
        self.actions_box.pack_start(self.scrolled_actions)

        buttonbox = gtk.HButtonBox()
        buttonbox.set_layout(gtk.BUTTONBOX_START)
        buttonbox.show()
        self.actions_box.pack_start(buttonbox, False)

        back_button = gtk.Button(_("Back to Matches"))
        back_button.set_image(
            gtk.image_new_from_stock(gtk.STOCK_GO_BACK, gtk.ICON_SIZE_MENU))
        back_button.set_relief(gtk.RELIEF_NONE)
        back_button.connect("clicked", self._on_go_back)
        back_button.show()
        buttonbox.pack_start(back_button, False, False, 0)

    def _focus_matches_if_visible(self, mode):
        if (self.results_box.get_property("visible")):
            if mode == "top":
                self.cview.select_first_item()
            elif mode == "bottom":
                self.cview.select_last_item()
            self.cview.grab_focus()
            return True
        else:
            return False

    def _on_go_back(self, widget):
        self._show_matches()
        self.cview.grab_focus()
        return False

    def _show_matches(self):
        self.scrolled_results.show()
        self.actions_box.hide()

    def _show_actions(self):
        self.scrolled_results.hide()
        self.actions_box.show()

    def clear_results(self):
        self.treeview_model.clear()

    def clear_actions(self):
        self.actions_model.clear()

    def clear_query(self):
        self.entry.set_text("")
        self.entry.set_icon(self.default_entry_pixbuf)

    def get_entry(self):
        return self.entry

    def set_clear(self):
        """
        Set a flag to clear the list of matches and actions
        as soon as the first result arrives
        """
        self._do_clear = True

    def mark_history_empty(self, val):
        pass

    def show_results(self):
        self.results_box.show()
        self._show_matches()

    def display_actions(self, actions, qstring):
        self.actions_model.clear()
        self._show_actions()
        self.actions_model.add_actions(actions, qstring)
        first_iter = self.actions_model.get_iter_first()
        self.aview.get_selection().select_iter(first_iter)

    def set_sensitive(self, active):
        """
        Called when the UI should be in/active because modules are loading
        """
        self.vbox_main.set_sensitive(active)
        if active:
            self.entry.grab_focus()

    def update_entry_icon(self, icon=None):
        if icon == None:
            icon = self.default_entry_pixbuf
            if not (self.cview.get_toplevel().flags() & gtk.MAPPED):
                # The view is hidden, just show default icon
                self.entry.set_icon(icon)
                return

            path, column = self.cview.get_cursor()

            if path != None and self.entry.get_text() != "":
                match = self.treeview_model[self.treeview_model.get_iter(
                    path)][self.treeview_model.MATCHES]
                if not isinstance(match, CuemiacCategory):
                    icon = match.get_icon()

        self.entry.set_icon(icon)

    def append_matches(self, sender, matches):
        """
        We suppose that the results belong to the text
        that is currently in the entry
        """
        if self._do_clear:
            self._do_clear = False
            self.clear_results()
            self.clear_actions()
            # Display default icon in entry
            self.update_entry_icon()
        self.treeview_model.append(matches, self.entry.get_text())