class ScanToolbar(HIGHBox):
    def __init__(self):
        HIGHBox.__init__(self)

        self._create_target()
        self._create_profile()

        self.scan_button = gtk.Button(_("Scan"))

        self._pack_noexpand_nofill(self.target_label)
        self._pack_expand_fill(self.target_entry)
        
        self._pack_noexpand_nofill(self.profile_label)
        self._pack_expand_fill(self.profile_entry)
        
        self._pack_noexpand_nofill(self.scan_button)

        self.target_entry.set_focus_child(self.target_entry.child)
        self.profile_entry.set_focus_child(self.profile_entry.child)

        self.target_entry.child.grab_focus()

        # Events
        self.target_entry.child.connect('key-press-event',\
                        self.next, self.profile_entry.child)
        self.target_entry.child.connect('activate',
                        lambda x: self.profile_entry.child.grab_focus())
        self.profile_entry.child.connect('activate',
                        lambda x: self.scan_button.clicked())
        
    def _create_target(self):
        self.target_label = HIGEntryLabel(_("Target:"))
        self.target_entry = TargetCombo()
        
        self.update_target_list()

    def _create_profile(self):
        self.profile_label = HIGEntryLabel(_('Profile:'))
        self.profile_entry = ProfileCombo()
        
        self.update()

    def next(self, widget, event, next_widget):
        if event.hardware_keycode == 23:
            next_widget.grab_focus()

    def get_target(self):
        return self.target_entry.get_child().get_text()

    def get_profile_name(self):
        return self.profile_entry.get_child().get_text()

    def update_target_list(self):
        self.target_entry.update()
        
    def add_new_target(self, target):
        self.target_entry.add_new_target(target)

    def get_selected_target(self):
        return self.target_entry.selected_target

    def set_selected_target(self, target):
        self.target_entry.selected_target = target

    def update(self):
        self.profile_entry.update()
    
    def set_profiles(self, profiles):
        self.profile_entry.set_profiles(profiles)

    def get_selected_profile(self):
        return self.profile_entry.selected_profile

    def set_selected_profile(self, profile):
        self.profile_entry.selected_profile = profile

    selected_profile = property(get_selected_profile, set_selected_profile)
    selected_target = property(get_selected_target, set_selected_target)