Beispiel #1
0
    def __init__(self, parent):
        self.parent = parent
        self.db = TarajimDB()
        self.size_font = asm_customs.split_font(
            self.parent.theme.font_nasse_books)[0]
        self.all_term = []
        Gtk.HPaned.__init__(self)
        self.set_border_width(3)

        self.tree_tarjama = Gtk.TreeView()
        self.tree_tarjama.set_name('Tree')
        self.sel_tarjama = self.tree_tarjama.get_selection()
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        kal = Gtk.TreeViewColumn('الرواة', cell, text=1)
        self.tree_tarjama.append_column(kal)
        self.store_tarjama = Gtk.TreeStore(int, str)
        self.tree_tarjama.set_model(self.store_tarjama)
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_tarjama)
        self.tree_tarjama.connect("cursor-changed", self.show_tarjama)
        self.pack1(scroll, True, True)

        self.view_tarjama = asm_customs.ViewClass()
        self.view_tarjama.set_name('View')
        self.view_tarjama_bfr = self.view_tarjama.get_buffer()
        self.view_tarjama_tag = self.view_tarjama_bfr.create_tag("tarjama")
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_tarjama)
        self.pack2(scroll, True, True)
        self.set_position(250)

        self.show_all()
Beispiel #2
0
    def __init__(self, parent):
        self.parent = parent
        self.mydict = DictDB()
        #self.size_font = int(self.parent.theme.font_text_book[-2:])
        self.all_term = []
        Gtk.HBox.__init__(self, False, 3)
        self.set_border_width(3)
        letters = [
            "ألف", "باء", 'تاء', 'ثاء', 'جيم', 'حاء', 'خاء', 'دال', 'ذال',
            'راء', 'زاي', 'سين', 'شين', 'صاد', 'ضاد', 'طاء', 'ظاء', 'عين',
            'غين', 'فاء', 'قاف', 'كاف', 'لام', 'ميم', 'نون', 'هاء', 'واو',
            'ياء'
        ]
        vbox = Gtk.VBox(False, 3)
        btn_letters = Gtk.ComboBoxText()
        btn_letters.set_wrap_width(5)
        for a in letters:
            btn_letters.append_text(a)
        btn_letters.connect('changed', self.select_letter)
        self.tree_dict = Gtk.TreeView()
        self.tree_dict.set_name('Tree')
        self.sel_dict = self.tree_dict.get_selection()
        cell = Gtk.CellRendererText()
        kal = Gtk.TreeViewColumn('الجذور', cell, text=0)
        self.tree_dict.append_column(kal)
        self.store_dict = Gtk.TreeStore(str)
        self.tree_dict.set_model(self.store_dict)
        scroll = Gtk.ScrolledWindow()
        scroll.set_size_request(150, -1)
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_dict)
        self.tree_dict.connect("cursor-changed",
                               lambda *a: self.search_on_page(""))
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        vbox.pack_start(btn_letters, False, False, 0)
        vbox.pack_start(scroll, True, True, 0)

        self.view_dict = asm_customs.ViewClass()
        self.view_dict.set_name('View')
        self.view_dict_bfr = self.view_dict.get_buffer()
        self.search_tag = self.view_dict_bfr.create_tag("search")
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_dict)
        self.pack_start(vbox, False, False, 0)
        self.pack_start(scroll, True, True, 0)

        self.show_all()
Beispiel #3
0
    def __init__(self, parent):
        self.parent = parent
        self.db = AuthorDB()
        #self.size_font = int(self.parent.theme.font_text_book[-2:])
        Gtk.HPaned.__init__(self)
        self.set_border_width(3)

        self.tree_author = Gtk.TreeView()
        self.tree_author.set_name('Tree')
        self.sel_author = self.tree_author.get_selection()
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        kal = Gtk.TreeViewColumn('المؤلفين', cell, text=1)
        self.tree_author.append_column(kal)
        self.store_author = Gtk.TreeStore(int, str, str)
        authors = self.db.all_author()
        self.modelfilter = self.store_author.filter_new()
        self.names_list = []
        for a in authors:
            self.store_author.append(None, a)
            self.names_list.append(a[2])
        self.theword = self.names_list[:]
        self.modelfilter.set_visible_func(self.visible_cb, self.theword)
        self.tree_author.set_model(self.modelfilter)
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_author)
        self.tree_author.connect("cursor-changed", self.show_author)
        self.pack1(scroll, True, True)

        self.view_author = asm_customs.ViewClass()
        self.view_author.set_name('View')
        self.view_author_bfr = self.view_author.get_buffer()
        self.view_author_tag = self.view_author_bfr.create_tag("author")
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_author)
        self.pack2(scroll, True, True)
        self.set_position(250)

        self.show_all()
