Ejemplo n.º 1
0
    def __on_button_click(self, source, event):
        # Detect a single right-click
        if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
            treepath = self.get_path_at_pos(event.x, event.y)

            if treepath:
                path, tree_column, x, y = treepath
                iter = self._model.get_iter(path)
                view = self._model.get_value(iter, 1)

                if isinstance(view, ContactView) or isinstance(view, GroupView):
                    self.grab_focus()
                    self.set_cursor(path, tree_column, 0)
                    menu = gtk.Menu()
                    common.createMenuItemsFromView(menu,
                                view.on_right_click_popup_menu.items)
                    menu.popup(None, None, None, event.button, event.time)

            return True

        # Detect a single left-click, but it is called even when a double-click occours,
        # so should we detect them or is there a simpler way?
        #elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
        #    return False

        else:
            return False
Ejemplo n.º 2
0
    def __on_button_click(self, source, event):
        # Detect a single right-click
        if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
            treepath = self.get_path_at_pos(event.x, event.y)

            if treepath:
                path, tree_column, x, y = treepath
                iter = self._model.get_iter(path)
                view = self._model.get_value(iter, 1)

                if isinstance(view, ContactView) or isinstance(
                        view, GroupView):
                    self.grab_focus()
                    self.set_cursor(path, tree_column, 0)
                    menu = gtk.Menu()
                    common.createMenuItemsFromView(
                        menu, view.on_right_click_popup_menu.items)
                    menu.popup(None, None, None, event.button, event.time)

            return True

        # Detect a single left-click, but it is called even when a double-click occours,
        # so should we detect them or is there a simpler way?
        #elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
        #    return False

        else:
            return False
Ejemplo n.º 3
0
 def setMenu(self, menu):
     """ This will allow the core to change the current window's main menu
     @type menu: MenuView
     """
     chldn = self.main_menu.get_children()
     if len(chldn) is not 0:
         for chl in chldn:
             self.main_menu.remove(chl)
     common.createMenuItemsFromView(self.main_menu, menu.items)
     self.main_menu.show()
Ejemplo n.º 4
0
 def setMenu(self, menu):
     """ This will allow the core to change the current window's main menu
     @type menu: MenuView
     """
     chldn = self.main_menu.get_children()
     if len(chldn) is not 0:
         for chl in chldn:
             self.main_menu.remove(chl)
     common.createMenuItemsFromView(self.main_menu, menu.items)
     self.main_menu.show()