Example #1
0
 def select_aya(self, w):
     sura = asm_customs.value_active(self.suras, 0)
     aya = int(w.get_text())
     adj = self.ayas.get_adjustment()
     if aya > adj.get_upper(): aya = adj.get_upper()
     tafsir = asm_customs.value_active(self.tafsirs, 0)
     self.show_tafsir(tafsir, sura, aya)
Example #2
0
 def select_sura(self, w):
     self.ayas.set_sensitive(True)
     sura = asm_customs.value_active(w, 0)
     ayat = asm_customs.value_active(w, 2)
     adj = self.ayas.get_adjustment()
     adj.set_upper(ayat)
     adj.set_value(1)
     tafsir = asm_customs.value_active(self.tafsirs, 0)
     self.show_tafsir(tafsir, sura, 1)
Example #3
0
 def import_book(self, *a):
     if len(self.store_add) == 0:
         return
     id_group = asm_customs.value_active(self.groups)
     nm_group = asm_customs.value_active(self.groups, 1)
     self.progress.set_fraction(0.0)
     self.btn_clear.set_sensitive(False)
     self.btn_convert.set_sensitive(False)
     self.btn_remove.set_sensitive(False)
     self.btn_add.set_sensitive(False)
     n_books = len(self.store_add)
     f = 0
     self.no_add = u""
     while len(self.store_add) > 0:
         if self.stop_n == 1:
             break
         while Gtk.events_pending():
             Gtk.main_iteration()
         book = self.store_add[0][0]
         nm_file = self.store_add[0][1]
         if nm_file[-4:] == u".asm":
             try:
                 con = sqlite3.connect(book)
                 cur = con.cursor()
                 cur.execute("SELECT * FROM main")
                 info = cur.fetchone()
                 is_tafsir = info[8]
                 nm_book = info[0]
                 new_book = join(asm_path.BOOK_DIR_rw, nm_group, nm_file)
                 copyfile(book, new_book)
                 self.db.add_book(nm_book, id_group, is_tafsir)
             except:
                 self.no_add += u"\n- " + nm_file[:-4]
                 print("not add {}".format(book))
         else:
             nm_book = nm_file[:-4]
             # try:
             DB_from_BOK(book, nm_group, id_group)
             self.progress.set_fraction(float(f) / float(n_books))
         #                except OSError: asm_customs.erro(self, "حزمة mdbtools \nيرجى تثبيتها لأجل استيراد الكتب غير مثبتة"); raise
         #                except: self.no_add += u'\n- '+nm_book; print ('not add {}'.format(book,))
         i = self.store_add.get_iter_first()
         self.store_add.remove(i)
         f += 1
     self.progress.set_text("انتهى !!")
     self.progress.set_fraction(1.0)
     self.btn_clear.set_sensitive(True)
     self.btn_convert.set_sensitive(True)
     self.btn_remove.set_sensitive(True)
     self.btn_add.set_sensitive(True)
     if self.no_add != u"":
         asm_customs.erro(self, u"الكتب التي لم يتم إضافتها {}".format(self.no_add))
Example #4
0
 def ok_result(self, *a):
     model, i = self.sel_search.get_selected()
     if i:
         sura = model.get_value(i,0)
         aya = model.get_value(i,1)
         tafsir = asm_customs.value_active(self.tafsirs1, 0)
         self.show_tafsir(tafsir, sura, aya)
Example #5
0
 def select_sura(self, w):
     if self.suras.get_active() == -1: return
     ayat = asm_customs.value_active(w, 2)
     adj = self.ayas.get_adjustment()
     adj.set_upper(ayat)
     adj.set_value(1)
     adj = self.n_ayas.get_adjustment()
     adj.set_upper(ayat)
     adj.set_value(1)
