Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2008-06-04 19:06:12 (GMT)
committer Simon Schampijer <simon@schampijer.de>2008-06-04 19:06:12 (GMT)
commit754b4c5d460db45555a36bbc0cddcb385ea071e0 (patch)
tree01efe2f65776b3d7c137a812266d478079fac279
parent2b6e3b653dd3de53991e180ef390b6a2abaeaf1d (diff)
Control Panel push missed these changes
-rw-r--r--configure.ac3
-rw-r--r--data/Makefile.am2
-rw-r--r--po/POTFILES.in17
-rw-r--r--src/config.py.in1
-rw-r--r--src/controlpanel/Makefile.am9
-rw-r--r--src/controlpanel/cmd.py131
-rw-r--r--src/controlpanel/control.py479
-rw-r--r--src/main.py4
-rw-r--r--src/view/frame/eventarea.py66
-rw-r--r--src/view/home/activitiesring.py68
10 files changed, 189 insertions, 591 deletions
diff --git a/configure.ac b/configure.ac
index 3e21245..c2b3908 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,9 +40,12 @@ AC_OUTPUT([
Makefile
bin/Makefile
data/Makefile
+data/icons/Makefile
service/Makefile
src/Makefile
src/controlpanel/Makefile
+src/controlpanel/model/Makefile
+src/controlpanel/view/Makefile
src/intro/Makefile
src/hardware/Makefile
src/view/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 698721d..cdf9dc5 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = icons
+
sugar.gtkrc: gtkrc.em
$(srcdir)/em.py -D theme=\'sugar\' $(srcdir)/gtkrc.em > \
$(top_builddir)/data/sugar.gtkrc
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 644b789..322e691 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,10 +7,25 @@ src/view/clipboardicon.py
src/view/home/HomeBox.py
src/view/home/MeshBox.py
src/view/devices/battery.py
+src/view/devices/speaker.py
src/view/devices/network/wireless.py
src/view/frame/zoomtoolbar.py
-src/controlpanel/control.py
src/controlpanel/cmd.py
+src/controlpanel/toolbar.py
+src/controlpanel/sectionview.py
+src/controlpanel/gui.py
+src/controlpanel/model/aboutme.py
+src/controlpanel/model/aboutxo.py
+src/controlpanel/model/datetime.py
+src/controlpanel/model/frame.py
+src/controlpanel/model/language.py
+src/controlpanel/model/network.py
+src/controlpanel/view/aboutme.py
+src/controlpanel/view/aboutxo.py
+src/controlpanel/view/datetime.py
+src/controlpanel/view/frame.py
+src/controlpanel/view/language.py
+src/controlpanel/view/network.py
src/view/devices/network/mesh.py
src/view/frame/activitiestray.py
src/view/home/activitiesring.py
diff --git a/src/config.py.in b/src/config.py.in
index 3b29a05..fb26181 100644
--- a/src/config.py.in
+++ b/src/config.py.in
@@ -16,3 +16,4 @@
prefix = '@prefix@'
data_path = '@prefix@/share/sugar/data'
+shell_path = '@prefix@/share/sugar/shell' \ No newline at end of file
diff --git a/src/controlpanel/Makefile.am b/src/controlpanel/Makefile.am
index f89132c..5acd9a1 100644
--- a/src/controlpanel/Makefile.am
+++ b/src/controlpanel/Makefile.am
@@ -1,5 +1,12 @@
+SUBDIRS = model view
+
sugardir = $(pkgdatadir)/shell/controlpanel
sugar_PYTHON = \
__init__.py \
cmd.py \
- control.py
+ gui.py \
+ inlinealert.py \
+ sectionview.py \
+ toolbar.py
+
+
diff --git a/src/controlpanel/cmd.py b/src/controlpanel/cmd.py
index 24653b2..a46a0aa 100644
--- a/src/controlpanel/cmd.py
+++ b/src/controlpanel/cmd.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2007, One Laptop Per Child
+# Copyright (C) 2007, 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
@@ -16,11 +16,20 @@
import sys
import getopt
+import os
from gettext import gettext as _
-from controlpanel import control
-
+import config
+
+_RESTART = 1
+
+_same_option_warning = _("sugar-control-panel: WARNING, found more than"
+ " one option with the same name: %s module: %r")
+_no_option_error = _("sugar-control-panel: key=%s not an available option")
+_general_error = _("sugar-control-panel: %s")
+
def cmd_help():
+ '''Print the help to the screen'''
print _('Usage: sugar-control-panel [ option ] key [ args ... ] \n\
Control for the sugar environment. \n\
Options: \n\
@@ -31,47 +40,89 @@ def cmd_help():
-s key set the current value for the key \n\
')
+def note_restart():
+ '''Instructions how to restart sugar'''
+ print _('To apply your changes you have to restart sugar.\n' +
+ 'Hit ctrl+alt+erase on the keyboard to trigger a restart.')
+
+def load_modules():
+ '''Build a list of pointers to available modules in the model directory
+ and load them.
+ '''
+ subpath = ['controlpanel', 'model']
+ file_names = os.listdir(os.path.join(config.shell_path, '/'.join(subpath)))
+
+ modules = []
+ for file_name in file_names:
+ if file_name.endswith('.py') and file_name != '__init__.py':
+ module_name = file_name.strip('.py')
+ module = __import__('.'.join(subpath) + '.' +
+ module_name, globals(), locals(),
+ [module_name])
+ modules.append(module)
+ return modules
+
def main():
try:
- opts, args = getopt.getopt(sys.argv[1:], "h:s:g:l", [])
+ options, args = getopt.getopt(sys.argv[1:], "h:s:g:l", [])
except getopt.GetoptError:
cmd_help()
sys.exit(2)
- if not opts:
+ if not options:
cmd_help()
- sys.exit()
-
- for opt, key in opts:
- if opt in ("-h"):
- method = getattr(control, 'set_' + key, None)
- if method is None:
- print _("sugar-control-panel: key=%s not an available option"
- % key)
- sys.exit()
- else:
- print method.__doc__
- if opt in ("-l"):
- elems = dir(control)
- for elem in elems:
- if elem.startswith('set_'):
- print elem[4:]
- if opt in ("-g"):
- method = getattr(control, 'print_' + key, None)
- if method is None:
- print _("sugar-control-panel: key=%s not an available option"
- % key)
- sys.exit()
- else:
- method()
- if opt in ("-s"):
- method = getattr(control, 'set_' + key, None)
- if method is None:
- print _("sugar-control-panel: key=%s not an available option"
- % key)
- sys.exit()
- else:
- try:
- method(*args)
- except Exception, e:
- print _("sugar-control-panel: %s"% e)
+ sys.exit(2)
+
+ modules = load_modules()
+
+ for option, key in options:
+ found = 0
+ if option in ("-h"):
+ for module in modules:
+ method = getattr(module, 'set_' + key, None)
+ if method:
+ found += 1
+ if found == 1:
+ print method.__doc__
+ else:
+ print _(_same_option_warning % (key, module))
+ if found == 0:
+ print _(_no_option_error % key)
+ if option in ("-l"):
+ for module in modules:
+ methods = dir(module)
+ print '%s:' % module.__name__.split('.')[-1]
+ for method in methods:
+ if method.startswith('get_'):
+ print ' %s' % method[4:]
+ if option in ("-g"):
+ for module in modules:
+ method = getattr(module, 'print_' + key, None)
+ if method:
+ found += 1
+ if found == 1:
+ try:
+ method()
+ except Exception, detail:
+ print _(_general_error % detail)
+ else:
+ print _(_same_option_warning % (key, module))
+ if found == 0:
+ print _(_no_option_error % key)
+ if option in ("-s"):
+ for module in modules:
+ method = getattr(module, 'set_' + key, None)
+ if method:
+ note = 0
+ found += 1
+ if found == 1:
+ try:
+ note = method(*args)
+ except Exception, detail:
+ print _(_general_error % detail)
+ if note == _RESTART:
+ note_restart()
+ else:
+ print _(_same_option_warning % (key, module))
+ if found == 0:
+ print _(_no_option_error % key)
diff --git a/src/controlpanel/control.py b/src/controlpanel/control.py
deleted file mode 100644
index bf3e681..0000000
--- a/src/controlpanel/control.py
+++ /dev/null
@@ -1,479 +0,0 @@
-# Copyright (C) 2007, 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
-#
-#
-# The language config is based on the system-config-language
-# (http://fedoraproject.org/wiki/SystemConfig/language) tool
-# and the timezone config on the system-config-date
-# (http://fedoraproject.org/wiki/SystemConfig/date) tool.
-# Parts of the code were reused.
-#
-
-import os
-import shutil
-from gettext import gettext as _
-import dbus
-
-from sugar import profile
-from sugar.graphics.xocolor import XoColor
-
-NM_SERVICE_NAME = 'org.freedesktop.NetworkManager'
-NM_SERVICE_PATH = '/org/freedesktop/NetworkManager'
-NM_SERVICE_IFACE = 'org.freedesktop.NetworkManager'
-NM_ASLEEP = 1
-
-_COLORS = {'red': {'dark':'#b20008', 'medium':'#e6000a', 'light':'#ffadce'},
- 'orange': {'dark':'#9a5200', 'medium':'#c97e00', 'light':'#ffc169'},
- 'yellow': {'dark':'#807500', 'medium':'#be9e00', 'light':'#fffa00'},
- 'green': {'dark':'#008009', 'medium':'#00b20d', 'light':'#8bff7a'},
- 'blue': {'dark':'#00588c', 'medium':'#005fe4', 'light':'#bccdff'},
- 'purple': {'dark':'#5e008c', 'medium':'#7f00bf', 'light':'#d1a3ff'}
- }
-
-_MODIFIERS = ('dark', 'medium', 'light')
-
-_TIMEZONE_CONFIG = '/etc/sysconfig/clock'
-
-_LANGUAGES = {
- 'Afrikaans/South_Africa': 'af_ZA',
- 'Albanian': 'sq_AL.UTF-8',
- 'Amharic/Ethiopian': 'am_ET.UTF-8',
- 'Arabic/Algeria': 'ar_DZ.UTF-8',
- 'Arabic/Bahrain': 'ar_BH.UTF-8',
- 'Arabic/Egypt': 'ar_EG.UTF-8',
- 'Arabic/India': 'ar_IN.UTF-8',
- 'Arabic/Iraq': 'ar_IQ.UTF-8',
- 'Arabic/Jordan': 'ar_JO.UTF-8',
- 'Arabic/Kuwait': 'ar_KW.UTF-8',
- 'Arabic/Lebanon': 'ar_LB.UTF-8',
- 'Arabic/Libyan_Arab_Jamahiriya': 'ar_LY.UTF-8',
- 'Arabic/Morocco': 'ar_MA.UTF-8',
- 'Arabic/Oman': 'ar_OM.UTF-8',
- 'Arabic/Qatar': 'ar_QA.UTF-8',
- 'Arabic/Saudi_Arabia': 'ar_SA.UTF-8',
- 'Arabic/Sudan': 'ar_SD.UTF-8',
- 'Arabic/Syrian_Arab_Republic': 'ar_SY.UTF-8',
- 'Arabic/Tunisia': 'ar_TN.UTF-8',
- 'Arabic/United_Arab_Emirates': 'ar_AE.UTF-8',
- 'Arabic/Yemen': 'ar_YE.UTF-8',
- 'Basque/Spain': 'eu_ES.UTF-8',
- 'Belarusian': 'be_BY.UTF-8',
- 'Bengali/BD': 'bn_BD.UTF-8',
- 'Bengali/India': 'bn_IN.UTF-8',
- 'Bosnian/Bosnia_and_Herzegowina': 'bs_BA',
- 'Breton/France': 'br_FR',
- 'Bulgarian': 'bg_BG.UTF-8',
- 'Catalan/Spain': 'ca_ES.UTF-8',
- 'Chinese/Hong_Kong': 'zh_HK.UTF-8',
- 'Chinese/P.R._of_China': 'zh_CN.UTF-8',
- 'Chinese/Taiwan': 'zh_TW.UTF-8',
- 'Cornish/Britain': 'kw_GB.UTF-8',
- 'Croatian': 'hr_HR.UTF-8',
- 'Czech': 'cs_CZ.UTF-8',
- 'Danish': 'da_DK.UTF-8',
- 'Dutch/Belgium': 'nl_BE.UTF-8',
- 'Dutch/Netherlands': 'nl_NL.UTF-8',
- 'English/Australia': 'en_AU.UTF-8',
- 'English/Botswana': 'en_BW.UTF-8',
- 'English/Canada': 'en_CA.UTF-8',
- 'English/Denmark': 'en_DK.UTF-8',
- 'English/Great_Britain': 'en_GB.UTF-8',
- 'English/Hong_Kong': 'en_HK.UTF-8',
- 'English/India': 'en_IN.UTF-8',
- 'English/Ireland': 'en_IE.UTF-8',
- 'English/New_Zealand': 'en_NZ.UTF-8',
- 'English/Philippines': 'en_PH.UTF-8',
- 'English/Singapore': 'en_SG.UTF-8',
- 'English/South_Africa': 'en_ZA.UTF-8',
- 'English/USA': 'en_US.UTF-8',
- 'English/Zimbabwe': 'en_ZW.UTF-8',
- 'Estonian': 'et_EE.UTF-8',
- 'Faroese/Faroe_Islands': 'fo_FO.UTF-8',
- 'Finnish': 'fi_FI.UTF-8',
- 'French/Belgium': 'fr_BE.UTF-8',
- 'French/Canada': 'fr_CA.UTF-8',
- 'French/France': 'fr_FR.UTF-8',
- 'French/Luxemburg': 'fr_LU.UTF-8',
- 'French/Switzerland': 'fr_CH.UTF-8',
- 'Galician/Spain': 'gl_ES.UTF-8',
- 'German/Austria': 'de_AT.UTF-8',
- 'German/Belgium': 'de_BE.UTF-8',
- 'German/Germany': 'de_DE.UTF-8',
- 'German/Luxemburg': 'de_LU.UTF-8',
- 'German/Switzerland': 'de_CH.UTF-8',
- 'Greek': 'el_GR.UTF-8',
- 'Greenlandic/Greenland': 'kl_GL.UTF-8',
- 'Gujarati/India': 'gu_IN.UTF-8',
- 'Hausa/Nigeria': 'ha_NG.UTF-8',
- 'Hebrew/Israel': 'he_IL.UTF-8',
- 'Hindi/India': 'hi_IN.UTF-8',
- 'Hungarian': 'hu_HU.UTF-8',
- 'Icelandic': 'is_IS.UTF-8',
- 'Igbo/Nigeria': 'ig_NG.UTF-8',
- 'Indonesian': 'id_ID.UTF-8',
- 'Irish': 'ga_IE.UTF-8',
- 'Italian/Italy': 'it_IT.UTF-8',
- 'Italian/Switzerland': 'it_CH.UTF-8',
- 'Japanese': 'ja_JP.UTF-8',
- 'Korean/Republic_of_Korea': 'ko_KR.UTF-8',
- 'Lao/Laos': 'lo_LA.UTF-8',
- 'Latvian/Latvia': 'lv_LV.UTF-8',
- 'Lithuanian': 'lt_LT.UTF-8',
- 'Macedonian': 'mk_MK.UTF-8',
- 'Malay/Malaysia': 'ms_MY.UTF-8',
- 'Maltese/malta': 'mt_MT.UTF-8',
- 'Manx/Britain': 'gv_GB.UTF-8',
- 'Marathi/India': 'mr_IN.UTF-8',
- 'Mongolian': 'mn_MN.UTF-8',
- 'Nepali': 'ne_NP.UTF-8',
- 'Northern/Norway': 'se_NO',
- 'Norwegian': 'nb_NO.UTF-8',
- 'Norwegian,/Norway': 'nn_NO.UTF-8',
- 'Occitan/France': 'oc_FR',
- 'Oriya/India': 'or_IN.UTF-8',
- 'Persian/Iran': 'fa_IR.UTF-8',
- 'Polish': 'pl_PL.UTF-8',
- 'Portuguese/Brasil': 'pt_BR.UTF-8',
- 'Portuguese/Portugal': 'pt_PT.UTF-8',
- 'Punjabi/India': 'pa_IN.UTF-8',
- 'Romanian': 'ro_RO.UTF-8',
- 'Russian': 'ru_RU.UTF-8',
- 'Russian/Ukraine': 'ru_UA.UTF-8',
- 'Serbian': 'sr_CS.UTF-8',
- 'Serbian/Latin': 'sr_CS.UTF-8@Latn',
- 'Slovak': 'sk_SK.UTF-8',
- 'Slovenian/Slovenia': 'sl_SI.UTF-8',
- 'Spanish/Argentina': 'es_AR.UTF-8',
- 'Spanish/Bolivia': 'es_BO.UTF-8',
- 'Spanish/Chile': 'es_CL.UTF-8',
- 'Spanish/Colombia': 'es_CO.UTF-8',
- 'Spanish/Costa_Rica': 'es_CR.UTF-8',
- 'Spanish/Dominican_Republic': 'es_DO.UTF-8',
- 'Spanish/El_Salvador': 'es_SV.UTF-8',
- 'Spanish/Equador': 'es_EC.UTF-8',
- 'Spanish/Guatemala': 'es_GT.UTF-8',
- 'Spanish/Honduras': 'es_HN.UTF-8',
- 'Spanish/Mexico': 'es_MX.UTF-8',
- 'Spanish/Nicaragua': 'es_NI.UTF-8',
- 'Spanish/Panama': 'es_PA.UTF-8',
- 'Spanish/Paraguay': 'es_PY.UTF-8',
- 'Spanish/Peru': 'es_PE.UTF-8',
- 'Spanish/Puerto_Rico': 'es_PR.UTF-8',
- 'Spanish/Spain': 'es_ES.UTF-8',
- 'Spanish/USA': 'es_US.UTF-8',
- 'Spanish/Uruguay': 'es_UY.UTF-8',
- 'Spanish/Venezuela': 'es_VE.UTF-8',
- 'Swedish/Finland': 'sv_FI.UTF-8',
- 'Swedish/Sweden': 'sv_SE.UTF-8',
- 'Tagalog/Philippines': 'tl_PH',
- 'Tamil/India': 'ta_IN.UTF-8',
- 'Telugu/India': 'te_IN.UTF-8',
- 'Thai': 'th_TH.UTF-8',
- 'Turkish': 'tr_TR.UTF-8',
- 'Ukrainian': 'uk_UA.UTF-8',
- 'Urdu/Pakistan': 'ur_PK',
- 'Uzbek/Uzbekistan': 'uz_UZ',
- 'Walloon/Belgium': 'wa_BE@euro',
- 'Welsh/Great_Britain': 'cy_GB.UTF-8',
- 'Xhosa/South_Africa': 'xh_ZA.UTF-8',
- 'Yoruba/Nigeria': 'yo_NG.UTF-8',
- 'Zulu/South_Africa': 'zu_ZA.UTF-8'
- }
-
-
-def _initialize():
- timezones = _read_zonetab()
-
- j = 0
- for timezone in timezones:
- set_timezone.__doc__ += timezone+', '
- j += 1
- if j % 3 == 0:
- set_timezone.__doc__ += '\n'
-
- keys = _LANGUAGES.keys()
- keys.sort()
- i = 0
- for key in keys:
- set_language.__doc__ += key + ', '
- i += 1
- if i % 3 == 0:
- set_language.__doc__ += '\n'
-
-def _note_restart():
- print _('To apply your changes you have to restart sugar.\n' +
- 'Hit at the same time ctrl+alt+erase on the keyboard to do this.')
-
-def get_jabber():
- pro = profile.get_profile()
- return pro.jabber_server
-
-def print_jabber():
- print get_jabber()
-
-def set_jabber(server):
- """Set the jabber server
- server : e.g. 'olpc.collabora.co.uk'
- """
- pro = profile.get_profile()
- pro.jabber_server = server
- pro.jabber_registered = False
- pro.save()
- _note_restart()
-
-def get_color():
- return profile.get_color()
-
-def print_color():
- color = get_color().to_string()
- tmp = color.split(',')
-
- stroke = None
- fill = None
- for color in _COLORS:
- for hue in _COLORS[color]:
- if _COLORS[color][hue] == tmp[0]:
- stroke = (color, hue)
- if _COLORS[color][hue] == tmp[1]:
- fill = (color, hue)
-
- if stroke is not None:
- print 'stroke: color=%s hue=%s' % (stroke[0], stroke[1])
- else:
- print 'stroke: %s' % (tmp[0])
- if fill is not None:
- print 'fill: color=%s hue=%s' % (fill[0], fill[1])
- else:
- print 'fill: %s' % (tmp[1])
-
-def set_color(stroke, fill, modstroke='medium', modfill='medium'):
- """Set the system color by setting a fill and stroke color.
- fill : [red, orange, yellow, blue, purple]
- stroke : [red, orange, yellow, blue, purple]
- hue stroke : [dark, medium, light] (optional)
- hue fill : [dark, medium, light] (optional)
- """
-
- if modstroke not in _MODIFIERS or modfill not in _MODIFIERS:
- print (_("Error in specified color modifiers."))
- return
- if stroke not in _COLORS or fill not in _COLORS:
- print (_("Error in specified colors."))
- return
-
- if modstroke == modfill:
- if modfill == 'medium':
- modfill = 'light'
- else:
- modfill = 'medium'
-
- color = _COLORS[stroke][modstroke] + ',' + _COLORS[fill][modfill]
- pro = profile.get_profile()
- pro.color = XoColor(color)
- pro.save()
- _note_restart()
-
-def get_nick():
- return profile.get_nick_name()
-
-def print_nick():
- print get_nick()
-
-def set_nick(nick):
- """Set the nickname.
- nick : e.g. 'walter'
- """
- pro = profile.get_profile()
- pro.nick_name = nick
- pro.save()
- _note_restart()
-
-def get_radio():
- bus = dbus.SystemBus()
- proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
- nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
- state = nm.getWirelessEnabled()
- if state == 0:
- return _('off')
- elif state == 1:
- return _('on')
- else:
- return _('State is unknown.')
-
-def print_radio():
- print get_radio()
-
-def set_radio(state):
- """Turn Radio 'on' or 'off'
- state : 'on/off'
- """
- if state == 'on':
- bus = dbus.SystemBus()
- proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
- nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
- nm.setWirelessEnabled(True)
- elif state == 'off':
- bus = dbus.SystemBus()
- proxy = bus.get_object(NM_SERVICE_NAME, NM_SERVICE_PATH)
- nm = dbus.Interface(proxy, NM_SERVICE_IFACE)
- nm.setWirelessEnabled(False)
- else:
- print (_("Error in specified radio argument use on/off."))
-
-def _check_for_superuser():
- if os.getuid():
- print _("Permission denied. You need to be root to run this method.")
- return False
- return True
-
-def get_timezone():
- if not os.access(_TIMEZONE_CONFIG, os.R_OK):
- # this is what the default is for the /etc/localtime
- return "America/New_York"
- fd = open(_TIMEZONE_CONFIG, "r")
- lines = fd.readlines()
- fd.close()
- try:
- for line in lines:
- line = line.strip()
- if len (line) and line[0] == '#':
- continue
- try:
- tokens = line.split("=")
- if tokens[0] == "ZONE":
- timezone = tokens[1].replace('"', '')
- return timezone
- except Exception, e:
- print "get_timezone: %s" % e
- except Exception, e:
- print "get_timezone: %s" % e
- return None
-
-def print_timezone():
- timezone = get_timezone()
- if timezone is None:
- print (_("Error in reading timezone"))
- else:
- print timezone
-
-def _read_zonetab(fn='/usr/share/zoneinfo/zone.tab'):
- fd = open (fn, 'r')
- lines = fd.readlines()
- fd.close()
- timezones = []
- for line in lines:
- if line.startswith('#'):
- continue
- line = line.split()
- if len(line) > 1:
- timezones.append(line[2])
- timezones.sort()
- return timezones
-
-def set_timezone(timezone):
- """Set the system timezone
- timezone :
- """
- if not _check_for_superuser():
- return
-
- timezones = _read_zonetab()
- if timezone in timezones:
- fromfile = os.path.join("/usr/share/zoneinfo/", timezone)
- try:
- shutil.copyfile(fromfile, "/etc/localtime")
- except OSError, detail:
- print (_("Error copying timezone (from %s): %s") %
- (fromfile, detail))
- return
- try:
- os.chmod("/etc/localtime", 0644)
- except OSError, detail:
- print (_("Changing permission of timezone: %s") % detail)
- return
-
- # Write info to the /etc/sysconfig/clock file
- fd = open(_TIMEZONE_CONFIG, "w")
- fd.write('# use sugar-control-panel to change this\n')
- fd.write('ZONE="%s"\n' % timezone)
- fd.write('UTC=true\n')
- fd.close()
- else:
- print (_("Error timezone does not exist."))
-
-def _write_i18n(lang):
- path = os.path.join(os.environ.get("HOME"), '.i18n')
- if os.access(path, os.W_OK) == 0:
- print(_("Could not access %s. Create standard settings.") % path)
- fd = open(path, 'w')
- fd.write('LANG="en_US.UTF-8"\n')
- fd.close()
- else:
- fd = open(path, 'r')
- lines = fd.readlines()
- fd.close()
- for i in range(len(lines)):
- if lines[i][:5] == "LANG=":
- lines[i] = 'LANG="' + lang + '"\n'
- fd = open(path, 'w')
- fd.writelines(lines)
- fd.close()
-
-def get_language():
- path = os.path.join(os.environ.get("HOME"), '.i18n')
- if os.access(path, os.R_OK) == 0:
- print(_("Could not access %s. Create standard settings.") % path)
- fd = open(path, 'w')
- default = 'en_US.UTF-8'
- fd.write('LANG="%s"\n' % default)
- fd.close()
- return default
-
- fd = open(path, "r")
- lines = fd.readlines()
- fd.close()
-
- lang = None
-
- for line in lines:
- if line[:5] == "LANG=":
- lang = line[5:].replace('"', '')
- lang = lang.strip()
-
- return lang
-
-def print_language():
- code = get_language()
-
- for lang in _LANGUAGES:
- if _LANGUAGES[lang] == code:
- print lang
- return
- print (_("Language for code=%s could not be determined.") % code)
-
-def set_language(language):
- """Set the system language.
- languages :
- """
- if language in _LANGUAGES:
- _write_i18n(_LANGUAGES[language])
- _note_restart()
- else:
- print (_("Sorry I do not speak \'%s\'.") % language)
-
-# inilialize the docstrings for the timezone and language
-_initialize()
-
diff --git a/src/main.py b/src/main.py
index 76d753f..d2da9cc 100644
--- a/src/main.py
+++ b/src/main.py
@@ -110,6 +110,10 @@ def main():
win.show_all()
gtk.main()
+ # set timezone
+ if os.environ.has_key('TZ'):
+ os.environ['TZ'] = get_profile().timezone
+
if os.environ.has_key("SUGAR_TP_DEBUG"):
# Allow the user time to start up telepathy connection managers
# using the Sugar DBus bus address
diff --git a/src/view/frame/eventarea.py b/src/view/frame/eventarea.py
index 99f8c76..0eba150 100644
--- a/src/view/frame/eventarea.py
+++ b/src/view/frame/eventarea.py
@@ -18,6 +18,10 @@ import gtk
import gobject
import wnck
+from sugar import profile
+
+_MAX_DELAY = 1000
+
class EventArea(gobject.GObject):
__gsignals__ = {
'enter': (gobject.SIGNAL_RUN_FIRST,
@@ -31,30 +35,56 @@ class EventArea(gobject.GObject):
self._windows = []
self._hover = False
+ self._sids = {}
+ pro = profile.get_profile()
+ self._hot_delay = int(pro.hot_corners_delay)
+ self._warm_delay = int(pro.warm_edges_delay)
right = gtk.gdk.screen_width() - 1
bottom = gtk.gdk.screen_height() -1
+ width = gtk.gdk.screen_width() - 2
+ height = gtk.gdk.screen_height() - 2
+
+ if self._warm_delay != _MAX_DELAY:
+ invisible = self._create_invisible(1, 0, width, 1, self._warm_delay)
+ self._windows.append(invisible)
+
+ invisible = self._create_invisible(1, bottom, width, 1,
+ self._warm_delay)
+ self._windows.append(invisible)
- invisible = self._create_invisible(0, 0, 1, 1)
- self._windows.append(invisible)
+ invisible = self._create_invisible(0, 1, 1, height,
+ self._warm_delay)
+ self._windows.append(invisible)
- invisible = self._create_invisible(right, 0, 1, 1)
- self._windows.append(invisible)
+ invisible = self._create_invisible(right, 1, 1, height,
+ self._warm_delay)
+ self._windows.append(invisible)
- invisible = self._create_invisible(0, bottom, 1, 1)
- self._windows.append(invisible)
+ if self._hot_delay != _MAX_DELAY:
+ invisible = self._create_invisible(0, 0, 1, 1, self._hot_delay)
+ self._windows.append(invisible)
- invisible = self._create_invisible(right, bottom, 1, 1)
- self._windows.append(invisible)
+ invisible = self._create_invisible(right, 0, 1, 1, self._hot_delay)
+ self._windows.append(invisible)
+
+ invisible = self._create_invisible(0, bottom, 1, 1, self._hot_delay)
+ self._windows.append(invisible)
+
+ invisible = self._create_invisible(right, bottom, 1, 1,
+ self._hot_delay)
+ self._windows.append(invisible)
screen = wnck.screen_get_default()
screen.connect('window-stacking-changed',
self._window_stacking_changed_cb)
- def _create_invisible(self, x, y, width, height):
+ def _create_invisible(self, x, y, width, height, delay):
invisible = gtk.Invisible()
- invisible.connect('enter-notify-event', self._enter_notify_cb)
- invisible.connect('leave-notify-event', self._leave_notify_cb)
+ if delay >= 0:
+ invisible.connect('enter-notify-event', self._enter_notify_cb,
+ delay)
+ invisible.connect('leave-notify-event', self._leave_notify_cb)
invisible.drag_dest_set(0, [], 0)
invisible.connect('drag_motion', self._drag_motion_cb)
@@ -78,10 +108,22 @@ class EventArea(gobject.GObject):
self._hover = False
self.emit('leave')
- def _enter_notify_cb(self, widget, event):
+ def _enter_notify_cb(self, widget, event, delay):
+ if widget in self._sids:
+ gobject.source_remove(self._sids[widget])
+ self._sids[widget] = gobject.timeout_add(delay,
+ self.__delay_cb,
+ widget)
+
+ def __delay_cb(self, widget):
+ del self._sids[widget]
self._notify_enter()
+ return False
def _leave_notify_cb(self, widget, event):
+ if widget in self._sids:
+ gobject.source_remove(self._sids[widget])
+ del self._sids[widget]
self._notify_leave()
def _drag_motion_cb(self, widget, drag_context, x, y, timestamp):
diff --git a/src/view/home/activitiesring.py b/src/view/home/activitiesring.py
index e299fab..beb1e81 100644
--- a/src/view/home/activitiesring.py
+++ b/src/view/home/activitiesring.py
@@ -43,6 +43,7 @@ from view.home.MyIcon import MyIcon
from model import shellmodel
from model.shellmodel import ShellModel
from hardware import schoolserver
+from controlpanel.gui import ControlPanel
_logger = logging.getLogger('ActivitiesRing')
@@ -306,14 +307,14 @@ class _MyIcon(MyIcon):
#secondary_text='Sample secondary label',
icon=palette_icon)
- item = MenuItem(_('About this XO'))
+ item = MenuItem(_('Control Panel'))
icon = Icon(icon_name='computer-xo', icon_size=gtk.ICON_SIZE_MENU,
xo_color=self._profile.color)
item.set_image(icon)
icon.show()
- item.connect('activate', self._about_activate_cb)
+ item.connect('activate', self.__controlpanel_activate_cb)
palette.menu.append(item)
item.show()
@@ -368,62 +369,13 @@ class _MyIcon(MyIcon):
if self._profile.is_registered():
self.get_palette().menu.remove(menuitem)
- def _about_activate_cb(self, menuitem):
- dialog = gtk.Dialog(_('About this XO'),
- self.palette,
- gtk.DIALOG_MODAL |
- gtk.DIALOG_DESTROY_WITH_PARENT,
- (gtk.STOCK_OK, gtk.RESPONSE_OK))
-
- not_available = _('Not available')
- build = self._read_file('/boot/olpc_build')
- if build is None:
- build = not_available
- label_build = gtk.Label('Build: %s' % build)
- label_build.set_alignment(0, 0.5)
- label_build.show()
- vbox = dialog.get_child()
- vbox.pack_start(label_build)
-
- firmware = self._read_file('/ofw/openprom/model')
- if firmware is None:
- firmware = not_available
- else:
- firmware = re.split(" +", firmware)
- if len(firmware) == 3:
- firmware = firmware[1]
- label_firmware = gtk.Label('Firmware: %s' % firmware)
- label_firmware.set_alignment(0, 0.5)
- label_firmware.show()
- vbox.pack_start(label_firmware)
-
- serial = self._read_file('/ofw/serial-number')
- if serial is None:
- serial = not_available
- label_serial = gtk.Label('Serial Number: %s' % serial)
- label_serial.set_alignment(0, 0.5)
- label_serial.show()
- vbox.pack_start(label_serial)
-
- dialog.set_default_response(gtk.RESPONSE_OK)
- dialog.connect('response', self._response_cb)
- dialog.show()
-
- def _read_file(self, path):
- if os.access(path, os.R_OK) == 0:
- _logger.error('read_file() No such file or directory: %s' % path)
- return None
-
- fd = open(path, 'r')
- value = fd.read()
- fd.close()
- if value:
- value = value.strip('\n')
- return value
- else:
- _logger.error('read_file() No information in file or directory: %s'
- % path)
- return None
+ def get_toplevel(self):
+ return hippo.get_canvas_for_item(self).get_toplevel()
+
+ def __controlpanel_activate_cb(self, menuitem):
+ panel = ControlPanel()
+ panel.set_transient_for(self.get_toplevel())
+ panel.show()
def _response_cb(self, widget, response_id):
if response_id == gtk.RESPONSE_OK: