Example #1
0
    def create_menus(system_name, actions):
        global global_vcs_menus
        global contextual_menu_labels

        need_to_create_contextual_menus = \
            system_name not in contextual_menu_labels
        need_to_create_menus = len(global_vcs_menus) == 0

        if need_to_create_contextual_menus:
            contextual_menu_labels[system_name] = []

        separator_count = 0
        for dict in actions:
            label = dict[LABEL]
            action_name = dict[ACTION]

            if action_name:
                action = GPS.Action(action_name)

                # Add item in the global menu
                if need_to_create_menus:
                    menu = action.menu("/_VCS/%s" % label)
                    global_vcs_menus.append(menu)

                # Add item in the contextual menu

                contextual_label = "Version Control/%s" % label.replace(
                    "_", "")

                if need_to_create_contextual_menus:
                    action.contextual(
                        path=contextual_label,
                        # filter=not_in_explorer,
                        # ref=last_menu,
                        add_before=True)

                    contextual_menu_labels[system_name] += [contextual_label]
                else:
                    GPS.Contextual(contextual_label).show()

            else:

                separator_count += 1

                # Add a separator in the global menu
                a = GPS.Action('__separator')
                menu = a.menu('/VCS/-%s-' % (separator_count, ))
                global_vcs_menus.append(menu)

                # Add a separator in the contextual menu

                if need_to_create_contextual_menus:
                    GPS.Contextual('').create(
                        on_activate=None,
                        label='Version Control/-',
                        #  filter=only_in_submenu,
                        ref=last_menu,
                        add_before=True)
Example #2
0
def on_gps_started(hook):
    GPS.Action('open Project Properties').disable()
    GPS.Action('open Switches editor').disable()
    GPS.Action('save all projects').disable()
    GPS.Action('new project').disable()
    GPS.Action('create project from template').disable()

    # Remove the contextual menus that may cause modifications in the
    # projects
    GPS.Contextual("Project dependencies").hide()
    GPS.Contextual("Add scenario variable").hide()
Example #3
0
    def preferences_changed(self):
        """Called when the preferences are changed"""

        cmd = self.pref_cmd.get()

        if self.ispell_command != cmd:
            if self.ispell:
                GPS.Logger('ISPELL').log('command changed, restart process')
                self.kill()

            self.ispell_command = ''
            if os_utils.locate_exec_on_path(cmd.split()[0]):
                GPS.Logger('ISPELL').log('initialize ispell module: %s' % cmd)
                self.ispell_command = cmd

        if self.ispell_command and self.pref_type.get() == 'static':
            GPS.Logger("ISPELL").log('Activate static contextual menu')
            if self.dynamic:
                self.dynamic.hide()
            Static_Contextual(ispell=self)

        elif self.ispell_command and self.pref_type.get() == 'dynamic':
            GPS.Logger("ISPELL").log("Activate dynamic contextual menu")
            GPS.Contextual('spell check word').hide()  # disable static menu
            if not self.dynamic:
                self.dynamic = Dynamic_Contextual(ispell=self)
            else:
                self.dynamic.show()

        else:
            if self.dynamic:
                self.dynamic.hide()
Example #4
0
    def remove_old_menus(system_name):
        global global_vcs_menus

        if system_name in contextual_menu_labels:
            # Remove old menus
            for menu in global_vcs_menus:
                menu.destroy()

            global_vcs_menus = []

            # Hide contextual menus
            for m in contextual_menu_labels[system_name]:
                GPS.Contextual(m).hide()