Skip to content
Permalink
Browse files
enhanced favorites: check hidden list to exclude favorites
Signed-off-by: Martin Abente Lahaye <tch@sugarlabs.org>
  • Loading branch information
tchx84 committed Jun 10, 2015
1 parent a71b363 commit c1886be
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
@@ -28,6 +28,10 @@ if test -z "$SUGAR_MIME_DEFAULTS"; then
export SUGAR_MIME_DEFAULTS="$sugardatadir/mime.defaults"
fi

if test -z "$SUGAR_ACTIVITIES_HIDDEN"; then
export SUGAR_ACTIVITIES_HIDDEN="$sugardatadir/activities.hidden"
fi

export GTK2_RC_FILES="@prefix@/share/sugar/data/sugar-$SUGAR_SCALING.gtkrc"

if ! test -f "$GTK2_RC_FILES"; then
@@ -10,6 +10,7 @@ sugar-100.gtkrc: gtkrc.em

sugardir = $(pkgdatadir)/data
sugar_DATA = \
activities.hidden \
group-labels.defaults \
ISO-639-2_utf-8.txt \
kbdconfig \
@@ -0,0 +1 @@
org.sugarlabs.GearsActivity
@@ -189,12 +189,31 @@ def _load_favorites(self):
self._favorite_bundles[i] = favorite_bundles

def _scan_new_favorites(self):
hidden_activities = []

path = os.environ.get('SUGAR_ACTIVITIES_HIDDEN', None)
try:
with open(path) as hidden_file:
for line in hidden_file.readlines():
bundle_id = line.strip()
if bundle_id:
hidden_activities.append(bundle_id)
except:
logging.error('Could not load hidden activities from %s', path)

for bundle in self:
bundle_id = bundle.get_bundle_id()
key = self._get_favorite_key(
bundle.get_bundle_id(), bundle.get_activity_version())
# If the entry exists we simply ignore it, otherwise create one.
if not self._favorite_bundles[_DEFAULT_VIEW].get(key, None):
self._favorite_bundles[_DEFAULT_VIEW][key] = {'favorite': True}
bundle_id, bundle.get_activity_version())
if key not in self._favorite_bundles[_DEFAULT_VIEW] and \
bundle_id in hidden_activities:
self._favorite_bundles[_DEFAULT_VIEW][key] = \
{'favorite': False}
elif not self._favorite_bundles[_DEFAULT_VIEW].get(key, None):
self._favorite_bundles[_DEFAULT_VIEW][key] = \
{'favorite': True}
elif 'favorite' not in self._favorite_bundles[_DEFAULT_VIEW][key]:
self._favorite_bundles[_DEFAULT_VIEW][key]['favorite'] = True
self._write_favorites_file(_DEFAULT_VIEW)

def get_bundle(self, bundle_id):

0 comments on commit c1886be

Please sign in to comment.