Exemplo n.º 1
0
    def set_search(self, txt):
        """Set the search to txt, ensuring there are results.

        If there are no results for the search, we'll try a partial
        search for only some of the words in txt. If that fails, we'll
        set the search to blank.
        """
        words = re.split(r'\W+', txt)
        # always search raw if possible... (it gets us the real thing
        # vs. canned/frozen/soup/babyfood, etc.)
        if 'raw' not in words:
            words += ['raw']
        search_terms = []
        search_in = self.rd.nutrition_table
        srch = []
        searchvw = None
        for w in words:
            if w in [',', ' ', ';', '.']: continue
            result = self.rd.search_nutrition(srch + [w])
            if result:
                srch += [w]
                searchvw = result
        groups = self.rd.fetch_food_groups_for_search(srch)
        cur_active = cb.cb_get_active_text(self.foodGroupComboBox)
        groups = [self.ALL_GROUPS] + groups
        cb.set_model_from_list(self.foodGroupComboBox, groups)
        cb.cb_set_active_text(self.foodGroupComboBox, cur_active)
        self.__override_search__ = True  # turn off any handling of text insertion
        search_text = ' '.join(srch)
        self.usdaSearchEntry.set_text(search_text)
        self.searchvw = searchvw or self.rd.fetch_all(self.rd.nutrition_table)
        self.nutrition_store.change_view(self.searchvw)
        self.__last_search__ = search_text
        self.__override_search__ = False  # turn back on search handling!
Exemplo n.º 2
0
 def __init__(self):
     self.init_player()
     self.ui = Gtk.Builder()
     self.ui.add_from_file(os.path.join(gglobals.uibase, 'timerDialog.ui'))
     self.timer = TimeSpinnerUI(self.ui.get_object('hoursSpinButton'),
                                self.ui.get_object('minutesSpinButton'),
                                self.ui.get_object('secondsSpinButton'))
     self.timer.connect_timer_hook(self.timer_done_cb)
     for w in [
             'timerDialog', 'mainLabel', 'soundComboBox',
             'repeatCheckButton', 'noteEntry', 'expander1', 'timerBox',
             'resetTimerButton', 'timerFinishedLabel', 'keepAnnoyingLabel'
     ]:
         setattr(self, w, self.ui.get_object(w))
     cb.set_model_from_list(self.soundComboBox,
                            list(self.sounds_and_files.keys()))
     cb.cb_set_active_text(self.soundComboBox, _('Ringing Sound'))
     self.ui.connect_signals({
         'reset_cb': self.timer.reset_cb,
         'pause_cb': self.timer.pause_cb,
         'start_cb': self.timer.start_cb,
         'note_changed_cb': self.note_changed_cb,
     })
     self.timerDialog.connect('response', self.response_cb)
     self.timerDialog.connect('close', self.close_cb)
     self.timerDialog.set_modal(False)
     self.note = ''
Exemplo n.º 3
0
    def setup_to_units(self):
        """Setup list of units we need to convert to.

        Usually, this will be a list of mass units.
        """
        masses = [
            i[0] for i in defaults.UNIT_GROUPS['metric mass'] +
            defaults.UNIT_GROUPS['imperial weight']
        ]
        volumes = [
            i[0] for i in defaults.UNIT_GROUPS['metric volume'] +
            defaults.UNIT_GROUPS['imperial volume']
        ]
        to_units = masses
        self.densities, self.extra_units = self.nd.get_conversions(self.ingkey)
        for d in list(self.densities.keys()):
            if d:
                to_units.extend(["%s (%s)" % (u, d) for u in volumes])
            else:
                to_units.extend(volumes)
        to_units.sort()
        for u in self.extra_units:
            to_units = [u] + to_units
        cb.set_model_from_list(self.toUnitCombo, to_units)
        self.toUnitCombo.set_active(0)
        self.toUnitCombo.set_wrap_width(3)
