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 show_page(self, new_font=None): lst_abiat = [] if new_font == None: new_font = self.new_font text_page = u'' self.view_abiat_bfr.set_text('') self.view_abiat.override_font(Pango.FontDescription(self.new_font)) for s in self.list_abiat: lst_abiat.append(s) lst_abiat.reverse() for a in lst_abiat: id_poem, abiat = self.parent.db.get_abiat(a) try: id_poet = self.parent.db.id_poet(id_poem) except: id_poet = 0 name_poet, lakab_poet = self.parent.db.name_poet(id_poet) speaker = lakab_poet itr = self.view_abiat_bfr.get_iter_at_offset(0) anchor = self.view_abiat_bfr.create_child_anchor(itr) if (anchor and not anchor.get_deleted()): box = Gtk.HBox(False, 0) img1 = Gtk.Image() img1.set_from_file(join(daw_customs.ICON_DIR, 'clear.png')) widget1 = Gtk.Button() widget1.set_image(img1) widget1.connect('clicked', self.rm_bayt) widget1.set_tooltip_text('احذف من المفضلة') widget1.set_name(str(a)) img2 = Gtk.Image() img2.set_from_file(join(daw_customs.ICON_DIR, 'to_poem.png')) widget2 = Gtk.Button() widget2.set_image(img2) widget2.connect('clicked', self.to_poem) widget2.set_tooltip_text('اعرض القصيدة الأصلية') widget2.set_name(str(id_poem)) widget3 = daw_customs.ButtonClass(speaker) widget3.connect('clicked', self.to_poet) widget3.set_name(speaker) box.pack_start(widget1, False, False, 0) box.pack_start(widget2, False, False, 0) box.pack_start(widget3, False, False, 0) self.view_abiat.add_child_at_anchor(box, anchor) box.show_all() size = self.parent.get_size() self.width_window = size[0]-240 if self.view_abiat.get_allocated_width() > 100: self.width_window = self.view_abiat.get_allocated_width() size_font = int(new_font[-2:]) label = Gtk.Label() label.override_font(Pango.FontDescription(new_font)) length, n_abiat = daw_tools.longer_half(abiat, label, 0) r_abiat, t = daw_tools.length_Half(abiat, label, length, size_font, self.width_window, 0) text_page = u'\n'+r_abiat+'\n' itr = self.view_abiat_bfr.get_iter_at_offset(1) self.view_abiat_bfr.insert(itr, text_page, -1)
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