Beispiel #4
0
    def build(self, *a):
        self.select_part = ''
        self.select_book = ''
        Gtk.HBox.__init__(self, False, 3)
        self.set_border_width(3)
        self.vbox_side = Gtk.VBox(False, 0)

        # a أيقونات الكتب--------------------------
        self.vbox_iconview = Gtk.VBox(False, 5)
        self.nb = Gtk.Notebook()
        self.nb.set_show_tabs(False)
        vbox = Gtk.VBox(False, 0)
        self.particon = GdkPixbuf.Pixbuf.new_from_file_at_size(
            join(asm_path.ICON_DIR, 'Groups-128.png'), 128, 128)
        self.bookicon = GdkPixbuf.Pixbuf.new_from_file_at_size(
            join(asm_path.ICON_DIR, 'Book-128.png'), 120, 120)
        sw = Gtk.ScrolledWindow()
        vbox.pack_start(sw, True, True, 0)
        self.store_parts_icon = Gtk.ListStore(str, GdkPixbuf.Pixbuf, int)
        self.iconview_parts = Gtk.IconView()
        self.iconview_parts.set_name('iconview')
        self.iconview_parts.set_reorderable(True)
        self.iconview_parts.set_model(self.store_parts_icon)
        self.iconview_parts.override_font(Pango.FontDescription('KacstOne 20'))
        self.iconview_parts.set_text_column(COL_NAME)
        self.iconview_parts.set_pixbuf_column(COL_PIXBUF)
        self.iconview_parts.set_item_width(150)
        self.iconview_parts.set_row_spacing(50)
        self.iconview_parts.connect("item-activated", self.item_part_active)
        sw.add(self.iconview_parts)
        self.iconview_parts.grab_focus()
        self.nb.append_page(vbox, Gtk.Label('0'))

        vbox = Gtk.VBox(False, 0)
        sw = Gtk.ScrolledWindow()
        vbox.pack_start(sw, True, True, 0)
        self.store_books_icon = Gtk.ListStore(str, GdkPixbuf.Pixbuf, int)
        self.iconview_books = Gtk.IconView()
        self.iconview_books.set_name('iconview')
        self.iconview_books.set_model(self.store_books_icon)
        self.iconview_books.override_font(Pango.FontDescription('KacstOne 16'))
        self.iconview_books.set_text_column(COL_NAME)
        self.iconview_books.set_pixbuf_column(COL_PIXBUF)
        self.iconview_books.connect("selection_changed", self.item_book_select)
        self.iconview_books.set_item_width(120)
        self.iconview_books.set_row_spacing(40)
        sw.add(self.iconview_books)
        self.iconview_books.grab_focus()
        self.nb.append_page(vbox, Gtk.Label('1'))
        self.vbox_iconview.pack_start(self.nb, True, True, 0)

        # a قائمة الكتب----------------------------
        self.particon1 = GdkPixbuf.Pixbuf.new_from_file_at_size(
            join(asm_path.ICON_DIR, 'Groups-128.png'), 32, 32)
        self.bookicon1 = GdkPixbuf.Pixbuf.new_from_file_at_size(
            join(asm_path.ICON_DIR, 'Book-128.png'), 28, 28)
        scroll = Gtk.ScrolledWindow()
        self.tree_parts = Gtk.TreeView()
        self.tree_parts.set_name('Tree')
        self.tree_parts.set_headers_visible(False)
        self.sel_parts = self.tree_parts.get_selection()
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        kal = Gtk.TreeViewColumn('الأقسام')
        icon_renderer = Gtk.CellRendererPixbuf()
        kal.pack_start(icon_renderer, False)
        kal.pack_start(cell, False)
        kal.add_attribute(icon_renderer, "pixbuf", 2)
        kal.add_attribute(cell, "text", 1)

        self.tree_parts.connect("row-activated", self.active_row_parts)
        self.tree_parts.append_column(kal)
        self.store_parts_list = Gtk.ListStore(int, str, GdkPixbuf.Pixbuf)
        scroll.add(self.tree_parts)
        self.tree_parts.set_model(self.store_parts_list)
        self.load_list()
        self.nb.append_page(scroll, Gtk.Label('2'))

        scroll = Gtk.ScrolledWindow()
        self.tree_books = Gtk.TreeView()
        self.tree_books.set_name('Tree')
        self.tree_books.set_headers_visible(False)
        self.sel_books = self.tree_books.get_selection()
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        kal = Gtk.TreeViewColumn('الكتب')
        icon_renderer = Gtk.CellRendererPixbuf()
        kal.pack_start(icon_renderer, False)
        kal.pack_start(cell, False)
        kal.add_attribute(icon_renderer, "pixbuf", 2)
        kal.add_attribute(cell, "text", 1)
        self.tree_books.connect("row-activated", self.active_row_books)
        self.tree_books.append_column(kal)
        self.store_books_list = Gtk.ListStore(int, str, GdkPixbuf.Pixbuf)
        scroll.add(self.tree_books)
        self.tree_books.set_model(self.store_books_list)
        self.nb.append_page(scroll, Gtk.Label('3'))

        # a بطاقة كتاب--------------------------------
        self.view_info = asm_customs.ViewClass()
        self.view_info.set_name('View')
        self.view_info_bfr = self.view_info.get_buffer()
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_info)
        scroll.set_size_request(250, 200)
        self.vbox_side.pack_start(scroll, False, False, 0)

        # a ------------------------------------------
        stack = Gtk.Stack()
        stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        stack.set_transition_duration(1000)

        # a الكتب الأخيرة------------------------------
        vbox = Gtk.Box(spacing=2, orientation=Gtk.Orientation.VERTICAL)
        #        vbox.set_border_width(3)
        self.tree_last = Gtk.TreeView()
        self.tree_last.set_name('Tree')
        self.tree_last.set_headers_visible(False)
        self.tree_last.set_size_request(250, -1)
        self.sel_last = self.tree_last.get_selection()
        cell = Gtk.CellRendererText()
        kal = Gtk.TreeViewColumn('الكتب الأخيرة', cell, text=1)
        self.tree_last.append_column(kal)
        self.store_last = Gtk.ListStore(int, str)
        self.load_last()
        self.tree_last.set_model(self.store_last)
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_last)
        self.tree_last.connect("row-activated", self.ok_last)
        vbox.pack_start(scroll, True, True, 0)

        remove_all = Gtk.Button("مسح القائمة")
        remove_all.connect('clicked', self.rm_last_all)
        vbox.pack_start(remove_all, False, False, 0)
        stack.add_titled(vbox, 'n0', 'الكتب الأخيرة')

        # a المفضلة-----------------------------------
        vbox = Gtk.Box(spacing=2, orientation=Gtk.Orientation.VERTICAL)
        #        vbox.set_border_width(3)
        self.tree_favorite = Gtk.TreeView()
        self.tree_favorite.set_name('Tree')
        self.tree_favorite.set_headers_visible(False)
        self.tree_favorite.set_size_request(250, -1)
        self.sel_favorite = self.tree_favorite.get_selection()
        cell = Gtk.CellRendererText()
        kal = Gtk.TreeViewColumn('الكتب المفضلة', cell, text=1)
        self.tree_favorite.append_column(kal)
        self.store_favorite = Gtk.ListStore(int, str)
        self.load_fav()
        self.tree_favorite.set_model(self.store_favorite)
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_favorite)
        self.tree_favorite.connect("row-activated", self.ok_fav)
        vbox.pack_start(scroll, True, True, 0)

        self.tree_books.connect("cursor-changed", self.select_row,
                                self.sel_books)
        self.tree_last.connect("cursor-changed", self.select_row,
                               self.sel_last)
        self.tree_favorite.connect("cursor-changed", self.select_row,
                                   self.sel_favorite)

        remove_one = Gtk.Button("حذف من المفضلة")
        remove_one.connect('clicked', self.rm_fav_one)
        vbox.pack_start(remove_one, False, False, 0)
        stack.add_titled(vbox, 'n1', 'الكتب المفضلة')

        hbox = Gtk.Box(spacing=2, orientation=Gtk.Orientation.HORIZONTAL)
        stack_switcher = Gtk.StackSwitcher()
        stack_switcher.set_stack(stack)
        hbox.pack_start(stack_switcher, True, False, 0)
        self.vbox_side.pack_start(hbox, False, False, 3)
        self.vbox_side.pack_start(stack, True, True, 0)

        self.pack_start(self.vbox_iconview, True, True, 0)
        self.pack_start(self.vbox_side, False, False, 0)
        self.show_all()

        #-----------------------------------------
        if asm_config.getn('view_books') == 0:
            pass
        else:
            self.nb.set_current_page(2)