Exemplo n.º 4
0
    def set_search (self, txt):
        """Set the search to txt, ensuring there are results.

        If there are no results for the search, we'll try a partial
        search for only some of the words in txt. If that fails, we'll
        set the search to blank.
        """
        words = re.split('\W+',txt)
        # always search raw if possible... (it gets us the real thing
        # vs. canned/frozen/soup/babyfood, etc.)
        if 'raw' not in words:
            words += ['raw']
        search_terms = []
        search_in = self.rd.nutrition_table
        srch = []
        searchvw = None
        for w in words:
            if w in [',',' ',';','.']: continue
            result = self.rd.search_nutrition(srch+[w])
            if result:
                srch += [w]
                searchvw = result
        groups = self.rd.fetch_food_groups_for_search(srch)
        cur_active = cb.cb_get_active_text(self.foodGroupComboBox)
        groups = [self.ALL_GROUPS] + groups
        cb.set_model_from_list(self.foodGroupComboBox,groups)
        cb.cb_set_active_text(self.foodGroupComboBox,cur_active)
        self.__override_search__ = True # turn off any handling of text insertion
        search_text = ' '.join(srch)
        self.usdaSearchEntry.set_text(search_text)
        self.searchvw = searchvw or self.rd.fetch_all(self.rd.nutrition_table)
        self.nutrition_store.change_view(self.searchvw)
        self.__last_search__ = search_text
        self.__override_search__ = False # turn back on search handling!
Exemplo n.º 5
0
 def __init__(self, rd, prefs, widgets):
     self.rd = rd
     self.prefs = prefs
     for name, w in widgets:
         setattr(self, name, w)
     self._setup_nuttree_()
     self.__last_search__ = ''
     self.__override_search__ = False
     # TODO: Fixing saving usdaSearchAsYouTypeToggle state
     # Button state is not being saved across sessions and always starts off
     # inactive. Of note, this problem seemed to also exist in the last
     # release (0.17.4), but the button always started off active.
     WidgetSaver.WidgetSaver(self.usdaSearchAsYouTypeToggle,
                             self.prefs.get('sautTog', {'active': True}),
                             ['toggled'])
     # Ensure usdaFindButton is shown if usdaSearchAsYouTypeToggle is
     # inactive
     self.toggle_saut()
     # search
     self.usdaSearchEntry.connect('changed', self.search_type_cb)
     self.usdaFindButton.connect('clicked', self.search_cb)
     self.usdaSearchAsYouTypeToggle.connect('toggled', self.toggle_saut)
     cb.set_model_from_list(
         self.foodGroupComboBox, [self.ALL_GROUPS] +
         self.rd.get_unique_values('foodgroup', self.rd.nutrition_table))
     cb.cb_set_active_text(self.foodGroupComboBox, self.ALL_GROUPS)
Exemplo n.º 6
0
 def __setup_widgets__(self):
     for w in [
             'valueDialog', 'treeview', 'fieldToEditCombo',
             'newValueComboBoxEntry', 'newValueEntry', 'changeValueButton',
             'deleteValueButton', 'forEachLabel', 'otherExpander',
             'otherFieldCombo', 'otherNewValueEntry',
             'otherNewValueComboBoxEntry', 'otherValueBlurbLabel',
             'otherChangeCheckButton', 'leaveValueButton'
     ]:
         setattr(self, w, self.ui.get_object(w))
     self.act_on_selection_widgets = [
         self.deleteValueButton, self.changeValueButton, self.newValueEntry,
         self.otherChangeCheckButton, self.leaveValueButton
     ]
     # Set up the combo-widget at the top with the
     self.fields = [gglobals.REC_ATTR_DIC[v] for v in self.values]
     cb.set_model_from_list(self.fieldToEditCombo, self.fields)
     cb.set_model_from_list(self.otherFieldCombo, self.fields)
     self.newValueComboBoxEntry.set_sensitive(False)
     self.otherValueBlurbLabel.hide()
     self.newValueEntryCompletion = Gtk.EntryCompletion()
     self.newValueEntry.set_completion(self.newValueEntryCompletion)
     self.otherNewValueEntryCompletion = Gtk.EntryCompletion()
     self.otherNewValueEntry.set_completion(
         self.otherNewValueEntryCompletion)
     self.valueDialog.connect('response', self.dialog_response_cb)
     self.valueDialog.set_response_sensitive(Gtk.ResponseType.APPLY, False)
