[Dextrose] [PATCH] Journal space messages alert and improved modal alert

Martin Abente martin.abente.lahaye at gmail.com
Wed Dec 8 00:32:06 EST 2010


I think it was bernie who mentioned the need for terminal access in some
cases, which seems valid to me.

So, it allows activities too, but when it create/modify a journal entry it
will activate the modal window again... From what i see in eben's comments,
this modal window it is supposed to insist on unnecessary entries deletion,
because is a critical moment.

On Wed, Dec 8, 2010 at 1:35 AM, Martin Abente <
martin.abente.lahaye at gmail.com> wrote:

> Forgot to mention, activities are allowed ;).
>
>
> On Tue, Dec 7, 2010 at 9:03 PM, Gary Martin <garycmartin at googlemail.com>wrote:
>
>> Hi Martin,
>>
>> Hmmmm....
>>
>> On 7 Dec 2010, at 21:04, Martin Abente <martin.abente.lahaye at gmail.com>
>> wrote:
>>
>> > Based on the comments from #630
>> >
>> > When available space reaches the _PREEMPTIVE_SPACE_TRESHOLD
>> > (75MB) a message notification will be displayed on every startup.
>> >
>> > When available space reaches the _SPACE_TRESHOLD (50MB) the
>> > ModalaAlert will be displayed.
>> >
>> > Changes on the ModaAlert:
>> >
>> > * It will remain active until there is enough available space again.
>> > * It will be deactivated when the journal is on the foreground
>> >  and it will be activated again otherwise.
>>
>> So, as a coder who does use XOs for dev work, I'm stuck with this modal
>> alert blocking my path while trying to use Terminal to access the filesystem
>> to clean up some yum install that has got out of hand, or some git clone
>> that's grabbed too much?
>>
>> Regards,
>> --Gary
>>
>> > * It contains a new progressbar to determine intuitively how much
>> >  deletion is required to reach the safe state again.
>> > ---
>> > src/jarabe/journal/journalactivity.py |   47
>> +++++++++++++++++++++++++-------
>> > src/jarabe/journal/modalalert.py      |   28 +++++++++++++++++--
>> > 2 files changed, 61 insertions(+), 14 deletions(-)
>> >
>> > diff --git a/src/jarabe/journal/journalactivity.py
>> b/src/jarabe/journal/journalactivity.py
>> > index eab292b..66299c9 100644
>> > --- a/src/jarabe/journal/journalactivity.py
>> > +++ b/src/jarabe/journal/journalactivity.py
>> > @@ -45,13 +45,16 @@ from jarabe.journal.journalentrybundle import
>> JournalEntryBundle
>> > from jarabe.journal.objectchooser import ObjectChooser
>> > from jarabe.journal.modalalert import ModalAlert
>> > from jarabe.journal import model
>> > +from jarabe.frame import get_view
>> >
>> > J_DBUS_SERVICE = 'org.laptop.Journal'
>> > J_DBUS_INTERFACE = 'org.laptop.Journal'
>> > J_DBUS_PATH = '/org/laptop/Journal'
>> >
>> > _SPACE_TRESHOLD = 52428800
>> > +_PREEMPTIVE_SPACE_TRESHOLD = _SPACE_TRESHOLD * 1.5
>> > _BUNDLE_ID = 'org.laptop.JournalActivity'
>> > +_JOURNAL_ICON = 'activity-journal'
>> >
>> > class JournalActivityDBusService(dbus.service.Object):
>> >     def __init__(self, parent):
>> > @@ -139,7 +142,7 @@ class JournalActivity(Window):
>> >         self.iconify()
>> >
>> >         self._critical_space_alert = None
>> > -        self._check_available_space()
>> > +        self._check_available_space(startup=True)
>> >
>> >     def _alert_notify_cb(self, gobject, strerror, severity):
>> >         alert = ErrorAlert()
>> > @@ -273,6 +276,9 @@ class JournalActivity(Window):
>> >                 kwargs['object_id'] ==
>> self._detail_view.props.metadata['uid']:
>> >             self.show_main_view()
>> >
>> > +        if self._critical_space_alert:
>> > +           self._check_available_space(display=False)
>> > +
>> >     def _focus_in_event_cb(self, window, event):
>> >         self.search_grab_focus()
>> >         self._list_view.update_dates()
>> > @@ -324,32 +330,51 @@ class JournalActivity(Window):
>> >             visible = not state & gtk.gdk.WINDOW_STATE_ICONIFIED
>> >             self._list_view.set_is_visible(visible)
>> >
>> > +            if self._critical_space_alert and not visible:
>> > +                self._check_available_space()
>> > +
>> >     def __visibility_notify_event_cb(self, window, event):
>> >         logging.debug('visibility_notify_event_cb %r', self)
>> >         visible = event.state != gtk.gdk.VISIBILITY_FULLY_OBSCURED
>> >         self._list_view.set_is_visible(visible)
>> >
>> > -    def _check_available_space(self):
>> > +    def _check_available_space(self, startup=False, display=True):
>> >         ''' Check available space on device
>> >
>> >             If the available space is below 50MB an alert will be
>> >             shown which encourages to delete old journal entries.
>> >         '''
>> > -
>> > -        if self._critical_space_alert:
>> > -            return
>> >         stat = os.statvfs(env.get_profile_path())
>> >         free_space = stat[statvfs.F_BSIZE] * stat[statvfs.F_BAVAIL]
>> > -        if free_space < _SPACE_TRESHOLD:
>> > +
>> > +        if self._critical_space_alert and free_space >=
>> _SPACE_TRESHOLD:
>> > +            self._critical_space_alert.destroy()
>> > +            self._critical_space_alert = None
>> > +
>> > +        elif free_space < _SPACE_TRESHOLD:
>> > +            space_fraction = 1.0 - (float(free_space) /
>> float(_SPACE_TRESHOLD))
>> > +            self._setup_space_alert(space_fraction, display)
>> > +
>> > +        elif startup and free_space < _PREEMPTIVE_SPACE_TRESHOLD:
>> > +            body = _('Your Journal currently contains too much entries'
>> > +                    ' please consider removing unnecessary ones')
>> > +
>> > +            frame = get_view()
>> > +            frame.add_message(body, icon_name=_JOURNAL_ICON)
>> > +
>> > +    def _setup_space_alert(self, space_fraction, display):
>> > +        if self._critical_space_alert is None:
>> >             self._critical_space_alert = ModalAlert()
>> > -            self._critical_space_alert.connect('destroy',
>> > -                                               self.__alert_closed_cb)
>> > -            self._critical_space_alert.show()
>> > +            self._critical_space_alert.connect('show-journal',
>> > +                                               self.__show_journal_cb)
>> > +
>>  self._critical_space_alert.update_space_fraction(space_fraction)
>> > +        if display:
>> > +            self._critical_space_alert.present()
>> >
>> > -    def __alert_closed_cb(self, data):
>> > +    def __show_journal_cb(self, data):
>> >         self.show_main_view()
>> >         self.reveal()
>> > -        self._critical_space_alert = None
>> > +        self._critical_space_alert.hide()
>> >
>> >     def set_active_volume(self, mount):
>> >         self._volumes_toolbar.set_active_volume(mount)
>> > diff --git a/src/jarabe/journal/modalalert.py
>> b/src/jarabe/journal/modalalert.py
>> > index c7c6a0a..0c774e7 100644
>> > --- a/src/jarabe/journal/modalalert.py
>> > +++ b/src/jarabe/journal/modalalert.py
>> > @@ -17,6 +17,7 @@
>> > import gtk
>> > from gettext import gettext as _
>> > import gconf
>> > +import gobject
>> >
>> > from sugar.graphics.icon import Icon
>> > from sugar.graphics import style
>> > @@ -26,6 +27,10 @@ class ModalAlert(gtk.Window):
>> >
>> >     __gtype_name__ = 'SugarModalAlert'
>> >
>> > +    __gsignals__ = {
>> > +        'show-journal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
>> ([]))
>> > +    }
>> > +
>> >     def __init__(self):
>> >         gtk.Window.__init__(self)
>> >
>> > @@ -35,6 +40,7 @@ class ModalAlert(gtk.Window):
>> >         height = gtk.gdk.screen_height() - offset * 2
>> >         self.set_size_request(width, height)
>> >         self.set_position(gtk.WIN_POS_CENTER_ALWAYS)
>> > +        self.set_accept_focus(True)
>> >         self.set_decorated(False)
>> >         self.set_resizable(False)
>> >         self.set_modal(True)
>> > @@ -71,6 +77,16 @@ class ModalAlert(gtk.Window):
>> >         self._vbox.pack_start(self._message, False)
>> >         self._message.show()
>> >
>> > +        self._space_bar = gtk.ProgressBar()
>> > +        self._vbox.pack_start(self._space_bar, False)
>> > +        self._space_bar.show()
>> > +
>> > +        advice = gtk.Label(_('Delete entries until this bar is empty'))
>> > +        advice.modify_fg(gtk.STATE_NORMAL,
>> > +                        style.COLOR_WHITE.get_gdk_color())
>> > +        self._vbox.pack_start(advice, False)
>> > +        advice.show()
>> > +
>> >         alignment = gtk.Alignment(xalign=0.5, yalign=0.5)
>> >         self._vbox.pack_start(alignment, expand=False)
>> >         alignment.show()
>> > @@ -91,7 +107,13 @@ class ModalAlert(gtk.Window):
>> >         self.window.set_accept_focus(True)
>> >
>> >     def __show_journal_cb(self, button):
>> > -        '''The opener will listen on the destroy signal
>> > -        '''
>> > -        self.destroy()
>> > +        self.emit('show-journal')
>> > +
>> > +    def update_space_fraction(self, fraction):
>> > +        if fraction > 1.0:
>> > +            fraction = 1.0
>> > +        elif fraction < 0.0:
>> > +            fraction = 0.0
>> > +
>> > +        self._space_bar.set_fraction(fraction)
>> >
>> > --
>> > 1.7.1
>> >
>> > _______________________________________________
>> > Dextrose mailing list
>> > Dextrose at lists.sugarlabs.org
>> > http://lists.sugarlabs.org/listinfo/dextrose
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/dextrose/attachments/20101208/0d1f5aeb/attachment.html>


More information about the Dextrose mailing list