diff options
-rw-r--r-- | data/icons/Makefile.am | 3 | ||||
-rw-r--r-- | data/icons/module-frame.svg | 22 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | src/controlpanel/model/frame.py | 23 | ||||
-rw-r--r-- | src/controlpanel/view/Makefile.am | 3 | ||||
-rw-r--r-- | src/controlpanel/view/frame.py | 220 | ||||
-rw-r--r-- | src/view/frame/eventarea.py | 5 |
7 files changed, 274 insertions, 3 deletions
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am index 5b7c8e6..625e78b 100644 --- a/data/icons/Makefile.am +++ b/data/icons/Makefile.am @@ -4,7 +4,8 @@ sugar_DATA = \ module-about_me.svg \ module-about_my_xo.svg \ module-date_and_time.svg \ + module-frame.svg \ module-language.svg \ - module-network.svg + module-network.svg EXTRA_DIST = $(sugar_DATA) diff --git a/data/icons/module-frame.svg b/data/icons/module-frame.svg new file mode 100644 index 0000000..caf4f6a --- /dev/null +++ b/data/icons/module-frame.svg @@ -0,0 +1,22 @@ +<?xml version="1.0" ?> +<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' + 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' [ + <!ENTITY stroke_color "#666666"> + <!ENTITY fill_color "#ffffff"> + ]> +<svg enable-background="new 0 0 55 55" height="55px" id="Layer_1" + version="1.1" viewBox="0 0 55 55" width="55px" x="0px" + xml:space="preserve" xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" y="0px"> + <g display="block" id="module-display"> + <g display="inline"> + <g> + <path d="M46.824,8.027H8.176c-3.581,0-6.51,2.929-6.51,6.509v25.926c0, + 3.58,2.929,6.511,6.51,6.511h38.648 c3.579,0,6.51-2.931, + 6.51-6.511V14.537C53.334,10.957,50.403, + 8.027,46.824,8.027z M45.978, + 39.962H9.282V11.575h36.695V39.962z" fill="&fill_color;"/> + </g> + </g> + </g> +</svg> diff --git a/po/POTFILES.in b/po/POTFILES.in index 8f7d629..5e32ed5 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -20,6 +20,7 @@ src/controlpanel/model/network.py src/controlpanel/model/timezone.py src/controlpanel/view/aboutme.py src/controlpanel/view/aboutxo.py +src/controlpanel/view/frame.py src/controlpanel/view/language.py src/controlpanel/view/network.py src/controlpanel/view/timezone.py diff --git a/src/controlpanel/model/frame.py b/src/controlpanel/model/frame.py index 8519dc9..783bb16 100644 --- a/src/controlpanel/model/frame.py +++ b/src/controlpanel/model/frame.py @@ -35,8 +35,29 @@ def set_delay(value): try: int(value) except ValueError: - raise ValueError(_("Value must be an integer.")) + raise ValueError(_("Value must be an int.")) pro = profile.get_profile() pro.frame_delay = int(value) pro.save() return 'RESTART' + +def get_top_active(): + pro = profile.get_profile() + return pro.frame_top_active + +def print_top_active(): + print get_top_active() + +def set_top_active(state): + """Toggle if the frame can be revealed at the top of the screen + state : on/off + """ + pro = profile.get_profile() + if state == 'on' or state == True: + pro.frame_top_active = True + elif state == 'off' or state == False: + pro.frame_top_active = False + else: + raise ValueError(_("Error in specified argument use on/off.")) + pro.save() + return 'RESTART' diff --git a/src/controlpanel/view/Makefile.am b/src/controlpanel/view/Makefile.am index faffc20..45a41e2 100644 --- a/src/controlpanel/view/Makefile.am +++ b/src/controlpanel/view/Makefile.am @@ -5,5 +5,6 @@ sugar_PYTHON = \ aboutme.py \ language.py \ timezone.py \ - aboutxo.py + aboutxo.py \ + frame.py diff --git a/src/controlpanel/view/frame.py b/src/controlpanel/view/frame.py new file mode 100644 index 0000000..26dba7f --- /dev/null +++ b/src/controlpanel/view/frame.py @@ -0,0 +1,220 @@ +# Copyright (C) 2008, OLPC +# +# 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 +import gobject +import gettext +_ = lambda msg: gettext.dgettext('sugar', msg) + +from sugar.graphics import style +from sugar.graphics.icon import Icon + +from controlpanel.sectionview import SectionView +from controlpanel.inlinealert import InlineAlert + +ICON = 'module-frame' +TITLE = _('Frame') + +class Frame(SectionView): + def __init__(self, model, alerts): + SectionView.__init__(self) + + self._delay_sid = 0 + self._delay_valid = True + self._top_valid = True + self.restart_alerts = alerts + + self._model = model + self._delay = self._model.get_delay() + self._top_active = self._model.get_top_active() + + self.set_border_width(style.DEFAULT_SPACING * 2) + self.set_spacing(style.DEFAULT_SPACING) + group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL) + + self._delay_alert_box = gtk.HBox(spacing=style.DEFAULT_SPACING) + self._top_alert_box = gtk.HBox(spacing=style.DEFAULT_SPACING) + + separator_delay = gtk.HSeparator() + self.pack_start(separator_delay, expand=False) + separator_delay.show() + + label_activation = gtk.Label(_('Activation')) + label_activation.set_alignment(0, 0) + self.pack_start(label_activation, expand=False) + label_activation.show() + box_activation = gtk.VBox() + box_activation.set_border_width(style.DEFAULT_SPACING * 2) + box_activation.set_spacing(style.DEFAULT_SPACING) + box_delay = gtk.HBox(spacing=style.DEFAULT_SPACING) + label_delay = gtk.Label(_('Delay:')) + label_delay.set_alignment(1, 0.75) + label_delay.modify_fg(gtk.STATE_NORMAL, + style.COLOR_SELECTION_GREY.get_gdk_color()) + box_delay.pack_start(label_delay, expand=False) + group.add_widget(label_delay) + label_delay.show() + + # (value, lower, upper, step_increment, page_increment, page_size) + adj = gtk.Adjustment(100, 0, 1000, 100, 100, 0) + self._scale = gtk.HScale(adj) + self._scale.set_digits(0) + self._scale.set_value(self._delay) + box_delay.pack_start(self._scale) + self._scale.show() + self._scale.connect('value-changed', self.__delay_changed_cb) + box_activation.pack_start(box_delay, expand=False) + box_delay.show() + + icon_delay = Icon(icon_name='emblem-warning', + fill_color=style.COLOR_SELECTION_GREY.get_svg(), + stroke_color=style.COLOR_WHITE.get_svg()) + self._delay_alert = InlineAlert(icon=icon_delay) + icon_delay.show() + label_delay_error = gtk.Label() + group.add_widget(label_delay_error) + self._delay_alert_box.pack_start(label_delay_error, expand=False) + label_delay_error.show() + self._delay_alert_box.pack_start(self._delay_alert, expand=False) + box_activation.pack_start(self._delay_alert_box, expand=False) + self._delay_alert_box.show() + try: + self._delay_state = self._model.get_delay() + except Exception, detail: + self._delay_alert.props.msg = detail + self._delay_alert.show() + if 'delay' in self.restart_alerts: + self._delay_alert.props.msg = self._restart_msg + self._delay_alert.show() + + box_top = gtk.HBox(spacing=style.DEFAULT_SPACING) + label_top = gtk.Label(_('Top:')) + label_top.set_alignment(1, 0.75) + label_top.modify_fg(gtk.STATE_NORMAL, + style.COLOR_SELECTION_GREY.get_gdk_color()) + box_top.pack_start(label_top, expand=False) + group.add_widget(label_top) + label_top.show() + + self._button = gtk.CheckButton() + self._button.set_alignment(0, 0) + self._button.set_active(self._top_active) + self._button.connect('toggled', self.__top_active_toggled_cb) + box_top.pack_start(self._button, expand=False) + self._button.show() + box_activation.pack_start(box_top, expand=False) + box_top.show() + + icon_top = Icon(icon_name='emblem-warning', + fill_color=style.COLOR_SELECTION_GREY.get_svg(), + stroke_color=style.COLOR_WHITE.get_svg()) + self._top_alert = InlineAlert(icon=icon_top) + icon_top.show() + label_top_error = gtk.Label() + group.add_widget(label_top_error) + self._top_alert_box.pack_start(label_top_error, expand=False) + label_top_error.show() + self._top_alert_box.pack_start(self._top_alert, expand=False) + box_activation.pack_start(self._top_alert_box, expand=False) + self._top_alert_box.show() + try: + self._top_state = self._model.get_top_active() + except Exception, detail: + self._top_alert.props.msg = detail + self._top_alert.show() + if 'top_active' in self.restart_alerts: + self._top_alert.props.msg = self._restart_msg + self._top_alert.show() + + self.pack_start(box_activation, expand=False) + box_activation.show() + + def undo(self): + self._model.set_delay(self._delay) + self._model.set_top_active(self._top_active) + self._scale.set_value(self._delay) + self._button.set_active(self._top_active) + if self._top_alert.props.visible: + self._top_alert.hide() + + self._delay_valid = True + self._top_valid = True + self.restart = False + self.restart_alerts = [] + + def __top_active_toggled_cb(self, widget, data=None): + state = ('off', 'on')[widget.get_active()] + try: + self._model.set_top_active(state) + except Exception, detail: + self._top_alert.props.msg = detail + self._top_valid = False + else: + self._top_alert.props.msg = self._restart_msg + self._top_valid = True + if state != self._top_active: + self.restart = True + self.restart_alerts.append('top_active') + else: + self.restart = False + + if self._top_valid and self._delay_valid: + self.props.valid_section = True + else: + self.props.valid_section = False + + if not self._top_alert.props.visible or \ + state != self._top_active: + self._top_alert.show() + else: + self._top_alert.hide() + + return False + + def __delay_changed_cb(self, widget, data=None): + if self._delay_sid: + gobject.source_remove(self._delay_sid) + self._delay_sid = gobject.timeout_add(1000, + self.__delay_timeout_cb, widget) + + def __delay_timeout_cb(self, widget): + self._delay_sid = 0 + try: + self._model.set_delay(widget.get_value()) + except ValueError, detail: + self._delay_alert.props.msg = detail + self._delay_valid = False + else: + self._delay_alert.props.msg = self._restart_msg + self._delay_valid = True + if widget.get_value() != self._delay: + self.restart = True + self.restart_alerts.append('delay') + else: + self.restart = False + + if self._delay_valid: + self.props.valid_section = True + else: + self.props.valid_section = False + + if not self._delay_alert.props.visible or \ + widget.get_value() != self._delay: + self._delay_alert.show() + else: + self._delay_alert.hide() + + return False diff --git a/src/view/frame/eventarea.py b/src/view/frame/eventarea.py index b7d0212..db95017 100644 --- a/src/view/frame/eventarea.py +++ b/src/view/frame/eventarea.py @@ -39,6 +39,11 @@ class EventArea(gobject.GObject): right = gtk.gdk.screen_width() - 1 bottom = gtk.gdk.screen_height() -1 + top = gtk.gdk.screen_width() - 2 + + if pro.frame_top_active: + invisible = self._create_invisible(0, top, 1, 1) + self._windows.append(invisible) invisible = self._create_invisible(0, 0, 1, 1) self._windows.append(invisible) |