Exemplo n.º 7
0
 def fieldChangedCB(self, combobox):
     name = cb.cb_get_active_text(combobox)
     self.field = gglobals.NAME_TO_ATTR.get(name, name)
     self.populate_treeview()
     other_fields = self.fields[:]
     if self.field != 'category':
         other_fields.remove(gglobals.REC_ATTR_DIC[self.field])
     cb.set_model_from_list(self.otherFieldCombo, other_fields)
Exemplo n.º 8
0
 def fieldChangedCB (self, combobox):
     name = cb.cb_get_active_text(combobox)
     self.field = gglobals.NAME_TO_ATTR.get(name,name)
     self.populate_treeview()
     other_fields = self.fields[:]
     if self.field != 'category':
         other_fields.remove(gglobals.REC_ATTR_DIC[self.field])
     cb.set_model_from_list(
         self.otherFieldCombo,
         other_fields
         )
Exemplo n.º 9
0
    def set_limit(self, ingredients, in_string=_('recipe')):
        """Set ingredients to show in index.

        in_string is a string describing what these ingredients
        represent. For example, recipe.
        """
        self.ingredients = ingredients
        self.in_string = in_string
        cb.set_model_from_list(
            self.nutritionFilterComboBox,
            [self.in_string, _('entire database')])
        cb.cb_set_active_text(self.nutritionFilterComboBox, self.in_string)
Exemplo n.º 10
0
    def set_limit (self, ingredients, in_string=_('recipe')):
        """Set ingredients to show in index.

        in_string is a string describing what these ingredients
        represent. For example, recipe.
        """
        self.ingredients = ingredients
        self.in_string = in_string
        cb.set_model_from_list(
            self.nutritionFilterComboBox,
            [self.in_string,_('entire database')]
            )
        cb.cb_set_active_text(self.nutritionFilterComboBox,self.in_string)
Exemplo n.º 11
0
 def _setup_custom_box(self):
     """Setup the interface for entering custom nutritional information.
     """
     t = gtk.Table()
     masses = [i[0] for i in defaults.UNIT_GROUPS['metric mass']\
               + defaults.UNIT_GROUPS['imperial weight']]
     cb.set_model_from_list(self.massUnitComboBox, masses)
     cb.cb_set_active_text(self.massUnitComboBox, 'g')
     self.customNutritionAmountEntry.set_value(100)
     self.nutrition_info = {}
     self.custom_box.add(t)
     self.changing_percent_internally = False
     self.changing_number_internally = False
     l = gtk.Label('%RDA')
     l.show()
     t.attach(l, 2, 3, 0, 1)
     for n, nutstuff in enumerate(NUT_LAYOUT):
         if nutstuff == SEP:
             hs = gtk.HSeparator()
             t.attach(hs, 0, 2, n + 1, n + 2, xoptions=gtk.FILL)
             hs.show()
             continue
         label_txt, typ, name, properties, show_percent, unit = nutstuff
         if unit: label_txt += " (" + unit + ")"
         label = gtk.Label(label_txt)
         label.show()
         label.set_alignment(0, 0.5)
         t.attach(label, 0, 1, n + 1, n + 2, xoptions=gtk.FILL)
         entry = NumberEntry(default_to_fractions=False)
         entry.show()
         t.attach(entry, 1, 2, n + 1, n + 2, xoptions=gtk.FILL)
         if show_percent:
             percent_entry = NumberEntry(default_to_fractions=False,
                                         decimals=0)
             percent_entry.entry.set_width_chars(4)
             percent_entry.show()
             percent_label = gtk.Label('%')
             percent_label.show()
             t.attach(percent_entry, 2, 3, n + 1, n + 2)
             t.attach(percent_label, 3, 4, n + 1, n + 2)
             percent_label.set_alignment(0, 0.5)
             percent_entry.connect('changed', self.percent_changed_cb, name,
                                   entry)
             percent_entry.entry.set_width_chars(5)
         else:
             percent_entry = None
         entry.connect('changed', self.number_changed_cb, name,
                       percent_entry)
     t.set_row_spacings(6)
     t.set_col_spacings(12)
     t.show()
