Skip to content

Commit 57053d4

Browse files
authored
ganjine@mohammad-sn: 1. Adding option to disabe history saving 2. Next poem feature added to menu (#1578)
1 parent aaaa875 commit 57053d4

2 files changed

Lines changed: 36 additions & 20 deletions

File tree

ganjine@mohammad-sn/files/ganjine@mohammad-sn/desklet.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ MyDesklet.prototype = {
100100
this.settings.bind("selected-poet", "selected_poet", this._updateBeyt);
101101
this.settings.bind("x-l", "XL", null);
102102
this.settings.bind("poem-history", "PoemHistory", null);
103+
this.settings.bind("history-save", "HistorySave", null);
103104
this.settings.bind("history-size", "HistorySize", null);
104105

105106
this._clipboard = St.Clipboard.get_default();
@@ -110,6 +111,11 @@ MyDesklet.prototype = {
110111
Gio.app_info_launch_default_for_uri(this.poet.link, global.create_app_launch_context());
111112
}));
112113

114+
let nextPoemMenuItem = new PopupMenu.PopupIconMenuItem("Next", "go-next", St.IconType.SYMBOLIC);
115+
nextPoemMenuItem.connect('activate', Lang.bind(this, function(menuItem, event) {
116+
this._updateBeyt();
117+
}));
118+
113119
let previousPoemMenuItem = new PopupMenu.PopupIconMenuItem("Previous", "go-previous", St.IconType.SYMBOLIC);
114120
previousPoemMenuItem.connect('activate', Lang.bind(this, function(menuItem, event) {
115121
if (this.history.length) {
@@ -137,6 +143,7 @@ MyDesklet.prototype = {
137143
this._menu.addMenuItem(takeShotMenuItem, 0);
138144
this._menu.addMenuItem(copyLinkMenuItem, 0);
139145
this._menu.addMenuItem(copyMenuItem, 0);
146+
this._menu.addMenuItem(nextPoemMenuItem, 0);
140147
this._menu.addMenuItem(previousPoemMenuItem, 0);
141148
this._menu.addMenuItem(openLinkMenuItem, 0);
142149

@@ -256,10 +263,12 @@ MyDesklet.prototype = {
256263
text = text.replace(/&#x([0-9A-Fa-f]+);/g, (match, hex) => String.fromCharCode(parseInt(hex, 16)));
257264
this.setText(text, true);
258265

266+
if (this.HistorySave) {
259267
if (this.PoemHistory.length > this.HistorySize)
260268
this.PoemHistory.splice(Math.floor(Math.random() * this.PoemHistory.length), this.PoemHistory.length - this.HistorySize);
261269
this.PoemHistory.push(text);
262270
this.settings._saveToFile();
271+
}
263272
} else {
264273
this.setText(this.PoemHistory[Math.floor(Math.random() * this.PoemHistory.length)], false);
265274
}

ganjine@mohammad-sn/files/ganjine@mohammad-sn/settings-schema.json

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,20 @@
3232
"step": 5,
3333
"description": "Refresh interval"
3434
},
35+
"history-save": {
36+
"default": false,
37+
"type": "switch",
38+
"description": "Save poems history"
39+
},
3540
"history-size": {
41+
"dependency": "history-save",
3642
"default": 10,
3743
"type": "spinbutton",
3844
"min": 1,
3945
"max": 99,
46+
"units": "Number",
4047
"step": 1,
41-
"description": "Number of poems to keep in history"
48+
"description": "Poems to keep in history"
4249
},
4350
"limit-poems": {
4451
"default": false,
@@ -50,25 +57,25 @@
5057
"default": "2",
5158
"type": "combobox",
5259
"options": {
53-
"حافظ" :"2",
54-
"خیام" :"3",
55-
"ابوسعید ابوالخیر" :"26",
56-
"صائب" :"22",
57-
"سعدی" :"7",
58-
"باباطاهر" :"28",
59-
"مولوی" :"5",
60-
"اوحدی" :"19",
61-
"خواجو" :"20",
62-
"شهریار" :"35",
63-
"عراقی" :"21",
64-
"فروغی بسطامی" :"32",
65-
"سلمان ساوجی" :"40",
66-
"محتشم کاشانی" :"29",
67-
"امیرخسرو دهلوی" :"34",
68-
"سیف فرغانی" :"31",
69-
"عبید زاکانی" :"33",
70-
"هاتف اصفهانی" :"25",
71-
"رهی معیری" :"41"
60+
"حافظ" :"2",
61+
"خیام" :"3",
62+
"ابوسعید ابوالخیر" :"26",
63+
"صائب" :"22",
64+
"سعدی" :"7",
65+
"باباطاهر" :"28",
66+
"مولوی" :"5",
67+
"اوحدی" :"19",
68+
"خواجو" :"20",
69+
"شهریار" :"35",
70+
"عراقی" :"21",
71+
"فروغی بسطامی" :"32",
72+
"سلمان ساوجی" :"40",
73+
"محتشم کاشانی" :"29",
74+
"امیرخسرو دهلوی" :"34",
75+
"سیف فرغانی" :"31",
76+
"عبید زاکانی" :"33",
77+
"هاتف اصفهانی" :"25",
78+
"رهی معیری" :"41"
7279
},
7380
"description": "Select poet"
7481
},

0 commit comments

Comments
 (0)