Beispiel #5
0
    def build(self, *a):
        Gtk.VPaned.__init__(self)
        vb = Gtk.VBox(False, 0)
        self.view_nasse = asm_customs.ViewClass()
        self.view_nasse.set_name('View')
        self.view_nasse_bfr = self.view_nasse.get_buffer()
        self.view_nasse.connect_after("populate-popup",
                                      asm_popup.populate_popup, self.parent)
        self.view_title_tag = self.view_nasse_bfr.create_tag("title")
        self.view_quran_tag = self.view_nasse_bfr.create_tag("quran")
        self.view_search_tag = self.view_nasse_bfr.create_tag("search")
        self.view_terms_tag = self.view_nasse_bfr.create_tag("terms")
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_nasse)
        self.pack1(scroll, True, False)
        hb = Gtk.HBox(False, 7)
        open_in_tab = Gtk.ToolButton(stock_id=Gtk.STOCK_FILE)
        open_in_tab.set_tooltip_text('افتح في لسان مستقل')
        open_in_tab.connect('clicked', self.open_new_tab)
        hb.pack_start(open_in_tab, False, False, 0)
        sav_result_btn = Gtk.ToolButton(stock_id=Gtk.STOCK_SAVE)
        sav_result_btn.set_tooltip_text('حفظ نتائج البحث الحالي باسم')
        hb.pack_start(sav_result_btn, False, False, 0)
        sav_result_btn.connect('clicked', self.sav_result_cb)
        self.sav_result_entry = Gtk.Entry()
        hb.pack_start(self.sav_result_entry, False, False, 0)
        self.search_result_btn = Gtk.ToolButton(stock_id=Gtk.STOCK_FIND)
        self.search_result_btn.set_tooltip_text('بحث في نتائج البحث')
        hb.pack_start(self.search_result_btn, False, False, 0)
        self.search_result_btn.connect('clicked', self.search_in_result)
        self.lab_n_result = Gtk.Label('عدد النتائج : 0')
        hb.pack_start(self.lab_n_result, False, False, 0)
        self.hb_stop = Gtk.HBox(False, 7)
        btn_stop = asm_customs.tool_button(join(asm_path.ICON_DIR, u'stp.png'),
                                           'أوقف عملية البحث',
                                           self.stop_search)
        self.hb_stop.pack_start(btn_stop, False, False, 0)
        self.progress = Gtk.ProgressBar()
        self.hb_stop.pack_start(self.progress, True, True, 0)
        hb.pack_start(self.hb_stop, True, True, 0)
        vb.pack_start(hb, False, False, 5)

        self.store_results = Gtk.ListStore(int, int, str, str, int, int, int)
        self.tree_results = Gtk.TreeView()
        self.tree_results.set_name('Tree')
        self.tree_results.set_model(self.store_results)
        self.sel_result = self.tree_results.get_selection()
        self.tree_results.connect("cursor-changed", self.show_result)
        self.tree_results.set_grid_lines(Gtk.TreeViewGridLines.HORIZONTAL)
        raq = Gtk.TreeViewColumn('#', Gtk.CellRendererText(), text=1)
        self.tree_results.append_column(raq)
        books = Gtk.TreeViewColumn('الكتاب', Gtk.CellRendererText(), text=2)
        self.tree_results.append_column(books)
        elbab = Gtk.TreeViewColumn('الباب', Gtk.CellRendererText(), text=3)
        self.tree_results.append_column(elbab)
        elbaher = Gtk.TreeViewColumn('الجزء', Gtk.CellRendererText(), text=4)
        self.tree_results.append_column(elbaher)
        elgharadh = Gtk.TreeViewColumn('الصفحة',
                                       Gtk.CellRendererText(),
                                       text=5)
        self.tree_results.append_column(elgharadh)
        elgharadh.set_expand(True)
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_results)
        scroll.set_size_request(-1, 200)
        vb.pack_start(scroll, True, True, 0)
        self.pack2(vb, False, True)
        self.change_font()
        self.show_all()