Example #6
0
 def start_convert(self, *a):
     if self.stack.get_visible_child_name() == "n3":
         if len(self.store_books) == 0:
             asm_customs.erro(self, "يجب إظهار قائمة الكتب أولا!")
             return
         self.btn_convert.set_sensitive(False)
         self.btn_stop.set_sensitive(True)
         self.stop_n = 0
         self.no_book = 1
         self.no_add = u""
         self.btn_convert.set_sensitive(False)
         self.store_books.foreach(self.import_shamela, True)
         if self.no_add != u"":
             asm_customs.erro(self, u"الكتب التي لم يتم إضافتها {}".format(self.no_add))
         self.lab_status.set_text(" لقد انتهت عملية التحويل ")
         self.btn_convert.set_sensitive(True)
     elif self.stack.get_visible_child_name() == "n1":
         id_group = asm_customs.value_active(self.groups)
         if id_group == None:
             if len(self.db.all_parts()) > 0:
                 asm_customs.info(self, "اختر القسم المراد ضم الكتب إليه")
             else:
                 asm_customs.info(self, "اذهب إلى صفحة تنظيم المكتبة وأضف قسما لاستيراد الملفات إليه")
         else:
             self.btn_convert.set_sensitive(False)
             self.btn_stop.set_sensitive(True)
             self.stop_n = 0
             self.import_book()
     elif self.stack.get_visible_child_name() == "n2":
         id_group = asm_customs.value_active(self.groups_doc)
         if id_group == None:
             if len(self.db.all_parts()) > 0:
                 asm_customs.info(self, "اختر القسم المراد ضم الكتب إليه")
             else:
                 asm_customs.info(self, "اذهب إلى صفحة تنظيم المكتبة وأضف قسما لاستيراد الملفات إليه")
         else:
             self.btn_convert.set_sensitive(False)
             self.btn_stop.set_sensitive(True)
             self.stop_n = 0
             self.import_docs()
Example #7
0
 def choose_part(self, parent, msg):
     dlg = Gtk.MessageDialog(parent, Gtk.DialogFlags.MODAL, Gtk.MessageType.WARNING,
                          Gtk.ButtonsType.YES_NO)
     dlg.set_markup(msg)
     ls = []
     for a in self.db.all_parts():
         ls.append([a[0], a[1]])
     hb, parts_g = asm_customs.combo(ls, u'')
     parts_g.set_active(0)
     self.received_part_name = asm_customs.value_active(parts_g, 1)
     self.received_part_id = asm_customs.value_active(parts_g)
     def sel_part(w):
         self.received_part_name = asm_customs.value_active(parts_g, 1)
         self.received_part_id = asm_customs.value_active(parts_g)
     parts_g.connect('changed', sel_part)
     area = dlg.get_content_area()
     area.set_spacing(7)
     hbox = Gtk.HBox(False, 7)
     hbox.pack_end(hb, False, False, 0)
     area.pack_start(hbox, False, False, 0)
     area.show_all()
     r = dlg.run()
     dlg.destroy()
     return r
Example #8
0
 def mov_browse(self, id_page):
     self.suras.handler_block(self.change_sura)
     self.ayas.handler_block(self.change_aya)
     self.all_in_page = self.db.get_text_body(id_page)#rowid, id, text, part, page, hno, sora, aya, na
     if self.all_in_page in [None, "", 0] or self.all_in_page[7] in [None, "", 0]: 
         self.suras.set_active(-1)
         self.ayas.set_sensitive(False)
     elif self.notebook.get_current_page() == 0: 
         if self.all_in_page[6] >= 1 and self.suras.get_active() != self.all_in_page[6]-1:
             self.suras.set_active(self.all_in_page[6]-1)
             self.ayas.set_sensitive(True)
             ayat = asm_customs.value_active(self.suras, 2)
             adj = self.ayas.get_adjustment()
             if ayat == None: ayat = 100
             adj.set_upper(ayat)
             adj.set_value(1)
         if self.aya_now in range(self.all_in_page[7], self.all_in_page[7]+self.all_in_page[8]):
             self.ayas.set_value(self.aya_now)
         else: self.ayas.set_value(self.all_in_page[7])
             
     self.suras.handler_unblock(self.change_sura)
     self.ayas.handler_unblock(self.change_aya)
