def adding_one(self, *a): text = daw_tools.right_space(self.nasse_bfr.get_text(self.nasse_bfr.get_start_iter(), self.nasse_bfr.get_end_iter(), False)).decode('utf8') if text == '': daw_customs.erro(self.parent, 'ضع القصيدة أولا'); return nam = self.name_poem.get_text().decode('utf8') if nam == '' : daw_customs.erro(self.parent, 'ضع اسما للقصيدة\nأو أول شطر منها'); return naw3 = daw_customs.value_active(self.naw3) if naw3 == None : daw_customs.erro(self.parent, 'حدد نوع القصيدة'); return if naw3 == 1: baher = daw_customs.value_active(self.baher) if baher == None : daw_customs.erro(self.parent, 'حدد بحر القصيدة'); return rawi = daw_customs.value_active(self.rawi) if rawi == None : daw_customs.erro(self.parent, 'حدد روي القصيدة'); return kafia = daw_customs.value_active(self.kafia) if kafia == None : daw_customs.erro(self.parent, 'حدد قافية القصيدة'); return arodh = daw_customs.value_active(self.arodh) if arodh == None : daw_customs.erro(self.parent, 'حدد عروض القصيدة'); return elif naw3 == 2: baher = daw_customs.value_active(self.baher) if baher == None : daw_customs.erro(self.parent, 'حدد بحر القصيدة'); return rawi = 0 kafia = 0 arodh = 0 else: baher = 0 rawi = 0 kafia = 0 arodh = 0 gharadh = daw_customs.value_active(self.gharadh) if gharadh == None : daw_customs.erro(self.parent, 'حدد غرض القصيدة'); return poet, sex, balad, age = self.add_poet() if poet == 'none': return charh = self.charh_bfr.get_text(self.charh_bfr.get_start_iter(), self.charh_bfr.get_end_iter(), False).decode('utf8') sabab = self.sabab_bfr.get_text(self.sabab_bfr.get_start_iter(), self.sabab_bfr.get_end_iter(), False).decode('utf8') label = Gtk.Label() label.override_font(Pango.FontDescription('KacstOne 15')) if naw3 != 5: if daw_tools.is_machtor(text): longer_half, n_abiat = daw_tools.longer_half(text, label, 1) else: longer_half, n_abiat = daw_tools.longer_half(text, label, 0) else: longer_half = 0 n_abiat = len(text.splitlines(1)) check = self.parent.db.add_poem(nam, text, sabab, charh, poet, sex, balad, age, n_abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half) self.parent.dawawinpage.refresh_poets() self.parent.dawawinpage.search_cb() self.parent.organizepage.refresh_poets() self.parent.organizepage.search_cb() if check == None: daw_customs.info(self.parent, 'تم إضافة القصيدة بنجاح'); return
def build(self, font='Simplified Naskh 18'): size = self.parent.get_size() self.width_window = size[0]-240 if self.view_poem.get_allocated_width() > 100: self.width_window = self.view_poem.get_allocated_width() b_a = daw_config.getn('b_abiat')*2 self.font = font self.size_font = int(self.font[-2:]) label = Gtk.Label() label.override_font(Pango.FontDescription(self.font)) if self.naw3 != 5: if daw_tools.is_machtor(self.text_poem): arodh = 1 else: arodh = 0 self.new_poem, self.t = daw_tools.length_Half(self.text_poem, label, self.length, self.size_font, self.width_window, arodh) poem = self.new_poem poem = self.speaker+poem self.view_poem_bfr.set_text(poem) daw_customs.with_tag(self.view_poem_bfr, self.speaker_poem_tag, [self.speaker,]) self.view_poem.override_font(Pango.FontDescription(self.font)) self.view_poem.set_pixels_below_lines((self.size_font*b_a)/3) self.view_poem.set_pixels_above_lines((self.size_font*b_a)/3)
def adding_muth(self, *a): text = daw_tools.right_space(self.nasse_bfr.get_text(self.nasse_bfr.get_start_iter(), self.nasse_bfr.get_end_iter(), False)).decode('utf8') if text == '': daw_customs.erro(self.parent, 'ضع القصائد أولا'); return gharadh = 0 baher = 0 rawi = 0 kafia = 0 arodh = 0 sabab = "" charh = "" poet, sex, balad, age = self.add_poet() if poet == 'none': return self.set_sensitive(False) list_poems = text.split('#') for poem_text in list_poems: while (Gtk.events_pending()): Gtk.main_iteration() name, poem, naw3, gharadh, baher, rawi, kafia = daw_tools.name_poem(poem_text) poem = daw_tools.right_space(poem) label = Gtk.Label() label.override_font(Pango.FontDescription('KacstOne 15')) if naw3 != 5: if daw_tools.is_machtor(poem): longer_half, n_abiat = daw_tools.longer_half(poem, label, 1) else: longer_half, n_abiat = daw_tools.longer_half(poem, label, 0) else: longer_half = 0 n_abiat = len(poem.splitlines(1)) self.parent.db.add_poem(name, poem, sabab, charh, poet, sex, balad, age, n_abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half) self.parent.dawawinpage.refresh_poets() self.parent.dawawinpage.search_cb() self.parent.organizepage.refresh_poets() self.parent.organizepage.search_cb() daw_customs.info(self.parent, 'تم إضافة جميع القصائد بنجاح') self.set_sensitive(True); return