Beispiel #6
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()
Beispiel #7
0
    def __init__(self, parent):
        self.db = None
        self.current_id = 1
        self.part_now = 1
        self.page_now = 1
        self.nm_book = 'التفسير الميسر'
        self.parent = parent
        self.othman = Othman()
        self.listbook = listDB()
        sura_list = self.othman.get_suras_names()
        self.opened_new = []
        self.opened_old = []
        Gtk.HBox.__init__(self, False, 0)
        vbox = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL)

        self.notebook = Gtk.Notebook()
        self.notebook.set_show_tabs(False)
        vb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL)
        vb.set_border_width(5)
        self.load_list()
        self.tafsirs = asm_customs.combo(self.store_tafasir, 'التفسير')
        self.tafsirs.set_wrap_width(self.n_warp)
        vb.pack_start(self.tafsirs, False, False, 0)
        self.tafsirs.set_active(0)

        adj = Gtk.Adjustment(1, 1, 7, 1, 5.0, 0.0)
        self.ayas = Gtk.SpinButton()
        self.ayas.set_adjustment(adj)
        self.ayas.set_value(1.0)
        self.ayas.connect('activate', self.select_aya)

        hb, self.suras = asm_customs.combo(sura_list, 'السورة')
        self.suras.set_wrap_width(10)
        vb.pack_start(hb, False, False, 0)
        self.suras.set_active(0)

        hb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.HORIZONTAL)
        lab = Gtk.Label('الآيــــة')
        self.ayas.set_wrap(True)
        self.ayas.set_size_request(140, -1)
        hb.pack_start(lab, False, False, 0)
        hb.pack_end(self.ayas, False, False, 0)
        vb.pack_start(hb, False, False, 0)

        show_search = Gtk.Button('أظهر البحث')

        def show_search_cb(w):
            self.notebook.set_current_page(1)
            self.ok_result()

        show_search.connect('clicked', show_search_cb)
        vb.pack_end(show_search, False, False, 0)
        modif_list_tafsir = Gtk.Button('تعديل قائمة التفاسير')
        modif_list_tafsir.connect('clicked', self.show_modif_list_tafsir)
        vb.pack_end(modif_list_tafsir, False, False, 0)
        self.notebook.append_page(vb, Gtk.Label('تصفح'))

        vb = Gtk.Box(spacing=7, orientation=Gtk.Orientation.VERTICAL)
        vb.set_border_width(5)

        self.tafsirs1 = asm_customs.combo(self.store_tafasir, 'التفسير')
        self.tafsirs1.set_wrap_width(self.n_warp)
        vb.pack_start(self.tafsirs1, False, False, 0)
        self.tafsirs1.set_active(0)

        self.search_entry = Gtk.SearchEntry()
        self.search_entry.set_placeholder_text('بحث في القرآن')
        self.search_entry.connect('activate', self.search_on_quran)
        hbox = Gtk.HBox(False, 2)
        hbox.pack_start(self.search_entry, True, True, 0)
        vb.pack_start(hbox, False, False, 0)

        self.store_search = Gtk.TreeStore(int, int, str)
        self.tree_search = Gtk.TreeView()
        self.tree_search.set_name('Tree')
        self.tree_search.set_model(self.store_search)
        cell = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn('السورة', cell, text=2)
        self.tree_search.append_column(column)
        cell = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn('الآية', cell, text=1)
        self.tree_search.append_column(column)
        self.sel_search = self.tree_search.get_selection()
        self.tree_search.connect("cursor-changed", self.ok_result)
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.tree_search)

        show_browse = Gtk.Button('أظهر التصفح')

        def show_browse_cb(w):
            self.notebook.set_current_page(0)
            self.select_tafsir()

        show_browse.connect('clicked', show_browse_cb)
        vb.pack_end(show_browse, False, False, 0)

        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        vb.pack_start(scroll, True, True, 0)
        self.notebook.append_page(vb, Gtk.Label('بحث'))
        vbox.pack_start(self.notebook, True, True, 0)
        self.pack_start(vbox, False, False, 0)

        self.view_tafsir = asm_customs.ViewClass()
        self.view_tafsir.set_name('View')
        self.view_tafsir_bfr = self.view_tafsir.get_buffer()
        self.view_tafsir.connect_after("populate-popup",
                                       asm_popup.populate_popup, self.parent)
        self.view_quran_tag = self.view_tafsir_bfr.create_tag("quran")
        self.view_search_tag = self.view_tafsir_bfr.create_tag("search")
        self.change_font()
        self.scroll_nasse = Gtk.ScrolledWindow()
        self.scroll_nasse.set_shadow_type(Gtk.ShadowType.IN)
        self.scroll_nasse.add(self.view_tafsir)
        self.pack_start(self.scroll_nasse, True, True, 0)

        self.tafsirs.connect('changed', self.select_tafsir)
        self.tafsirs1.connect('changed', self.ok_result)
        self.change_sura = self.suras.connect('changed', self.select_sura)
        self.change_aya = self.ayas.connect('value-changed', self.select_aya)
        self.show_all()
        self.select_aya(self.ayas)
