def copy_profiles(self, widget):
        """
        Copy selected Profile
        """
        if self.get_selected_profile() is None:
            return None
        d = ProfileName(_("Insert a profile name"))
        profile_name = d.run()
        if profile_name is None or profile_name == "":
            return None
        #get commands of selected profile
        profile_selected = self.get_selected_profile()
        command = self.profiles.get_command(profile_selected)
        hint = self.profiles.get_hint(profile_selected)
        description = self.profiles.get_description(profile_selected)
        annotation = self.profiles.get_annotation(profile_selected)
        #Options
        prof = self.profiles.get_profile(profile_selected)
        options_used = prof['options']
        options = CommandConstructor(options_used)

        self.profiles.add_profile(profile_name,\
                                  command=command,\
                                  hint=hint,\
                                  description=description,\
                                  annotation=annotation,\
                                  options=options.get_options())

        myiter = self.model.insert_before(None, None)
        self.model.set_value(myiter, 0, profile_name)
        self.model.set_value(myiter, 1, self.profiles.get_hint(profile_name))
        treeselection = self.profiles_tv.get_selection()
        treeselection.select_iter(myiter)
    def load_data(self):
        self.profile = CommandProfile()
        options_used = {}

        self.constructor = CommandConstructor(options_used)
        self.options = self._profilecore
        i = 0
        for tab in self.options.groups:
            self.create_tab(tab, self.options.section_names[tab],
                            self.options.tabs[tab], i)
            i = i + 1
    def __init__(self, profile_name=None, delete=False):
        HIGWindow.__init__(self)
        self.set_title(_('Profile Editor'))
        self.set_position(gtk.WIN_POS_CENTER)
        self.profile_name = profile_name
        self.__create_widgets()
        self.__pack_widgets()

        self.scan_notebook = None
        self.profilemanager = None

        self.profile = CommandProfile()

        self.deleted = False
        options_used = {}

        if profile_name:
            log.debug("Showing profile %s" % profile_name)
            prof = self.profile.get_profile(profile_name)
            options_used = prof['options']

            # Interface settings
            self.profile_name_entry.set_text(profile_name)
            self.profile_hint_entry.set_text(prof['hint'])
            self.profile_description_text.get_buffer().set_text(
                prof['description'])
            self.profile_annotation_text.get_buffer().set_text(
                prof['annotation'])

            if delete:
                # Removing profile. It must be saved again
                self.remove_profile()

        self.constructor = CommandConstructor(options_used)
        self.options = OptionBuilder(profile_editor_file, self.constructor,
                                     self.update_command)
        log.debug("Option groups: %s" % str(self.options.groups))
        log.debug("Option section names: %s" % str(self.options.section_names))
        #log.debug("Option tabs: %s" % str(self.options.tabs))

        for tab in self.options.groups:
            self.__create_tab(tab, self.options.section_names[tab],
                              self.options.tabs[tab])

        self.update_command()