diff options
author | Anish Mangal <anish@sugarlabs.org> | 2011-01-26 02:22:12 (GMT) |
---|---|---|
committer | Anish Mangal <anish@sugarlabs.org> | 2011-01-26 02:22:12 (GMT) |
commit | 1cd4c31cd474bb84985fff97ac5f5b9e693469db (patch) | |
tree | b062f7afd65e71a6d3119501e60a7d820b7c0977 | |
parent | 7036b8dbde71a0c999fd401d73f45d118902033a (diff) |
Update cpu and memory resource indicator patch
-rw-r--r-- | rpms/sugar/cpu-and-memory-resource-indicator.patch | 133 |
1 files changed, 110 insertions, 23 deletions
diff --git a/rpms/sugar/cpu-and-memory-resource-indicator.patch b/rpms/sugar/cpu-and-memory-resource-indicator.patch index 69f8a03..8fa3229 100644 --- a/rpms/sugar/cpu-and-memory-resource-indicator.patch +++ b/rpms/sugar/cpu-and-memory-resource-indicator.patch @@ -1,7 +1,62 @@ -From f7d9d1b7e3166ea2558992bde9d3566a6b462868 Mon Sep 17 00:00:00 2001 + +Delivered-To: anishmangal2002@gmail.com +Received: by 10.216.177.81 with SMTP id c59cs4860wem; + Sat, 22 Jan 2011 04:38:33 -0800 (PST) +Received: by 10.151.85.21 with SMTP id n21mr2031131ybl.160.1295699909582; + Sat, 22 Jan 2011 04:38:29 -0800 (PST) +Return-Path: <sugar-devel-bounces@lists.sugarlabs.org> +Received: from sunjammer.sugarlabs.org (sunjammer.sugarlabs.org [140.186.70.53]) + by mx.google.com with ESMTP id h22si11794919vcr.186.2011.01.22.04.38.29; + Sat, 22 Jan 2011 04:38:29 -0800 (PST) +Received-SPF: pass (google.com: domain of sugar-devel-bounces@lists.sugarlabs.org designates 140.186.70.53 as permitted sender) client-ip=140.186.70.53; +Authentication-Results: mx.google.com; spf=pass (google.com: domain of sugar-devel-bounces@lists.sugarlabs.org designates 140.186.70.53 as permitted sender) smtp.mail=sugar-devel-bounces@lists.sugarlabs.org +Received: from sunjammer.sugarlabs.org (localhost [127.0.0.1]) + by sunjammer.sugarlabs.org (Postfix) with ESMTP id 5120C120745; + Sat, 22 Jan 2011 07:38:28 -0500 (EST) +Received: from smtp.chost.de (setoy.chost.de [217.160.209.225]) + by sunjammer.sugarlabs.org (Postfix) with ESMTPS id 01C6012073D + for <sugar-devel@lists.sugarlabs.org>; + Sat, 22 Jan 2011 07:38:24 -0500 (EST) +Received: (qmail 3931 invoked by uid 5015); 22 Jan 2011 12:38:27 -0000 +Received: (nullmailer pid 12250 invoked by uid 8193); + Sat, 22 Jan 2011 12:38:21 -0000 +Received: (nullmailer pid 3883 invoked by uid 8193); + Sat, 22 Jan 2011 12:38:23 -0000 +From: Sascha Silbe <sascha-pgp@silbe.org> +To: sugar-devel <sugar-devel@lists.sugarlabs.org> +Date: Sat, 22 Jan 2011 13:38:08 +0100 +Message-Id: <1295699888-3846-1-git-send-email-sascha-pgp@silbe.org> +X-Mailer: git-send-email 1.7.2.3 +In-Reply-To: <1295623111-3326-1-git-send-email-sascha-pgp@silbe.org> +References: <1295623111-3326-1-git-send-email-sascha-pgp@silbe.org> +Mail-Followup-To: <sugar-devel@lists.sugarlabs.org> +X-Spam-Status: No, score=0.0 required=3.5 tests=none autolearn=unavailable + version=3.3.1 +X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on + sunjammer.sugarlabs.org +X-Topics: Patches and patch reviews +Subject: [Sugar-devel] [PATCH sugar v2] Add cpu and memory resource + indicator to frame +X-BeenThere: sugar-devel@lists.sugarlabs.org +X-Mailman-Version: 2.1.13 +Precedence: list +Reply-To: Sascha Silbe <sascha-ml-reply-to-2011-1@silbe.org> +List-Id: "Discussion of Sugar development and other technical matters." + <sugar-devel.lists.sugarlabs.org> +List-Unsubscribe: <http://lists.sugarlabs.org/options/sugar-devel>, + <mailto:sugar-devel-request@lists.sugarlabs.org?subject=unsubscribe> +List-Archive: <http://lists.sugarlabs.org/archive/sugar-devel> +List-Post: <mailto:sugar-devel@lists.sugarlabs.org> +List-Help: <mailto:sugar-devel-request@lists.sugarlabs.org?subject=help> +List-Subscribe: <http://lists.sugarlabs.org/listinfo/sugar-devel>, + <mailto:sugar-devel-request@lists.sugarlabs.org?subject=subscribe> +MIME-Version: 1.0 +Content-Type: text/plain; charset="us-ascii" +Content-Transfer-Encoding: 7bit +Sender: sugar-devel-bounces@lists.sugarlabs.org +Errors-To: sugar-devel-bounces@lists.sugarlabs.org + From: anishmangal2002 <anishmangal2002@gmail.com> -Date: Fri, 2 Jul 2010 20:45:28 +0530 -Subject: [PATCH] Add cpu and memory resource indicator to frame This patch adds an icon to the frame, whose palette menu displays the memory and cpu resources. For computing @@ -14,14 +69,21 @@ Similarly, the palette menu entries are updated after every 5 seconds as well. Signed-off-by: anishmangal2002 <anishmangal2002@gmail.com> +[style fixes, increase weight of memory utilisation for "system mood" so +bursts of CPU activity don't take us from "happy" directly to "sad"; +pop up on left click since there is no primary action] +Signed-off-by: Sascha Silbe <sascha-pgp@silbe.org> +Reviewed-by: Sascha Silbe <sascha-pgp@silbe.org> --- +v1->v2: pop up palette on left click + extensions/deviceicon/Makefile.am | 1 + - extensions/deviceicon/resources.py | 206 ++++++++++++++++++++++++++++++++++++ - 2 files changed, 207 insertions(+), 0 deletions(-) - create mode 100644 extensions/deviceicon/resources.py + extensions/deviceicon/resources.py | 215 ++++++++++++++++++++++++++++++++++++ + po/POTFILES.in | 1 + + 3 files changed, 217 insertions(+), 0 deletions(-) diff --git a/extensions/deviceicon/Makefile.am b/extensions/deviceicon/Makefile.am -index 8a2e765..eff368d 100644 +index 118d866..0d15c38 100644 --- a/extensions/deviceicon/Makefile.am +++ b/extensions/deviceicon/Makefile.am @@ -4,6 +4,7 @@ sugar_PYTHON = \ @@ -30,14 +92,14 @@ index 8a2e765..eff368d 100644 network.py \ + resources.py \ speaker.py \ - touchpad.py \ + touchpad.py \ volume.py diff --git a/extensions/deviceicon/resources.py b/extensions/deviceicon/resources.py new file mode 100644 -index 0000000..331459d +index 0000000..65e00dc --- /dev/null +++ b/extensions/deviceicon/resources.py -@@ -0,0 +1,206 @@ +@@ -0,0 +1,215 @@ +# Copyright (C) Anish Mangal <anishmangal2002@gmail.com> +# +# This program is free software; you can redistribute it and/or modify @@ -67,8 +129,11 @@ index 0000000..331459d +from sugar.graphics.palette import Palette +from sugar.graphics import style + ++ +_SYSTEM_MOODS = ['-sad', '-normal', '-happy'] +_ICON_NAME = 'computer' ++_UPDATE_INTERVAL = 5*1000 ++ + +class DeviceView(TrayIcon): + @@ -79,9 +144,9 @@ index 0000000..331459d + self._color = XoColor(client.get_string('/desktop/sugar/user/color')) + TrayIcon.__init__(self, icon_name=_ICON_NAME, xo_color=self._color) + self.create_palette() ++ self._icon_widget.connect('button-release-event', self._click_cb) + + def create_palette(self): -+ logging.debug('palette created') + self.palette = ResourcePalette(_('System resources')) + self.palette.set_group_id('frame') + self.palette.add_timer() @@ -89,14 +154,18 @@ index 0000000..331459d + self._system_mood_changed_cb) + return self.palette + -+ def _system_mood_changed_cb(self, gobject, mood): ++ def _system_mood_changed_cb(self, palette_, mood): + self.icon.props.icon_name = _ICON_NAME + mood + ++ def _click_cb(self, widget, event): ++ self.palette_invoker.notify_right_click() ++ ++ +class ResourcePalette(Palette): + __gsignals__ = { + 'system-mood-changed': (gobject.SIGNAL_RUN_FIRST, + gobject.TYPE_NONE, -+ ([str])) ++ ([str])), + } + + def __init__(self, primary_text): @@ -119,6 +188,7 @@ index 0000000..331459d + style.zoom(style.GRID_CELL_SIZE * 4), -1) + self.vbox.pack_start(self._memory_bar, padding=style.DEFAULT_PADDING) + ++ self._system_mood = None + try: + self._cpu_times = self._get_cpu_times_list() + except IOError: @@ -133,7 +203,7 @@ index 0000000..331459d + self._memory_bar.show() + + def add_timer(self): -+ self._timer = gobject.timeout_add(5000, self.__timer_cb) ++ gobject.timeout_add(_UPDATE_INTERVAL, self.__timer_cb) + + def _get_cpu_times_list(self): + """Return various cpu times as read from /proc/stat @@ -165,7 +235,7 @@ index 0000000..331459d + _cpu_times_new = self._get_cpu_times_list() + _cpu_times_current = [(new - old) + for new, old in zip(_cpu_times_new, self._cpu_times)] -+ user, nice, system, idle, iowait = _cpu_times_current ++ user_, nice_, system_, idle, iowait = _cpu_times_current + cpu_free = (idle + iowait) * 100.0 / sum(_cpu_times_current) + self._cpu_times = self._get_cpu_times_list() + return cpu_free @@ -176,7 +246,7 @@ index 0000000..331459d + + """ + for line in file('/proc/meminfo'): -+ name, value, unit = line.split()[:3] ++ name, value, unit_ = line.split()[:3] + if 'MemTotal:' == name: + total = int(value) + elif 'MemFree:' == name: @@ -196,18 +266,18 @@ index 0000000..331459d + except IOError: + logging.exception('An error ocurred while trying to ' + 'retrieve resource usage statistics') -+ self._stop_computing_statistics() ++ self._stop_and_show_error() + return False + else: + self._cpu_text.set_label(_('CPU in use: %d%%' % cpu_in_use)) -+ self._cpu_bar.set_fraction( cpu_in_use / 100.0 ) ++ self._cpu_bar.set_fraction(float(cpu_in_use) / 100) + self._memory_text.set_label(_('Memory in use: %d%%' % + memory_in_use)) -+ self._memory_bar.set_fraction( memory_in_use / 100.0 ) ++ self._memory_bar.set_fraction(float(memory_in_use) / 100) + + # both cpu_free and memory_free lie between 0-100 + system_mood = _SYSTEM_MOODS[ -+ int( ( 200 - (cpu_in_use + memory_in_use) ) / 66.66 ) ] ++ int(300 - (cpu_in_use + 2 * memory_in_use)) // 100] + + # check if self._system_mood exists + try: @@ -220,9 +290,9 @@ index 0000000..331459d + + return True + -+ def _stop_computing_statistics(self): ++ def _stop_and_show_error(self): + """ -+ Stop computing usage statistics and display and error message ++ Stop computing usage statistics and display an error message + since we've hit an exception. + + """ @@ -238,12 +308,29 @@ index 0000000..331459d + self.vbox.remove(self._memory_bar) + self.emit('system-mood-changed', '-error') + ++ +def setup(tray): + if not (os.path.exists('/proc/stat') and os.path.exists('/proc/meminfo')): + logging.warning('Either /proc/stat or /proc/meminfo not present. Not ' + 'adding the CPU and memory usage icon to the frame') + return + tray.add_device(DeviceView()) +diff --git a/po/POTFILES.in b/po/POTFILES.in +index 9e46831..b799339 100644 +--- a/po/POTFILES.in ++++ b/po/POTFILES.in +@@ -27,6 +27,7 @@ extensions/cpsection/updater/__init__.py + extensions/cpsection/updater/view.py + extensions/deviceicon/battery.py + extensions/deviceicon/network.py ++extensions/deviceicon/resources.py + extensions/deviceicon/speaker.py + extensions/deviceicon/touchpad.py + extensions/deviceicon/volume.py -- -1.7.1 +1.7.2.3 +_______________________________________________ +Sugar-devel mailing list +Sugar-devel@lists.sugarlabs.org +http://lists.sugarlabs.org/listinfo/sugar-devel |