def ch_color(self, btn): nconf = btn.get_name() dialog = Gtk.ColorSelectionDialog("اختر لونا") colorsel = dialog.get_color_selection() colorsel.set_current_rgba(daw_customs.rgba(daw_config.getv(nconf))) response = dialog.run() if response == Gtk.ResponseType.OK: color = colorsel.get_current_color().to_string() daw_config.setv(nconf, color) dialog.destroy() self.parent.theme.refrech()
def __init__(self, parent): self.parent = parent self.db = MyDB() Gtk.Notebook.__init__(self) # a -------------------------------------------- vb1 = Gtk.VBox(False, 11) vb1.set_border_width(11) hb = Gtk.HBox(False, 11) self.verse_prog = daw_customs.ViewClass() self.verse_prog_bfr = self.verse_prog.get_buffer() self.verse_prog.override_font(Pango.FontDescription("Simplified Naskh 22")) self.verse_prog.set_size_request(-1, 64) hb.pack_start(Gtk.Label("البرنامج"), False, False, 0) hb.pack_start(self.verse_prog, True, True, 0) vb1.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_0 = Gtk.Label("القائل : ") lab_0.set_alignment(0, 0.5) hb.pack_start(lab_0, False, False, 0) self.lab_speaker0 = Gtk.Label() hb.pack_start(self.lab_speaker0, False, False, 0) lab_1 = Gtk.Label(" الروي : ") lab_1.set_alignment(0, 0.5) hb.pack_start(lab_1, False, False, 0) self.lab_rawi = Gtk.Label() hb.pack_start(self.lab_rawi, False, False, 0) vb1.pack_start(hb, False, False, 0) vb1.pack_start(Gtk.Separator(), False, False, 0) hb = Gtk.HBox(False, 11) self.verse_usr = daw_customs.ViewEdit() self.verse_usr_bfr = self.verse_usr.get_buffer() self.verse_usr.override_font(Pango.FontDescription("Simplified Naskh 22")) self.verse_usr.set_size_request(-1, 64) hb.pack_start(Gtk.Label("المستخدم"), False, False, 0) hb.pack_start(self.verse_usr, True, True, 0) vb1.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 11) self.ok_verse = daw_customs.ButtonClass("اعتمدْ") self.ok_verse.connect("clicked", self.ok_verse_cb) hb.pack_start(self.ok_verse, False, False, 0) self.answer_verse = daw_customs.ButtonClass("أجبْ") self.answer_verse.connect("clicked", self.answer_verse_cb) hb.pack_start(self.answer_verse, False, False, 0) self.skip_verse = daw_customs.ButtonClass("جديد") self.skip_verse.connect("clicked", self.skip_verse_cb) hb.pack_start(self.skip_verse, False, False, 0) self.lab_answer_user = Gtk.Label(0) hb.pack_end(self.lab_answer_user, False, False, 0) lab_2 = Gtk.Label(" المستخدم : ") lab_2.set_alignment(0, 0.5) hb.pack_end(lab_2, False, False, 0) self.lab_answer_prog = Gtk.Label(0) hb.pack_end(self.lab_answer_prog, False, False, 0) lab_1 = Gtk.Label("البرنامج : ") lab_1.set_alignment(0, 0.5) hb.pack_end(lab_1, False, False, 0) vb1.pack_start(hb, False, False, 0) self.verse_all = daw_customs.ViewClass() self.verse_all_bfr = self.verse_all.get_buffer() self.verse_all_tag = self.verse_all_bfr.create_tag("prog") self.verse_all_tag.set_property("foreground", self.parent.theme.coloran) scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(self.verse_all) scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) vb1.pack_start(scroll, True, True, 0) self.verse_all.override_font(Pango.FontDescription("Simplified Naskh 14")) self.new_verse_debate() self.append_page(vb1, Gtk.Label("مساجلة شعرية")) # a -------------------------------------------- vb2 = Gtk.VBox(False, 11) vb2.set_border_width(11) hb = Gtk.HBox(False, 11) self.verse_who = daw_customs.ViewClass() self.verse_who_bfr = self.verse_who.get_buffer() self.verse_who.override_font(Pango.FontDescription("Simplified Naskh 22")) self.verse_who.set_size_request(-1, 64) hb.pack_start(Gtk.Label("البيت"), False, False, 0) hb.pack_start(self.verse_who, True, True, 0) vb2.pack_start(hb, False, False, 0) vb2.pack_start(Gtk.Separator(), False, False, 0) hb = Gtk.HBox(False, 11) self.answer_who = daw_customs.ButtonClass("أجبْ") self.answer_who.connect("clicked", self.answer_who_cb) hb.pack_start(self.answer_who, False, False, 0) self.new_who = daw_customs.ButtonClass("جديد") self.new_who.connect("clicked", self.new_who_cb) hb.pack_start(self.new_who, False, False, 0) vb2.pack_start(hb, False, False, 0) vb2.pack_start(Gtk.Separator(), False, False, 0) hb = Gtk.HBox(False, 3) self.choice_1 = Gtk.CheckButton("") hb.pack_start(self.choice_1, False, False, 0) self.choice_1.connect("toggled", self.choice_speaker) self.entry_speaker_1 = Gtk.Entry() self.entry_speaker_1.set_size_request(400, -1) self.entry_speaker_1.set_editable(False) hb.pack_start(self.entry_speaker_1, False, False, 0) vb2.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) self.choice_2 = Gtk.CheckButton("") hb.pack_start(self.choice_2, False, False, 0) self.choice_2.connect("toggled", self.choice_speaker) self.entry_speaker_2 = Gtk.Entry() self.entry_speaker_2.set_size_request(400, -1) self.entry_speaker_2.set_editable(False) hb.pack_start(self.entry_speaker_2, False, False, 0) vb2.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) self.choice_3 = Gtk.CheckButton("") hb.pack_start(self.choice_3, False, False, 0) self.choice_3.connect("toggled", self.choice_speaker) self.entry_speaker_3 = Gtk.Entry() self.entry_speaker_3.set_size_request(400, -1) self.entry_speaker_3.set_editable(False) hb.pack_start(self.entry_speaker_3, False, False, 0) vb2.pack_start(hb, False, False, 0) vb2.pack_start(Gtk.Separator(), False, False, 0) hb = Gtk.HBox(False, 3) lab_1 = Gtk.Label("الإجابات الصحيحة : ") lab_1.set_alignment(0, 0.5) lab_1.set_size_request(180, -1) hb.pack_start(lab_1, False, False, 0) self.lab_correct_who = Gtk.Label(0) hb.pack_start(self.lab_correct_who, False, False, 0) vb2.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_2 = Gtk.Label("المحاولات الفاشلة : ") lab_2.set_alignment(0, 0.5) lab_2.set_size_request(180, -1) hb.pack_start(lab_2, False, False, 0) self.lab_false_who = Gtk.Label(0) hb.pack_start(self.lab_false_who, False, False, 0) vb2.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_3 = Gtk.Label("غير المجاب عنه : ") lab_3.set_alignment(0, 0.5) lab_3.set_size_request(180, -1) hb.pack_start(lab_3, False, False, 0) self.lab_skip_who = Gtk.Label(0) hb.pack_start(self.lab_skip_who, False, False, 0) vb2.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_4 = Gtk.Label("التقييم العام : ") lab_4.set_alignment(0, 0.5) lab_4.set_size_request(180, -1) hb.pack_start(lab_4, False, False, 0) self.lab_appraisal_who = Gtk.Label("لا شيء") hb.pack_start(self.lab_appraisal_who, False, False, 0) vb2.pack_start(hb, False, False, 0) self.new_verse_who() self.append_page(vb2, Gtk.Label("من القائل ؟")) # a -------------------------------------------- vb3 = Gtk.VBox(False, 11) vb3.set_border_width(11) hb = Gtk.HBox(False, 3) lab_0 = Gtk.Label("القائل : ") lab_0.set_alignment(0, 0.5) hb.pack_start(lab_0, False, False, 0) self.lab_speaker = Gtk.Label(0) hb.pack_start(self.lab_speaker, False, False, 0) vb3.pack_start(hb, False, False, 0) vb3.pack_start(Gtk.Separator(), False, False, 0) half1 = Gtk.EventBox() half2 = Gtk.EventBox() half1.override_background_color(Gtk.StateFlags.NORMAL, daw_customs.rgba(self.parent.theme.colorb)) half2.override_background_color(Gtk.StateFlags.NORMAL, daw_customs.rgba(self.parent.theme.colorb)) half1.set_size_request(-1, 70) half2.set_size_request(-1, 70) box_verse = Gtk.HBox(False, 53) self.box_half1 = Gtk.HBox(False, 0) self.box_half2 = Gtk.HBox(False, 0) half1.add(self.box_half1) half2.add(self.box_half2) box_verse.pack_start(half1, True, True, 0) box_verse.pack_start(half2, True, True, 0) vb3.pack_start(box_verse, False, False, 0) self.new_verse_organize() vb3.pack_start(Gtk.Separator(), False, False, 0) hb = Gtk.HBox(False, 11) self.check_verse = daw_customs.ButtonClass("تحقّق") self.check_verse.connect("clicked", self.check_verse_cb) hb.pack_start(self.check_verse, False, False, 0) self.new_verse = daw_customs.ButtonClass("جديد") self.new_verse.connect("clicked", self.new_verse_cb) hb.pack_start(self.new_verse, False, False, 0) self.org_verse = daw_customs.ButtonClass("نظّم") self.org_verse.connect("clicked", self.org_verse_cb) hb.pack_start(self.org_verse, False, False, 0) vb3.pack_start(hb, False, False, 0) vb3.pack_start(Gtk.Separator(), False, False, 0) hb = Gtk.HBox(False, 3) lab_1 = Gtk.Label("الإجابات الصحيحة : ") lab_1.set_alignment(0, 0.5) lab_1.set_size_request(180, -1) hb.pack_start(lab_1, False, False, 0) self.lab_correct = Gtk.Label(0) hb.pack_start(self.lab_correct, False, False, 0) vb3.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_2 = Gtk.Label("المحاولات الفاشلة : ") lab_2.set_alignment(0, 0.5) lab_2.set_size_request(180, -1) hb.pack_start(lab_2, False, False, 0) self.lab_false = Gtk.Label(0) hb.pack_start(self.lab_false, False, False, 0) vb3.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_3 = Gtk.Label("غير المجاب عنه : ") lab_3.set_alignment(0, 0.5) lab_3.set_size_request(180, -1) hb.pack_start(lab_3, False, False, 0) self.lab_skip = Gtk.Label(0) hb.pack_start(self.lab_skip, False, False, 0) vb3.pack_start(hb, False, False, 0) hb = Gtk.HBox(False, 3) lab_4 = Gtk.Label("التقييم العام : ") lab_4.set_alignment(0, 0.5) lab_4.set_size_request(180, -1) hb.pack_start(lab_4, False, False, 0) self.lab_appraisal = Gtk.Label("لا شيء") hb.pack_start(self.lab_appraisal, False, False, 0) vb3.pack_start(hb, False, False, 0) self.append_page(vb3, Gtk.Label("رتّب البيت")) self.show_all()
def build(self,*a): Gtk.Dialog.__init__(self, parent=self.parent) self.set_icon_name("Dawawin") self.set_title("التفضيلات") self.resize(500, 300) area = self.get_content_area() area.set_spacing(6) self.connect('delete-event', lambda w,*a: w.hide() or True) self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) lab_info = Gtk.Label('بعض الخيارات قد تحتاج إلى إعادة تشغيل البرنامج') lab_info.override_background_color(Gtk.StateFlags.NORMAL, daw_customs.rgba('#FFF14E')) lab_info.override_color(Gtk.StateFlags.NORMAL, daw_customs.rgba('#E90003')) lab_info.override_font(Pango.FontDescription("8")) self.notebook = Gtk.Notebook() self.box0 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.box00 = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.box1 = Gtk.Box(spacing=4, orientation=Gtk.Orientation.VERTICAL) self.box2 = Gtk.Box(spacing=4,orientation=Gtk.Orientation.VERTICAL) hbox = Gtk.Box(spacing=40,orientation=Gtk.Orientation.HORIZONTAL) hbox.pack_start(self.box1, False, False, 0) hbox.pack_start(self.box2, False, False, 0) self.frame = Gtk.Frame() self.frame.add(hbox) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) self.dfo = Gtk.RadioButton.new_with_label_from_widget(None, 'افتراضي') self.cos = Gtk.RadioButton.new_with_label_from_widget(self.dfo,'مخصص') self.dfo.connect('toggled',self.specified,'0') self.cos.connect('toggled',self.specified,'1') hbox.pack_start(self.dfo, False, False, 0) hbox.pack_start(self.cos, False, False, 0) self.sel_theme = Gtk.CheckButton('تلوين النافذة') hbox.pack_end(self.sel_theme, False, False, 0) if daw_config.getv('theme') == '1': self.sel_theme.set_active(True) else: self.sel_theme.set_active(False) self.sel_theme.connect("toggled", self.has_mytheme) hbox.set_border_width(5) self.box0.pack_start(hbox, False, False, 0) self.box0.pack_start(self.frame, True, True, 0) list_w1 = [[u'القوائم الجانبية','td'], [u'قائمة القصائد','tp'], [u'متن القصيدة','mp'], [u'الشرح والترجمة','ch'], [u'العناوين','an']] list_w2 = [[u'لون خلفية العرض','b'], [u'لون خط التحديد','fs'], [u'لون خلفية التحديد','bs'], [u'لون تحديد البحث','ss'], [u'لون خلفية خاص','bp']] for a in list_w1: hbox = Gtk.Box(spacing=10,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(btn2, False, False, 0) hbox.pack_start(btn1, False, False, 0) hbox.pack_start(Gtk.Label(a[0]), False, False, 0) self.box1.pack_start(hbox, False, False, 0) for a in list_w2: hbox = Gtk.Box(spacing=10,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(btn, False, False, 0) hbox.pack_start(Gtk.Label(a[0]), False, False, 0) self.box2.pack_start(hbox, False, False, 0) self.notebook.append_page(self.box0, Gtk.Label('خط ولون')) vb = Gtk.VBox(False, 6) vb.set_border_width(6) ls = [[0, u'ضيق'], [1, u'وسط'], [2, u'واسع']] hb, self.bayn_abiat = daw_customs.combo(ls, u'المسافة بين الأبيات', 3) self.bayn_abiat.set_active(daw_config.getn('b_abiat')) self.bayn_abiat.connect('changed', self.change_vls, u'b_abiat') vb.pack_start(hb, False, False, 0) ls = [[0, u'ضيق'], [1, u'وسط'], [2, u'واسع']] hb, self.bayn_shater = daw_customs.combo(ls, u'المسافة بين شطري البيت', 3) self.bayn_shater.set_active(daw_config.getn('b_half')) self.bayn_shater.connect('changed', self.change_vls, u'b_half') vb.pack_start(hb, False, False, 0) ls = [[0, u'دوما'], [1, u'للحاجة']] hb, self.tarakeb = daw_customs.combo(ls, u'تراكب شطري البيت', 3) self.tarakeb.set_active(daw_config.getn('tarakeb')) self.tarakeb.connect('changed', self.change_vls, u'tarakeb') vb.pack_start(hb, False, False, 0) ls = [[0, u'بالتطويلات'], [1, u'بالمسافات']] hb, self.tandhid = daw_customs.combo(ls, u'تعديل طول الشطر', 3) self.tandhid.set_active(daw_config.getn('tandhid')) self.tandhid.connect('changed', self.change_vls, u'tandhid') vb.pack_start(hb, False, False, 0) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) lab = Gtk.Label('أدنى طول للشطر بالبكسلات') lab.set_alignment(0,0.5) hbox.pack_start(lab, False, False, 0) adj = Gtk.Adjustment(150, 100, 700, 1, 5, 0) self.min_long = Gtk.SpinButton() self.min_long.set_adjustment(adj) self.min_long.set_wrap(True) self.min_long.set_value(daw_config.getf('min_long')) def change_min(widget, *a): v = self.min_long.get_value() daw_config.setv('min_long', v) self.min_long.connect('value-changed', change_min) hbox.pack_start(self.min_long, False, False, 0) vb.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) lab = Gtk.Label('التراكب إذا تجاوز طول الشطر') lab.set_alignment(0,0.5) hbox.pack_start(lab, False, False, 0) adj = Gtk.Adjustment(350, 300, 1000, 1, 5, 0) self.max_long = Gtk.SpinButton() self.max_long.set_adjustment(adj) self.max_long.set_wrap(True) self.max_long.set_value(daw_config.getf('max_long')) def change_max(widget, *a): v = self.max_long.get_value() daw_config.setv('max_long', v) self.max_long.connect('value-changed', change_max) hbox.pack_start(self.max_long, False, False, 0) vb.pack_start(hbox, False, False, 0) self.notebook.append_page(vb, Gtk.Label('تخطيط')) vb = Gtk.VBox(False, 6) vb.set_border_width(6) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) self.del_all = daw_customs.ButtonClass('مسح عام') self.del_all.connect('clicked', self.del_all_cb) hbox.pack_start(self.del_all, False, False, 0) vb.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) self.add_db = daw_customs.ButtonClass('أنشاء قاعدة بيانات جديدة') self.add_db.connect('clicked', self.new_db) hbox.pack_start(self.add_db, False, False, 0) if not exists(dirname(daw_config.getv('path'))): self.add_db.set_sensitive(False) vb.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=6,orientation=Gtk.Orientation.HORIZONTAL) self.e_dest = Gtk.Entry() self.e_dest.set_text(daw_config.getv('path').decode('utf8')) self.b_dest = daw_customs.ButtonClass('تغيير المسار') self.b_dest.connect('clicked', self.change_path_db) hbox.pack_start(self.b_dest, False, False, 0) hbox.pack_start(self.e_dest, True, True, 0) vb.pack_start(hbox, False, False, 0) hbox = Gtk.Box(spacing=6,orientation=Gtk.Orientation.HORIZONTAL) db_void = Gtk.LinkButton.new_with_label("http://sourceforge.net/projects/dawawin/files/", 'صفحة البرنامج على النت') hbox.pack_start(db_void, False, False, 0) vb.pack_start(hbox, False, False, 0) self.notebook.append_page(vb, Gtk.Label('خيارات')) vb = Gtk.VBox(False, 6) vb.set_border_width(6) self.n_dawawin = Gtk.Label('عدد الدواوين : '+daw_config.getv('n_dawawin')) self.n_dawawin.set_alignment(0,0.5) vb.pack_start(self.n_dawawin, False, False, 0) self.n_poems = Gtk.Label('عدد القصائد : '+daw_config.getv('n_poems')) self.n_poems.set_alignment(0,0.5) vb.pack_start(self.n_poems, False, False, 0) self.n_verses = Gtk.Label('عدد الأبيات : '+daw_config.getv('n_verses')) self.n_verses.set_alignment(0,0.5) vb.pack_start(self.n_verses, False, False, 0) hbox = Gtk.Box(spacing=6,orientation=Gtk.Orientation.HORIZONTAL) self.rapid_count = daw_customs.ButtonClass('إحصاء سريع') self.rapid_count.connect('clicked', self.count_cb) self.detail_count = daw_customs.ButtonClass('إحصاء مفصل') self.detail_count.connect('clicked', self.show_count) self.web_count = daw_customs.ButtonClass('صفحة ويب') self.web_count.connect('clicked', lambda *a: self.parent.countpage.make_html()) hbox.pack_start(self.rapid_count, False, False, 0) hbox.pack_start(self.detail_count, False, False, 0) hbox.pack_start(self.web_count, False, False, 0) vb.pack_end(hbox, False, False, 0) self.notebook.append_page(vb, Gtk.Label('إحصاء')) vbox = Gtk.Box(spacing=4, orientation=Gtk.Orientation.VERTICAL) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) self.sel_ornament = Gtk.CheckButton('اعتمد زخرفة الخلفية') hbox.pack_start(self.sel_ornament, False, False, 0) if daw_config.getv('ornament') == '1': self.sel_ornament.set_active(True) else: self.sel_ornament.set_active(False) self.sel_ornament.connect("toggled", self.has_ornament) vbox.pack_start(hbox, False, False, 0) liststore = Gtk.ListStore(Pixbuf, str) iconview = Gtk.IconView.new() iconview.set_model(liststore) iconview.set_pixbuf_column(0) iconview.set_reorderable(True) list_icons = os.listdir(daw_customs.ORNAMENT) iconview.set_columns(6) iconview.connect('item-activated', self.sel_ORNAMENT) for a in list_icons: try: pixbuf = Pixbuf.new_from_file_at_size(join(daw_customs.ORNAMENT, a), 64, 64 ) liststore.append([pixbuf, a]) except: pass scroll = Gtk.ScrolledWindow() scroll.set_shadow_type(Gtk.ShadowType.IN) scroll.add(iconview) scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) vbox.pack_start(scroll, True, True, 0) self.notebook.append_page(vbox, Gtk.Label('الزخرفة')) self.box.pack_start(self.notebook, True, True, 0) self.box.pack_start(lab_info, False, False, 0) clo = daw_customs.ButtonClass("إغلاق") clo.connect('clicked',lambda *a: self.hide()) ref = daw_customs.ButtonClass("تحديث الواجهة") ref.connect('clicked',lambda *a: self.parent.theme.refrech()) ref.connect('clicked',lambda *a: self.parent.refrech()) hbox = Gtk.Box(spacing=10,orientation=Gtk.Orientation.HORIZONTAL) hbox.set_border_width(5) hbox.pack_start(ref, False, False, 0) hbox.pack_end(clo, False, False, 0) self.box.pack_start(hbox, False, False, 0) if daw_config.getv('tr') == '1': self.cos.set_active(True) else: self.frame.set_sensitive(False) self.dfo.set_active(True) area.pack_start(self.box, True, True, 0)