-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom button refresh time #70
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ var ArgosButton = new Lang.Class({ | |
this._isDestroyed = false; | ||
|
||
this._updateTimeout = null; | ||
this._cycleTimeout = null; | ||
this._cycleTimeouts = []; | ||
|
||
this.connect("destroy", Lang.bind(this, this._onDestroy)); | ||
|
||
|
@@ -59,8 +59,10 @@ var ArgosButton = new Lang.Class({ | |
|
||
if (this._updateTimeout !== null) | ||
Mainloop.source_remove(this._updateTimeout); | ||
if (this._cycleTimeout !== null) | ||
Mainloop.source_remove(this._cycleTimeout); | ||
if (this._cycleTimeouts.length > 0){ | ||
this._cycleTimeouts.forEach(cycle => Mainloop.source_remove(cycle)); | ||
this._cycleTimeouts = []; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both this line, and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. I just tried to keep as close to your implementation as possible - and you've been using this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reread your comment and fixed something. Is that what you meant? |
||
} | ||
|
||
this.menu.removeAll(); | ||
}, | ||
|
@@ -131,25 +133,28 @@ var ArgosButton = new Lang.Class({ | |
|
||
this.menu.removeAll(); | ||
|
||
if (this._cycleTimeout !== null) { | ||
Mainloop.source_remove(this._cycleTimeout); | ||
this._cycleTimeout = null; | ||
if (this._cycleTimeouts.length > 0) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here also the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Totally. Same as :62 to :64. Will remove this... |
||
this._cycleTimeouts.forEach(cycle => Mainloop.source_remove(cycle)); | ||
this._cycleTimeouts = []; | ||
} | ||
|
||
if (buttonLines.length === 0) { | ||
this._lineView.setMarkup(GLib.markup_escape_text(this._file.get_basename(), -1)); | ||
} else if (buttonLines.length === 1) { | ||
this._lineView.setLine(buttonLines[0]); | ||
} else { | ||
this._lineView.setLine(buttonLines[0]); | ||
let i = 0; | ||
this._cycleTimeout = Mainloop.timeout_add_seconds(3, Lang.bind(this, function() { | ||
i++; | ||
this._lineView.setLine(buttonLines[i % buttonLines.length]); | ||
return true; | ||
})); | ||
|
||
let fullsec = 0; | ||
for (let j = 0; j < buttonLines.length; j++) { | ||
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, fullsec, Lang.bind(this, function() { | ||
this._cycleTimeouts.push(Mainloop.timeout_add_seconds(fullsec, Lang.bind(this, function() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are there two nested timeouts here? I don't understand this part at all. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's the tricky part... But after some tries, it is the easiest way I found. The first wrapping Then the second timeout always has a fixed
Line A is shown directly (because As a native German speaker I hope that I was able to describe the idea good enough to make it understandable. If not so, just keep asking... ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So to summarize, each line has its own independent periodic timeout with interval equal to the total timeout of all lines, and each of those timeouts is offset by another timeout equal to the sum of timeouts of all lines before it. That's a nice idea, but it doesn't quite work. The problem is that Desktop Linux is not a realtime operating system, and functions like See the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
check!
check! I got the "recalculation" thing from the docs wrong... 😞
check! I'll continue optimizing. Thanks for taking the time to respond. |
||
this._lineView.setLine(buttonLines[j]); | ||
return true; | ||
}))); | ||
this._lineView.setLine(buttonLines[j]); | ||
return false; | ||
})); | ||
fullsec += +buttonLines[j].timeout || 3; | ||
|
||
if (buttonLines[j].dropdown !== "false") | ||
this.menu.addMenuItem(new ArgosMenuItem(this, buttonLines[j])); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I very much appreciate that you thought of adding documentation. However, I must ask you to remove it again, because I don't plan to push another release to the GNOME Shell extensions website anytime soon, and if what is documented here doesn't match what the version available there can do, I will be spammed with repeated questions asking why feature X doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally okay with that... Would it be an option to set the MASTER branch to the currently deployed version and set a
dev
branch for not-published versions? If anybody gets to the issue page and finds it closed, the same problem arises.Since I have a head like a sieve, I would forget about adding this section again before updating the ext next time. But that might be special to my sieved coffee-input-unit... ;-P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Having a DEV branch and MASTER being the version published is a good idea. PRs could got there we could already test new features more easily.