def replace_all(self, *a): txt1 = self.ent_replace1.get_text().decode('utf8') txt2 = self.ent_replace2.get_text().decode('utf8') 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 self.reg_exp.get_active(): text_new = re.sub(txt1, txt2, text) else: text_new = text.replace(txt1, txt2) text_new = daw_tools.right_space(text_new) self.nasse_bfr.set_text(text_new)
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 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
def modify_data(self, *a): model, i = self.sel_poem.get_selected() id_poem = model.get_value(i,0) text = daw_tools.right_space(self.view_nasse_bfr.get_text(self.view_nasse_bfr.get_start_iter(), self.view_nasse_bfr.get_end_iter(), False)).decode('utf8') if text == '': daw_customs.erro(self.parent, 'لقد تم مسح القصيدة'); return nam = self.nm_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 : if self.active_baher.get_active() == False: baher = 0 else: daw_customs.erro(self.parent, 'حدد بحر القصيدة'); return rawi = daw_customs.value_active(self.rawi) if rawi == None : if self.active_rawi.get_active() == False: rawi = 0 else: daw_customs.erro(self.parent, 'حدد روي القصيدة'); return kafia = daw_customs.value_active(self.kafia) if kafia == None : if self.active_kafia.get_active() == False: kafia = 0 else: daw_customs.erro(self.parent, 'حدد قافية القصيدة'); return arodh = daw_customs.value_active(self.arodh) if arodh == None : if self.active_arodh.get_active() == False: arodh = 0 else: daw_customs.erro(self.parent, 'حدد عروض القصيدة'); return elif naw3 == 2: baher = daw_customs.value_active(self.baher) if baher == None : if self.active_baher.get_active() == False: baher = 0 else: 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 : if self.active_gharadh.get_active() == False: gharadh = 0 else: daw_customs.erro(self.parent, 'حدد غرض القصيدة'); return charh = self.view_charh_bfr.get_text(self.view_charh_bfr.get_start_iter(), self.view_charh_bfr.get_end_iter(), False).decode('utf8') sabab = self.view_sabab_bfr.get_text(self.view_sabab_bfr.get_start_iter(), self.view_sabab_bfr.get_end_iter(), False).decode('utf8') label = Gtk.Label() label.override_font(Pango.FontDescription('KacstOne 15')) if naw3 != 5: if arodh in [26, 27, 37, 39, 40]: 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 msg = daw_customs.sure(self.parent, ''' هل أنت متأكد بأنك تريد تعديل البيانات ؟ ''' ) if msg == Gtk.ResponseType.NO: return check = self.parent.db.modify_poem(id_poem, nam, text, sabab, charh, n_abiat, baher, rawi, kafia, arodh, gharadh, naw3, longer_half) if check == None: daw_customs.info(self.parent, 'تم تعديل البيانات بنجاح'); return
def save_ta3lik(self, *a): text = daw_tools.right_space(self.view_charh_bfr.get_text(self.view_charh_bfr.get_start_iter(), self.view_charh_bfr.get_end_iter(), False)) self.parent.db.set_ta3lik(self.id_poem, text.decode('utf8'))