def site_in_book(self, *a): list_marks = eval(asm_config.getv('marks')) if self.notebook.get_current_page() == 1: n = self.viewerbook.get_current_page() ch =self.viewerbook.get_nth_page(n) list_marks.append([ch.all_in_page[1], ch.nm_book, ch.id_book]) marks = repr(list_marks) asm_config.setv('marks', marks) asm_customs.info(self, u'تم تعليم هذا الموضع')
def ch_color(self, btn): nconf = btn.get_name() dialog = Gtk.ColorChooserDialog("اختر لونا", self.parent) dialog.set_rgba(asm_customs.rgba(asm_config.getv(nconf))) response = dialog.run() if response == Gtk.ResponseType.OK: color = dialog.get_rgba().to_string() asm_config.setv(nconf, color) dialog.destroy() self.parent.theme.refresh()
def ch_font(self, btn): nconf = btn.get_name() dialog = Gtk.FontChooserDialog("اختر خطا", self.parent) dialog.set_font(asm_config.getv(nconf)) response = dialog.run() if response == Gtk.ResponseType.OK: font = dialog.get_font() asm_config.setv(nconf, font) dialog.destroy() self.parent.theme.refresh()
def save_list(self, *a): list_tafsir = eval(asm_config.getv('list_tafsir')) list_tafsir[2] = 1 list_tafsir[1] = [] list_tafsir[0] = self.col_btn.get_active() for a in self.store_tafsir_added: list_tafsir[1].append(a[0]) list_tafsir = repr(list_tafsir) asm_config.setv('list_tafsir', list_tafsir) self.parent.tafsirpage.refresh_list() self.destroy()
def load_list(self, *a): self.store_tafasir = [] list_tafsir = eval(asm_config.getv('list_tafsir')) if list_tafsir[2] == 0: all_tafsir = self.listbook.all_tafsir() for a in all_tafsir: self.store_tafasir.append(a) elif list_tafsir[2] == 1: for a in list_tafsir[1]: if self.listbook.tit_book(a) != None and len(self.listbook.tit_book(a)) > 1: self.store_tafasir.append([a, self.listbook.tit_book(a)[1]]) self.store_tafasir.insert(0, [-1, 'التفسير الميسر']) self.n_warp = list_tafsir[0]+1
def load_tafasir(self, *a): list_tafsir = eval(asm_config.getv('list_tafsir')) all_tafsir = self.parent.db.all_tafsir() if list_tafsir[2] == 0: for a in all_tafsir: self.store_tafsir_added.append(a) list_tafsir[1].append(a[0]) else: for a in list_tafsir[1]: self.store_tafsir_added.append(self.parent.db.tit_book(a)) for t in all_tafsir: if t[0] not in list_tafsir[1]: self.store_tafsir_no_added.append(t) self.col_btn.set_active(list_tafsir[0]) list_tafsir[2] = 1 list_tafsir = repr(list_tafsir) asm_config.setv('list_tafsir', list_tafsir)
def refresh_list(self, *a): model = self.tafsirs.get_model() model1 = self.tafsirs1.get_model() model.clear() model1.clear() list_tafsir = eval(asm_config.getv('list_tafsir')) model.append([-1, 'التفسير الميسر', 0]) model1.append([-1, 'التفسير الميسر', 0]) for a in list_tafsir[1]: model.append([a, self.listbook.tit_book(a)[1], 0]) model1.append([a, self.listbook.tit_book(a)[1], 0]) self.tafsirs.set_active(0) self.tafsirs1.set_active(0) self.tafsirs.set_wrap_width(list_tafsir[0]+1) self.tafsirs1.set_wrap_width(list_tafsir[0]+1) self.tafsirs.show_all() self.tafsirs1.show_all()
def start_session(self, *a): session = eval(asm_config.getv('start_session')) if asm_config.getn('saved_session') == 0: return if session[1][-1] == 1: if self.viewerbook.get_n_pages() == 0: self.notebook.set_current_page(session[1][-2]) else: self.notebook.set_current_page(session[1][-1]) elif session[1][-1] in [0, 2, 3, 4, 5, 6, 8]: self.notebook.set_current_page(session[1][-1]) else: self.notebook.set_current_page(session[1][-2]) if session[0] == []: return for id_book in session[0][0]: book = self.db.file_book(id_book) sr = OpenBook(self, book, id_book) self.viewerbook.append_page(sr,TabLabel(sr, self.db.tit_book(id_book)[1])) sr.set_index() sr.scroll_search.hide() self.viewerbook.set_current_page(session[0][1])
def __init__(self, parent): self.parent = parent self.list_marks = eval(asm_config.getv("marks")) Gtk.Dialog.__init__(self, parent=self.parent) self.set_icon_name("asmaa") hb_bar = Gtk.HeaderBar() hb_bar.set_show_close_button(True) self.set_titlebar(hb_bar) hb_bar.set_title("المواضع المحفوظة") self.set_default_size(350, 300) box = self.vbox box.set_spacing(3) self.store_sav = Gtk.ListStore(int, str, int) for a in self.list_marks: self.store_sav.append(a) self.tree_sav = asm_customs.TreeIndex() self.tree_sav.connect("row-activated", self.ok_m) column = Gtk.TreeViewColumn("الكتاب", Gtk.CellRendererText(), text=1) self.tree_sav.append_column(column) column = Gtk.TreeViewColumn("الموضع", Gtk.CellRendererText(), text=0) self.tree_sav.append_column(column) self.tree_sav.set_model(self.store_sav) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_sav) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(hbox.get_style_context(), "linked") remove = asm_customs.ButtonClass("حذف") remove.connect("clicked", self.remove_iter) hbox.pack_start(remove, False, False, 0) remove_all = asm_customs.ButtonClass("مسح") remove_all.connect("clicked", self.remove_iters) hbox.pack_start(remove_all, False, False, 0) hb_bar.pack_start(hbox) box.pack_start(scroll, True, True, 0) self.show_all()
def build(self,*a): Gtk.Dialog.__init__(self, parent=self.parent) self.set_default_size(500, 400) vbox1 = self.vbox vbox = Gtk.Box(spacing=0,orientation=Gtk.Orientation.HORIZONTAL) hb_bar = Gtk.HeaderBar() hb_bar.set_show_close_button(True) self.set_titlebar(hb_bar) hb_bar.set_custom_title(vbox) Gtk.StyleContext.add_class(vbox.get_style_context(), "linked") vbox.set_border_width(3) self.notebook = Gtk.Notebook() self.notebook.set_show_tabs(False) box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL) box1 = Gtk.Box(spacing=4, orientation=Gtk.Orientation.VERTICAL) box1.set_border_width(5) self.frame = Gtk.Frame() box.set_border_width(5) ls = [u'بدون', u'مقترح', u'متباين', u'مخصص'] style_btn = Gtk.ComboBoxText() for a in ls: style_btn.append_text(a) style_btn.connect("changed", self.specified) style_btn.set_active(asm_config.getn('theme')) hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(Gtk.Label('النمط'), False, False, 0) hb.pack_end(style_btn, False, False, 0) box.pack_start(hb, False, False, 0) box.pack_start(self.frame, True, True, 0) list_w1 = [[u'قائمة الأقسام','_prts'], [u'قائمة الكتب','_bks'], [u'القوائم الجانبية','_idx'], [u'نصوص الكتاب','_nass'], [u'النص القرآني', '_qrn'], [u'نصوص أخرى','_oth'], [u'العناوين','_tit']] list_w2 = [[u'لون خلفية العرض','_bg'], [u'خلفية النص القرآني', '_bg_qrn'], [u'لون خلفية القوائم','_bgs', [u'لون خط التحديد','_sel'], [u'لون خلفية التحديد','_bg_sel'], [u'لون تحديد البحث','_fnd']]] for a in list_w1: hbox = Gtk.Box(spacing=3,orientation=Gtk.Orientation.HORIZONTAL) btn1 = Gtk.ToolButton(stock_id = Gtk.STOCK_SELECT_FONT) btn1.set_name('font'+a[1]) btn1.connect('clicked',self.ch_font) btn2 = Gtk.ToolButton(stock_id = Gtk.STOCK_SELECT_COLOR) btn2.set_name('color'+a[1]) btn2.connect('clicked',self.ch_color) hbox.pack_start(Gtk.Label(a[0]), False, False, 0) hbox.pack_end(btn2, False, False, 0) hbox.pack_end(btn1, False, False, 0) box1.pack_start(hbox, False, False, 0) for a in list_w2: hbox = Gtk.Box(spacing=3,orientation=Gtk.Orientation.HORIZONTAL) btn = Gtk.ToolButton(stock_id = Gtk.STOCK_SELECT_COLOR) btn.set_name('color'+a[1]) btn.connect('clicked',self.ch_color) hbox.pack_start(Gtk.Label(a[0]), False, False, 0) hbox.pack_end(btn, False, False, 0) box1.pack_start(hbox, False, False, 0) ref = Gtk.Button("تحديث الواجهة") ref.connect('clicked', lambda *a: self.parent.theme.refresh()) ref.connect('clicked', self.refresh) box.pack_end(ref, False, False, 0) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(box1) self.frame.add(scroll) self.notebook.append_page(box, Gtk.Label('خط ولون')) box = Gtk.VBox(False, 6) box.set_border_width(6) btn_win_organize = Gtk.Button('تعديل المكتبة') btn_win_organize.connect('clicked', lambda *a: self.parent.notebook.set_current_page(8)) box.pack_start(btn_win_organize, False, False, 0) btn_win_siana = Gtk.Button('نافذة الصيانة') btn_win_siana.connect('clicked', lambda *a: SianaWin(self.parent)) box.pack_start(btn_win_siana, False, False, 0) btn_win_add = Gtk.Button('نافذة الاستيراد') btn_win_add.connect('clicked', lambda *a: AddBooks(self.parent)) box.pack_start(btn_win_add, False, False, 0) btn_win_export = Gtk.Button('نافذة التصدير') btn_win_export.set_sensitive(False) #btn_win_export.connect('clicked', lambda *a: AddBooks(self.parent)) box.pack_start(btn_win_export, False, False, 0) btn_win_index = Gtk.Button('نافذة الفهرسة') #btn_win_index.set_sensitive(False) try: from Asmaa.asm_indexer import WinIndexer btn_win_index.connect('clicked', lambda *a: WinIndexer(self.parent)) except: pass box.pack_start(btn_win_index, False, False, 0) self.notebook.append_page(box, Gtk.Label('النوافذ')) box = Gtk.VBox(False, 6) box.set_border_width(6) self.add_db = Gtk.Button('إنشاء مكتبة مفرّغة') self.add_db.connect('clicked', self.new_db) box.pack_start(self.add_db, False, False, 0) self.b_dest = Gtk.Button('تغيير مسار المكتبة') self.b_dest.connect('clicked', self.change_path_db) self.b_path = Gtk.Button('عرض المسار الحاليّ') self.b_path.connect('clicked', lambda *a: asm_customs.info(self.parent, asm_config.getv('path'))) box.pack_start(self.b_dest, False, False, 0) box.pack_start(self.b_path, False, False, 0) self.copy_to_home = Gtk.Button('نسخ المكتبة إلى المنزل') self.copy_to_home.set_tooltip_text('هذا الخيار إذا كانت كتب المكتبة في الدليل :\n"/usr/share/asmaa/"') if self.db.check_books_library() == False: self.copy_to_home.set_sensitive(False) self.copy_to_home.connect('clicked', self.copy_to_home_cb) box.pack_start(self.copy_to_home, False, False, 0) self.notebook.append_page(box, Gtk.Label('المسار')) box = Gtk.VBox(False, 6) box.set_border_width(5) self.saved_session = Gtk.CheckButton('حفظ الجلسة عند الإغلاق') box.pack_start(self.saved_session, False, False, 0) if asm_config.getn('saved_session') == 1: self.saved_session.set_active(True) else: self.saved_session.set_active(False) self.saved_session.connect("toggled", self.saved_session_cb) self.active_mouse_browse = Gtk.CheckButton('التصفح بعجلة الفأرة') box.pack_start(self.active_mouse_browse, False, False, 0) if asm_config.getn('mouse_browse') == 1: self.active_mouse_browse.set_active(True) else: self.active_mouse_browse.set_active( False) self.active_mouse_browse.connect("toggled", self.active_mouse_browse_cb) ls = [u'بدون', u'اختفاء وظهور', u'زحلقة أفقية', u'زحلقة عمودية'] style_browse = Gtk.ComboBoxText() for a in ls: style_browse.append_text(a) style_browse.connect("changed", self.style_browse_cb) style_browse.set_active(asm_config.getn('style_browse')) hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(Gtk.Label('نمط التصفح'), False, False, 0) hb.pack_end(style_browse, False, False, 0) box.pack_start(hb, False, False, 0) ls = [u'0.1', u'0.2', u'0.5', u'1', u'1.5', u'2', u'3'] time_browse = Gtk.ComboBoxText() for a in ls: time_browse.append_text(a) time_browse.connect("changed", self.time_browse_cb) time_browse.set_active(asm_config.getn('time_browse')) hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(Gtk.Label('زمن التصفح بالثواني'), False, False, 0) hb.pack_end(time_browse, False, False, 0) box.pack_start(hb, False, False, 0) ls = [u'1', u'2', u'3', u'4', u'5', u'10'] auto_browse = Gtk.ComboBoxText() for a in ls: auto_browse.append_text(a) auto_browse.connect("changed", self.auto_browse_cb) idx = ls.index(str(asm_config.getv('auto_browse')), ) auto_browse.set_active(idx) hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(Gtk.Label('سرعة الاستعراض الآلي'), False, False, 0) hb.pack_end(auto_browse, False, False, 0) box.pack_start(hb, False, False, 0) self.numbers = Gtk.CheckButton('استعمال أرقام المغاربة') box.pack_start(self.numbers, False, False, 0) if asm_config.getn('nmbrs') == 1: self.numbers.set_active(True) else: self.numbers.set_active(False) self.numbers.connect("toggled", self.numbers_cb) self.notebook.append_page(box, Gtk.Label('خيارات')) box = Gtk.VBox(False, 6) box.set_border_width(6) self.rv_index = Gtk.Button('حذف الفهارس') self.rv_index.connect('clicked', self.rv_index_cb) box.pack_start(self.rv_index, False, False, 0) self.notebook.append_page(box, Gtk.Label('العمليات')) box = Gtk.VBox(False, 6) box.set_border_width(6) self.n_books_parts = Gtk.Button('عدد الكتب') self.n_books_parts.connect('clicked', self.count_cb) box.pack_start(self.n_books_parts, False, False, 0) self.rapid_count = Gtk.Button('إحصاء سريع') self.rapid_count.connect('clicked', self.count_fast) self.detail_count = Gtk.Button('إحصاء مفصل') self.detail_count.connect('clicked', self.count_detail) box.pack_start(self.rapid_count, False, False, 0) box.pack_start(self.detail_count, False, False, 0) btn_about = Gtk.Button('حول المكتبة') btn_about.connect('clicked', lambda *a: About(self.parent)) box.pack_start(btn_about, False, False, 0) btn_help = Gtk.Button('صفحة المساعدة') btn_help.connect('clicked', lambda *a: self.parent.notebook.set_current_page(5)) box.pack_start(btn_help, False, False, 0) web_page = Gtk.LinkButton.new_with_label("http://sourceforge.net/projects/asmaalibrary/files/", 'صفحة البرنامج على الشّبكة') box.pack_start(web_page, False, False, 0) db_void = Gtk.LinkButton.new_with_label("http://sourceforge.net/projects/asmaalibrary/files/AsmaaLibrary.tar.gz/download", 'تنزيل قاعدة بيانات للتجربة') box.pack_start(db_void, False, False, 0) self.notebook.append_page(box, Gtk.Label('المعلومات')) vbox1.pack_start(self.notebook, True, True, 0) self.theme_btn = Gtk.ToggleButton() img = Gtk.Image() img.set_from_stock(Gtk.STOCK_SELECT_COLOR, Gtk.IconSize.LARGE_TOOLBAR) self.theme_btn.set_image(img) self.theme_btn.set_name('theme') self.theme_btn.set_active(True) self.theme_btn.connect("clicked", self.switch_page) vbox.pack_start(self.theme_btn, False, False, 0) self.wins_btn = Gtk.ToggleButton() img = Gtk.Image() img.set_from_stock(Gtk.STOCK_HOME, Gtk.IconSize.LARGE_TOOLBAR) self.wins_btn.set_image(img) self.wins_btn.set_name('wins') self.wins_btn.connect("clicked", self.switch_page) vbox.pack_start(self.wins_btn, False, False, 0) self.path_btn = Gtk.ToggleButton() img = Gtk.Image() img.set_from_stock(Gtk.STOCK_OPEN, Gtk.IconSize.LARGE_TOOLBAR) self.path_btn.set_image(img) self.path_btn.set_name('path') self.path_btn.connect("clicked", self.switch_page) vbox.pack_start(self.path_btn, False, False, 0) self.prop_btn = Gtk.ToggleButton() img = Gtk.Image() img.set_from_stock(Gtk.STOCK_PROPERTIES, Gtk.IconSize.LARGE_TOOLBAR) self.prop_btn.set_image(img) self.prop_btn.set_name('prop') self.prop_btn.connect("clicked", self.switch_page) vbox.pack_start(self.prop_btn, False, False, 0) self.modifie_btn = Gtk.ToggleButton() img = Gtk.Image() img.set_from_stock(Gtk.STOCK_PREFERENCES, Gtk.IconSize.LARGE_TOOLBAR) self.modifie_btn.set_image(img) self.modifie_btn.set_name('modifie') self.modifie_btn.connect("clicked", self.switch_page) vbox.pack_start(self.modifie_btn, False, False, 0) self.info_btn = Gtk.ToggleButton() img = Gtk.Image() img.set_from_stock(Gtk.STOCK_INFO, Gtk.IconSize.LARGE_TOOLBAR) self.info_btn.set_image(img) self.info_btn.set_name('info') self.info_btn.connect("clicked", self.switch_page) vbox.pack_start(self.info_btn, False, False, 0) self.show_all()
def apply_preference(self, *a): if asm_config.getn('theme') == 3: self.font_tit = asm_config.getv('font_tit') self.font_idx = asm_config.getv('font_idx') self.font_nass = asm_config.getv('font_nass') self.font_qrn = asm_config.getv('font_qrn') self.font_prts = asm_config.getv('font_prts') self.font_bks = asm_config.getv('font_bks') self.color_tit = asm_config.getv('color_tit') self.color_idx = asm_config.getv('color_idx') self.color_nass = asm_config.getv('color_nass') self.color_qrn = asm_config.getv('color_qrn') self.color_prts = asm_config.getv('color_prts') self.color_bks = asm_config.getv('color_bks') self.color_bg = asm_config.getv('color_bg') self.color_bgs = asm_config.getv('color_bgs') self.color_sel = asm_config.getv('color_sel') self.color_fnd = asm_config.getv('color_fnd') self.color_bg_sel = asm_config.getv('color_bg_sel') self.color_bg_qrn = asm_config.getv('color_bg_qrn') elif asm_config.getn('theme') == 2: self.font_tit = 'KacstOne 32' self.font_idx = 'KacstOne 18' self.font_nass = 'Amiri Quran 32' self.font_qrn = 'Amiri Quran 32' self.font_prts = 'KacstOne 22' self.font_bks = 'KacstOne 20' self.color_tit = '#f7f7e6e69494' self.color_idx = '#ffffffffffff' self.color_nass = '#ffffffffffff' self.color_qrn = '#ffffffffffff' self.color_prts = '#ffffffffffff' self.color_bks = '#ffffffffffff' self.color_bg = '#555555555555' self.color_bgs = '#555555555555' self.color_sel = '#444444444444' self.color_fnd = '#222222222222' self.color_bg_sel = '#dddddddddddd' self.color_bg_qrn = '#888888888888' else: self.font_tit = 'KacstOne Bold 20' self.font_idx = 'KacstOne 13' self.font_nass = 'Simplified Naskh 22' self.font_qrn = 'Amiri Quran 23' self.font_bks = 'KacstOne 15' self.font_prts = 'KacstOne 17' self.color_tit = '#868609091515' self.color_idx = '#676f0584533d' self.color_nass = '#1bac34a102b8' self.color_qrn = '#202040400000' self.color_prts = '#1bac34a102b8' self.color_bks = '#868609091515' self.color_bg = '#f7d1f3fce63d' self.color_bgs = '#fca9fca9f231' self.color_sel = '#ffffffffffff' self.color_fnd = '#fe71fab0870b' self.color_bg_sel = '#9e9ec1c17a7a' self.color_bg_qrn = '#fcb2eb47aeb5'
con = sqlite3.connect(join(LIBRARY_DIR_rw, 'data', 'Listbooks.db')) cur = con.cursor() cur.execute('UPDATE books SET cat=-1') con.commit() else: con = sqlite3.connect(join(LIBRARY_DIR_rw, 'data', 'Listbooks.db')) cur = con.cursor() cur.execute('CREATE TABLE IF NOT EXISTS groups (id_group integer primary key, \ tit varchar(255), sub INTEGER, cat INTEGER)') cur.execute('CREATE TABLE IF NOT EXISTS books (id_book integer primary key, tit varchar(255), \ parent INTEGER, fav INTEGER DEFAULT 0, last INTEGER DEFAULT 1, cat INTEGER DEFAULT 0,\ tafsir INTEGER DEFAULT 0, indx INTEGER DEFAULT 0)') # a --------------------------------------------------------------------------------------- if asm_config.getv('path') != join(LIBRARY_DIR_rw, 'data', 'Listbooks.db'): if not exists(asm_config.getv('path')): res = sure_start() # a تحديد المسار-------------------------- if res == 2: open_dlg = Gtk.FileChooserDialog('تحديد مسار قاعدة البيانات', None, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_OK, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)) Filter = Gtk.FileFilter() Filter.set_name(u"قاعدة البيانات") Filter.add_pattern("Listbooks.db") open_dlg.add_filter(Filter) res = open_dlg.run() if res == Gtk.ResponseType.OK: