Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix bug where you can't disable the extension #1

Merged
merged 1 commit into from

2 participants

@mathematicalcoffee

Hi,

I fixed your bug where you can't disable the extension.

When you connect to an event via object.connect(signal, callback); it returns an ID that you can use to disconnect that event later.

So when you disconnect in disable you should use the same IDs that were returned when you connected in enable, not a new connection ID (which is what you are currently doing).

That's why I've created some global variables showID and hideID, I store the ID returned from Overview.connect, and use it to disconnect in disable.

Hope that helps :) Keep up playing with extensions, it's fun!

@jancborchardt jancborchardt merged commit 6f7d136 into jancborchardt:master
@jancborchardt

People like you is why I love open source. Thank you so much, especially for the good explanation! :rocket:

@jancborchardt

And the fix is now up and approved: https://extensions.gnome.org/extension/393/distraction-free/

Thanks again @mathematicalcoffee !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 30, 2012
  1. @mathematicalcoffee
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 4 deletions.
  1. +6 −4 distraction-free@jancborchardt.net/extension.js
View
10 distraction-free@jancborchardt.net/extension.js
@@ -5,21 +5,23 @@ const Overview = imports.ui.main.overview;
const Panel = imports.ui.main.panel;
const MessageTray = imports.ui.main.messageTray;
+let showID, hideID;
+
function init() {
}
function enable() {
hideDistractions();
Panel._activitiesButton.actor.hide();
- Overview.connect('hiding', hideDistractions);
- Overview.connect('showing', showDistractions);
+ hideID = Overview.connect('hiding', hideDistractions);
+ showID = Overview.connect('showing', showDistractions);
}
function disable() {
+ Overview.disconnect(showID);
+ Overview.disconnect(hideID);
showDistractions();
Panel._activitiesButton.actor.show();
- Overview.disconnect(Overview.connect('hiding', hideDistractions));
- Overview.disconnect(Overview.connect('showing', showDistractions));
}
function hideDistractions() {
Something went wrong with that request. Please try again.