def _set_widgets(self, value): """ Set the widgets tot their correct state for adding/editing @param value: True for edit mode, False for normal """ utils.set_multiple_sensitive([self.widgets.treeview], not value) utils.set_multiple_visible(self._normalbuttons, not value) utils.set_multiple_visible(self._editbuttons, value) show_me = database.get_address_data({"me": 1}) is None or \ (self._mode == enums.Action.edit and database.get_address_data({"me": 1})[0] == self._get_address_key()) utils.set_multiple_visible([self.widgets.checkme], show_me if value else False) shadow = gtk.SHADOW_NONE if value else gtk.SHADOW_IN for entry in self._entries: entry.set_editable(value) if isinstance(entry, latlongentry.LatLongEntry): # These will handle the frame itself by setting it editable continue entry.set_has_frame(value) entry.get_parent().set_shadow_type(shadow) self.widgets.entryname.grab_focus() self.widgets.entryname.set_position(-1)
def on_iconview_changed(self, widget): model = widget.get_model() try: path = widget.get_selected_items()[0] except IndexError: self.set_pixbuf(None) self.disable_toolbuttons() return pindex = model[path][1] image = pigeonparser.parser.pigeons[pindex].get_image() self.set_pixbuf(image) self.current_picture = path[0] utils.set_multiple_sensitive({ self.widgets.first_button: self.current_picture, self.widgets.prev_button: self.current_picture, self.widgets.next_button: self.current_picture < self.picture_no - 1, self.widgets.last_button: self.current_picture < self.picture_no - 1, self.widgets.zoom_in_button: True, self.widgets.zoom_out_button: True, self.widgets.zoom_fit_button: True, self.widgets.slide_button: True })
def disable_toolbuttons(self): utils.set_multiple_sensitive([ self.widgets.first_button, self.widgets.prev_button, self.widgets.next_button, self.widgets.last_button, self.widgets.zoom_in_button, self.widgets.zoom_out_button, self.widgets.zoom_fit_button, self.widgets.slide_button ], False)
def _build_menubar(self): uimanager = gtk.UIManager() uimanager.add_ui_from_string(self.ui) uimanager.insert_action_group(self.widgets.actiongroup, 0) accelgroup = uimanager.get_accel_group() self.add_accel_group(accelgroup) widgetDic = { "menubar": uimanager.get_widget("/MenuBar"), "toolbar": uimanager.get_widget("/Toolbar"), "MenuShowAll": uimanager.get_widget("/MenuBar/ViewMenu/ShowAll"), "MenuArrows": uimanager.get_widget("/MenuBar/ViewMenu/Arrows"), "MenuStats": uimanager.get_widget("/MenuBar/ViewMenu/Stats"), "MenuToolbar": uimanager.get_widget("/MenuBar/ViewMenu/Toolbar"), "MenuStatusbar": \ uimanager.get_widget("/MenuBar/ViewMenu/Statusbar"), "Filtermenu": uimanager.get_widget("/MenuBar/ViewMenu/FilterMenu"), "MenuEdit": uimanager.get_widget("/MenuBar/PigeonMenu/Edit"), "MenuRemove": uimanager.get_widget("/MenuBar/PigeonMenu/Remove"), "MenuPedigree": \ uimanager.get_widget("/MenuBar/PigeonMenu/Pedigree"), "MenuAddresult": \ uimanager.get_widget("/MenuBar/PigeonMenu/Addresult"), "ToolEdit": uimanager.get_widget("/Toolbar/Edit"), "ToolRemove": uimanager.get_widget("/Toolbar/Remove"), "ToolPedigree": uimanager.get_widget("/Toolbar/Pedigree") } for name, widget in widgetDic.items(): setattr(self.widgets, name, widget) utils.set_multiple_sensitive([ self.widgets.MenuEdit, self.widgets.MenuRemove, self.widgets.MenuPedigree, self.widgets.MenuAddresult, self.widgets.ToolEdit, self.widgets.ToolRemove, self.widgets.ToolPedigree], False) self.widgets.mainvbox.pack_start(self.widgets.menubar, False, False) self.widgets.mainvbox.pack_start(self.widgets.toolbar, False, False) if gtkosx is not None: logger.debug("Setting up Mac menubar") self.widgets.menubar.hide() gtkosx.set_menu_bar(self.widgets.menubar) quit = uimanager.get_widget("/MenuBar/FileMenu/Quit") quit.hide() about = uimanager.get_widget("/MenuBar/HelpMenu/About") upd = uimanager.get_widget("/MenuBar/HelpMenu/Update") prefs = uimanager.get_widget("/MenuBar/EditMenu/Preferences") gtkosx.insert_app_menu_item(about, 0) gtkosx.insert_app_menu_item(gtk.SeparatorMenuItem(), 1) gtkosx.insert_app_menu_item(upd, 2) gtkosx.insert_app_menu_item(prefs, 3)
def on_selection_changed(self, selection): model, rowiter = selection.get_selected() widgets = [self.widgets.buttonremove, self.widgets.buttonopen] utils.set_multiple_sensitive(widgets, not rowiter is None) self.widgets.image.clear() if rowiter is None: return mimetype = model.get_value(rowiter, 1) if mime.is_image(mimetype): path = unicode(model.get_value(rowiter, 2)) self.widgets.image.set_from_pixbuf(thumbnail.get_image(path)) else: try: image = mime.get_pixbuf(mimetype) self.widgets.image.set_from_pixbuf(image) except mime.MimeIconError: self.widgets.image.set_from_stock(gtk.STOCK_FILE, gtk.ICON_SIZE_DIALOG)
def on_selection_changed(self, selection): n_rows_selected = selection.count_selected_rows() model, paths = selection.get_selected_rows() widgets = [self.widgets.ToolRemove, self.widgets.MenuRemove, self.widgets.ToolEdit, self.widgets.ToolPedigree, self.widgets.MenuEdit, self.widgets.MenuPedigree, self.widgets.MenuAddresult] for tab in self._loaded_tabs: widgets.extend(tab.get_pigeon_state_widgets()) if n_rows_selected == 1: tree_iter = model.get_iter(paths[0]) utils.set_multiple_sensitive(widgets, True) elif n_rows_selected == 0: self._clear_pigeon_data() utils.set_multiple_sensitive(widgets, False) return elif n_rows_selected > 1: # Disable everything except the remove buttons self._clear_pigeon_data() utils.set_multiple_sensitive(widgets[2:], False) return self.current_pigeon = paths[0][0] pigeon = model.get_value(tree_iter, 0) self.detailsview.set_details(pigeon) for tab in self._loaded_tabs: tab.set_pigeon(pigeon)
def on_selection_changed(self, selection): model, rowiter = selection.get_selected() # Never select parent rows. Expand them and select first child row. if rowiter is not None and self.widgets.treestore.iter_depth( rowiter) == 0: path = self.widgets.treestore.get_path(rowiter) self.widgets.treeview.expand_row(path, False) rowiter = self.widgets.treestore.iter_children(rowiter) selection.select_iter(rowiter) widgets = [self.widgets.buttonremove, self.widgets.buttonedit] utils.set_multiple_sensitive(widgets, not rowiter is None) try: data = dict(database.get_breeding_for_key(model[rowiter][0])) except TypeError: data = {} success1 = data.get("success1", 0) success2 = data.get("success2", 0) self.widgets.datelaid1.set_text(data.get("laid1", "")) self.widgets.datehatched1.set_text(data.get("hatched1", "")) self.widgets.bandentry1.set_pindex(data.get("pindex1", "")) self.widgets.successcheck1.set_active(success1) self.widgets.datelaid2.set_text(data.get("laid2", "")) self.widgets.datehatched2.set_text(data.get("hatched2", "")) self.widgets.bandentry2.set_pindex(data.get("pindex2", "")) self.widgets.successcheck2.set_active(success2) self.widgets.entryclutch.set_text(data.get("clutch", "")) self.widgets.entrybox.set_text(data.get("box", "")) self.widgets.textviewcomment.get_buffer().set_text( data.get("comment", "")) p1 = not self.widgets.bandentry1.is_empty() p2 = not self.widgets.bandentry2.is_empty() self.widgets.buttoninfo1.set_sensitive(p1) self.widgets.buttongoto1.set_sensitive(p1) self.widgets.buttoninfo2.set_sensitive(p2) self.widgets.buttongoto2.set_sensitive(p2)
def on_selection_changed(self, selection): model, rowiter = selection.get_selected() widgets = [self.widgets.buttonremove, self.widgets.buttonedit] if rowiter is not None: utils.set_multiple_sensitive(widgets, True) else: utils.set_multiple_sensitive(widgets, False) for entry in self.get_objects_from_prefix("entry"): entry.set_text("") self.widgets.entrydate.set_text("") self.widgets.checkvaccination.set_active(False) return data = database.get_medication_for_id(model[rowiter][0]) self.widgets.entrydate.set_text(data["date"]) self.widgets.entrydescription.set_text(data["description"]) self.widgets.entryby.set_text(data["doneby"]) self.widgets.entrymedication.set_text(data["medication"]) self.widgets.entrydosage.set_text(data["dosage"]) self.widgets.entrycomment.set_text(data["comment"]) self.widgets.checkvaccination.set_active(data["vaccination"])
def on_selection_changed(self, selection): model, rowiter = selection.get_selected() widgets = [self.widgets.buttonremove, self.widgets.buttonedit] if rowiter: utils.set_multiple_sensitive(widgets, True) else: utils.set_multiple_sensitive(widgets, False) self._empty_entries() return data = database.get_address_data({"Addresskey": model[rowiter][0]}) self.widgets.entryname.set_text(data["name"]) self.widgets.entrystreet.set_text(data["street"]) self.widgets.entryzip.set_text(data["code"]) self.widgets.entrycity.set_text(data["city"]) self.widgets.entrycountry.set_text(data["country"]) self.widgets.entryphone.set_text(data["phone"]) self.widgets.entryemail.set_text(data["email"]) self.widgets.entrycomment.set_text(data["comment"]) self.widgets.checkme.set_active(data["me"]) self.widgets.entrylat.set_text(data["latitude"]) self.widgets.entrylong.set_text(data["longitude"])
def on_selection_changed(self, selection): model, rowiter = selection.get_selected() widgets = [self.widgets.buttonremove, self.widgets.buttonedit] utils.set_multiple_sensitive(widgets, not rowiter is None)