def __init__(self, parent): self.parent = parent self.myfile = None self.edit_html = EditHTML() self.edit_html.set_sensitive(False) Gtk.HPaned.__init__(self) self.set_border_width(5) self.set_position(150) vbox = Gtk.Box(spacing=3, orientation=Gtk.Orientation.VERTICAL) hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) self.ent_new = Gtk.Entry() self.ent_new.set_placeholder_text('ورقة بحث جديدة') hbox.pack_end(self.ent_new, False, False, 0) new_btn = Gtk.ToolButton(stock_id=Gtk.STOCK_NEW) new_btn.connect('clicked', self.new_waraka) new_btn.set_tooltip_text('أضف ورقة بحث جديدة') hbox.pack_end(new_btn, False, False, 0) vbox.pack_start(hbox, False, False, 0) self.tree_waraka = Gtk.TreeView() self.tree_waraka.set_name('Tree') self.tree_waraka.set_size_request(150, -1) self.sel_waraka = self.tree_waraka.get_selection() cell = Gtk.CellRendererText() kal = Gtk.TreeViewColumn('أوراق البحث', cell, text=0) self.tree_waraka.append_column(kal) self.store_waraka = Gtk.ListStore(str) self.load_warakat() self.tree_waraka.set_model(self.store_waraka) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_waraka) self.tree_waraka.connect("cursor-changed", self.show_waraka) scroll.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) vbox.pack_start(scroll, True, True, 0) remove = asm_customs.ButtonClass("حذف") remove.connect('clicked', self.remove_one) hbox = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL) hbox.pack_start(remove, True, True, 0) remove_all = asm_customs.ButtonClass("مسح") remove_all.connect('clicked', self.remove_all) hbox.pack_start(remove_all, True, True, 0) vbox.pack_start(hbox, False, False, 0) self.pack1(vbox, False, False) self.pack2(self.edit_html, True, False) self.show_all()
def dialog_move_to_page(self, *a): dlg = Gtk.Dialog(parent=self.parent) dlg.set_icon_name("asmaa") dlg.set_position(Gtk.WindowPosition.MOUSE) dlg.set_title('انتقل إلى صفحة محدّدة') parts_all, pages_all = self.db.parts_pages(self.all_in_page[3]) ent_page = Gtk.Entry() lab_page = Gtk.Label(u"عدد الصفحات " + str(pages_all)) ent_page.set_text(str(self.all_in_page[4])) ent_part = Gtk.Entry() lab_part = Gtk.Label(u"عدد الأجزاء " + str(parts_all)) ent_part.set_text(str(self.all_in_page[3])) clo = asm_customs.ButtonClass("ألغ") clo.connect('clicked', lambda *a: dlg.destroy()) move = Gtk.Button("انتقل") def replace_cb(widget): n_page = int(ent_page.get_text()) n_part = int(ent_part.get_text()) id_page = self.db.go_to_page(n_part, n_page) if id_page == None: for n in range(20): id_page = self.db.go_to_nearer_page(n_part, n_page, n + 1) if id_page != None: break if id_page == None: asm_customs.erro(self.parent, "لا يمكن الذهاب إلى الصفحة المحددة") return if self.current_id < id_page[0]: self.stack.set_transition_type(self.style_browse_next) elif self.current_id > id_page[0]: self.stack.set_transition_type(self.style_browse_prev) elif self.current_id == id_page[0]: return self.show_page(id_page[0]) ch = self.stack.get_visible_child_name() if ch == "n1": self.stack.set_visible_child_name("n2") else: self.stack.set_visible_child_name("n1") dlg.destroy() move.connect('clicked', replace_cb) ent_page.connect('activate', replace_cb) ent_part.connect('activate', replace_cb) box = dlg.vbox box.set_border_width(5) hb = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(ent_page, False, False, 3) hb.pack_start(lab_page, False, False, 3) box.pack_start(hb, False, False, 3) hb = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(ent_part, False, False, 3) hb.pack_start(lab_part, False, False, 3) box.pack_start(hb, False, False, 3) hb = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(move, False, False, 0) hb.pack_end(clo, False, False, 0) box.pack_end(hb, False, False, 0) dlg.show_all()
def __init__(self, parent): self.parent = parent Gtk.Dialog.__init__(self, parent=self.parent) self.set_icon_name("asmaa") area = self.get_content_area() area.set_spacing(3) 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 = Gtk.Box(spacing=3,orientation=Gtk.Orientation.VERTICAL) self.store_sav = Gtk.ListStore(str) self.list_n = os.listdir(join(asm_path.HOME_DIR, 'searchs')) self.store_sav.clear() for v in self.list_n: if '.pkl' in v: nm = v.replace('.pkl', '') self.store_sav.append([nm]) self.tree_sav = Gtk.TreeView() self.tree_sav.set_name('Tree') self.tree_sav.connect("row-activated", self.ok_m) 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) area.pack_start(box, True, True, 0) self.show_all()
def replace_all(self, *a): if self.parent.notebook.get_current_page() == 7: dlg = Gtk.Dialog(parent=self.parent) dlg.set_icon_name("asmaa") dlg.set_title('إيجاد واستبدال') text_old = Gtk.Entry() text_old.set_placeholder_text('النص القديم') if self.view_nasse_bfr.get_has_selection(): sel = self.view_nasse_bfr.get_selection_bounds() text = self.view_nasse_bfr.get_text(sel[0], sel[1], True) text_old.set_text(text) text_new = Gtk.Entry() text_new.set_placeholder_text('النص الجديد') use_re = Gtk.CheckButton('استعمل التعبيرات المنتظمة') clo = asm_customs.ButtonClass("إغلاق") clo.connect('clicked', lambda *a: dlg.destroy()) rpl = asm_customs.ButtonClass("استبدل الكل") def replace_cb(widget): old_t = self.view_nasse_bfr.get_text( self.view_nasse_bfr.get_start_iter(), self.view_nasse_bfr.get_end_iter(), False) if use_re.get_active(): new_t = re.sub(text_old.get_text(), text_new.get_text(), old_t) else: new_t = old_t.replace(text_old.get_text(), text_new.get_text()) self.view_nasse_bfr.set_text(new_t) rpl.connect('clicked', replace_cb) hb = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL) box = dlg.vbox box.set_border_width(5) hb.pack_start(rpl, False, False, 0) hb.pack_end(clo, False, False, 0) box.pack_start(text_old, False, False, 3) box.pack_start(text_new, False, False, 3) box.pack_start(use_re, False, False, 3) box.pack_end(hb, False, False, 0) dlg.show_all()
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 = Gtk.TreeView() self.tree_sav.set_name('Tree') 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_border_width(3) self.set_icon_name("asmaa") area = self.get_content_area() area.set_spacing(3) hb_bar = Gtk.HeaderBar() hb_bar.set_show_close_button(True) self.set_titlebar(hb_bar) self.stack = Gtk.Stack() self.stack.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.stack.set_transition_duration(1000) stack_switcher = Gtk.StackSwitcher() stack_switcher.set_stack(self.stack) # hb_bar.pack_end(stack_switcher) vbox1 = Gtk.Box(spacing=3, orientation=Gtk.Orientation.VERTICAL) vbox2 = Gtk.Box(spacing=3, orientation=Gtk.Orientation.VERTICAL) self.set_size_request(600, 450) self.connect('delete-event', lambda w, *a: w.hide() or True) #--------------------------------------------------- hbox = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL) self.entry_search = Gtk.SearchEntry() # self.entry_search.set_size_request(400,-1) try: self.list_terms = pickle.load( open(join(asm_path.HOME_DIR, u'last-terms.pkl'), "rb")) except: self.list_terms = [] completion = Gtk.EntryCompletion() self.list_ts = Gtk.ListStore(str) for a in self.list_terms: self.list_ts.append([a]) completion.set_model(self.list_ts) completion.set_text_column(0) self.entry_search.set_completion(completion) self.entry_search.set_size_request(500, -1) self.entry_search.connect('activate', self.search) self.entry_search.set_placeholder_text('أدخل النص المراد البحث عنه') self.btn_search = asm_customs.ButtonClass('بحث') hb_bar.pack_start(self.btn_search) hb_bar.pack_start(self.entry_search) self.btn_search.connect('clicked', self.search) vbox1.pack_start(hbox, False, False, 0) #------------------------------------------------------- hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) vbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) hb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) self.ent_search = Gtk.SearchEntry() self.ent_search.set_placeholder_text('بحث عن كتاب') self.ent_search.connect('changed', self.search_entry_cb) hb.pack_end(self.ent_search, False, False, 0) self.ent_search.connect('activate', self.search_cb) vbox.pack_start(hb, False, False, 0) hbox.pack_start(vbox, False, False, 0) self.store_fields = Gtk.ListStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING) self.load_fields() self.tree_fields = Gtk.TreeView(self.store_fields) self.tree_fields.set_rules_hint(True) celltext = Gtk.CellRendererText() celltext.set_property("ellipsize", Pango.EllipsizeMode.END) celltoggle = Gtk.CellRendererToggle() celltoggle.set_property('activatable', True) columntoggle = Gtk.TreeViewColumn("اختر", celltoggle) columntext = Gtk.TreeViewColumn("النطاق", celltext, text=1) columntext.set_expand(True) columntoggle.add_attribute(celltoggle, "active", 0) celltoggle.connect('toggled', self.fixed_toggled_field, self.store_fields) self.tree_fields.append_column(columntoggle) self.tree_fields.append_column(columntext) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_fields) vbox.pack_start(scroll, True, True, 0) self.store_books = Gtk.TreeStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING, GObject.TYPE_INT) self.load_books() self.tree_books = Gtk.TreeView() self.tree_books.set_model(self.store_books) self.sel_books = self.tree_books.get_selection() scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_books) scroll.set_size_request(200, -1) celltext = Gtk.CellRendererText() celltext.set_property("ellipsize", Pango.EllipsizeMode.END) celltoggle = Gtk.CellRendererToggle() celltoggle.set_property('activatable', True) columntoggle = Gtk.TreeViewColumn("ضمّ", celltoggle) columntoggle.set_clickable(True) columntoggle.connect('clicked', lambda *a: self.tree_books.collapse_all()) self.columntext1 = Gtk.TreeViewColumn("علّم جميع الكتب", celltext, text=1) self.columntext1.set_clickable(True) self.columntext1.connect('clicked', self.select_all) self.columntext1.set_expand(True) columntoggle.add_attribute(celltoggle, "active", 0) celltoggle.connect('toggled', self.fixed_toggled, self.store_books) self.tree_books.append_column(columntoggle) self.tree_books.append_column(self.columntext1) hbox.pack_start(scroll, True, True, 0) vbox1.pack_start(hbox, True, True, 0) #------------------------------------------------------- expander = Gtk.Expander.new("خيارات متقدمة") notebk = Gtk.Notebook() expander.add(notebk) box = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(7) notebk.append_page(box, Gtk.Label('مجالات البحث')) self.dict_field = {'nass': True, 'tit': False} self.in_nasse = Gtk.RadioButton.new_with_label_from_widget( None, u'في النصوص') self.in_nasse.set_name('nass') box.pack_start(self.in_nasse, False, False, 0) self.in_nasse.connect('toggled', self.select_field, 1) self.in_title = Gtk.RadioButton.new_with_label_from_widget( self.in_nasse, u'في العناوين') self.in_title.set_name('tit') box.pack_start(self.in_title, False, False, 0) self.in_title.connect('toggled', self.select_field, 2) box = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(7) notebk.append_page(box, Gtk.Label('خيارات البحث')) self.dict_perf = {} for a in [[u'بدون لواصق', u'identical'], [u'عبارة متصلة', u'cursive'], [u'إحدى الكلمات', u'one_term'], [u'مع التشكيل', u'with_tachkil']]: btn = Gtk.CheckButton(a[0]) btn.set_name(a[1]) box.pack_start(btn, False, False, 0) btn.connect('toggled', self.select_perf) self.dict_perf[a[1]] = False box = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(7) notebk.append_page(box, Gtk.Label('حفظ النطاقات')) sav_field = Gtk.Button('حفظ النطاق المحدد') sav_field.set_tooltip_text("حفظ نطاق البحث المحدد حالياً") hb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(sav_field, False, False, 0) sav_field.connect('clicked', self.save_fields) self.ent_field = Gtk.Entry() self.ent_field.set_placeholder_text('اسم النطاق') hb.pack_start(self.ent_field, False, False, 0) box.pack_start(hb, False, False, 0) hb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) rm_field = Gtk.Button('حذف النطاق المحدد') hb.pack_start(rm_field, False, False, 0) box.pack_start(hb, False, False, 0) def rm_field_cb(widget, *a): model, i = self.tree_fields.get_selection().get_selected() if i: nm = model.get_value(i, 1) if nm == u"المفضلة": return os.remove( join(asm_path.LIBRARY_DIR, u'fields-search', nm + '.pkl')) model.remove(i) rm_field.connect('clicked', rm_field_cb) box = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(7) notebk.append_page(box, Gtk.Label('خيارات أخرى')) del_term = Gtk.Button('مسح الكلمات المحفوظة') hb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(del_term, False, False, 0) del_term.connect('clicked', self.del_history) box.pack_start(hb, False, False, 0) vbox1.pack_start(expander, False, False, 0) self.stack.add_titled(vbox1, 'n1', 'بحث عادي') hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) box = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(7) self.dict_field_index = {'nass': True, 'tit': False} self.in_nasse_index = Gtk.RadioButton.new_with_label_from_widget( None, u'في النصوص') self.in_nasse_index.set_name('nass') box.pack_start(self.in_nasse_index, False, False, 0) self.in_nasse_index.connect('toggled', self.select_field_index, 1) self.in_title_index = Gtk.RadioButton.new_with_label_from_widget( self.in_nasse_index, u'في العناوين') self.in_title_index.set_name('tit') box.pack_start(self.in_title_index, False, False, 0) self.in_title_index.connect('toggled', self.select_field_index, 2) hbox.pack_start(box, False, False, 0) box = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(7) self.dict_perf_index = {} for a in [[u'بدون لواصق', u'identical'], [u'عبارة متصلة', u'cursive'], [u'إحدى الكلمات', u'one_term'], [u'مع التشكيل', u'with_tachkil']]: btn = Gtk.CheckButton(a[0]) btn.set_name(a[1]) box.pack_start(btn, False, False, 0) btn.connect('toggled', self.select_perf_index) self.dict_perf_index[a[1]] = False hbox.pack_start(box, False, False, 0) vbox2.pack_start(hbox, True, True, 0) self.stack.add_titled(vbox2, 'n2', 'بحث مفهرس') if asm_config.getn('search') == 0: self.stack.set_visible_child_name("n1") else: self.stack.set_visible_child_name("n2") self.stack.show_all() area.pack_start(self.stack, True, True, 0)
def __init__(self, parent, id_book): self.parent = parent self.listdb = listDB() book = self.listdb.file_book(id_book) self.db = bookDB(book, id_book) self.othman = Othman() Gtk.Dialog.__init__(self, parent=self.parent) self.set_icon_name("asmaa") self.resize(750, 450) self.set_modal(True) self.set_title(u'تعديل تفسير : {}'.format(self.db.book_name,)) self.connect('destroy', self.quit_dlg) box = self.vbox box.set_border_width(5) # a عارض النص----------------------------------- self.view_nasse = asm_customs.ViewClass() self.view_nasse.set_name('View') self.view_nasse_bfr = self.view_nasse.get_buffer() self.view_quran_tag = self.view_nasse_bfr.create_tag("quran") self.view_quran_tag.set_property('foreground', self.parent.theme.color_quran) self.view_quran_tag.set_property("paragraph-background", self.parent.theme.background_quran) self.view_quran_tag.set_property('font', self.parent.theme.font_quran) self.scroll_nasse = Gtk.ScrolledWindow() self.scroll_nasse.set_shadow_type(Gtk.ShadowType.IN) self.scroll_nasse.add(self.view_nasse) box.pack_start(self.scroll_nasse, True, True, 0) box.pack_start(Gtk.HSeparator(), False, False, 3) hb = Gtk.Box(spacing=7,orientation=Gtk.Orientation.HORIZONTAL) self.lab_id_pg = Gtk.Label('جزء 1 ، صفحة 1') hb.pack_start(self.lab_id_pg, False, False, 3) adj = Gtk.Adjustment(1, 1, len(self.db.list_pages), 1, 5.0, 0.0) self.id_pg = Gtk.SpinButton() self.id_pg.connect('changed', self.change_id_pg) self.id_pg.set_adjustment(adj) lab = Gtk.Label('معرف الصفحة') self.id_pg.set_wrap(True) self.id_pg.set_size_request(100, -1) hb.pack_end(self.id_pg, False, False, 0) hb.pack_end(lab, False, False, 0) box.pack_start(hb, False, False, 3) box.pack_start(Gtk.HSeparator(), False, False, 3) hb = Gtk.Box(spacing=7,orientation=Gtk.Orientation.HORIZONTAL) sura_list = self.othman.get_suras_names() hb0, self.suras = asm_customs.combo(sura_list, u'السورة') hb.pack_start(hb0, False, False, 3) self.suras.set_active(-1) adj = Gtk.Adjustment(0, 0, 0, 1, 5.0, 0.0) self.n_ayas = Gtk.SpinButton() self.n_ayas.set_adjustment(adj) lab = Gtk.Label('عدد الآيات') self.n_ayas.set_wrap(True) self.n_ayas.set_size_request(100, -1) hb.pack_end(self.n_ayas, False, False, 0) hb.pack_end(lab, False, False, 0) adj = Gtk.Adjustment(0, 0, 0, 1, 5.0, 0.0) self.ayas = Gtk.SpinButton() self.ayas.set_adjustment(adj) lab = Gtk.Label('أول آية') self.ayas.set_wrap(True) self.ayas.set_size_request(100, -1) hb.pack_end(self.ayas, False, False, 0) hb.pack_end(lab, False, False, 0) box.pack_start(hb, False, False, 3) hbox = Gtk.Box(spacing=5,orientation=Gtk.Orientation.HORIZONTAL) save_btn = asm_customs.ButtonClass("غيّر") save_btn.set_tooltip_text('ثبت السورة والآيات للصفحة الحالية') save_btn.connect('clicked', self.save_cb) hbox.pack_start(save_btn, False, False, 0) no_save_btn = asm_customs.ButtonClass("أخل") no_save_btn.set_tooltip_text('ألغ ربط الصفحة الحالية بالآيات') no_save_btn.connect('clicked', self.no_save_cb) hbox.pack_start(no_save_btn, False, False, 0) clo = asm_customs.ButtonClass("إغلاق") clo.connect('clicked', self.quit_dlg) hbox.pack_end(clo, False, False, 0) box.pack_end(hbox, False, False, 0) box.pack_end(Gtk.HSeparator(), False, False, 3) self.suras.connect('changed', self.select_sura) self.show_all()
def build(self, *a): Gtk.Dialog.__init__(self, parent=self.parent) self.set_border_width(3) self.set_icon_name("asmaa") self.set_size_request(620, 450) self.connect('delete-event', lambda *a: self.destroy()) vbox = self.vbox hb_bar = Gtk.HeaderBar() hb_bar.set_title("تعديل قائمة التفاسير") hb_bar.set_show_close_button(True) self.set_titlebar(hb_bar) hbox = Gtk.Box(spacing=5,orientation=Gtk.Orientation.HORIZONTAL) vbox1 = Gtk.Box(spacing=5,orientation=Gtk.Orientation.VERTICAL) self.store_tafsir_added = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING) self.tree_tafsir_added = Gtk.TreeView() self.tree_tafsir_added.set_model(self.store_tafsir_added) self.sel_tafsir_added = self.tree_tafsir_added.get_selection() scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_tafsir_added) scroll.set_size_request(200, -1) celltext = Gtk.CellRendererText() celltext.set_property("ellipsize", Pango.EllipsizeMode.END) columntext = Gtk.TreeViewColumn("التفاسير المعتمدة", celltext, text = 1 ) columntext.set_expand(True) self.tree_tafsir_added.append_column(columntext) vbox1.pack_start(scroll, True, True, 3) hbox.pack_start(vbox1, True, True, 0) vbox1 = Gtk.Box(spacing=5,orientation=Gtk.Orientation.VERTICAL) icon_theme = Gtk.IconTheme.get_default () no_add = Gtk.Button() img = Gtk.Image() has = icon_theme.has_icon("gtk-go-forward-rtl") if has: img.set_from_icon_name('gtk-go-forward-rtl', Gtk.IconSize.BUTTON) else: img.set_from_stock(Gtk.STOCK_GO_BACK, Gtk.IconSize.BUTTON) no_add.set_image(img) no_add.set_tooltip_text('ألغ') no_add.connect('clicked', self.no_add_cb) vbox1.pack_start(no_add, True, False, 0) #-------------------------------------- to_add = Gtk.Button() img = Gtk.Image() has = icon_theme.has_icon("gtk-go-back-rtl") if has: img.set_from_icon_name('gtk-go-back-rtl', Gtk.IconSize.BUTTON) else: img.set_from_stock(Gtk.STOCK_GO_FORWARD, Gtk.IconSize.BUTTON) to_add.set_image(img) to_add.set_tooltip_text('أضف') to_add.connect('clicked', self.to_add_cb) vbox1.pack_start(to_add, True, False, 0) hbox.pack_start(vbox1, False, False, 0) #-------------------------------------- vbox1 = Gtk.Box(spacing=5,orientation=Gtk.Orientation.VERTICAL) self.store_tafsir_no_added = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING) self.tree_tafsir_no_added = Gtk.TreeView() self.tree_tafsir_no_added.set_model(self.store_tafsir_no_added) self.sel_tafsir_no_added = self.tree_tafsir_no_added.get_selection() scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_tafsir_no_added) scroll.set_size_request(200, -1) celltext = Gtk.CellRendererText() celltext.set_property("ellipsize", Pango.EllipsizeMode.END) columntext = Gtk.TreeViewColumn("التفاسير المهملة", celltext, text = 1 ) columntext.set_expand(True) self.tree_tafsir_no_added.append_column(columntext) vbox1.pack_start(scroll, True, True, 3) hbox.pack_start(vbox1, True, True, 0) vbox.pack_start(hbox, True, True, 0) ls = ['1', '2', '3', '4', '5'] self.col_btn = Gtk.ComboBoxText() for a in ls: self.col_btn.append_text(a) hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) hb.pack_start(Gtk.Label('عدد الأعمدة في قائمة التفاسير'), False, False, 0) hb.pack_start(self.col_btn, False, False, 0) btn_re = Gtk.Button("إزالة من التفاسير") btn_re.connect("clicked", self.out_tafsir) hb.pack_end(btn_re, False, False, 0) vbox.pack_start(hb, False, False, 5) self.btn_save = asm_customs.ButtonClass('حفظ') self.btn_save.connect('clicked', self.save_list) hb_bar.pack_start(self.btn_save) self.load_tafasir() self.show_all()
def __init__(self, parent): self.no_all_book = 1 self.parent = parent self.db_bok = None self.stop_n = 0 self.db = listDB() vbox = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL) box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL) Gtk.Dialog.__init__(self, parent=self.parent) self.resize(550, 450) area = self.get_content_area() area.set_spacing(3) self.set_position(Gtk.WindowPosition.CENTER) hb_bar = Gtk.HeaderBar() hb_bar.set_show_close_button(True) self.set_titlebar(hb_bar) self.stack = Gtk.Stack() self.stack.set_transition_type( Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) self.stack.set_transition_duration(1000) stack_switcher = Gtk.StackSwitcher() stack_switcher.set_stack(self.stack) hb_bar.set_custom_title(stack_switcher) # a استيراد ملفات bok & asm---------------------------- hb = Gtk.HBox(False, 3) self.btn_add = Gtk.Button("جديد") self.btn_add.connect('clicked', self.add_bok) hb.pack_start(self.btn_add, False, False, 0) hb.pack_start(Gtk.Label('«bok, asm»'), True, True, 0) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(hbox.get_style_context(), "linked") hb.pack_end(hbox, False, False, 0) self.btn_remove = Gtk.Button("حذف") self.btn_remove.connect('clicked', self.remove_iter) hbox.pack_start(self.btn_remove, False, False, 0) self.btn_clear = Gtk.Button("مسح") self.btn_clear.connect('clicked', lambda *a: self.store_add.clear()) hbox.pack_start(self.btn_clear, False, False, 0) box.pack_start(hb, False, False, 0) self.store_add = Gtk.ListStore(str, str) self.tree_add = Gtk.TreeView() self.tree_add.set_name('Tree') self.sel_add = self.tree_add.get_selection() column = Gtk.TreeViewColumn('الكتب', Gtk.CellRendererText(), text=1) self.tree_add.append_column(column) self.tree_add.set_model(self.store_add) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_add) box.pack_start(scroll, True, True, 0) ls = [] for a in self.db.all_parts(): ls.append([a[0], a[1]]) hbox, self.groups = asm_customs.combo(ls, 'ضع هذه الكتب في قسم :') box.pack_start(hbox, False, False, 0) box.set_border_width(5) self.stack.add_titled(box, 'n1', 'ملفات كتب') # a استيراد الملفات النصية---------------------------- box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(5) hb = Gtk.HBox(False, 3) self.btn_add_doc = Gtk.Button("جديد") self.btn_add_doc.connect('clicked', self.add_doc) hb.pack_start(self.btn_add_doc, False, False, 0) hb.pack_start(Gtk.Label('«odt, docx, doc, rtf, txt, html»'), True, True, 0) hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(hbox.get_style_context(), "linked") hb.pack_end(hbox, False, False, 0) self.btn_remove_doc = Gtk.Button("حذف") self.btn_remove_doc.connect('clicked', self.remove_iter) hbox.pack_start(self.btn_remove_doc, False, False, 0) self.btn_clear_doc = Gtk.Button("مسح") self.btn_clear_doc.connect('clicked', lambda *a: self.store_add_doc.clear()) hbox.pack_start(self.btn_clear_doc, False, False, 0) box.pack_start(hb, False, False, 0) self.store_add_doc = Gtk.ListStore(str, str) self.tree_add_doc = Gtk.TreeView() self.tree_add_doc.set_name('Tree') self.sel_add_doc = self.tree_add_doc.get_selection() column = Gtk.TreeViewColumn('الملفات', Gtk.CellRendererText(), text=1) self.tree_add_doc.append_column(column) self.tree_add_doc.set_model(self.store_add_doc) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_add_doc) box.pack_start(scroll, True, True, 0) hbox = Gtk.Box(spacing=10, orientation=Gtk.Orientation.HORIZONTAL) self.is_book_radio = Gtk.RadioButton.new_with_label_from_widget( None, 'كتاب') self.is_part_radio = Gtk.RadioButton.new_with_label_from_widget( self.is_book_radio, 'جزء') self.is_page_radio = Gtk.RadioButton.new_with_label_from_widget( self.is_part_radio, 'صفحة') self.is_book_radio.connect('toggled', self.specified, '0') self.is_part_radio.connect('toggled', self.specified, '1') self.is_page_radio.connect('toggled', self.specified, '2') hbox.pack_start(Gtk.Label('كل ملف يمثل : '), False, False, 0) hbox.pack_start(self.is_book_radio, False, False, 0) hbox.pack_start(self.is_part_radio, False, False, 0) hbox.pack_start(self.is_page_radio, False, False, 0) hbox.set_border_width(5) box.pack_start(hbox, False, False, 0) hb = Gtk.HBox(False, 7) hb.pack_start(Gtk.Label('اسم الكتاب : '), False, False, 0) self.name_book_entry = Gtk.Entry() self.name_book_entry.set_sensitive(False) hb.pack_start(self.name_book_entry, True, True, 0) box.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 7) self.letters = Gtk.CheckButton('عدد الأحرف في الصفحة') hb.pack_start(self.letters, False, False, 0) adj = Gtk.Adjustment(3000, 10, 100000, 1, 5.0, 0.0) self.n_letters = Gtk.SpinButton() self.n_letters.set_adjustment(adj) self.n_letters.set_wrap(True) self.n_letters.set_sensitive(False) hb.pack_start(self.n_letters, False, False, 0) box.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 7) self.fasil = Gtk.CheckButton('رمز فاصل بين الصفحات') hb.pack_start(self.fasil, False, False, 0) self.separative = Gtk.Entry() self.separative.set_placeholder_text("الفاصل يتم حذفه من الكتاب") self.separative.set_sensitive(False) hb.pack_start(self.separative, True, True, 0) box.pack_start(hb, False, False, 0) def letters_cb(widget, *a): if self.letters.get_active(): self.n_letters.set_sensitive(True) self.fasil.set_active(False) else: self.n_letters.set_sensitive(False) self.letters.connect('toggled', letters_cb) def fasil_cb(widget, *a): if self.fasil.get_active(): self.separative.set_sensitive(True) self.letters.set_active(False) else: self.separative.set_sensitive(False) self.fasil.connect('toggled', fasil_cb) box.pack_start(Gtk.HSeparator(), False, False, 0) hbox, self.groups_doc = asm_customs.combo(ls, 'ضع هذه الكتب في قسم :') box.pack_start(hbox, False, False, 0) self.stack.add_titled(box, 'n2', 'ملفات نصية') # a استيراد الشاملة---------------------------- box = Gtk.Box(spacing=3, orientation=Gtk.Orientation.VERTICAL) box.set_border_width(5) hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) self.entry_books_dir = Gtk.Entry() b_shamila = Gtk.Button('...') b_shamila.connect('clicked', self.select_path) hbox.pack_start(Gtk.Label('مجلد الكتب'), False, False, 0) hbox.pack_start(self.entry_books_dir, True, True, 0) hbox.pack_start(b_shamila, False, False, 0) box.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) self.entry_main_mdb = Gtk.Entry() b_shamila = Gtk.Button('...') b_shamila.connect('clicked', self.select_file, self.entry_main_mdb) hbox.pack_start(Gtk.Label('ملف main.mdb'), False, False, 0) hbox.pack_start(self.entry_main_mdb, True, True, 0) hbox.pack_start(b_shamila, False, False, 0) box.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) self.entry_special_mdb = Gtk.Entry() b_shamila = Gtk.Button('...') b_shamila.connect('clicked', self.select_file, self.entry_special_mdb) hbox.pack_start(Gtk.Label('ملف special.mdb'), False, False, 0) hbox.pack_start(self.entry_special_mdb, True, True, 0) hbox.pack_start(b_shamila, False, False, 0) box.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=6, orientation=Gtk.Orientation.HORIZONTAL) b_show = Gtk.Button('أظهر قائمة الكتب') b_show.connect('clicked', self.show_books) hbox.pack_start(b_show, False, False, 0) box.pack_start(hbox, False, False, 0) #self.store_books = Gtk.TreeStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING, GObject.TYPE_INT) self.store_books = Gtk.TreeStore( GObject.TYPE_BOOLEAN, GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_STRING, GObject.TYPE_INT, GObject.TYPE_INT) ######## self.tree_books = Gtk.TreeView() self.tree_books.set_model(self.store_books) self.sel_books = self.tree_books.get_selection() scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.tree_books) scroll.set_size_request(200, -1) celltext = Gtk.CellRendererText() celltext.set_property("ellipsize", Pango.EllipsizeMode.END) celltoggle = Gtk.CellRendererToggle() celltoggle.set_property('activatable', True) columntoggle = Gtk.TreeViewColumn("اختر", celltoggle) columntext = Gtk.TreeViewColumn("الكتب", celltext, text=2) columntext.set_expand(True) columntoggle.add_attribute(celltoggle, "active", 0) celltoggle.connect('toggled', self.fixed_toggled, self.store_books) self.tree_books.append_column(columntoggle) self.tree_books.append_column(columntext) box.pack_start(scroll, True, True, 0) hbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL) self.all_books = Gtk.CheckButton('الكل') self.all_books.connect('toggled', self.select_all) hbox.pack_start(self.all_books, False, False, 0) self.lab_status = Gtk.Label('') self.lab_status.set_ellipsize(Pango.EllipsizeMode.END) hbox.pack_end(self.lab_status, False, False, 0) box.pack_end(hbox, False, False, 0) self.stack.add_titled(box, 'n3', 'قرص الشاملة') hbox = Gtk.Box(spacing=3, orientation=Gtk.Orientation.HORIZONTAL) hbox.set_border_width(5) self.btn_close = asm_customs.ButtonClass("إغلاق") self.btn_close.connect('clicked', lambda *a: self.destroy()) hbox.pack_end(self.btn_close, False, False, 0) hb = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) Gtk.StyleContext.add_class(hb.get_style_context(), "linked") hbox.pack_start(hb, False, False, 0) self.btn_convert = Gtk.Button("تحويل") self.btn_convert.connect('clicked', self.start_convert) hb.pack_start(self.btn_convert, False, False, 0) self.btn_stop = Gtk.Button("إيقاف") self.btn_stop.connect('clicked', self.stop_operation) self.btn_stop.set_sensitive(False) hb.pack_start(self.btn_stop, False, False, 0) vbox.pack_start(self.stack, True, True, 0) self.progress = Gtk.ProgressBar() vbox.pack_start(self.progress, False, False, 0) vbox.pack_start(hbox, False, False, 0) area.pack_start(vbox, True, True, 0) self.change_font() self.show_all()
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()