Exemple #1
0
    def on_search_clicked(self, widget):
        self.filter.clear()

        year = self.widgets.spinyear.get_value_as_int()
        yearop = self.widgets.comboyear.get_operator()
        self.filter.add("year", year, yearop, int)

        if self.widgets.checksex.get_active():
            sex = self.widgets.combosex.get_sex()
            self.filter.add("sex", sex, type_=int, allow_empty_value=True)

        if self.widgets.checkstatus.get_active():
            status = self.widgets.combostatus.get_status()
            self.filter.add("active",
                            status,
                            type_=int,
                            allow_empty_value=True)

        colour = self.widgets.combocolour.child.get_text()
        self.filter.add("colour", colour)

        strain = self.widgets.combostrain.child.get_text()
        self.filter.add("strain", strain)

        loft = self.widgets.comboloft.child.get_text()
        self.filter.add("loft", loft)

        self.treeview._modelfilter.refilter()
        component.get("Statusbar").set_filter(self.filter.has_filters())
        self.treeview.emit("pigeons-changed")
Exemple #2
0
    def on_clear_clicked(self, widget):
        for combo in ["year", "sex", "status"]:
            getattr(self.widgets, "combo" + combo).set_active(0)
        for spin in ["year"]:
            getattr(self.widgets, "spin" + spin).set_value(0)
        for combo in ["colour", "strain", "loft"]:
            getattr(self.widgets, "combo" + combo).child.set_text("")
        for check in ["sex", "status"]:
            getattr(self.widgets, "check" + check).set_active(False)

        self.filter.clear()
        self.treeview._modelfilter.refilter()
        component.get("Statusbar").set_filter(False)
        self.treeview.emit("pigeons-changed")
Exemple #3
0
 def on_addtopedigree_clicked(self, widget):
     result = self.widgets.resultview.get_selected()
     text = "%se %s %s %s." % (result["placed"], result["point"],
                               result["out"], _("Pigeons")[0].lower())
     for index, field in enumerate(self.pigeon.get_extra()):
         if field == "":
             database.update_pigeon(self.pigeon.pindex,
                                    {"extra%s" % (index + 1): text})
             pigeonparser.parser.update_pigeon(self.pigeon.pindex)
             component.get("DetailsView").set_details(self.pigeon)
             break
     else:
         InfoDialog(
             (_("No empty space found in pedigree details."), "", ""),
             self._parent, None)
Exemple #4
0
    def on_buttonexport_clicked(self, widget):
        filepath = self.widgets.entrypath.get_text()
        path = os.path.dirname(filepath)
        if not os.path.exists(path) or os.path.isdir(filepath):
            ErrorDialog((_("Invalid input!"), None, _("Error")),
                        self.widgets.window)
            return
        self.widgets.imageprogress.hide()
        self.widgets.spinner.show()
        self.widgets.spinner.start()

        treeview = component.get("Treeview")
        if self.widgets.radioselected.get_active():
            pigeons = treeview.get_selected_pigeon()
            # pigeons can be a list of selected or just one pigeon object.
            if not isinstance(pigeons, list):
                pigeons = [pigeons]
        elif self.widgets.radiovisible.get_active():
            pigeons = treeview.get_pigeons(True)
        else:
            pigeons = pigeonparser.parser.pigeons.values()
        exporter = self.__get_exporter()
        try:
            exporter.run(filepath, pigeons)
        except IOError as e:
            logger.exception(e)
            ErrorDialog(
                (_("The selected path is not writeable."), None, _("Error")),
                self.widgets.window)
        else:
            self.widgets.imageprogress.show()

        self.widgets.spinner.hide()
        self.widgets.spinner.stop()
Exemple #5
0
    def __init__(self, parent=None, register=False):
        builder.GtkBuilder.__init__(self, "DetailsView.ui")
        gobject.GObject.__init__(self)
        if register:
            component.Component.__init__(self, "DetailsView")

        self.parent = parent or component.get("MainWindow")
        self.pedigree_mode = False
        self.pigeon = None
        self.child = None

        self.widgets.pigeonimage = PigeonImageWidget(False, self, parent)
        self.widgets.viewportImage.add(self.widgets.pigeonimage)
        self.widgets.pigeonimage_edit = PigeonImageWidget(True, self, parent)
        self.widgets.viewportImageEdit.add(self.widgets.pigeonimage_edit)

        self.widgets.combocolour.set_data(database.get_all_data(
            database.Tables.COLOURS),
                                          sort=False)
        self.widgets.combostrain.set_data(database.get_all_data(
            database.Tables.STRAINS),
                                          sort=False)
        self.widgets.comboloft.set_data(database.get_all_data(
            database.Tables.LOFTS),
                                        sort=False)

        self.widgets.combostatus.set_active(1)
        self.widgets.combostatus.emit("changed")

        self.widgets.statusdialog.set_transient_for(parent)
        self.widgets.root.show_all()
Exemple #6
0
    def __init__(self):
        gtk.TreeView.__init__(self)
        component.Component.__init__(self, "Treeview")

        component.get("Statusbar").set_filter(False)
        self._liststore = self._build_treeview()
        self._modelfilter = self._liststore.filter_new()
        self._modelfilter.set_visible_func(self._visible_func)
        self._modelsort = gtk.TreeModelSort(self._modelfilter)
        self._modelsort.set_sort_func(3, self._sort_func)
        self._modelsort.set_sort_column_id(3, gtk.SORT_ASCENDING)
        self.set_model(self._modelsort)
        self.set_rules_hint(True)
        self._selection = self.get_selection()
        self._selection.set_mode(gtk.SELECTION_MULTIPLE)
        self._filterdialog = FilterDialog(self)
        self.set_columns()
        self.show_all()
Exemple #7
0
    def __init__(self):
        builder.GtkBuilder.__init__(self, "BreedingView.ui")
        basetab.BaseTab.__init__(self, "BreedingTab", _("Breeding"),
                                 "icon_breeding.png")

        self.maintreeview = component.get("Treeview")
        self.widgets.selection = self.widgets.treeview.get_selection()
        self.widgets.selection.connect("changed", self.on_selection_changed)
        self.widgets.editdialog.set_transient_for(self._parent)
Exemple #8
0
    def __init__(self, name, title, img):
        component.Component.__init__(self, name)

        self._parent = component.get("MainWindow")

        self.widgets._label = gtk.VBox()
        img = os.path.join(const.IMAGEDIR, img)
        if gtk.gdk.screen_height() <= 768:
            self.widgets._label.set_orientation(gtk.ORIENTATION_HORIZONTAL)
            pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(img, 18, 18)
        else:
            pixbuf = gtk.gdk.pixbuf_new_from_file(img)
        image = gtk.image_new_from_pixbuf(pixbuf)
        label = gtk.Label(title)
        self.widgets._label.pack_start(image)
        self.widgets._label.pack_start(label)
        self.widgets._label.show_all()
Exemple #9
0
 def on_goto_pigeon(self, widget, pigeon):
     if not component.get("Treeview").select_pigeon(None, pigeon.get_pindex()):
         InfoDialog(messages.MSG_NO_PIGEON, self._parent)
Exemple #10
0
 def _redraw(self):
     self.draw_pedigree(self.tables, self.pigeon, True)
     component.get("Treeview").get_selection().emit("changed")
Exemple #11
0
 def _select_pigeon(self, widget, pigeon, parent):
     pindex = pigeon.get_pindex()
     if not component.get("Treeview").select_pigeon(None, pindex):
         InfoDialog(messages.MSG_NO_PIGEON, parent)