Ticket #2087: 0001-Protected-Activities-Support.patch

File 0001-Protected-Activities-Support.patch, 4.1 KB (added by tch, 11 years ago)
  • data/sugar.schemas.in

    From 47678b9155b0c7d970e2c503aadb6e9024317473 Mon Sep 17 00:00:00 2001
    From: Martin Abente <mabente@paraguayeduca.org>
    Date: Thu, 19 Aug 2010 13:55:21 -0400
    Subject: [PATCH] Protected Activities Support
    Organization: Paraguay Educa
    
    Activities deletion causes troubles during classes. Teachers from
    Paraguay and Uruguay asked for a mecanism to protect activities
    from being easily deleted.
    
    This patch provides a mecanism that uses a gconf value to determine
    which activities will not contain the erase option at the list view
    palette.
    
    The gconf value contains a list of activities bundle indentifiers.
    
    More information at http://bugs.sugarlabs.org/ticket/2087
    
    Signed-off-by: Martin Abente <mabente@paraguayeduca.org>
    ---
     data/sugar.schemas.in                |   14 ++++++++++++++
     src/jarabe/desktop/activitieslist.py |   17 +++++++++--------
     src/jarabe/model/bundleregistry.py   |    7 +++++++
     3 files changed, 30 insertions(+), 8 deletions(-)
    
    diff --git a/data/sugar.schemas.in b/data/sugar.schemas.in
    index 2e6b820..5733627 100644
    a b  
    343343      </locale>
    344344    </schema>
    345345
     346    <schema>
     347      <key>/schemas/desktop/sugar/protected_activities</key>
     348      <applyto>/desktop/sugar/protected_activities</applyto>
     349      <owner>sugar</owner>
     350      <type>list</type>
     351      <list_type>string</list_type>
     352      <default>[]</default>
     353      <locale name="C">
     354        <short>Protected Activities Bundle Indentifiers</short>
     355        <long>Users will not be allowed to erase these
     356        activities through the list view.</long>
     357      </locale>
     358    </schema>
     359
    346360  </schemalist>
    347361</gconfschemafile>
  • src/jarabe/desktop/activitieslist.py

    diff --git a/src/jarabe/desktop/activitieslist.py b/src/jarabe/desktop/activitieslist.py
    index c14d31e..3ad882f 100644
    a b class ActivityListPalette(ActivityPalette): 
    400400        self.menu.append(self._favorite_item)
    401401        self._favorite_item.show()
    402402
    403         if activity_info.is_user_activity():
    404             menu_item = MenuItem(_('Erase'), 'list-remove')
    405             menu_item.connect('activate', self.__erase_activate_cb)
    406             self.menu.append(menu_item)
    407             menu_item.show()
    408 
    409             if not os.access(activity_info.get_path(), os.W_OK):
    410                 menu_item.props.sensitive = False
     403        if activity_info.is_user_activity() and \
     404            not registry.is_activity_protected(self._bundle_id):
     405                menu_item = MenuItem(_('Erase'), 'list-remove')
     406                menu_item.connect('activate', self.__erase_activate_cb)
     407                self.menu.append(menu_item)
     408                menu_item.show()
     409
     410                if not os.access(activity_info.get_path(), os.W_OK):
     411                    menu_item.props.sensitive = False
    411412
    412413        registry = bundleregistry.get_registry()
    413414        self._activity_changed_sid = registry.connect('bundle_changed',
  • src/jarabe/model/bundleregistry.py

    diff --git a/src/jarabe/model/bundleregistry.py b/src/jarabe/model/bundleregistry.py
    index b96de86..1c839d7 100644
    a b import os 
    1919import logging
    2020import traceback
    2121
     22import gconf
    2223import gobject
    2324import gio
    2425import simplejson
    class BundleRegistry(gobject.GObject): 
    6667        self._last_defaults_mtime = -1
    6768        self._favorite_bundles = {}
    6869
     70        client = gconf.client_get_default()
     71        self._protected_activities = client.get_list('/desktop/sugar/protected_activities',
     72                                                      gconf.VALUE_STRING)
    6973        try:
    7074            self._load_favorites()
    7175        except Exception:
    class BundleRegistry(gobject.GObject): 
    312316        key = self._get_favorite_key(bundle_id, version)
    313317        return key in self._favorite_bundles
    314318
     319    def is_activity_protected(self, bundle_id):
     320        return bundle_id in self._protected_activities
     321
    315322    def set_bundle_position(self, bundle_id, version, x, y):
    316323        key = self._get_favorite_key(bundle_id, version)
    317324        if key not in self._favorite_bundles: