Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ganjine@mohammad-sn/files/ganjine@mohammad-sn/desklet.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down
47 changes: 27 additions & 20 deletions ganjine@mohammad-sn/files/ganjine@mohammad-sn/settings-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
},
Expand Down