Beispiel #8
0
    def build(self, *a):
        self.vadj_page_next = 0
        self.vadj_page_prev = 0
        self.hp = Gtk.HPaned()
        self.parent.connect("check-resize", self.convert_browse)

        # a الفهرس-----------------------------------
        vbox = Gtk.VBox(False, 0)
        self.tree_index = Gtk.TreeView()
        self.tree_index.set_name('Tree')
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        kal = Gtk.TreeViewColumn('الفهرس', cell, text=1)
        self.tree_index.append_column(kal)
        self.store_index = Gtk.TreeStore(int, str)
        self.tree_index.set_model(self.store_index)
        self.sel_index = self.tree_index.get_selection()
        self.tree_index.connect("cursor-changed", self.ok_index)
        self.scroll_index = Gtk.ScrolledWindow()
        self.scroll_index.set_shadow_type(Gtk.ShadowType.IN)
        self.scroll_index.add(self.tree_index)
        #self.scroll_index.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.AUTOMATIC)
        self.scroll_index.get_hadjustment().set_value(0.0)
        vbox.pack_start(self.scroll_index, True, True, 0)
        #----------------------------------------------
        self.tree_search = Gtk.TreeView()
        self.tree_search.set_name('Tree')
        cell = Gtk.CellRendererText()
        raq = Gtk.TreeViewColumn('الرقم', cell, text=1)
        self.tree_search.append_column(raq)
        cell = Gtk.CellRendererText()
        cell.set_property("ellipsize", Pango.EllipsizeMode.END)
        kal = Gtk.TreeViewColumn('أغلق النتائج', cell, text=2)
        kal.set_expand(True)
        kal.set_clickable(True)
        kal.connect('clicked', self.hide_search)
        self.tree_search.append_column(kal)
        self.store_search = Gtk.ListStore(int, int, str, str, int, int, str,
                                          int)
        self.tree_search.set_model(self.store_search)
        self.sel_search = self.tree_search.get_selection()
        self.tree_search.connect("cursor-changed", self.ok_search)
        self.scroll_search = Gtk.ScrolledWindow()
        self.scroll_search.set_shadow_type(Gtk.ShadowType.IN)
        self.scroll_search.add(self.tree_search)
        self.scroll_search.get_hadjustment().set_value(0.0)
        vbox.pack_start(self.scroll_search, True, True, 0)

        try:
            self.entry_index = Gtk.SearchEntry()
        except:
            self.entry_index = Gtk.Entry()
        self.entry_index.set_placeholder_text('بحث في الفهرس')
        self.entry_index.connect('changed', self.search_entry)
        vbox.pack_start(self.entry_index, False, False, 3)
        self.hp.pack1(vbox, True, True)

        # a عارض النص-----------------------------------
        vbox = Gtk.VBox(False, 0)
        self.stack = Gtk.Stack()
        vbox.pack_start(self.stack, True, True, 0)
        #-------------------------------------
        self.view_nasse1 = asm_customs.ViewClass()
        self.view_nasse1.set_name('View')
        self.view_nasse_bfr1 = self.view_nasse1.get_buffer()
        self.view_nasse1.connect_after("populate-popup",
                                       asm_popup.populate_popup, self.parent)
        #self.view_nasse1.connect('button-press-event', self.sss)
        self.scroll_nasse1 = Gtk.ScrolledWindow()
        #self.scroll_nasse1.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.scroll_nasse1.set_shadow_type(Gtk.ShadowType.IN)
        self.scroll_nasse1.add(self.view_nasse1)
        self.scroll_event_name1 = self.scroll_nasse1.connect(
            'scroll-event', self.scroll_event)
        self.view_title_tag1 = self.view_nasse_bfr1.create_tag("title1")
        self.view_quran_tag1 = self.view_nasse_bfr1.create_tag("quran1")
        self.view_search_tag1 = self.view_nasse_bfr1.create_tag("search1")
        self.view_terms_tag1 = self.view_nasse_bfr1.create_tag("terms1")
        self.title_select_tag1 = self.view_nasse_bfr1.create_tag("tit_select1")
        self.stack.add_named(self.scroll_nasse1, 'n1')
        #-------------------------------------
        self.view_nasse2 = asm_customs.ViewClass()
        self.view_nasse2.set_name('View')
        self.view_nasse_bfr2 = self.view_nasse2.get_buffer()
        self.view_nasse2.connect_after("populate-popup",
                                       asm_popup.populate_popup, self.parent)
        self.scroll_nasse2 = Gtk.ScrolledWindow()
        #self.scroll_nasse2.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
        self.scroll_nasse2.set_shadow_type(Gtk.ShadowType.IN)
        self.scroll_nasse2.add(self.view_nasse2)
        self.scroll_event_name2 = self.scroll_nasse2.connect(
            'scroll-event', self.scroll_event)
        self.view_title_tag2 = self.view_nasse_bfr2.create_tag("title2")
        self.view_quran_tag2 = self.view_nasse_bfr2.create_tag("quran2")
        self.view_search_tag2 = self.view_nasse_bfr2.create_tag("search2")
        self.view_terms_tag2 = self.view_nasse_bfr2.create_tag("terms2")
        self.title_select_tag2 = self.view_nasse_bfr2.create_tag("tit_select2")
        self.stack.add_named(self.scroll_nasse2, 'n2')
        #----------------------------------------
        hbox = Gtk.HBox(False, 3)
        hbox.set_border_width(3)
        hbox.pack_start(Gtk.Label('('), False, False, 0)
        self.ent_page = Gtk.Label()
        hbox.pack_start(self.ent_page, False, False, 0)
        hbox.pack_start(Gtk.Label('/'), False, False, 0)
        self.ent_part = Gtk.Label()
        hbox.pack_start(self.ent_part, False, False, 0)
        hbox.pack_start(Gtk.Label(')'), False, False, 0)

        move_btn = Gtk.MenuButton()
        img = Gtk.Image.new_from_icon_name('go-jump-symbolic', 2)
        move_btn.set_image(img)
        self.popover = Gtk.Popover()
        move_btn.set_popover(self.popover)
        self.ent_page_move = Gtk.Entry()
        self.ent_part_move = Gtk.Entry()
        self.lab_page_move = Gtk.Label("عدد الصفحات ")
        self.lab_part_move = Gtk.Label("عدد الأجزاء ")
        move = Gtk.Button("انتقل")

        def replace_cb(widget):
            n_page = int(self.ent_page_move.get_text())
            n_part = int(self.ent_part_move.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")
            self.popover.hide()

        move.connect('clicked', replace_cb)
        self.ent_page_move.connect('activate', replace_cb)
        self.ent_part_move.connect('activate', replace_cb)
        box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL)
        box.set_border_width(5)
        hb = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL)
        hb.pack_start(self.ent_page_move, False, False, 3)
        hb.pack_start(self.lab_page_move, False, False, 3)
        box.pack_start(hb, False, False, 3)
        hb = Gtk.Box(spacing=5, orientation=Gtk.Orientation.HORIZONTAL)
        hb.pack_start(self.ent_part_move, False, False, 3)
        hb.pack_start(self.lab_part_move, 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)
        box.pack_end(hb, False, False, 0)
        move_btn.connect("clicked", self.move_to_page)
        box.show_all()
        self.popover.add(box)
        move_btn.set_tooltip_text('الانتقال إلى الصفحة المحددة')
        hbox.pack_start(move_btn, False, False, 10)

        btnbox_action = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        Gtk.StyleContext.add_class(btnbox_action.get_style_context(), "linked")

        self.comment_btn = Gtk.Button()
        self.comment_btn.set_tooltip_text("أظهر التعليق")
        self.comment_btn.connect('clicked', self.comment_cb)
        btnbox_action.pack_start(self.comment_btn, False, False, 0)
        vbox.pack_start(hbox, False, False, 0)
        self.btn_autoScroll = Gtk.ToggleButton()
        img = Gtk.Image.new_from_icon_name('media-seek-forward-symbolic-rtl',
                                           2)
        self.btn_autoScroll.add(img)
        self.btn_autoScroll.set_tooltip_text("استعراض آلي")
        btnbox_action.pack_start(self.btn_autoScroll, False, False, 0)
        hbox.pack_start(btnbox_action, False, False, 0)
        self.autoScrolling = False
        self.btn_autoScroll.connect("clicked", self.autoScrollCb)
        self.timeo = GLib.timeout_add(
            100 / ((asm_config.getn('auto_browse')) * 8), self.autoScroll,
            None)

        btnbox_info = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
        Gtk.StyleContext.add_class(btnbox_info.get_style_context(), "linked")

        bitaka = Gtk.Button()
        bitaka.set_tooltip_text("بطاقة عن الكتاب")
        bitaka.connect('clicked', self.show_bitaka)
        img = Gtk.Image.new_from_icon_name('dialog-information-symbolic', 2)
        bitaka.set_image(img)
        btnbox_info.pack_start(bitaka, False, False, 0)
        edit_book = Gtk.Button()
        edit_book.set_tooltip_text("تحرير الكتاب الحاليّ")
        edit_book.connect('clicked', self.editbk_cb)
        img = Gtk.Image.new_from_icon_name('text-editor-symbolic', 2)
        edit_book.set_image(img)
        btnbox_info.pack_start(edit_book, False, False, 0)
        hbox.pack_end(btnbox_info, False, False, 0)

        self.convert_browse()
        self.hp.pack2(vbox, True, False)
        self.pack_start(self.hp, True, True, 0)
        self.show_all()
        self.scroll_search.hide()
        self.change_font()
