def cheeck_page(self, btn, v): if asm_path.can_modify(self.parent): if v == 1: if asm_path.can_modify(self.parent): self.parent.notebook.set_current_page(8) elif v == 2: if asm_path.can_modify(self.parent): SianaWin(self.parent) elif v == 3: if asm_path.can_modify(self.parent): AddBooks(self.parent) elif v == 4: if asm_path.can_modify(self.parent): WinIndexer(self.parent)
def add_to_favory(self, *a): if asm_path.can_modify(self): if self.notebook.get_current_page() == 1: n = self.viewerbook.get_current_page() ch = self.viewerbook.get_nth_page(n) check = ch.db_list.to_favorite(ch.id_book) if check == None: asm_customs.info( self, 'تم إضافة كتاب "{}" للمفضلة'.format(ch.nm_book, )) self.list_books.load_fav()
def editbk_cb(self, *a): if asm_path.can_modify(self.parent): msg = asm_customs.sure( self.parent, 'عملية تعديل الكتاب عملية دقيقة،\nأي خطأ قد يؤدي لتلف الكتاب،\nهل تريد الاستمرار؟' ) if msg == Gtk.ResponseType.YES: self.parent.editbook.close_db() book = self.db_list.file_book(self.id_book) self.parent.editbook.add_book(book, self.id_book, self.all_in_page[1]) self.parent.notebook.set_current_page(7)
def new_waraka(self, *a): if asm_path.can_modify(self.parent): new_waraka = self.ent_new.get_text() if new_waraka == u'': return myfile = join(asm_path.LIBRARY_DIR, u'waraka-search', new_waraka) if not exists(myfile): try: f = open(myfile,'w+') f.write(new_w) f.close() except: raise else: asm_customs.erro(self.parent, "يوجد ورقة بنفس الاسم يرجى تغيير الاسم.") return self.store_waraka.append([new_waraka]) self.ent_new.set_text('')
def organize_page(self, *a): if asm_path.can_modify(self): self.notebook.set_current_page(8)
def comment_cb(self, *a): if asm_path.can_modify(self.parent): # interface-------------------------------------- box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL) dlg = Gtk.Dialog(parent=self.parent) dlg.set_icon_name("asmaa") dlg.set_default_size(380, 300) area = dlg.get_content_area() area.set_spacing(6) hb_bar = Gtk.HeaderBar() hb_bar.set_show_close_button(True) dlg.set_titlebar(hb_bar) hb_bar.set_title('التعليق') view_comment = Gtk.TextView() view_comment_bfr = view_comment.get_buffer() scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(view_comment) # functions------------------------------------ id_page = self.all_in_page[1] def add_widget(): dlg.show_all() if self.db.show_comment( id_page) != None and self.db.show_comment( id_page) != []: update_btn.show_all() delete_btn.show_all() save_btn.hide() view_comment_bfr.set_text(self.db.show_comment(id_page)[0]) else: save_btn.show_all() update_btn.hide() delete_btn.hide() #----------------------- def save_cb(w): comment = view_comment_bfr.get_text( view_comment_bfr.get_start_iter(), view_comment_bfr.get_end_iter(), False) if comment == '': return self.db.add_comment(id_page, comment) add_widget() img = Gtk.Image.new_from_icon_name('view-paged-symbolic', 2) self.comment_btn.set_image(img) self.comment_btn.show_all() #------------------------ def update_cb(w): comment = view_comment_bfr.get_text( view_comment_bfr.get_start_iter(), view_comment_bfr.get_end_iter(), False) self.db.update_comment(id_page, comment) #------------------------- def delete_cb(w): self.db.remove_comment(id_page) view_comment_bfr.set_text('') add_widget() img = Gtk.Image.new_from_icon_name('document-new-symbolic', 2) self.comment_btn.set_image(img) self.comment_btn.show_all() #----------------------------------- save_btn = asm_customs.ButtonClass("حفظ") save_btn.connect('clicked', save_cb) update_btn = asm_customs.ButtonClass("حفظ") update_btn.connect('clicked', update_cb) delete_btn = asm_customs.ButtonClass("حذف") delete_btn.connect('clicked', delete_cb) hbox = Gtk.Box(spacing=0, orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(hbox.get_style_context(), "linked") hbox.pack_start(update_btn, False, False, 0) hbox.pack_start(delete_btn, False, False, 0) hb_bar.pack_start(hbox) hb_bar.pack_start(save_btn) #---------------------------- box.pack_start(scroll, True, True, 0) area.pack_start(box, True, True, 0) #dlg.show_all() add_widget()