Exemplo n.º 12
0
 def _setup_custom_box (self):
     """Setup the interface for entering custom nutritional information.
     """
     t = gtk.Table()
     masses = [i[0] for i in defaults.UNIT_GROUPS['metric mass']\
               + defaults.UNIT_GROUPS['imperial weight']]
     cb.set_model_from_list(
         self.massUnitComboBox,
         masses)
     cb.cb_set_active_text(self.massUnitComboBox,'g')
     self.customNutritionAmountEntry.set_value(100)
     self.nutrition_info = {}
     self.custom_box.add(t)
     self.changing_percent_internally = False
     self.changing_number_internally = False
     l=gtk.Label('%RDA'); l.show()
     t.attach(l,2,3,0,1)
     for n,nutstuff in enumerate(NUT_LAYOUT):
         if nutstuff == SEP:
             hs = gtk.HSeparator()
             t.attach(hs,0,2,n+1,n+2,xoptions=gtk.FILL)
             hs.show()
             continue
         label_txt,typ,name,properties,show_percent,unit = nutstuff
         if unit: label_txt += " (" + unit + ")"
         label = gtk.Label(label_txt); label.show()
         label.set_alignment(0,0.5)
         t.attach(label,0,1,n+1,n+2,xoptions=gtk.FILL)
         entry = NumberEntry(default_to_fractions=False)
         entry.show()
         t.attach(entry,1,2,n+1,n+2,xoptions=gtk.FILL)
         if show_percent:
             percent_entry = NumberEntry(default_to_fractions=False,
                                         decimals=0)
             percent_entry.entry.set_width_chars(4)
             percent_entry.show()
             percent_label = gtk.Label('%'); percent_label.show()
             t.attach(percent_entry,2,3,n+1,n+2)
             t.attach(percent_label,3,4,n+1,n+2)
             percent_label.set_alignment(0,0.5)
             percent_entry.connect('changed',self.percent_changed_cb,name,entry)
             percent_entry.entry.set_width_chars(5)
         else: percent_entry = None
         entry.connect('changed',self.number_changed_cb,name,percent_entry)
     t.set_row_spacings(6)
     t.set_col_spacings(12)
     t.show()
Exemplo n.º 13
0
 def search (self):
     txt = self.usdaSearchEntry.get_text()
     if self.__last_search__ == txt and self.group == self.__last_group__:
         return
     words = re.split('\W+',txt)
     groups = self.rd.fetch_food_groups_for_search(words)
     cur_active = cb.cb_get_active_text(self.foodGroupComboBox)
     groups = [self.ALL_GROUPS] + groups
     if cur_active not in groups:
         groups += [cur_active]
     cb.set_model_from_list(self.foodGroupComboBox,groups)
     cb.cb_set_active_text(self.foodGroupComboBox,cur_active)
     self.searchvw = self.rd.search_nutrition(words,group=self.group)
     self.__last_search__ = txt
     self.__last_group__ = self.group
     self.nutrition_store.change_view(self.searchvw)
     self.nutrition_store.set_page(0)
Exemplo n.º 14
0
 def search(self):
     txt = self.usdaSearchEntry.get_text()
     if self.__last_search__ == txt and self.group == self.__last_group__:
         return
     words = re.split(r'\W+', txt)
     groups = self.rd.fetch_food_groups_for_search(words)
     cur_active = cb.cb_get_active_text(self.foodGroupComboBox)
     groups = [self.ALL_GROUPS] + groups
     if cur_active not in groups:
         groups += [cur_active]
     cb.set_model_from_list(self.foodGroupComboBox, groups)
     cb.cb_set_active_text(self.foodGroupComboBox, cur_active)
     self.searchvw = self.rd.search_nutrition(words, group=self.group)
     self.__last_search__ = txt
     self.__last_group__ = self.group
     self.nutrition_store.change_view(self.searchvw)
     self.nutrition_store.set_page(0)
