[Goodies-commits] r3976 - xfce4-cpugraph-plugin/trunk/panel-plugin
ludovic mercier
lidiriel at xfce.org
Wed Feb 20 08:36:42 CET 2008
Author: lidiriel
Date: 2008-02-20 07:36:42 +0000 (Wed, 20 Feb 2008)
New Revision: 3976
Modified:
xfce4-cpugraph-plugin/trunk/panel-plugin/Makefile.am
xfce4-cpugraph-plugin/trunk/panel-plugin/cpu.c
xfce4-cpugraph-plugin/trunk/panel-plugin/mode.c
xfce4-cpugraph-plugin/trunk/panel-plugin/mode.h
Log:
correct led mode
cleanup function mode name
TODO : tooltips & grid mode
Modified: xfce4-cpugraph-plugin/trunk/panel-plugin/Makefile.am
===================================================================
--- xfce4-cpugraph-plugin/trunk/panel-plugin/Makefile.am 2008-02-19 19:40:23 UTC (rev 3975)
+++ xfce4-cpugraph-plugin/trunk/panel-plugin/Makefile.am 2008-02-20 07:36:42 UTC (rev 3976)
@@ -9,16 +9,12 @@
@LIBXFCE4PANEL_LIBS@
xfce4_cpugraph_plugin_SOURCES = \
- mode.c \
- mode.h \
- option.c \
- option.h \
- settings.c \
- settings.h \
- cpu.c \
- cpu.h \
- cpu_os.c \
- cpu_os.h
+ mode.c \
+ mode.h \
+ cpu.c \
+ cpu.h \
+ os.c \
+ os.h
# .desktop file
#
Modified: xfce4-cpugraph-plugin/trunk/panel-plugin/cpu.c
===================================================================
--- xfce4-cpugraph-plugin/trunk/panel-plugin/cpu.c 2008-02-19 19:40:23 UTC (rev 3975)
+++ xfce4-cpugraph-plugin/trunk/panel-plugin/cpu.c 2008-02-20 07:36:42 UTC (rev 3976)
@@ -363,6 +363,7 @@
UpdateTooltip (CPUGraph * base)
{
char tooltip[32];
+ fprintf(stderr, "update tooltip\n");
int pos = snprintf (tooltip, 32, "Usage: %d%%", base->m_CpuData[0].load*100/CPU_SCALE);
if( base->m_CpuData[0].scalCurFreq )
snprintf (tooltip+pos, 32-pos, " (%d MHz)", base->m_CpuData[0].scalCurFreq/1000);
@@ -392,10 +393,11 @@
{
gtk_widget_set_size_request (GTK_WIDGET (plugin),
size, base->m_Width);
- gtk_widget_set_size_request(
- GTK_WIDGET(base->m_pBar[i]),
- size,
- BORDER);
+ for(i=0; i<base->nrCores; i++)
+ gtk_widget_set_size_request(
+ GTK_WIDGET(base->m_pBar[i]),
+ size,
+ BORDER);
}
return TRUE;
@@ -795,7 +797,7 @@
gint i;
base->m_CpuData = cpuData_read();
for(i=0; i<base->nrCores; i++){
- fprintf(stderr,"bar load = %f\n",(gdouble)base->m_CpuData[i+1].load);
+ //fprintf(stderr,"bar load = %f\n",(gdouble)base->m_CpuData[i+1].load);
gtk_progress_bar_set_fraction(
GTK_PROGRESS_BAR(base->m_pBar[i]),
(gdouble)base->m_CpuData[i+1].load/CPU_SCALE);
@@ -823,7 +825,8 @@
, base->m_History
, (base->m_Values*2-1)*sizeof(int));
}
- base->m_History[0] = base->m_CpuData[0].load;
+ fprintf(stderr,"cpu data load %f\n",base->m_CpuData[0].load);
+ base->m_History[0] = (long)base->m_CpuData[0].load;
base->m_History[base->m_Values] = base->m_CpuData[0].scalCurFreq;
/* Tooltip */
@@ -853,20 +856,16 @@
if (base->m_Mode == 0)
{
- drawGraphMode0(base, fg1, da, w, h);
+ drawGraphModeNormal(base, fg1, da, w, h);
}
else if (base->m_Mode == 1)
{
- drawGraphMode1(base, fg1, fg2, da, w, h);
+ drawGraphModeLED(base, fg1, fg2, da, w, h);
}
else if (base->m_Mode == 2)
{
- drawGraphMode2(base, fg1, fg2, da, w, h);
+ drawGraphModeNoHistory(base, fg1, fg2, da, w, h);
}
- else if (base->m_Mode == 4)
- {
- drawGraphMode4(base, fg1, da, w, h);
- }
g_object_unref (fg2);
g_object_unref (fg1);
@@ -1029,7 +1028,7 @@
base->m_CpuData = cpuData_read();
base->m_CpuData[0].pUsed = 0;
base->m_CpuData[0].pTotal = 0;
- int usage = base->m_CpuData[0].load;
+ long usage = base->m_CpuData[0].load;
for (i = size - 1; i >= base->m_Values; i--)
{
base->m_History[i] = usage;
Modified: xfce4-cpugraph-plugin/trunk/panel-plugin/mode.c
===================================================================
--- xfce4-cpugraph-plugin/trunk/panel-plugin/mode.c 2008-02-19 19:40:23 UTC (rev 3975)
+++ xfce4-cpugraph-plugin/trunk/panel-plugin/mode.c 2008-02-20 07:36:42 UTC (rev 3976)
@@ -1,7 +1,30 @@
+/* mode.c
+ * Part of xfce4-cpugraph-plugin
+ *
+ * Copyright (c) Alexander Nordfelth <alex.nordfelth at telia.com>
+ * Copyright (c) gatopeich <gatoguan-os at yahoo.com>
+ * Copyright (c) 2007-2008 Angelo Arrifano <miknix at gmail.com>
+ * Copyright (c) 2007-2008 Lidiriel <lidiriel at coriolys.org>
+ *
+ * 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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
#include "mode.h"
-/*** MODE 0 ***/
-void drawGraphMode0 (CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h){
+/*** MODE 0 : Normal ***/
+void drawGraphModeNormal (CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h){
int x, y;
for (x = w; x >= 0; x--)
@@ -70,31 +93,33 @@
}
-/*** MODE 1 ***/
-void drawGraphMode1 (CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h){
- int nrx = (w + 1) / 3.0;
- int nry = (h + 1) / 2.0;
- float tstep = nry / CPU_SCALE;
+/*** MODE 1 : LED ***/
+void drawGraphModeLED (CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h){
+ int nrx = (int)((w + 1) / 3.0);
+ int nry = (int)((h + 1) / 2.0);
int x, y;
+ gdk_gc_set_rgb_fg_color (fg1, &base->m_ForeGround1);
+ gdk_gc_set_rgb_fg_color (fg2, &base->m_ForeGround2);
+
+
+ //fprintf(stderr,"nry %i %d\n", nry, CPU_SCALE);
+
for (x = nrx ; x >= 0; x--)
{
- float usage = base->m_History[nrx - x] * tstep;
int tmp = 0;
- int length = usage;
-
- gdk_gc_set_rgb_fg_color (fg2, &base->m_ForeGround2);
+ int idx = nrx-x;
+ int limit = (int)(nry - nry * base->m_History[idx]/CPU_SCALE);
+ //fprintf(stderr,"lim=%d %d %d %d\n",limit, idx, nry, base->m_History[idx]);
for (y = nry; y >= 0; y--)
{
- GdkGC *draw = fg2;
-
if (base->m_ColorMode > 0)
{
GdkColor color;
double t =
(base->m_ColorMode == 1) ?
- (tmp / (double) (nry)) :
- (tmp / (double) (length));
+ (tmp / nry) :
+ (tmp / limit);
color.red =
_lerp (t, base->m_ForeGround2.red,
base->m_ForeGround3.red);
@@ -104,20 +129,19 @@
color.blue =
_lerp (t, base->m_ForeGround2.blue,
base->m_ForeGround3.blue);
- gdk_gc_set_rgb_fg_color (fg1, &color);
+ gdk_gc_set_rgb_fg_color (fg2, &color);
tmp++;
- draw = fg1;
}
-
gdk_draw_rectangle (da->window,
- draw,
+ (y >= limit) ? fg1 : fg2,
TRUE, x * 3, y * 2, 2, 1);
+
}
}
}
-/*** MODE 2 ***/
-void drawGraphMode2(CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h){
+/*** MODE 2 : NoHistory ***/
+void drawGraphModeNoHistory(CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h){
int y;
long usage = h * base->m_History[0] / CPU_SCALE;
int tmp = 0;
@@ -148,12 +172,3 @@
0, y, w, y);
}
}
-
-/*** MODE 4 ***/
-void drawGraphMode4(CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h){
- gdk_draw_rectangle (da->window,
- fg1,
- TRUE,
- 0, (h - (base->m_History[0]*h/CPU_SCALE)),
- w, (base->m_History[0]*h/CPU_SCALE));
-}
Modified: xfce4-cpugraph-plugin/trunk/panel-plugin/mode.h
===================================================================
--- xfce4-cpugraph-plugin/trunk/panel-plugin/mode.h 2008-02-19 19:40:23 UTC (rev 3975)
+++ xfce4-cpugraph-plugin/trunk/panel-plugin/mode.h 2008-02-20 07:36:42 UTC (rev 3976)
@@ -3,9 +3,8 @@
#include "cpu.h"
-void drawGraphMode0(CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h);
-void drawGraphMode1(CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h);
-void drawGraphMode2(CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h);
-void drawGraphMode4(CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h);
+void drawGraphModeNormal(CPUGraph *base, GdkGC *fg1, GtkWidget *da, int w, int h);
+void drawGraphModeLED(CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h);
+void drawGraphModeNoHistory(CPUGraph *base, GdkGC *fg1, GdkGC *fg2, GtkWidget *da, int w, int h);
#endif
More information about the Goodies-commits
mailing list