Re: [Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
Excerpts from shanjit's message of Fri Oct 15 23:37:42 +0200 2010: > Downgrading an activity is now made possible. [...] You've told git send-email to mark your patch as a reply to some message that I've not only never received, but that's also the same as the one referenced by a totally different patch against Paint. Because of this both patches now appear in the same thread, turning review into quite a mess. Please don't set In-Reply-To for patches unless you know exactly what you're doing. And even then please think twice whether it's really a good idea. Sascha -- http://sascha.silbe.org/ http://www.infra-silbe.de/ signature.asc Description: PGP signature ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
Downgrading an activity is now made possible. When a .xo file of a version older than the currently installed version is clicked, a downgrading option is made available, by popping up of a confirmation alert. Depending upton the choice selected you can downgrade the activity. v1 -> v2. Named according to the nomenclature suggested,inline function used,signal emission condition revised,global variables removed. v2 -> v3. Taking care of all calling of misc.resume. Signed-off-by: Shanjit Singh Jajmann , Anubhav Aggarwal --- src/jarabe/journal/misc.py | 29 +--- src/jarabe/journal/versionalert.py | 121 src/jarabe/model/bundleregistry.py |9 ++- 3 files changed, 145 insertions(+), 14 deletions(-) create mode 100644 src/jarabe/journal/versionalert.py diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py index 32a2847..99ea2d4 100644 --- a/src/jarabe/journal/misc.py +++ b/src/jarabe/journal/misc.py @@ -30,6 +30,7 @@ from sugar.graphics.xocolor import XoColor from sugar import mime from sugar.bundle.activitybundle import ActivityBundle from sugar.bundle.contentbundle import ContentBundle +from sugar.bundle.bundle import AlreadyInstalledException from sugar import util from jarabe.view import launcher @@ -150,6 +151,7 @@ def get_activities(metadata): def resume(metadata, bundle_id=None): registry = bundleregistry.get_registry() +version_downgrade = False if is_activity_bundle(metadata) and bundle_id is None: @@ -159,20 +161,25 @@ def resume(metadata, bundle_id=None): bundle = ActivityBundle(file_path) if not registry.is_installed(bundle): logging.debug('Installing activity bundle') -registry.install(bundle) +try: +registry.install(bundle) +except AlreadyInstalledException: +v_alert = VersionAlert() +v_alert.give_bundle(bundle) +version_downgrade= True else: logging.debug('Upgrading activity bundle') registry.upgrade(bundle) - -logging.debug('activityfactory.creating bundle with id %r', -bundle.get_bundle_id()) -installed_bundle = registry.get_bundle(bundle.get_bundle_id()) -if installed_bundle: -launch(installed_bundle) -else: -logging.error('Bundle %r is not installed.', - bundle.get_bundle_id()) - +if not version_downgrade: +logging.debug('activityfactory.creating bundle with id %r', +bundle.get_bundle_id()) +installed_bundle = registry.get_bundle(bundle.get_bundle_id()) +if installed_bundle: +launch(installed_bundle) +else: +logging.error('Bundle %r is not installed.', + bundle.get_bundle_id()) + elif is_content_bundle(metadata) and bundle_id is None: logging.debug('Creating content bundle') diff --git a/src/jarabe/journal/versionalert.py b/src/jarabe/journal/versionalert.py new file mode 100644 index 000..2f27a2f --- /dev/null +++ b/src/jarabe/journal/versionalert.py @@ -0,0 +1,121 @@ + +# Copyright (C) 2008 One Laptop Per Child +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +import gtk +from gettext import gettext as _ + +from sugar.graphics import style +from jarabe.model import bundleregistry +from sugar.activity import activityfactory + +class VersionAlert(gtk.Window): + +def __init__(self): +gtk.Window.__init__(self) + +self.set_border_width(style.LINE_WIDTH) +offset = style.GRID_CELL_SIZE +width = gtk.gdk.screen_width() - offset * 3 +height = gtk.gdk.screen_height() - offset * 8.5 +self.set_size_request(width, height) +self.set_position(gtk.WIN_POS_CENTER_ALWAYS) +self.set_decorated(gtk.WINDOW_TOPLEVEL) +self.set_resizable(False) +self.set_modal(False) + +self._main_view = gtk.EventBox() +self._vbox = gtk.VBox() +self._vbox.set_spacing(style.DEFAULT_SPACING) +self._vbox.set_border_width(style.GRID_CELL_SIZE - 30) +self._main_view.modify_bg(gtk.STATE_NORMAL, +
Re: [Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
On Wed, Oct 13, 2010 at 07:28:51PM +0530, shan...@seeta.in wrote: > Downgrading an activity is now made possible. When a .xo file of a version > older than the currently installed version is clicked, a downgrading option > is made available, by popping up of a confirmation alert. Depending upton the > choice selected you can downgrade the activity. > > v1 -> v2. Named according to the nomenclature suggested,inline function > used,signal emission condition revised,global variables removed. As I was talking while IRC discussion, I don't think that processing downgrade hook in every misc.resume invocation place (you missed misc.resume call in expandedentry.py, journaltoolbox.py and palettes.py) is useful, more apriproate is keeping it in one place (whatevery it will be). > Signed-off-by: Shanjit Singh Jajmann , Anubhav Aggarwal > > --- > src/jarabe/journal/journalactivity.py | 15 +++ > src/jarabe/journal/listview.py| 22 ++ > src/jarabe/journal/misc.py|8 +--- > src/jarabe/model/bundleregistry.py| 11 ++- > 4 files changed, 44 insertions(+), 12 deletions(-) > > diff --git a/src/jarabe/journal/journalactivity.py > b/src/jarabe/journal/journalactivity.py > index 44cc018..d0af20a 100644 > --- a/src/jarabe/journal/journalactivity.py > +++ b/src/jarabe/journal/journalactivity.py > @@ -28,6 +28,7 @@ import os > > from sugar.graphics.window import Window > from sugar.graphics.alert import ErrorAlert > +from sugar.graphics.alert import ConfirmationAlert > > from sugar.bundle.bundle import ZipExtractException, RegistrationException > from sugar import env > @@ -166,6 +167,7 @@ class JournalActivity(Window): > self._list_view = ListView() > self._list_view.connect('detail-clicked', self.__detail_clicked_cb) > self._list_view.connect('clear-clicked', self.__clear_clicked_cb) > +self._list_view.connect('older-version-clicked', > self.__older_version_clicked_cb) > self._main_view.pack_start(self._list_view) > self._list_view.show() > > @@ -204,6 +206,19 @@ class JournalActivity(Window): > > def __go_back_clicked_cb(self, detail_view): > self.show_main_view() > +def __older_version_clicked_cb(self,a): > +alert1=ConfirmationAlert() > +alert1.props.title = _('Newer Version Found') > +alert1.props.msg = _('Newer version of the chosen activity is > available do you still want to continue with the installation? > If Yes click Ok > and the activity icon of the older .xo file in the Journal') > +alert1.connect('response',self.__downgrade_alert_response_cb) > +self.add_alert(alert1) > +alert1.show() > +def __downgrade_alert_response_cb(self, alert1, response_id): > +if response_id is gtk.RESPONSE_OK: > +self.remove_alert(alert1) > +self._list_view.downgrade_confirmation() > +elif response_id is gtk.RESPONSE_CANCEL: > +self.remove_alert(alert1) > > def _query_changed_cb(self, toolbar, query): > self._list_view.update_with_query(query) > diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py > index 3d6281a..653f400 100644 > --- a/src/jarabe/journal/listview.py > +++ b/src/jarabe/journal/listview.py > @@ -27,6 +27,7 @@ import pango > from sugar.graphics import style > from sugar.graphics.icon import CanvasIcon, Icon, CellRendererIcon > from sugar.graphics.xocolor import XoColor > +from sugar.bundle.bundle import AlreadyInstalledException > from sugar import util > > from jarabe.journal.listmodel import ListModel > @@ -466,12 +467,17 @@ class ListView(BaseListView): > __gsignals__ = { > 'detail-clicked': (gobject.SIGNAL_RUN_FIRST, > gobject.TYPE_NONE, > - ([object])) > + ([object])), > +'older-version-clicked': (gobject.SIGNAL_RUN_FIRST, > + gobject.TYPE_NONE, > + ([])) > } > + > > def __init__(self): > BaseListView.__init__(self) > self._is_dragging = False > +self.downgrade = False > > self.tree_view.connect('drag-begin', self.__drag_begin_cb) > self.tree_view.connect('button-release-event', > @@ -522,12 +528,20 @@ class ListView(BaseListView): > > def __detail_clicked_cb(self, cell, uid): > self.emit('detail-clicked', uid) > - > +def downgrade_confirmation(self): > +self.downgrade = True > def __icon_clicked_cb(self, cell, path): > row = self.tree_view.get_model()[path] > metadata = model.get(row[ListModel.COLUMN_UID]) > -misc.resume(metadata) > - > +if not self.downgrade: > +try: > +misc.resume(metadata) > +
[Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
Downgrading an activity is now made possible. When a .xo file of a version older than the currently installed version is clicked, a downgrading option is made available, by popping up of a confirmation alert. Depending upton the choice selected you can downgrade the activity. v1 -> v2. Named according to the nomenclature suggested,inline function used,signal emission condition revised,global variables removed. Signed-off-by: Shanjit Singh Jajmann , Anubhav Aggarwal --- src/jarabe/journal/journalactivity.py | 15 +++ src/jarabe/journal/listview.py| 22 ++ src/jarabe/journal/misc.py|8 +--- src/jarabe/model/bundleregistry.py| 11 ++- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index 44cc018..d0af20a 100644 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -28,6 +28,7 @@ import os from sugar.graphics.window import Window from sugar.graphics.alert import ErrorAlert +from sugar.graphics.alert import ConfirmationAlert from sugar.bundle.bundle import ZipExtractException, RegistrationException from sugar import env @@ -166,6 +167,7 @@ class JournalActivity(Window): self._list_view = ListView() self._list_view.connect('detail-clicked', self.__detail_clicked_cb) self._list_view.connect('clear-clicked', self.__clear_clicked_cb) +self._list_view.connect('older-version-clicked', self.__older_version_clicked_cb) self._main_view.pack_start(self._list_view) self._list_view.show() @@ -204,6 +206,19 @@ class JournalActivity(Window): def __go_back_clicked_cb(self, detail_view): self.show_main_view() +def __older_version_clicked_cb(self,a): +alert1=ConfirmationAlert() +alert1.props.title = _('Newer Version Found') +alert1.props.msg = _('Newer version of the chosen activity is available do you still want to continue with the installation? If Yes click Ok and the activity icon of the older .xo file in the Journal') +alert1.connect('response',self.__downgrade_alert_response_cb) +self.add_alert(alert1) +alert1.show() +def __downgrade_alert_response_cb(self, alert1, response_id): +if response_id is gtk.RESPONSE_OK: +self.remove_alert(alert1) +self._list_view.downgrade_confirmation() +elif response_id is gtk.RESPONSE_CANCEL: +self.remove_alert(alert1) def _query_changed_cb(self, toolbar, query): self._list_view.update_with_query(query) diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py index 3d6281a..653f400 100644 --- a/src/jarabe/journal/listview.py +++ b/src/jarabe/journal/listview.py @@ -27,6 +27,7 @@ import pango from sugar.graphics import style from sugar.graphics.icon import CanvasIcon, Icon, CellRendererIcon from sugar.graphics.xocolor import XoColor +from sugar.bundle.bundle import AlreadyInstalledException from sugar import util from jarabe.journal.listmodel import ListModel @@ -466,12 +467,17 @@ class ListView(BaseListView): __gsignals__ = { 'detail-clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([object])) + ([object])), +'older-version-clicked': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([])) } + def __init__(self): BaseListView.__init__(self) self._is_dragging = False +self.downgrade = False self.tree_view.connect('drag-begin', self.__drag_begin_cb) self.tree_view.connect('button-release-event', @@ -522,12 +528,20 @@ class ListView(BaseListView): def __detail_clicked_cb(self, cell, uid): self.emit('detail-clicked', uid) - +def downgrade_confirmation(self): +self.downgrade = True def __icon_clicked_cb(self, cell, path): row = self.tree_view.get_model()[path] metadata = model.get(row[ListModel.COLUMN_UID]) -misc.resume(metadata) - +if not self.downgrade: +try: +misc.resume(metadata) +except AlreadyInstalledException : +self.emit('older-version-clicked') +if self.downgrade: +self.downgrade = False +misc.resume(metadata,forcing_downgrade=True) + def __cell_title_edited_cb(self, cell, path, new_text): row = self._model[path] metadata = model.get(row[ListModel.COLUMN_UID]) diff --git a/src/jarabe/journal/misc.py b/src/jarabe/journal/misc.py index 32a2847..0ae4a1d 100644 --- a/src/jarabe/journal/misc.py +++ b/src/jarabe/journal/misc.py @@ -148,7 +148,7 @@ def get_activit
Re: [Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
Nak. See detailed comments below. On Tue, Oct 12, 2010 at 01:15:34AM +0530, shan...@seeta.in wrote: > From: Shanjit Singh Jajmann > > Downgrading an activity is now made possible. When a .xo file of a version > older than the currently installed version is clicked, a downgrading option > is made available, by popping up of a confirmation alert. Depending upton the > choice selected you can downgrade the activity. Please text wrap these subsequent lines of your commit message. > mode change 100644 => 100755 src/jarabe/journal/journalactivity.py > mode change 100644 => 100755 src/jarabe/journal/misc.py > mode change 100644 => 100755 src/jarabe/model/bundleregistry.py You are incorrectly changing file modes. Please restore the file modes before you commit. > @@ -128,7 +129,7 @@ class JournalActivity(Window): > self.connect('window-state-event', self.__window_state_event_cb) > self.connect('key-press-event', self._key_press_event_cb) > self.connect('focus-in-event', self._focus_in_event_cb) > - > + Please remove this gratuitous whitespace change from your patch. > @@ -145,7 +145,30 @@ class JournalActivity(Window): > alert.connect('response', self.__alert_response_cb) > self.add_alert(alert) > alert.show() > - > + > +def __activity_alert1_cb(self): Please use a method name that describes the action to be taken. As Bernie pointed out, the name you used did not explain the reason for the alert. > + if misc.check_previous_install() == 1 and misc.return_checked()==0: > + alert1 = ConfirmationAlert() > + logging.debug('value of misc is %d', > misc.check_previous_install()) > + alert1.props.title=_('Previous Version Found') > + alert1.props.msg = _('A previous version of an installed > activity was found. Are you sure you want to continue with installation ? > If Yes click > Ok and the activity icon of the older .xo file in the Journal') The message you have written is ambiguous and could be read in either of two ways; that the user has clicked on a newer version, or that the user has clicked on an older version. > +def __alert1_response_cb(self, alert1, response_id): > +if response_id is gtk.RESPONSE_OK: > +logging.debug('value of checked initial %d', > misc.return_checked()) > +logging.debug('Installing previous version') > +self.remove_alert(alert1) > +misc.checked = 1 > +logging.debug('value of checked final %d', misc.return_checked()) > + > +elif response_id is gtk.RESPONSE_CANCEL: > +logging.debug('Cancelled by user') > +self.remove_alert(alert1) The logging is useful to you at this stage of development, but you should assess whether it is useful to other developers. Perhaps some of these and later logging calls should be removed. > @@ -148,31 +152,53 @@ def get_activities(metadata): > [...] > def resume(metadata, bundle_id=None): > registry = bundleregistry.get_registry() > - > +global checker > +global checked I agree with Bernie ... there seems to be no justification for using globals in this situation. -- James Cameron http://quozl.linux.org.au/ ___ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel
[Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
From: Shanjit Singh Jajmann Downgrading an activity is now made possible. When a .xo file of a version older than the currently installed version is clicked, a downgrading option is made available, by popping up of a confirmation alert. Depending upton the choice selected you can downgrade the activity. --- src/jarabe/journal/journalactivity.py | 31 +++-- src/jarabe/journal/listview.py| 7 ++- src/jarabe/journal/misc.py| 56 - src/jarabe/model/bundleregistry.py| 18 +++--- 4 files changed, 91 insertions(+), 26 deletions(-) mode change 100644 => 100755 src/jarabe/journal/journalactivity.py mode change 100644 => 100755 src/jarabe/journal/misc.py mode change 100644 => 100755 src/jarabe/model/bundleregistry.py diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py old mode 100644 new mode 100755 index 44cc018..5f9d708 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -28,6 +28,7 @@ import os from sugar.graphics.window import Window from sugar.graphics.alert import ErrorAlert +from sugar.graphics.alert import ConfirmationAlert from sugar.bundle.bundle import ZipExtractException, RegistrationException from sugar import env @@ -128,7 +129,7 @@ class JournalActivity(Window): self.connect('window-state-event', self.__window_state_event_cb) self.connect('key-press-event', self._key_press_event_cb) self.connect('focus-in-event', self._focus_in_event_cb) - + model.created.connect(self.__model_created_cb) model.updated.connect(self.__model_updated_cb) model.deleted.connect(self.__model_deleted_cb) @@ -136,7 +137,6 @@ class JournalActivity(Window): self._dbus_service = JournalActivityDBusService(self) self.iconify() - self._critical_space_alert = None self._check_available_space() @@ -145,7 +145,30 @@ class JournalActivity(Window): alert.connect('response', self.__alert_response_cb) self.add_alert(alert) alert.show() - + +def __activity_alert1_cb(self): + if misc.check_previous_install() == 1 and misc.return_checked()==0: + alert1 = ConfirmationAlert() + logging.debug('value of misc is %d', misc.check_previous_install()) + alert1.props.title=_('Previous Version Found') + alert1.props.msg = _('A previous version of an installed activity was found. Are you sure you want to continue with installation ? If Yes click Ok and the activity icon of the older .xo file in the Journal') + alert1.connect('response', self.__alert1_response_cb) + self.add_alert(alert1) + alert1.show() + +def __alert1_response_cb(self, alert1, response_id): +if response_id is gtk.RESPONSE_OK: +logging.debug('value of checked initial %d', misc.return_checked()) +logging.debug('Installing previous version') +self.remove_alert(alert1) +misc.checked = 1 +logging.debug('value of checked final %d', misc.return_checked()) + +elif response_id is gtk.RESPONSE_CANCEL: +logging.debug('Cancelled by user') +self.remove_alert(alert1) + def __alert_response_cb(self, alert, response_id): self.remove_alert(alert) @@ -166,6 +189,8 @@ class JournalActivity(Window): self._list_view = ListView() self._list_view.connect('detail-clicked', self.__detail_clicked_cb) self._list_view.connect('clear-clicked', self.__clear_clicked_cb) +self._list_view.connect('icon-clicked', self.__icon_clicked_cb) +logging.debug('icon clicked in main') self._main_view.pack_start(self._list_view) self._list_view.show() @@ -195,7 +220,11 @@ class JournalActivity(Window): keyname = gtk.gdk.keyval_name(event.keyval) if keyname == 'Escape': self.show_main_view() - + +def __icon_clicked_cb(self): + logging.debug('value of misc is %d', misc.check_previous_install()) + self.__activity_alert1_cb() + def __detail_clicked_cb(self, list_view, object_id): self._show_secondary_view(object_id) diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py index 3d6281a..4e59ed3 100644 --- a/src/jarabe/journal/listview.py +++ b/src/jarabe/journal/listview.py @@ -466,8 +466,12 @@ class ListView(BaseListView): __gsignals__ = { 'detail-clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([object])) + ([object])), +'icon-clicked': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_
Re: [Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
On Thu, Oct 07, 2010 at 07:30:36PM +0530, shan...@seeta.in wrote: > From: Shanjit Singh Jajmann , Anubhav Aggarwal > > > Downgrading an activity is now made possible. When a .xo file of a version > older than the currently installed version is clicked, a downgrading option > is made available, by popping up of a confirmation alert. Depending upton the > choice selected you can downgrade the activity. > --- > src/jarabe/journal/journalactivity.py | 36 +++-- > src/jarabe/journal/listview.py|7 +++- > src/jarabe/journal/misc.py| 56 > - > src/jarabe/model/bundleregistry.py| 18 +++--- > 4 files changed, 91 insertions(+), 26 deletions(-) > mode change 100644 => 100755 src/jarabe/journal/misc.py > mode change 100644 => 100755 src/jarabe/model/bundleregistry.py > > diff --git a/src/jarabe/journal/journalactivity.py > b/src/jarabe/journal/journalactivity.py > index 44cc018..2af55d3 100644 > --- a/src/jarabe/journal/journalactivity.py > +++ b/src/jarabe/journal/journalactivity.py > @@ -28,6 +28,7 @@ import os > > from sugar.graphics.window import Window > from sugar.graphics.alert import ErrorAlert > +from sugar.graphics.alert import ConfirmationAlert > > from sugar.bundle.bundle import ZipExtractException, RegistrationException > from sugar import env > @@ -128,7 +129,7 @@ class JournalActivity(Window): > self.connect('window-state-event', self.__window_state_event_cb) > self.connect('key-press-event', self._key_press_event_cb) > self.connect('focus-in-event', self._focus_in_event_cb) > - > + > model.created.connect(self.__model_created_cb) > model.updated.connect(self.__model_updated_cb) > model.deleted.connect(self.__model_deleted_cb) > @@ -136,7 +137,6 @@ class JournalActivity(Window): > self._dbus_service = JournalActivityDBusService(self) > > self.iconify() > - > self._critical_space_alert = None > self._check_available_space() > > @@ -145,7 +145,29 @@ class JournalActivity(Window): > alert.connect('response', self.__alert_response_cb) > self.add_alert(alert) > alert.show() > - > + > +def __activity_alert1_cb(self): > + if misc.check_previous_install() == 1 and misc.return_checked()==0: > + alert1 = ConfirmationAlert() > + logging.debug('value of misc is %d', > misc.check_previous_install()) > + alert1.props.title=_('Previous Version Found') > + alert1.props.msg = _('A previous version of an installed > activity was found. Are you sure you want to continue with installation ? > If Yes click > Ok and the activity icon of the older .xo file in the Journal') > + alert1.connect('response', self.__alert1_response_cb) > + self.add_alert(alert1) > + alert1.show() > + > +def __alert1_response_cb(self, alert1, response_id): > +if response_id is gtk.RESPONSE_OK: > +logging.debug('value of checked initial %d', > misc.return_checked()) > +logging.debug('Installing previous version') > +self.remove_alert(alert1) > +misc.checked = 1 > +logging.debug('value of checked final %d', misc.return_checked()) > + > +elif response_id is gtk.RESPONSE_CANCEL: > +logging.debug('Cancelled by user') > +self.remove_alert(alert1) > + > def __alert_response_cb(self, alert, response_id): > self.remove_alert(alert) > > @@ -166,6 +188,8 @@ class JournalActivity(Window): > self._list_view = ListView() > self._list_view.connect('detail-clicked', self.__detail_clicked_cb) > self._list_view.connect('clear-clicked', self.__clear_clicked_cb) > +self._list_view.connect('icon-clicked', self.__icon_clicked_cb) > +logging.debug('icon clicked in main') > self._main_view.pack_start(self._list_view) > self._list_view.show() > > @@ -195,7 +219,11 @@ class JournalActivity(Window): > keyname = gtk.gdk.keyval_name(event.keyval) > if keyname == 'Escape': > self.show_main_view() > - > + > +def __icon_clicked_cb(self,a): > + logging.debug('value of misc is %d', > misc.check_previous_install()) > + self.__activity_alert1_cb() > + > def __detail_clicked_cb(self, list_view, object_id): > self._show_secondary_view(object_id) > > diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py > index 3d6281a..3dbcc2d 100644 > --- a/src/jarabe/journal/listview.py > +++ b/src/jarabe/journal/listview.py > @@ -466,8 +466,12 @@ class ListView(BaseListView): > __gsignals__ = { > 'detail-clicked': (gobject.SIGNAL_RUN_FIRST, >
[Sugar-devel] [PATCH] Downgrading activities not allowed. (#2164)
From: Shanjit Singh Jajmann , Anubhav Aggarwal Downgrading an activity is now made possible. When a .xo file of a version older than the currently installed version is clicked, a downgrading option is made available, by popping up of a confirmation alert. Depending upton the choice selected you can downgrade the activity. --- src/jarabe/journal/journalactivity.py | 36 +++-- src/jarabe/journal/listview.py|7 +++- src/jarabe/journal/misc.py| 56 - src/jarabe/model/bundleregistry.py| 18 +++--- 4 files changed, 91 insertions(+), 26 deletions(-) mode change 100644 => 100755 src/jarabe/journal/misc.py mode change 100644 => 100755 src/jarabe/model/bundleregistry.py diff --git a/src/jarabe/journal/journalactivity.py b/src/jarabe/journal/journalactivity.py index 44cc018..2af55d3 100644 --- a/src/jarabe/journal/journalactivity.py +++ b/src/jarabe/journal/journalactivity.py @@ -28,6 +28,7 @@ import os from sugar.graphics.window import Window from sugar.graphics.alert import ErrorAlert +from sugar.graphics.alert import ConfirmationAlert from sugar.bundle.bundle import ZipExtractException, RegistrationException from sugar import env @@ -128,7 +129,7 @@ class JournalActivity(Window): self.connect('window-state-event', self.__window_state_event_cb) self.connect('key-press-event', self._key_press_event_cb) self.connect('focus-in-event', self._focus_in_event_cb) - + model.created.connect(self.__model_created_cb) model.updated.connect(self.__model_updated_cb) model.deleted.connect(self.__model_deleted_cb) @@ -136,7 +137,6 @@ class JournalActivity(Window): self._dbus_service = JournalActivityDBusService(self) self.iconify() - self._critical_space_alert = None self._check_available_space() @@ -145,7 +145,29 @@ class JournalActivity(Window): alert.connect('response', self.__alert_response_cb) self.add_alert(alert) alert.show() - + +def __activity_alert1_cb(self): + if misc.check_previous_install() == 1 and misc.return_checked()==0: + alert1 = ConfirmationAlert() + logging.debug('value of misc is %d', misc.check_previous_install()) + alert1.props.title=_('Previous Version Found') + alert1.props.msg = _('A previous version of an installed activity was found. Are you sure you want to continue with installation ? If Yes click Ok and the activity icon of the older .xo file in the Journal') + alert1.connect('response', self.__alert1_response_cb) + self.add_alert(alert1) + alert1.show() + +def __alert1_response_cb(self, alert1, response_id): +if response_id is gtk.RESPONSE_OK: +logging.debug('value of checked initial %d', misc.return_checked()) +logging.debug('Installing previous version') +self.remove_alert(alert1) +misc.checked = 1 +logging.debug('value of checked final %d', misc.return_checked()) + +elif response_id is gtk.RESPONSE_CANCEL: +logging.debug('Cancelled by user') +self.remove_alert(alert1) + def __alert_response_cb(self, alert, response_id): self.remove_alert(alert) @@ -166,6 +188,8 @@ class JournalActivity(Window): self._list_view = ListView() self._list_view.connect('detail-clicked', self.__detail_clicked_cb) self._list_view.connect('clear-clicked', self.__clear_clicked_cb) +self._list_view.connect('icon-clicked', self.__icon_clicked_cb) +logging.debug('icon clicked in main') self._main_view.pack_start(self._list_view) self._list_view.show() @@ -195,7 +219,11 @@ class JournalActivity(Window): keyname = gtk.gdk.keyval_name(event.keyval) if keyname == 'Escape': self.show_main_view() - + +def __icon_clicked_cb(self,a): + logging.debug('value of misc is %d', misc.check_previous_install()) + self.__activity_alert1_cb() + def __detail_clicked_cb(self, list_view, object_id): self._show_secondary_view(object_id) diff --git a/src/jarabe/journal/listview.py b/src/jarabe/journal/listview.py index 3d6281a..3dbcc2d 100644 --- a/src/jarabe/journal/listview.py +++ b/src/jarabe/journal/listview.py @@ -466,8 +466,12 @@ class ListView(BaseListView): __gsignals__ = { 'detail-clicked': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, - ([object])) + ([object])), +'icon-clicked': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, + ([])) } + def __init__(s