Exemplo n.º 15
0
 def __init__(self, rd, prefs, widgets):
     self.rd = rd
     self.prefs = prefs
     for name, w in widgets:
         setattr(self, name, w)
     self._setup_nuttree_()
     self.__last_search__ = ''
     self.__override_search__ = False
     WidgetSaver.WidgetSaver(self.usdaSearchAsYouTypeToggle,
                             self.prefs.get('sautTog', {'active': True}),
                             ['toggled'])
     # search
     self.usdaSearchEntry.connect('changed', self.search_type_cb)
     self.usdaFindButton.connect('clicked', self.search_cb)
     self.usdaSearchAsYouTypeToggle.connect('toggled', self.toggle_saut)
     cb.set_model_from_list(
         self.foodGroupComboBox, [self.ALL_GROUPS] +
         self.rd.get_unique_values('foodgroup', self.rd.nutrition_table))
     cb.cb_set_active_text(self.foodGroupComboBox, self.ALL_GROUPS)
Exemplo n.º 16
0
 def __init__ (self, rd, prefs, widgets):
     self.rd = rd; self.prefs = prefs
     for name,w in widgets: setattr(self,name,w)
     self._setup_nuttree_()
     self.__last_search__ = ''
     self.__override_search__ = False
     WidgetSaver.WidgetSaver(
         self.usdaSearchAsYouTypeToggle,
         self.prefs.get('sautTog',
                        {'active':True}),
         ['toggled'])
     # search
     self.usdaSearchEntry.connect('changed',self.search_type_cb)
     self.usdaFindButton.connect('clicked',self.search_cb)
     self.usdaSearchAsYouTypeToggle.connect('toggled',self.toggle_saut)
     cb.set_model_from_list(self.foodGroupComboBox,
                            [self.ALL_GROUPS]+self.rd.get_unique_values('foodgroup',self.rd.nutrition_table)
                            )
     cb.cb_set_active_text(self.foodGroupComboBox,self.ALL_GROUPS)
Exemplo n.º 17
0
    def setup_to_units (self):
        """Setup list of units we need to convert to.

        Usually, this will be a list of mass units.
        """
        masses = [i[0] for i in defaults.UNIT_GROUPS['metric mass'] + defaults.UNIT_GROUPS['imperial weight']]
        volumes = [i[0] for i in  defaults.UNIT_GROUPS['metric volume'] + defaults.UNIT_GROUPS['imperial volume']]
        to_units = masses
        self.densities,self.extra_units = self.nd.get_conversions(self.ingkey)
        for d in self.densities.keys():
            if d:
                to_units.extend(["%s (%s)"%(u,d) for u in volumes])
            else:
                to_units.extend(volumes)
        to_units.sort()
        for u in self.extra_units:
            to_units = [u]+to_units
        cb.set_model_from_list(self.toUnitCombo,
                               to_units)
        self.toUnitCombo.set_active(0)
        self.toUnitCombo.set_wrap_width(3)
Exemplo n.º 18
0
 def __setup_widgets__ (self):
     for w in [
         'valueDialog',
         'treeview',
         'fieldToEditCombo','newValueComboBoxEntry',
         'newValueEntry','changeValueButton',
         'deleteValueButton','forEachLabel',
         'otherExpander','otherFieldCombo',
         'otherNewValueEntry','otherNewValueComboBoxEntry',
         'otherValueBlurbLabel','otherChangeCheckButton',
         'leaveValueButton'
         ]:
         setattr(self,w,self.ui.get_object(w))
     self.act_on_selection_widgets = [
         self.deleteValueButton, self.changeValueButton,
         self.newValueEntry,self.otherChangeCheckButton,
         self.leaveValueButton
         ]
     # Set up the combo-widget at the top with the 
     self.fields = [gglobals.REC_ATTR_DIC[v] for v in self.values]
     cb.set_model_from_list(
         self.fieldToEditCombo,
         self.fields
         )
     cb.set_model_from_list(
         self.otherFieldCombo,
         self.fields
         )
     self.newValueComboBoxEntry.set_sensitive(False)
     self.otherValueBlurbLabel.hide()
     self.newValueEntryCompletion = gtk.EntryCompletion()
     self.newValueEntry.set_completion(self.newValueEntryCompletion)
     self.otherNewValueEntryCompletion = gtk.EntryCompletion()
     self.otherNewValueEntry.set_completion(
         self.otherNewValueEntryCompletion
         )
     self.valueDialog.connect('response',self.dialog_response_cb)
     self.valueDialog.set_response_sensitive(gtk.RESPONSE_APPLY,False)
