diff options
author | Aleksey Lim <alsroot@member.fsf.org> | 2009-03-02 04:17:35 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@member.fsf.org> | 2009-03-02 06:32:19 (GMT) |
commit | c2b9cc5fd53da654d288db34ea7782017e37163a (patch) | |
tree | 17134c2ffa9a386de36a77ffb1f3c30a7b9c4d06 | |
parent | b58a03a601781cf0bcbb041e92b69d6cd956f1c9 (diff) |
User alert to notify about existed wiki article
-rw-r--r-- | library.py | 5 | ||||
-rw-r--r-- | shared.py | 24 | ||||
-rw-r--r-- | xol.py | 34 |
3 files changed, 35 insertions, 28 deletions
@@ -212,8 +212,9 @@ class Toolbar(gtk.Toolbar): return if book.wiki.find('%s (from %s)' % (title, wiki))[0]: - self.library.progress.set_label(_('"%s" article already exists') % title) - Timer(10, self._clear_progress).start() + self.activity.notify_alert( + _('Exists'), + _('"%s" article already exists') % title) else: Timer(0, self._download, [title, wiki]).start() @@ -12,12 +12,14 @@ # 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 import logging import telepathy from gobject import property, SIGNAL_RUN_FIRST, TYPE_PYOBJECT from sugar.activity.activity import Activity from sugar.presence.sugartubeconn import SugarTubeConnection +from sugar.graphics.alert import ConfirmationAlert, NotifyAlert logger = logging.getLogger('infoslicer') @@ -45,6 +47,28 @@ class CanvasActivity(Activity): self.emit('init') return False + def notify_alert(self, title, msg): + alert = NotifyAlert(title=title, msg=msg) + + def response(alert, response_id, self): + self.remove_alert(alert) + + alert.connect('response', response, self) + alert.show_all() + self.add_alert(alert) + + def confirmation_alert(self, title, msg, cb, *cb_args): + alert = ConfirmationAlert(title=title, msg=msg) + + def response(alert, response_id, self, cb, *cb_args): + self.remove_alert(alert) + if response_id is gtk.RESPONSE_OK: + cb(*cb_args) + + alert.connect('response', response, self, cb, *cb_args) + alert.show_all() + self.add_alert(alert) + class SharedActivity(CanvasActivity): __gsignals__ = { 'tube' : (SIGNAL_RUN_FIRST, None, 2*[TYPE_PYOBJECT]) } @@ -11,7 +11,6 @@ from gettext import gettext as _ from sugar.activity.activity import get_bundle_path, get_activity_root, get_bundle_name
from sugar.datastore import datastore
from sugar import activity
-from sugar.graphics.alert import ConfirmationAlert, NotifyAlert
from Processing.NewtifulSoup import NewtifulStoneSoup as BeautifulStoneSoup
import book
@@ -20,17 +19,9 @@ logger = logging.getLogger('infoslicer') def publish(activity, force=False):
if not [i for i in book.custom.index if i['ready']]:
- alert = NotifyAlert(
- title=_('Nothing to publish'),
- msg=_('Mark arcticles from "Custom" panel and try again.'))
-
- def response(alert, response_id, activity):
- activity.remove_alert(alert)
-
- alert.connect('response', response, activity)
- alert.show_all()
- activity.add_alert(alert)
-
+ activity.notify_alert(
+ _('Nothing to publish'),
+ _('Mark arcticles from "Custom" panel and try again.'))
return
title = activity.metadata['title']
@@ -45,21 +36,12 @@ def publish(activity, force=False): if force:
jobject = jobject[0]
else:
- alert = ConfirmationAlert(
- title=_('Overwrite existed bundle?'),
- msg=_('A bundle for current object was already created. ' \
- 'Click "OK" to overwrite it.'))
-
- def response(alert, response_id, activity):
- activity.remove_alert(alert)
- if response_id is gtk.RESPONSE_OK:
- publish(activity, True)
-
- alert.connect('response', response, activity)
- alert.show_all()
- activity.add_alert(alert)
+ activity.confirmation_alert(
+ _('Overwrite existed bundle?'),
+ _('A bundle for current object was already created. ' \
+ 'Click "OK" to overwrite it.'),
+ publish, activity, True)
jobject[0].destroy()
-
return
else:
jobject = datastore.create()
|