Example #9
0
 def import_docs(self, *a):
     self.no_add = u""
     if len(self.store_add_doc) == 0:
         return
     id_group = asm_customs.value_active(self.groups_doc)
     nm_group = asm_customs.value_active(self.groups_doc, 1)
     self.progress.set_fraction(0.0)
     self.btn_clear_doc.set_sensitive(False)
     self.btn_convert.set_sensitive(False)
     self.btn_remove_doc.set_sensitive(False)
     self.btn_add_doc.set_sensitive(False)
     if not self.is_book_radio.get_active():
         new_book = self.name_book_entry.get_text()
         if new_book == u"":
             asm_customs.info(self, "ضع اسما للكتاب المراد استيراده")
             return
         list_page = []
         list_title = []
         id_page = 1
     n_docs = len(self.store_add_doc)
     f = 0
     self.no_add = u""
     while len(self.store_add_doc) > 0:
         f += 1
         self.progress.set_fraction(float(f) / float(n_docs))
         while Gtk.events_pending():
             Gtk.main_iteration()
         if self.is_book_radio.get_active():
             new_book = re.sub(u"\....?.?$", u"", self.store_add_doc[0][1])
             text_book = self.get_text_from_file(self.store_add_doc[0][0], self.store_add_doc[0][1])
             if text_book != None and len(text_book) != 0:
                 pages = self.split_text_to_pages(text_book)
                 list_page = []
                 for a in range(len(pages)):
                     list_page.append([a + 1, pages[a], 1, a + 1])
                 list_title = [[1, new_book, 1, 0]]
                 self.make_book(new_book, id_group, nm_group, list_page, list_title)
         elif self.is_part_radio.get_active():
             text_book = self.get_text_from_file(self.store_add_doc[0][0], self.store_add_doc[0][1])
             if text_book != None and len(text_book) != 0:
                 pages = self.split_text_to_pages(text_book)
                 for a in range(len(pages)):
                     list_page.append([id_page, pages[a], f, a + 1])
                     id_page += 1
                 list_title.append([id_page - len(pages), u"الجزء {}".format(f), 1, 0])
         else:
             text_book = self.get_text_from_file(self.store_add_doc[0][0], self.store_add_doc[0][1])
             if text_book != None and len(text_book) != 0:
                 list_page.append([f, text_book, 1, f])
         i = self.store_add_doc.get_iter_first()
         self.store_add_doc.remove(i)
     if not self.is_book_radio.get_active():
         if list_title == []:
             list_title = [[1, new_book, 1, 0]]
         if self.no_add != u"":
             msg = asm_customs.sure(
                 self,
                 u"""
             عدد الملفات التي لم يتمكن من إضافتها هو {}
             هل تريد الاستمرار في تكوين الكتاب ؟
             """.format(
                     len(self.no_add.split("\n"))
                 ),
             )
             if msg == Gtk.ResponseType.YES:
                 self.make_book(new_book, id_group, nm_group, list_page, list_title)
     self.progress.set_text("انتهى !!")
     self.progress.set_fraction(1.0)
     self.btn_clear_doc.set_sensitive(True)
     self.btn_convert.set_sensitive(True)
     self.btn_remove_doc.set_sensitive(True)
     self.btn_add_doc.set_sensitive(True)
     if self.no_add != u"":
         asm_customs.erro(self, u"الملفات التي لم يتم إضافتها {}".format(self.no_add))
Example #10
0
 def select_tafsir(self, *a):
     self.nm_book = asm_customs.value_active(self.tafsirs, 1)
     tafsir = asm_customs.value_active(self.tafsirs, 0)
     sura = asm_customs.value_active(self.suras, 0)
     aya = self.ayas.get_value()
     self.show_tafsir(tafsir, sura, aya)
Example #11
0
 def sel_part(w):
     self.received_part_name = asm_customs.value_active(parts_g, 1)
     self.received_part_id = asm_customs.value_active(parts_g)