Beispiel #9
0
    def show_bitaka(self, *a):
        box = Gtk.Box(spacing=5, orientation=Gtk.Orientation.VERTICAL)
        bitaka_book = self.db.info_book()[3]
        info_book = self.db.info_book()[4]
        dlg = Gtk.Dialog(parent=self.parent)
        dlg.set_icon_name("asmaa")
        dlg.set_default_size(450, 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)
        stack = Gtk.Stack()
        stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        stack.set_transition_duration(1000)
        stack_switcher = Gtk.StackSwitcher()
        stack_switcher.set_stack(stack)
        hb_bar.set_custom_title(stack_switcher)

        self.view_info = asm_customs.ViewClass()
        self.view_info.set_name('View')
        self.view_info_bfr = self.view_info.get_buffer()
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_info)
        stack.add_titled(scroll, 'n1', ' بطاقة')
        self.view_info_bfr.set_text(bitaka_book)

        self.view_info1 = asm_customs.ViewClass()
        self.view_info1.set_name('View')
        self.view_info_bfr1 = self.view_info1.get_buffer()
        scroll = Gtk.ScrolledWindow()
        scroll.set_shadow_type(Gtk.ShadowType.IN)
        scroll.add(self.view_info1)
        stack.add_titled(scroll, 'n2', 'نبذة')
        self.view_info_bfr1.set_text(info_book)
        #-----------------------------------------
        ls2 = [self.view_info, self.view_info1]
        for a in ls2:
            szfont, fmfont = asm_customs.split_font(
                self.parent.theme.font_nasse_others)
            data = '''
            * {
            font-family: "''' + fmfont + '''";
            font-size: ''' + szfont + '''px;
            color: ''' + asm_customs.rgb(
                self.parent.theme.color_nasse_others) + ''';
            background-color: ''' + asm_customs.rgb(
                    self.parent.theme.background_nasse_others) + ''';
            }
            #View text selection, #View:selected  {
            color: ''' + asm_customs.rgb(
                        self.parent.theme.color_selected) + ''';
            background-color: ''' + asm_customs.rgb(
                            self.parent.theme.background_selected) + ''';
            }
            '''
            css_provider = Gtk.CssProvider()
            context = a.get_style_context()
            css_provider.load_from_data(data.encode('utf8'))
            context.add_provider(css_provider,
                                 Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
        box.pack_start(stack, True, True, 0)
        area.pack_start(box, True, True, 0)
        dlg.show_all()