From d1c5c5a5dd60f453f6b9cb0ed5bce07a19aeabcc Mon Sep 17 00:00:00 2001 From: Tuomo Tanskanen Date: Fri, 29 Jan 2010 17:03:09 +0200 Subject: [PATCH] temporary commit, might not even compile --- configure.ac | 2 +- debian/changelog | 6 ++-- debian/control | 8 +++-- src/cpumem_status_area_item.c | 71 ++++++++++++++++++++++++----------------- src/cpumem_status_area_item.h | 7 ++++ 5 files changed, 59 insertions(+), 35 deletions(-) diff --git a/configure.ac b/configure.ac index 747e851..dc9d520 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ AC_INIT(Makefile.am) -AM_INIT_AUTOMAKE(cpumem-applet, 0.1-4) +AM_INIT_AUTOMAKE(cpumem-applet, 0.5-1) AM_CONFIG_HEADER(config.h) AC_CANONICAL_HOST diff --git a/debian/changelog b/debian/changelog index ddf2ff0..0f2246a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,10 @@ -cpumem-applet (0.1-4) unstable; urgency=low +cpumem-applet (0.5-1) unstable; urgency=low * Add XB-Maemo-Display-Name user-friendly package name + * Fixed Bugtracker to point to bugs.maemo.org + * Bumped version to reflect maturity of the project (excuses...) - -- Tuomo Tanskanen Sun, 20 Dec 2009 23:38:05 +0200 + -- Tuomo Tanskanen Fri, 29 Jan 2010 14:03:56 +0200 cpumem-applet (0.0.3) unstable; urgency=low diff --git a/debian/control b/debian/control index de7f496..8cde543 100644 --- a/debian/control +++ b/debian/control @@ -9,8 +9,8 @@ Package: cpumem-applet Section: user/utilities Architecture: any Depends: ${shlibs:Depends}, libhildon1 (>=2.1.29), libosso1 (>=2.0), libhildondesktop1 (>=2.1.0) -XB-Maemo-Display-Name: CPU/Memory Applet -XSBC-Bugtracker: https://garage.maemo.org/tracker/?atid=4412&group_id=1175&func=browse +XB-Maemo-Display-Name: CPU/Memory Load Applet +XSBC-Bugtracker: https://bugs.maemo.org/buglist.cgi?product=cpumem-applet XB-Maemo-Icon-26: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c 6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0 @@ -90,6 +90,8 @@ XB-Maemo-Icon-26: RU5ErkJggg== === Description: Show CPU and memory usage in small status-area icon. - Stripped down version of Jakub Pavelek's load-applet. Displays CPU and memory utilisation in small status-area icon. + Left side bars in the icon are CPU usage, right side bars + are memory usage. + Stripped down version of Jakub Pavelek's load-applet. diff --git a/src/cpumem_status_area_item.c b/src/cpumem_status_area_item.c index 050f6e0..29f3c03 100644 --- a/src/cpumem_status_area_item.c +++ b/src/cpumem_status_area_item.c @@ -1,8 +1,10 @@ /* * Cpumem-applet - status area plugin + * + * Copyright (c) 2005-2009 Jakub Pavelek + * Copyright (c) 2009-2010 Tuomo Tanskanen */ - #include #include #include @@ -42,7 +44,7 @@ HD_DEFINE_PLUGIN_MODULE (CpumemAppletStatusAreaItem, cpumem_applet_status_area_i * Read current MEM usage and return indicator between 5 and 1 - how many bars are "full" */ static guchar -la_check_mem (CpumemAppletStatusAreaItemPrivate *priv) +check_mem (CpumemAppletStatusAreaItemPrivate *priv) { #define MEMFILE "/proc/meminfo" #define MAX_READ_CHARS 128 @@ -93,7 +95,7 @@ la_check_mem (CpumemAppletStatusAreaItemPrivate *priv) * Read current CPU usage and return indicator between 5 and 1 - how many bars are "full" */ static guchar -la_check_cpu (CpumemAppletStatusAreaItemPrivate *priv) +check_cpu (CpumemAppletStatusAreaItemPrivate *priv) { #define CPUFILE "/proc/stat" gint curU, curN, curIO, curI; @@ -151,7 +153,7 @@ la_check_cpu (CpumemAppletStatusAreaItemPrivate *priv) * Compose and blit the current status of memory bars */ static void -la_blit_memory_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv) +blit_mem_barsconst guchar level, CpumemAppletStatusAreaItemPrivate *priv) { guint x, y; @@ -160,18 +162,23 @@ la_blit_memory_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv x = 9; y = 1; if (level > 4) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); y = 5; if (level > 3) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); y = 9; if (level > 2) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); y = 13; if (level > 1) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); else - gdk_pixbuf_composite(priv->pixbuf_off, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_off, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); } @@ -179,7 +186,7 @@ la_blit_memory_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv * Compose and blit current status of CPU bars */ static void -la_blit_cpu_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv) +blit_cpu_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv) { guint x, y; @@ -188,24 +195,30 @@ la_blit_cpu_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv) if (level > 4) { if (priv->red == TRUE) { - gdk_pixbuf_composite(priv->pixbuf_red, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_red, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); priv->red = FALSE; } else { - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); priv->red = TRUE; } } y = 5; if (level > 3) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); y = 9; if (level > 2) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); y = 13; if (level > 1) - gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_on, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); else - gdk_pixbuf_composite(priv->pixbuf_off, priv->pixbuf, x, y, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + gdk_pixbuf_composite(priv->pixbuf_off, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT, x, y, 1, 1, GDK_INTERP_NEAREST, 255); } @@ -213,21 +226,21 @@ la_blit_cpu_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv) * Ran to check and update the CPU and memory reading */ static gboolean -la_check_load (gpointer data) +check_load (gpointer data) { guchar current_cpu_level; guchar current_mem_level; CpumemAppletStatusAreaItem *item = (CpumemAppletStatusAreaItem*)data; CpumemAppletStatusAreaItemPrivate *priv = (CpumemAppletStatusAreaItemPrivate*)item->priv; - current_cpu_level = la_check_cpu(priv); - current_mem_level = la_check_mem(priv); + current_cpu_level = check_cpu(priv); + current_mem_level = check_mem(priv); //g_debug(g_strdup_printf("LOADAPLET - UPDATED CPU %d MEM %d", current_cpu_level, current_mem_level)); //Update and blit only if data changed! if ((current_mem_level != priv->last_mem_level) || (current_cpu_level != priv->last_cpu_level)) { - la_blit_memory_bars (current_mem_level, priv); - la_blit_cpu_bars (current_cpu_level, priv); + blit_mem_bars (current_mem_level, priv); + blit_cpu_bars (current_cpu_level, priv); if (current_cpu_level == CPUMEM_CPU_MAX) priv->red = FALSE; hd_status_plugin_item_set_status_area_icon (HD_STATUS_PLUGIN_ITEM(data), priv->pixbuf); @@ -235,7 +248,7 @@ la_check_load (gpointer data) priv->last_cpu_level = current_cpu_level; } else if (current_cpu_level == CPUMEM_CPU_MAX) { //Pulsate max CPU load icon also when CPU load stays at max - la_blit_cpu_bars (current_cpu_level, priv); + blit_cpu_bars (current_cpu_level, priv); hd_status_plugin_item_set_status_area_icon (HD_STATUS_PLUGIN_ITEM(data), priv->pixbuf); } @@ -255,16 +268,16 @@ cpumem_applet_status_area_item_display_cb(osso_display_state_t state, gpointer u if (state == OSSO_DISPLAY_ON) { //Restart the updates, do one right away - if (item->priv->timeout_id == -1) + if (item->priv->timeout_id == 0) { - item->priv->timeout_id = gtk_timeout_add(1000, la_check_load, item); + item->priv->timeout_id = gtk_timeout_add(1000, check_load, item); + check_load(item); } } else { //Suspend the updates - screen is off - if (g_source_remove(item->priv->timeout_id) != TRUE) - { - } else { - item->priv->timeout_id = -1; + if (item->priv->timeout_id) != 0) { + g_source_remove(item->priv->timeout_id); + item->priv->timeout_id = 0; } } } @@ -339,7 +352,7 @@ cpumem_applet_status_area_item_init (CpumemAppletStatusAreaItem *item) cpumem_applet_status_area_item_set_area_icon(item); item->priv->osso = osso_initialize ("cpumem_applet_status_area_item", "Maemo5", TRUE, NULL); - item->priv->timeout_id = gtk_timeout_add(1000, la_check_load, item); + item->priv->timeout_id = gtk_timeout_add(1000, check_load, item); osso_hw_set_display_event_cb (item->priv->osso, cpumem_applet_status_area_item_display_cb, item); } diff --git a/src/cpumem_status_area_item.h b/src/cpumem_status_area_item.h index 7cf0131..4d73351 100644 --- a/src/cpumem_status_area_item.h +++ b/src/cpumem_status_area_item.h @@ -1,3 +1,10 @@ +/* + * Cpumem-applet - status area plugin header + * + * Copyright (c) 2005-2009 Jakub Pavelek + * Copyright (c) 2009-2010 Tuomo Tanskanen + */ + #ifndef __CPUMEM_APPLET_STATUS_AREA_ITEM_H__ #define __CPUMEM_APPLET_STATUS_AREA_ITEM_H__ -- 1.7.9.5