Add menu entry with dialog to show About this XO #4941
This commit is contained in:
parent
549348cfbd
commit
6e1065454d
1
NEWS
1
NEWS
@ -1,3 +1,4 @@
|
|||||||
|
* #4941: Add menu entry with dialog to show About this XO (erikos)
|
||||||
* #5089: show frame shortly when adding object to clipboard (erikos)
|
* #5089: show frame shortly when adding object to clipboard (erikos)
|
||||||
* #5097: Fix pasting text between activities through the clipboard. (tomeu)
|
* #5097: Fix pasting text between activities through the clipboard. (tomeu)
|
||||||
* #4660: Use improved PS API which streamlines ShareActivity process (smcv)
|
* #4660: Use improved PS API which streamlines ShareActivity process (smcv)
|
||||||
|
@ -15,9 +15,10 @@
|
|||||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import signal
|
import signal
|
||||||
import math
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
|
import re
|
||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import gtk
|
import gtk
|
||||||
@ -26,9 +27,7 @@ import dbus
|
|||||||
|
|
||||||
from hardware import hardwaremanager
|
from hardware import hardwaremanager
|
||||||
from sugar.graphics import style
|
from sugar.graphics import style
|
||||||
from sugar.graphics.xocolor import XoColor
|
from sugar.graphics.palette import Palette
|
||||||
from sugar.graphics.palette import Palette, CanvasInvoker
|
|
||||||
from sugar.graphics.icon import CanvasIcon
|
|
||||||
from sugar.profile import get_profile
|
from sugar.profile import get_profile
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
@ -38,6 +37,8 @@ from view.home.MyIcon import MyIcon
|
|||||||
from model.shellmodel import ShellModel
|
from model.shellmodel import ShellModel
|
||||||
from hardware import schoolserver
|
from hardware import schoolserver
|
||||||
|
|
||||||
|
_logger = logging.getLogger('HomeBox')
|
||||||
|
|
||||||
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
|
||||||
__gtype_name__ = 'SugarHomeBox'
|
__gtype_name__ = 'SugarHomeBox'
|
||||||
|
|
||||||
@ -171,6 +172,11 @@ class _MyIcon(MyIcon):
|
|||||||
palette.menu.append(item)
|
palette.menu.append(item)
|
||||||
item.show()
|
item.show()
|
||||||
|
|
||||||
|
item = gtk.MenuItem(_('About this XO'))
|
||||||
|
item.connect('activate', self._about_activate_cb)
|
||||||
|
palette.menu.append(item)
|
||||||
|
item.show()
|
||||||
|
|
||||||
self.set_palette(palette)
|
self.set_palette(palette)
|
||||||
|
|
||||||
def _reboot_activate_cb(self, menuitem):
|
def _reboot_activate_cb(self, menuitem):
|
||||||
@ -206,6 +212,65 @@ class _MyIcon(MyIcon):
|
|||||||
if self._profile.is_registered():
|
if self._profile.is_registered():
|
||||||
self.get_palette().menu.remove(menuitem)
|
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()
|
||||||
|
dialog.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()
|
||||||
|
dialog.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()
|
||||||
|
dialog.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 _response_cb(self, widget, response_id):
|
||||||
|
if response_id == gtk.RESPONSE_OK:
|
||||||
|
widget.destroy()
|
||||||
|
|
||||||
def _close_emulator(self):
|
def _close_emulator(self):
|
||||||
if os.environ.has_key('SUGAR_EMULATOR_PID'):
|
if os.environ.has_key('SUGAR_EMULATOR_PID'):
|
||||||
pid = int(os.environ['SUGAR_EMULATOR_PID'])
|
pid = int(os.environ['SUGAR_EMULATOR_PID'])
|
||||||
|
Loading…
Reference in New Issue
Block a user