Exemplo n.º 19
0
 def __init__(self, rd=None, rg=None):
     self.ui = gtk.Builder()
     self.ui.add_from_file(os.path.join(current_path, 'keyeditor.ui'))
     self.rd = rd
     self.rg = rg
     self.widget_names = [
         'treeview', 'searchByBox', 'searchEntry', 'searchButton', 'window',
         'searchAsYouTypeToggle', 'regexpTog', 'changeKeyEntry',
         'changeItemEntry', 'changeUnitEntry', 'changeAmountEntry',
         'applyEntriesButton', 'clearEntriesButton'
     ]
     for w in self.widget_names:
         setattr(self, w, self.ui.get_object(w))
     self.entries = {
         'ingkey': self.changeKeyEntry,
         'item': self.changeItemEntry,
         'unit': self.changeUnitEntry,
         'amount': self.changeAmountEntry,
     }
     # setup entry callback to sensitize/desensitize apply
     self.applyEntriesButton.set_sensitive(False)
     self.clearEntriesButton.set_sensitive(False)
     for e in self.entries.values():
         e.connect('changed', self.entryChangedCB)
     # Make our lovely model
     self.makeTreeModel()
     # setup completion in entry
     model = gtk.ListStore(str)
     for k in self.rd.get_unique_values('ingkey',
                                        table=self.rd.ingredients_table):
         model.append([k])
     cb.make_completion(self.changeKeyEntry, model)
     # Setup next/prev/first/last buttons for view
     self.prev_button = self.ui.get_object('prevButton')
     self.next_button = self.ui.get_object('nextButton')
     self.first_button = self.ui.get_object('firstButton')
     self.last_button = self.ui.get_object('lastButton')
     self.showing_label = self.ui.get_object('showingLabel')
     self.prev_button.connect('clicked',
                              lambda *args: self.treeModel.prev_page())
     self.next_button.connect('clicked',
                              lambda *args: self.treeModel.next_page())
     self.first_button.connect(
         'clicked', lambda *args: self.treeModel.goto_first_page())
     self.last_button.connect('clicked',
                              lambda *args: self.treeModel.goto_last_page())
     # Setup search stuff
     self.search_string = ""
     self.search_by = _('key')
     self.use_regexp = True
     self.setupTreeView()
     self.treeview.set_model(self.treeModel)
     self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
     #self.treeview.set_model(self.treeModel)
     self.ui.connect_signals({
         'iSearch':
         self.isearchCB,
         'search':
         self.searchCB,
         'search_as_you_type_toggle':
         self.search_as_you_typeCB,
         'applyEntries':
         self.applyEntriesCB,
         'clearEntries':
         self.clearEntriesCB,
         'close_window':
         lambda *args: self.window.hide(),
         #'editNutritionalInfo':self.editNutritionalInfoCB,
     })
     # setup mnemonic manager
     self.mm = mnemonic_manager.MnemonicManager()
     self.mm.sacred_cows.append('search for')
     self.mm.add_builder(self.ui)
     self.mm.add_treeview(self.treeview)
     self.mm.fix_conflicts_peacefully()
     # to set our regexp_toggled variable
     cb.set_model_from_list(
         self.searchByBox,
         [_('key'), _('item'), _('unit')])
     self.searchByBox.set_active(0)
     self.dont_ask = self.rg.prefs.get('dontAskDeleteKey', False)
     # setup WidgetSavers
     self.rg.conf.append(
         WidgetSaver.WidgetSaver(
             self.searchAsYouTypeToggle,
             self.rg.prefs.get(
                 'sautTog',
                 {'active': self.searchAsYouTypeToggle.get_active()}),
             ['toggled']))
     self.rg.conf.append(
         WidgetSaver.WidgetSaver(
             self.regexpTog,
             self.rg.prefs.get('regexpTog',
                               {'active': self.regexpTog.get_active()}),
             ['toggled']))
