From 79bc053795bb4c49865314eb76ba4727d4b0657d Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 9 Jan 2007 23:02:01 +0100 Subject: [PATCH 1/4] Bump version. --- tools/build-snapshot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/build-snapshot.sh b/tools/build-snapshot.sh index 6117205f..5370f9de 100755 --- a/tools/build-snapshot.sh +++ b/tools/build-snapshot.sh @@ -1,6 +1,6 @@ VERSION=0.63 DATE=`date +%Y%m%d` -RELEASE=2.4 +RELEASE=2.6 TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2 rm sugar-$VERSION.tar.bz2 From 84d34716134a71bfd53af2b16712068556c45881 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 10 Jan 2007 15:30:21 +0100 Subject: [PATCH 2/4] Fix to follow the new home api --- shell/view/BuddyMenu.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/view/BuddyMenu.py b/shell/view/BuddyMenu.py index a020a59b..82e58c24 100644 --- a/shell/view/BuddyMenu.py +++ b/shell/view/BuddyMenu.py @@ -88,9 +88,9 @@ class BuddyMenu(Menu): icon = CanvasIcon(icon_name='stock-add') self.add_action(icon, BuddyMenu.ACTION_MAKE_FRIEND) - activity_id = shell_model.get_current_activity() - if activity_id != None: - activity_ps = pservice.get_activity(activity_id) + activity = shell_model.get_home().get_current_activity() + if activity != None: + activity_ps = pservice.get_activity(activity.get_id()) # FIXME check that the buddy is not in the activity already From 6e599ead06e81cf2c9328940fcdbf0e018c10512 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Wed, 10 Jan 2007 17:12:23 +0100 Subject: [PATCH 3/4] Toggle console visibility --- services/console/console.py | 8 ++++++-- shell/view/Shell.py | 8 ++++---- tools/build-snapshot.sh | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/services/console/console.py b/services/console/console.py index 1b2a371a..2a19e9e1 100755 --- a/services/console/console.py +++ b/services/console/console.py @@ -80,8 +80,12 @@ class Service(dbus.service.Object): self._console = Console() @dbus.service.method(CONSOLE_IFACE) - def show(self): - self._console.window.present() + def toggle_visibility(self): + window = self._console.window + if not window.props.visible: + window.present() + else: + window.hide() bus = dbus.SessionBus() name = dbus.service.BusName(CONSOLE_BUS, bus) diff --git a/shell/view/Shell.py b/shell/view/Shell.py index 8a3136cb..f687a2bc 100644 --- a/shell/view/Shell.py +++ b/shell/view/Shell.py @@ -138,7 +138,7 @@ class Shell(gobject.GObject): elif key == 'F8': self._hw_manager.set_display_mode(HardwareManager.B_AND_W_MODE) elif key == 'equal' or key == '0': - gobject.idle_add(self._show_console_cb) + gobject.idle_add(self._toggle_console_visibility_cb) elif key == 'f': self._frame.notify_key_press() elif key == 'o': @@ -158,12 +158,12 @@ class Shell(gobject.GObject): box = self._home_window.get_home_box() box.grab_and_rotate() - def _show_console_cb(self): + def _toggle_console_visibility_cb(self): bus = dbus.SessionBus() proxy = bus.get_object('org.laptop.sugar.Console', '/org/laptop/sugar/Console') - mgr = dbus.Interface(proxy, 'org.laptop.sugar.Console') - mgr.show() + console = dbus.Interface(proxy, 'org.laptop.sugar.Console') + console.toggle_visibility() def _shutdown(self): bus = dbus.SystemBus() diff --git a/tools/build-snapshot.sh b/tools/build-snapshot.sh index 5370f9de..0f8dd815 100755 --- a/tools/build-snapshot.sh +++ b/tools/build-snapshot.sh @@ -1,6 +1,6 @@ VERSION=0.63 DATE=`date +%Y%m%d` -RELEASE=2.6 +RELEASE=2.7 TARBALL=sugar-$VERSION-$RELEASE.${DATE}git.tar.bz2 rm sugar-$VERSION.tar.bz2 From 7a185a51f4da396f9ca0c3c6eee20397521a4e21 Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Wed, 10 Jan 2007 18:19:05 -0300 Subject: [PATCH 4/4] [devconsole] XO interface updates: new build number and internal changes --- services/console/interface/xo/Makefile.am | 5 +- services/console/interface/xo/cpu.py | 185 ++++++++++++++++++++++ services/console/interface/xo/system.py | 53 +++++++ services/console/interface/xo/xo.py | 161 ++----------------- 4 files changed, 251 insertions(+), 153 deletions(-) create mode 100644 services/console/interface/xo/cpu.py create mode 100644 services/console/interface/xo/system.py diff --git a/services/console/interface/xo/Makefile.am b/services/console/interface/xo/Makefile.am index f4af6d34..d18a7d4e 100644 --- a/services/console/interface/xo/Makefile.am +++ b/services/console/interface/xo/Makefile.am @@ -2,5 +2,8 @@ sugardir = $(pkgdatadir)/services/console/interface/xo sugar_PYTHON = \ __init__.py \ drwarea.py \ - xo.py + xo.py \ + cpu.py \ + system.py + diff --git a/services/console/interface/xo/cpu.py b/services/console/interface/xo/cpu.py new file mode 100644 index 00000000..029223d0 --- /dev/null +++ b/services/console/interface/xo/cpu.py @@ -0,0 +1,185 @@ +#!/usr/bin/env python + +# Copyright (C) 2007, Eduardo Silva (edsiper@gmail.com). +# +# 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 os +import sys +import gtk +import string +import gobject +import drwarea + +class CPU_Usage: + + CPU_HZ = 0 + last_jiffies = 0 + times = 0 + + def __init__(self): + self.CPU_hz = os.sysconf(2) + + def _get_CPU_data(self): + # Uptime info + stat_file = "/proc/stat" + + try: + infile = file(stat_file, "r") + except: + print "Error trying uptime file" + return -1 + + stat_line = infile.readline() + cpu_info = string.split(stat_line, ' ') + infile.close() + + return cpu_info + + def _get_CPU_usage(self): + + cpu_info = self._get_CPU_data() + + used_jiffies = (int(cpu_info[2]) + int(cpu_info[3]) + int(cpu_info[4])) + + if self.times ==0: + self.last_jiffies = used_jiffies + self.times +=1 + return True + + new_ujiffies = (used_jiffies - self.last_jiffies) + new_ajiffies = ((self.frequency/1000) * self.CPU_hz) + + if new_ajiffies <= 0: + pcpu = 0.0 + else: + pcpu = ((new_ujiffies*100)/new_ajiffies) + + if pcpu >100: + pcpu = 100 + + self.times +=1 + self.last_jiffies = used_jiffies + + return pcpu + +class XO_CPU(gtk.Frame): + + context = None + frequency_timer = 1 + graph_offset = 7 + + def __init__(self): + gtk.Frame.__init__(self, 'System CPU Usage') + + self.drw_width = gtk.gdk.screen_width() * 90 / 100 + self.drw_height = gtk.gdk.screen_height() * 20 / 100 + + self.set_size_request(self.drw_width, self.drw_height + 60) + self.set_border_width(10) + + self.y_cpu = self.drw_height - self.graph_offset + self._cpu = 0 + self._cpu_buffer = [] + + self._drawingarea = gtk.DrawingArea() + self._drawingarea.set_size_request(self.drw_width, self.drw_height) + self._drawingarea.connect("expose-event", self.do_expose) + + self.dat = drwarea.Drawing_Area_Tools(self._drawingarea) + + fixed = gtk.Fixed(); + fixed.set_border_width(10) + fixed.add(self._drawingarea) + + self.add(fixed) + + DRW_CPU = CPU_Usage() + DRW_CPU.frequency = 1000 # 1 Second + + gobject.timeout_add(DRW_CPU.frequency, self._update_cpu_usage, DRW_CPU) + + + def _update_cpu_usage(self, DRW_CPU): + + if ((self.frequency_timer + 1)*self.graph_offset) >= (self.drw_width - self.graph_offset): + self.frequency_timer = 1 + self._cpu_buffer = [] + + self._cpu = DRW_CPU._get_CPU_usage() + self._cpu_buffer.append(self._cpu) + + self._updated = True + self._drawingarea.queue_draw() + self.frequency_timer += 1 + + return True + + def _get_y_cpu(self, pcpu): + + height = (self.dat.range_y['to']) - (self.dat.range_y['from']) + + # Get percent of cpu usage + y_value = (height - ((pcpu*height)/100) + 4) + + return int(y_value) + + def do_expose(self, widget, event): + context = widget.window.cairo_create() + + context.rectangle(0, 0, self.dat.width - 1, self.dat.height - 1) + #context.clip() + + context.set_source_rgb (0,0,0) + context.fill_preserve() + + # Drawing horizontal and vertical border lines + self.dat.draw_border_lines(context) + + # Drawing grid + line_margin = self.dat.margin + context.set_source_rgb(1, 1, 1) + context.set_line_width(1) + self.dat.draw_grid(context, line_margin + 1, line_margin + 1, self.dat.width - line_margin - 2, self.dat.height - line_margin - 2) + context.stroke() + + self._draw_buffer(widget, context) + + cpu_label = str(round(self._cpu, 4)) + self.set_label('System CPU Usage: ' + cpu_label + ' %') + + self._updated = False + return False + + def _draw_buffer(self, drwarea, context): + freq = 1 # Frequency timer + last_y = self.drw_height - self.graph_offset + + for pcpu in self._cpu_buffer: + + from_x = freq * self.graph_offset + from_y = last_y + + freq+=1 + + to_x = freq * self.graph_offset + last_y = to_y = self._get_y_cpu(pcpu) + + # Context properties + context.set_line_width(2) + context.set_source_rgb(0,1,0) + + self.dat.draw_line(context, from_x, from_y, to_x, to_y) + context.stroke() diff --git a/services/console/interface/xo/system.py b/services/console/interface/xo/system.py new file mode 100644 index 00000000..21e32953 --- /dev/null +++ b/services/console/interface/xo/system.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +# Copyright (C) 2007, Eduardo Silva (edsiper@gmail.com). +# +# 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 os +import gtk + +class XO_System(gtk.Fixed): + + def __init__(self): + gtk.Fixed.__init__(self) + self.set_border_width(10) + + build = self._get_system_build() + label_build = gtk.Label('OLPC Build: ' + str(build)) + + hbox = gtk.HBox(False, 0) + hbox.pack_start(label_build, False, False, 5) + + fixed_border = gtk.Fixed() + fixed_border.set_border_width(8) + fixed_border.add(hbox) + + frame = gtk.Frame('System Information') + frame.add(fixed_border) + + self.add(frame) + self.show_all() + + def _get_system_build(self): + build_file_path = '/boot/olpc_build' + + try: + f = open(build_file_path, 'r') + build = f.read() + f.close() + return build + except: + return "None" diff --git a/services/console/interface/xo/xo.py b/services/console/interface/xo/xo.py index fe8af726..7b02106e 100644 --- a/services/console/interface/xo/xo.py +++ b/services/console/interface/xo/xo.py @@ -24,162 +24,19 @@ import cairo import string import drwarea - -class CPU_Usage: - - CPU_HZ = 0 - last_jiffies = 0 - times = 0 - - def __init__(self): - self.CPU_hz = os.sysconf(2) - - def _get_CPU_data(self): - # Uptime info - stat_file = "/proc/stat" - - try: - infile = file(stat_file, "r") - except: - print "Error trying uptime file" - return -1 - - stat_line = infile.readline() - cpu_info = string.split(stat_line, ' ') - infile.close() - - return cpu_info - - def _get_CPU_usage(self): - - cpu_info = self._get_CPU_data() - - used_jiffies = (int(cpu_info[2]) + int(cpu_info[3]) + int(cpu_info[4])) - - if self.times ==0: - self.last_jiffies = used_jiffies - self.times +=1 - return True - - new_ujiffies = (used_jiffies - self.last_jiffies) - new_ajiffies = ((self.frequency/1000) * self.CPU_hz) - - if new_ajiffies <= 0: - pcpu = 0.0 - else: - pcpu = ((new_ujiffies*100)/new_ajiffies) - - if pcpu >100: - pcpu = 100 - - self.times +=1 - self.last_jiffies = used_jiffies - - return pcpu +from cpu import XO_CPU +from system import XO_System class Interface: - - context = None - frequency_timer = 1 - graph_offset = 7 - - def __init__(self): - - self.drw_width = gtk.gdk.screen_width() * 90 / 100 - self.drw_height = gtk.gdk.screen_height() * 20 / 100 - self.y_cpu = self.drw_height - self.graph_offset - self._cpu = 0 - self._cpu_buffer = [] - - self._drawingarea = gtk.DrawingArea() - self._drawingarea.set_size_request(self.drw_width, self.drw_height) - self._drawingarea.connect("expose-event", self.do_expose) - - self.dat = drwarea.Drawing_Area_Tools(self._drawingarea) - fixed = gtk.Fixed(); - fixed.set_border_width(10) - fixed.add(self._drawingarea) + def __init__(self): - self.frame = gtk.Frame('System CPU Usage: 0%') - self.frame.set_border_width(10) - self.frame.add(fixed) + self.widget = self.vbox = gtk.VBox(False, 3) - self.widget = self.hbox = gtk.HBox(False, 3) - self.hbox.pack_start(self.frame, True, True, 0) - self.hbox.show_all() - - DRW_CPU = CPU_Usage() - DRW_CPU.frequency = 1000 # 1 Second - - gobject.timeout_add(DRW_CPU.frequency, self._update_cpu_usage, DRW_CPU) - - def _update_cpu_usage(self, DRW_CPU): - - if ((self.frequency_timer + 1)*self.graph_offset) >= (self.drw_width - self.graph_offset): - self.frequency_timer = 1 - self._cpu_buffer = [] + xo_system = XO_System() + self.vbox.pack_start(xo_system, False, False, 0) - self._cpu = DRW_CPU._get_CPU_usage() - self._cpu_buffer.append(self._cpu) - - self._drawingarea.queue_draw() - self.frequency_timer += 1 + xo_cpu = XO_CPU() + self.vbox.pack_start(xo_cpu, False, False, 0) - return True - - def _get_y_cpu(self, pcpu): - - height = (self.dat.range_y['to']) - (self.dat.range_y['from']) - - # Get percent of cpu usage - y_value = (height - ((pcpu*height)/100) + 4) - - return int(y_value) - - def do_expose(self, widget, event): - context = widget.window.cairo_create() - - context.rectangle(0, 0, self.dat.width - 1, self.dat.height - 1) - #context.clip() - - context.set_source_rgb (0,0,0) - context.fill_preserve() - - # Drawing horizontal and vertical border lines - self.dat.draw_border_lines(context) - - # Drawing grid - line_margin = self.dat.margin - context.set_source_rgb(1, 1, 1) - context.set_line_width(1) - self.dat.draw_grid(context, line_margin + 1, line_margin + 1, self.dat.width - line_margin - 2, self.dat.height - line_margin - 2) - context.stroke() - - self._draw_buffer(widget, context) - - cpu_label = str(round(self._cpu, 4)) - self.frame.set_label('System CPU Usage: ' + cpu_label + ' %') - - return False - - def _draw_buffer(self, drwarea, context): - freq = 1 # Frequency timer - last_y = self.drw_height - self.graph_offset - - for pcpu in self._cpu_buffer: - - from_x = freq * self.graph_offset - from_y = last_y - - freq+=1 - - to_x = freq * self.graph_offset - last_y = to_y = self._get_y_cpu(pcpu) - - # Context properties - context.set_line_width(2) - context.set_source_rgb(0,1,0) - - self.dat.draw_line(context, from_x, from_y, to_x, to_y) - context.stroke() + self.vbox.show_all()