Exemple #1
0
    def _removeMenu(self):
        # TODO: remove menu. cleanup
        w = modoshotgunsupport.get_shotgun_widget()
        w.create_menu()

        return
Exemple #2
0
    def _removeMenu(self):
        # TODO: remove menu. cleanup
        w = modoshotgunsupport.get_shotgun_widget()
        w.create_menu()

        return
Exemple #3
0
    def create_menu(self, *args):
        """
        Render the entire Shotgun menu.
        In order to have commands enable/disable themselves based on the enable_callback, 
        re-create the menu items every time.
        """
        #import rpdb2;rpdb2.start_embedded_debugger("1234")

        base_widget = modoshotgunsupport.get_shotgun_widget()
        self._menu_handle = menu = base_widget.get_menu()
        #menu.clear()
        
        # now add the context item on top of the main menu
        self._context_menu = self._add_context_menu()

        menu.addSeparator()

        # now enumerate all items and create menu objects for them
        menu_items = []
        for (cmd_name, cmd_details) in self._engine.commands.items():
             menu_items.append( AppCommand(cmd_name, cmd_details) )

        # sort list of commands in name order
        menu_items.sort(key=lambda x: x.name) 

        # now add favourites
        for fav in self._engine.get_setting("menu_favourites"):
            app_instance_name = fav["app_instance"]
            menu_name = fav["name"]
            # scan through all menu items
            for cmd in menu_items:                 
                 if cmd.get_app_instance_name() == app_instance_name and cmd.name == menu_name:
                     # found our match!
                     cmd.add_command_to_menu(self._menu_handle)
                     # mark as a favourite item
                     cmd.favourite = True

        menu.addSeparator()

        # now go through all of the menu items.
        # separate them out into various sections
        commands_by_app = {}
        
        for cmd in menu_items:

            if cmd.get_type() == "context_menu":
                # context menu!
                cmd.add_command_to_menu(self._context_menu)             
                
            else:
                # normal menu
                app_name = cmd.get_app_name()
                if app_name is None:
                    # un-parented app
                    app_name = "Other Items" 
                if not app_name in commands_by_app:
                    commands_by_app[app_name] = []
                commands_by_app[app_name].append(cmd)
        
        # now add all apps to main menu
        self._add_app_menu(commands_by_app)
Exemple #4
0
    def create_menu(self, *args):
        """
        Render the entire Shotgun menu.
        In order to have commands enable/disable themselves based on the enable_callback, 
        re-create the menu items every time.
        """
        #import rpdb2;rpdb2.start_embedded_debugger("1234")

        base_widget = modoshotgunsupport.get_shotgun_widget()
        self._menu_handle = menu = base_widget.get_menu()
        #menu.clear()

        # now add the context item on top of the main menu
        self._context_menu = self._add_context_menu()

        menu.addSeparator()

        # now enumerate all items and create menu objects for them
        menu_items = []
        for (cmd_name, cmd_details) in self._engine.commands.items():
            menu_items.append(AppCommand(cmd_name, cmd_details))

        # sort list of commands in name order
        menu_items.sort(key=lambda x: x.name)

        # now add favourites
        for fav in self._engine.get_setting("menu_favourites"):
            app_instance_name = fav["app_instance"]
            menu_name = fav["name"]
            # scan through all menu items
            for cmd in menu_items:
                if cmd.get_app_instance_name(
                ) == app_instance_name and cmd.name == menu_name:
                    # found our match!
                    cmd.add_command_to_menu(self._menu_handle)
                    # mark as a favourite item
                    cmd.favourite = True

        menu.addSeparator()

        # now go through all of the menu items.
        # separate them out into various sections
        commands_by_app = {}

        for cmd in menu_items:

            if cmd.get_type() == "context_menu":
                # context menu!
                cmd.add_command_to_menu(self._context_menu)

            else:
                # normal menu
                app_name = cmd.get_app_name()
                if app_name is None:
                    # un-parented app
                    app_name = "Other Items"
                if not app_name in commands_by_app:
                    commands_by_app[app_name] = []
                commands_by_app[app_name].append(cmd)

        # now add all apps to main menu
        self._add_app_menu(commands_by_app)