Exemplo n.º 20
0
 def __init__ (self, rd=None, rg=None):
     self.ui = gtk.Builder()
     self.ui.add_from_file(os.path.join(current_path,'keyeditor.ui'))
     self.rd = rd
     self.rg = rg
     self.widget_names = ['treeview', 'searchByBox', 'searchEntry', 'searchButton', 'window',
                          'searchAsYouTypeToggle', 'regexpTog',
                          'changeKeyEntry',
                          'changeItemEntry',
                          'changeUnitEntry',
                          'changeAmountEntry',
                          'applyEntriesButton',
                          'clearEntriesButton']
     for w in self.widget_names:
         setattr(self,w,self.ui.get_object(w))
     self.entries = {'ingkey':self.changeKeyEntry,
                     'item':self.changeItemEntry,
                     'unit':self.changeUnitEntry,
                     'amount':self.changeAmountEntry,
                     }
     # setup entry callback to sensitize/desensitize apply
     self.applyEntriesButton.set_sensitive(False)
     self.clearEntriesButton.set_sensitive(False)
     for e in self.entries.values():
         e.connect('changed',self.entryChangedCB)
     # Make our lovely model
     self.makeTreeModel()
     # setup completion in entry
     model = gtk.ListStore(str)
     for k in self.rd.get_unique_values('ingkey',table=self.rd.ingredients_table): model.append([k])
     cb.make_completion(self.changeKeyEntry,model)
     # Setup next/prev/first/last buttons for view
     self.prev_button = self.ui.get_object('prevButton')
     self.next_button = self.ui.get_object('nextButton')
     self.first_button = self.ui.get_object('firstButton')
     self.last_button = self.ui.get_object('lastButton')
     self.showing_label = self.ui.get_object('showingLabel')
     self.prev_button.connect('clicked',lambda *args: self.treeModel.prev_page())
     self.next_button.connect('clicked',lambda *args: self.treeModel.next_page())
     self.first_button.connect('clicked',lambda *args: self.treeModel.goto_first_page())
     self.last_button.connect('clicked',lambda *args: self.treeModel.goto_last_page())
     # Setup search stuff
     self.search_string=""
     self.search_by = _('key')
     self.use_regexp=True
     self.setupTreeView()
     self.treeview.set_model(self.treeModel)
     self.treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
     #self.treeview.set_model(self.treeModel)
     self.ui.connect_signals({
         'iSearch':self.isearchCB,
         'search':self.searchCB,
         'search_as_you_type_toggle':self.search_as_you_typeCB,
         'applyEntries':self.applyEntriesCB,
         'clearEntries':self.clearEntriesCB,
         'close_window': lambda *args: self.window.hide(),
         #'editNutritionalInfo':self.editNutritionalInfoCB,
         })
     # setup mnemonic manager
     self.mm = mnemonic_manager.MnemonicManager()
     self.mm.sacred_cows.append('search for')
     self.mm.add_builder(self.ui)
     self.mm.add_treeview(self.treeview)
     self.mm.fix_conflicts_peacefully()
     # to set our regexp_toggled variable
     cb.set_model_from_list(self.searchByBox, [_('key'),_('item'),_('unit')])
     self.searchByBox.set_active(0)
     self.dont_ask = self.rg.prefs.get('dontAskDeleteKey',False)
     # setup WidgetSavers
     self.rg.conf.append(WidgetSaver.WidgetSaver(
         self.searchAsYouTypeToggle,
         self.rg.prefs.get('sautTog',
                        {'active':self.searchAsYouTypeToggle.get_active()}),
         ['toggled']))
     self.rg.conf.append(WidgetSaver.WidgetSaver(
         self.regexpTog,
         self.rg.prefs.get('regexpTog',
                        {'active':self.regexpTog.get_active()}),
         ['toggled']))