From 0090dd30fcfed319a148c555750ef11305ea9522 Mon Sep 17 00:00:00 2001 From: Morteza Fakhraee Date: Tue, 9 Sep 2025 16:01:05 +0330 Subject: [PATCH] ganjine@mohammad-sn: 1. Adding option to disabe history saving 2. Next poem feature added to menu --- .../files/ganjine@mohammad-sn/desklet.js | 9 ++++ .../ganjine@mohammad-sn/settings-schema.json | 47 +++++++++++-------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/ganjine@mohammad-sn/files/ganjine@mohammad-sn/desklet.js b/ganjine@mohammad-sn/files/ganjine@mohammad-sn/desklet.js index e9da2d48c..d3f3f082d 100644 --- a/ganjine@mohammad-sn/files/ganjine@mohammad-sn/desklet.js +++ b/ganjine@mohammad-sn/files/ganjine@mohammad-sn/desklet.js @@ -100,6 +100,7 @@ MyDesklet.prototype = { this.settings.bind("selected-poet", "selected_poet", this._updateBeyt); this.settings.bind("x-l", "XL", null); this.settings.bind("poem-history", "PoemHistory", null); + this.settings.bind("history-save", "HistorySave", null); this.settings.bind("history-size", "HistorySize", null); this._clipboard = St.Clipboard.get_default(); @@ -110,6 +111,11 @@ MyDesklet.prototype = { Gio.app_info_launch_default_for_uri(this.poet.link, global.create_app_launch_context()); })); + let nextPoemMenuItem = new PopupMenu.PopupIconMenuItem("Next", "go-next", St.IconType.SYMBOLIC); + nextPoemMenuItem.connect('activate', Lang.bind(this, function(menuItem, event) { + this._updateBeyt(); + })); + let previousPoemMenuItem = new PopupMenu.PopupIconMenuItem("Previous", "go-previous", St.IconType.SYMBOLIC); previousPoemMenuItem.connect('activate', Lang.bind(this, function(menuItem, event) { if (this.history.length) { @@ -137,6 +143,7 @@ MyDesklet.prototype = { this._menu.addMenuItem(takeShotMenuItem, 0); this._menu.addMenuItem(copyLinkMenuItem, 0); this._menu.addMenuItem(copyMenuItem, 0); + this._menu.addMenuItem(nextPoemMenuItem, 0); this._menu.addMenuItem(previousPoemMenuItem, 0); this._menu.addMenuItem(openLinkMenuItem, 0); @@ -256,10 +263,12 @@ MyDesklet.prototype = { text = text.replace(/&#x([0-9A-Fa-f]+);/g, (match, hex) => String.fromCharCode(parseInt(hex, 16))); this.setText(text, true); + if (this.HistorySave) { if (this.PoemHistory.length > this.HistorySize) this.PoemHistory.splice(Math.floor(Math.random() * this.PoemHistory.length), this.PoemHistory.length - this.HistorySize); this.PoemHistory.push(text); this.settings._saveToFile(); + } } else { this.setText(this.PoemHistory[Math.floor(Math.random() * this.PoemHistory.length)], false); } diff --git a/ganjine@mohammad-sn/files/ganjine@mohammad-sn/settings-schema.json b/ganjine@mohammad-sn/files/ganjine@mohammad-sn/settings-schema.json index e686f3ded..ba8e02f73 100644 --- a/ganjine@mohammad-sn/files/ganjine@mohammad-sn/settings-schema.json +++ b/ganjine@mohammad-sn/files/ganjine@mohammad-sn/settings-schema.json @@ -32,13 +32,20 @@ "step": 5, "description": "Refresh interval" }, + "history-save": { + "default": false, + "type": "switch", + "description": "Save poems history" + }, "history-size": { + "dependency": "history-save", "default": 10, "type": "spinbutton", "min": 1, "max": 99, + "units": "Number", "step": 1, - "description": "Number of poems to keep in history" + "description": "Poems to keep in history" }, "limit-poems": { "default": false, @@ -50,25 +57,25 @@ "default": "2", "type": "combobox", "options": { -"حافظ" :"2", -"خیام" :"3", -"ابوسعید ابوالخیر" :"26", -"صائب" :"22", -"سعدی" :"7", -"باباطاهر" :"28", -"مولوی" :"5", -"اوحدی" :"19", -"خواجو" :"20", -"شهریار" :"35", -"عراقی" :"21", -"فروغی بسطامی" :"32", -"سلمان ساوجی" :"40", -"محتشم کاشانی" :"29", -"امیرخسرو دهلوی" :"34", -"سیف فرغانی" :"31", -"عبید زاکانی" :"33", -"هاتف اصفهانی" :"25", -"رهی معیری" :"41" + "حافظ" :"2", + "خیام" :"3", + "ابوسعید ابوالخیر" :"26", + "صائب" :"22", + "سعدی" :"7", + "باباطاهر" :"28", + "مولوی" :"5", + "اوحدی" :"19", + "خواجو" :"20", + "شهریار" :"35", + "عراقی" :"21", + "فروغی بسطامی" :"32", + "سلمان ساوجی" :"40", + "محتشم کاشانی" :"29", + "امیرخسرو دهلوی" :"34", + "سیف فرغانی" :"31", + "عبید زاکانی" :"33", + "هاتف اصفهانی" :"25", + "رهی معیری" :"41" }, "description": "Select poet" },