[Xfce4-commits] <xfce4-cpugraph-plugin:master> Clean up the code
Florian
noreply at xfce.org
Sat Apr 17 16:16:44 CEST 2010
Updating branch refs/heads/master
to d6609fd7f3106caedeaeca06adf5d16548db1817 (commit)
from ee6f87b76b9bd8e296061ad1b2b02e3343cbdfbf (commit)
commit d6609fd7f3106caedeaeca06adf5d16548db1817
Author: Florian <frivoal at gmail.com>
Date: Mon Mar 15 23:09:33 2010 +0900
Clean up the code
Clean up, mostly focused on naming and using the g* functions or type
where it makes sense.
panel-plugin/cpu.c | 26 +++++++++---------
panel-plugin/cpu.h | 21 +++++++-------
panel-plugin/mode.c | 62 +++++++++++++++++++++--------------------
panel-plugin/mode.h | 8 +++---
panel-plugin/os.c | 66 +++++++++++++++++++++------------------------
panel-plugin/os.h | 12 +++++---
panel-plugin/properties.c | 36 ++++++++++++------------
panel-plugin/settings.c | 8 +++---
8 files changed, 119 insertions(+), 120 deletions(-)
diff --git a/panel-plugin/cpu.c b/panel-plugin/cpu.c
index ae24228..22ddc37 100644
--- a/panel-plugin/cpu.c
+++ b/panel-plugin/cpu.c
@@ -9,7 +9,7 @@ static void create_bars( CPUGraph *base );
static guint init_cpu_data( CpuData **data );
static void shutdown( XfcePanelPlugin *plugin, CPUGraph *base );
static void delete_bars( CPUGraph *base );
-static gboolean size_cb( XfcePanelPlugin *plugin, int size, CPUGraph *base );
+static gboolean size_cb( XfcePanelPlugin *plugin, guint size, CPUGraph *base );
static void set_bars_size( CPUGraph *base, gint size, GtkOrientation orientation );
static void orientation_cb( XfcePanelPlugin *plugin, GtkOrientation orientation, CPUGraph *base );
static void set_bars_orientation( CPUGraph *base, GtkOrientation orientation);
@@ -126,7 +126,7 @@ static void delete_bars( CPUGraph *base )
}
}
-static gboolean size_cb( XfcePanelPlugin *plugin, int size, CPUGraph *base )
+static gboolean size_cb( XfcePanelPlugin *plugin, guint size, CPUGraph *base )
{
gint frame_h, frame_v, history;
GtkOrientation orientation;
@@ -148,9 +148,9 @@ static gboolean size_cb( XfcePanelPlugin *plugin, int size, CPUGraph *base )
gtk_widget_set_size_request( GTK_WIDGET( base->frame_widget ), frame_h, frame_v );
- base->history = (int *) g_realloc( base->history, history * sizeof( int ) );
+ base->history = (guint *) g_realloc( base->history, history * sizeof( guint ) );
if( history > base->history_size )
- memset( base->history + base->history_size, 0, (history - base->history_size) * sizeof( int ) );
+ memset( base->history + base->history_size, 0, (history - base->history_size) * sizeof( guint ) );
base->history_size = history;
if( base->has_bars )
@@ -232,7 +232,7 @@ static gboolean update_cb( CPUGraph * base )
base->history[i--] = (a * (factor-1) + b) / factor;
}
} else {
- memmove( base->history + 1 , base->history , (base->history_size - 1) * sizeof( int ) );
+ memmove( base->history + 1 , base->history , (base->history_size - 1) * sizeof( guint ) );
}
base->history[0] = base->cpu_data[0].load;
@@ -245,7 +245,7 @@ static gboolean update_cb( CPUGraph * base )
static void update_tooltip( CPUGraph * base )
{
gchar tooltip[32];
- int pos = g_snprintf( tooltip, 32, "Usage: %d%%", (int)base->cpu_data[0].load*100/CPU_SCALE );
+ g_snprintf( tooltip, 32, "Usage: %u%%", (guint)base->cpu_data[0].load*100/CPU_SCALE );
gtk_widget_set_tooltip_text( base->frame_widget, tooltip );
}
@@ -257,7 +257,7 @@ static void draw_area_cb( GtkWidget * da, GdkEventExpose * event, gpointer data
static void draw_graph( CPUGraph * base )
{
GtkWidget *da = base->draw_area;
- int w, h;
+ gint w, h;
w = da->allocation.width;
h = da->allocation.height;
@@ -339,9 +339,9 @@ void set_nonlinear_time( CPUGraph *base, gboolean nonlinear )
base->non_linear = nonlinear;
}
-void set_update_rate( CPUGraph *base, int rate )
+void set_update_rate( CPUGraph *base, guint rate )
{
- int update;
+ guint update;
base->update_interval = rate;
@@ -364,23 +364,23 @@ void set_update_rate( CPUGraph *base, int rate )
base->timeout_id = g_timeout_add( update, (GtkFunction) update_cb, base );
}
-void set_size( CPUGraph *base, int size )
+void set_size( CPUGraph *base, guint size )
{
base->size = size;
size_cb( base->plugin, xfce_panel_plugin_get_size( base->plugin ), base );
}
-void set_color_mode( CPUGraph *base, int color_mode )
+void set_color_mode( CPUGraph *base, guint color_mode )
{
base->color_mode = color_mode;
}
-void set_mode( CPUGraph *base, int mode )
+void set_mode( CPUGraph *base, guint mode )
{
base->mode = mode;
}
-void set_color( CPUGraph *base, int number, GdkColor color )
+void set_color( CPUGraph *base, guint number, GdkColor color )
{
base->colors[number] = color;
if( number == 0 )
diff --git a/panel-plugin/cpu.h b/panel-plugin/cpu.h
index 2d5c570..b6b1a37 100644
--- a/panel-plugin/cpu.h
+++ b/panel-plugin/cpu.h
@@ -31,11 +31,11 @@ typedef struct
GtkWidget *color_buttons[4];
/* Settings */
- int update_interval; /* Number of ms between updates. */
+ guint update_interval; /* Number of ms between updates. */
gboolean non_linear;
- int size;
- int mode;
- int color_mode;
+ guint size;
+ guint mode;
+ guint color_mode;
gboolean has_frame;
gboolean has_border;
gboolean has_bars;
@@ -47,9 +47,8 @@ typedef struct
/* Runtime data */
guint nr_cores;
guint timeout_id;
- int *history;
+ guint *history;
gssize history_size;
- int orientation;
CpuData *cpu_data;
} CPUGraph;
@@ -60,9 +59,9 @@ void set_bars( CPUGraph * base, gboolean bars);
void set_border( CPUGraph *base, gboolean border);
void set_frame( CPUGraph *base, gboolean frame );
void set_nonlinear_time( CPUGraph *base, gboolean nonlinear );
-void set_update_rate( CPUGraph *base, int rate );
-void set_size( CPUGraph *base, int width );
-void set_color_mode( CPUGraph *base, int color_mode );
-void set_mode( CPUGraph *base, int mode );
-void set_color( CPUGraph *base, int number, GdkColor color );
+void set_update_rate( CPUGraph *base, guint rate );
+void set_size( CPUGraph *base, guint width );
+void set_color_mode( CPUGraph *base, guint color_mode );
+void set_mode( CPUGraph *base, guint mode );
+void set_color( CPUGraph *base, guint number, GdkColor color );
#endif /* !_XFCE_CPU_H_ */
diff --git a/panel-plugin/mode.c b/panel-plugin/mode.c
index 4d83634..e396a99 100644
--- a/panel-plugin/mode.c
+++ b/panel-plugin/mode.c
@@ -23,12 +23,12 @@
#include "mode.h"
-static guint16 _lerp( double t, guint16 a, guint16 b )
+static guint16 _lerp( gdouble t, guint16 a, guint16 b )
{
return (guint16) (a + t * (b - a));
}
-static void mix_colors( double ratio, GdkColor *color1, GdkColor *color2, GdkGC *target )
+static void mix_colors( gdouble ratio, GdkColor *color1, GdkColor *color2, GdkGC *target )
{
GdkColor color;
color.red = _lerp (ratio, color1->red, color2->red);
@@ -37,12 +37,12 @@ static void mix_colors( double ratio, GdkColor *color1, GdkColor *color2, GdkGC
gdk_gc_set_rgb_fg_color( target, &color );
}
-void draw_graph_normal( CPUGraph *base, GtkWidget *da, int w, int h )
+void draw_graph_normal( CPUGraph *base, GtkWidget *da, gint w, gint h )
{
- int x, y;
- int usage;
- double t;
- int tmp;
+ gint x, y;
+ gint usage;
+ gdouble t;
+ gint tmp;
GdkGC *fg1 = gdk_gc_new( da->window );
if( base->color_mode == 0 )
@@ -64,8 +64,8 @@ void draw_graph_normal( CPUGraph *base, GtkWidget *da, int w, int h )
for( y = h-1; y >= h - usage; y--, tmp++ )
{
t = (base->color_mode == 1) ?
- (tmp / (double) (h)) :
- (tmp / (double) (usage));
+ (tmp / (gdouble) (h)) :
+ (tmp / (gdouble) (usage));
mix_colors( t, &base->colors[1], &base->colors[2], fg1);
gdk_draw_point( da->window, fg1, x, y );
}
@@ -74,11 +74,13 @@ void draw_graph_normal( CPUGraph *base, GtkWidget *da, int w, int h )
g_object_unref( fg1 );
}
-void draw_graph_LED( CPUGraph *base, GtkWidget *da, int w, int h )
+void draw_graph_LED( CPUGraph *base, GtkWidget *da, gint w, gint h )
{
- int nrx = (w + 1) / 3;
- int nry = (h + 1) / 2;
- int x, y;
+ gint nrx = (w + 1) / 3;
+ gint nry = (h + 1) / 2;
+ gint x, y;
+ gint idx;
+ gint limit;
GdkGC *fg1 = gdk_gc_new( da->window );
GdkGC *fg2 = gdk_gc_new( da->window );
@@ -87,15 +89,15 @@ void draw_graph_LED( CPUGraph *base, GtkWidget *da, int w, int h )
for( x = 0; x * 3 < w; x++ )
{
- int idx = nrx-x;
- int limit = nry - nry * base->history[idx]/CPU_SCALE;
+ idx = nrx-x;
+ limit = nry - nry * base->history[idx]/CPU_SCALE;
for( y = 0; y * 2 < h; y++ )
{
if( base->color_mode != 0 && y < limit )
{
- double t = (base->color_mode == 1) ?
- (y / (double)nry) :
- (y / (double)limit);
+ gdouble t = (base->color_mode == 1) ?
+ (y / (gdouble)nry) :
+ (y / (gdouble)limit);
mix_colors( t, &base->colors[3], &base->colors[2], fg2);
}
gdk_draw_rectangle (da->window, y >= limit ? fg1 : fg2, TRUE, x * 3, y * 2, 2, 1);
@@ -105,12 +107,12 @@ void draw_graph_LED( CPUGraph *base, GtkWidget *da, int w, int h )
g_object_unref( fg2 );
}
-void draw_graph_no_history( CPUGraph *base, GtkWidget *da, int w, int h )
+void draw_graph_no_history( CPUGraph *base, GtkWidget *da, gint w, gint h )
{
- int y;
- int usage = h * base->history[0] / CPU_SCALE;
- int tmp = 0;
- double t;
+ gint y;
+ gint usage = h * base->history[0] / CPU_SCALE;
+ gint tmp = 0;
+ gdouble t;
GdkGC *fg1 = gdk_gc_new( da->window );
if( base->color_mode == 0 )
@@ -123,8 +125,8 @@ void draw_graph_no_history( CPUGraph *base, GtkWidget *da, int w, int h )
for( y = h-1; y > h - 1 - usage; y-- )
{
t = (base->color_mode == 1) ?
- (tmp / (double) (h)) :
- (tmp / (double) (usage));
+ (tmp / (gdouble) (h)) :
+ (tmp / (gdouble) (usage));
mix_colors( t, &base->colors[1], &base->colors[2], fg1 );
tmp++;
gdk_draw_line( da->window, fg1, 0, y, w-1, y );
@@ -135,14 +137,14 @@ void draw_graph_no_history( CPUGraph *base, GtkWidget *da, int w, int h )
typedef struct
{
- int x;
- int y;
+ gint x;
+ gint y;
} point;
-void draw_graph_grid( CPUGraph *base, GtkWidget *da, int w, int h )
+void draw_graph_grid( CPUGraph *base, GtkWidget *da, gint w, gint h )
{
- int x, y;
- int usage;
+ gint x, y;
+ gint usage;
point last, current;
last.x = 0;
last.y = h;
diff --git a/panel-plugin/mode.h b/panel-plugin/mode.h
index 3108097..383e20b 100644
--- a/panel-plugin/mode.h
+++ b/panel-plugin/mode.h
@@ -3,9 +3,9 @@
#include "cpu.h"
-void draw_graph_normal( CPUGraph *base, GtkWidget *da, int w, int h );
-void draw_graph_LED( CPUGraph *base, GtkWidget *da, int w, int h );
-void draw_graph_no_history( CPUGraph *base, GtkWidget *da, int w, int h );
-void draw_graph_grid( CPUGraph *base, GtkWidget *da, int w, int h );
+void draw_graph_normal( CPUGraph *base, GtkWidget *da, gint w, gint h );
+void draw_graph_LED( CPUGraph *base, GtkWidget *da, gint w, gint h );
+void draw_graph_no_history( CPUGraph *base, GtkWidget *da, gint w, gint h );
+void draw_graph_grid( CPUGraph *base, GtkWidget *da, gint w, gint h );
#endif /* !_XFCE_MODE_H_ */
diff --git a/panel-plugin/os.c b/panel-plugin/os.c
index 65b7988..e7d89ca 100644
--- a/panel-plugin/os.c
+++ b/panel-plugin/os.c
@@ -6,7 +6,6 @@
#include <stdio.h>
#include <string.h>
-#include <glib.h>
#if defined (__linux__)
#define PROC_STAT "/proc/stat"
@@ -45,11 +44,11 @@
#endif
#if defined (__linux__)
-unsigned int detect_cpu_number()
+guint detect_cpu_number()
{
- int nb_lines= 0;
+ guint nb_lines= 0;
FILE *fstat = NULL;
- char cpuStr[PROCMAXLNLEN];
+ gchar cpuStr[PROCMAXLNLEN];
if( !(fstat = fopen( PROC_STAT, "r" )) )
return 0;
@@ -67,12 +66,12 @@ unsigned int detect_cpu_number()
return nb_lines > 1 ? nb_lines - 1 : 0;
}
-int read_cpu_data( CpuData *data, unsigned int nb_cpu)
+gboolean read_cpu_data( CpuData *data, guint nb_cpu)
{
FILE *fStat;
- char cpuStr[PROCMAXLNLEN];
- unsigned int user, nice, system, idle, used, total, iowait, irq, softirq;
- unsigned int line;
+ gchar cpuStr[PROCMAXLNLEN];
+ guint user, nice, system, idle, used, total, iowait, irq, softirq;
+ guint line;
if( !(fStat = fopen( PROC_STAT, "r" )) )
return FALSE;
@@ -109,23 +108,22 @@ int read_cpu_data( CpuData *data, unsigned int nb_cpu)
}
#elif defined (__FreeBSD__)
-unsigned int detect_cpu_number()
+guint detect_cpu_number()
{
return 1;
}
-int read_cpu_data( CpuData *data, unsigned int nb_cpu)
+gboolean read_cpu_data( CpuData *data, guint nb_cpu)
{
- unsigned int user, nice, sys, bsdidle, idle;
- unsigned int used, total;
- int cp_time[CPUSTATES];
- size_t len = sizeof( cp_time );
+ guint user, nice, sys, bsdidle, idle;
+ guint used, total;
+ gint cp_time[CPUSTATES];
+ gsize len = sizeof( cp_time );
- int usage;
+ guint usage;
if( sysctlbyname( "kern.cp_time", &cp_time, &len, NULL, 0 ) < 0 )
{
- printf( "Cannot get kern.cp_time.\n" );
return FALSE1;
}
@@ -138,7 +136,7 @@ int read_cpu_data( CpuData *data, unsigned int nb_cpu)
used = user+nice+sys;
total = used+bsdidle;
if( (total - data[0].previous_total) != 0 )
- data[0].load = (CPU_SCALE.0 * (used - data[0].previous_total))/(total - data[0].previous_total);
+ data[0].load = (CPU_SCALE * (used - data[0].previous_total))/(total - data[0].previous_total);
else
data[0].load = 0;
@@ -149,22 +147,21 @@ int read_cpu_data( CpuData *data, unsigned int nb_cpu)
}
#elif defined (__NetBSD__)
-unsigned int detect_cpu_number()
+guint detect_cpu_number()
{
return 1;
}
-int read_cpu_data( CpuData *data, unsigned int nb_cpu)
+gboolean read_cpu_data( CpuData *data, guint nb_cpu)
{
- int user, nice, sys, bsdidle, idle;
- int used, total;
- static int mib[] = {CTL_KERN, KERN_CP_TIME };
- u_int64_t cp_time[CPUSTATES];
- size_t len = sizeof( cp_time );
+ guint user, nice, sys, bsdidle, idle;
+ guint used, total;
+ static gint mib[] = {CTL_KERN, KERN_CP_TIME };
+ guint64 cp_time[CPUSTATES];
+ gsize len = sizeof( cp_time );
if( sysctl( mib, 2, &cp_time, &len, NULL, 0 ) < 0 )
{
- printf( "Cannot get kern.cp_time\n" );
return FALSE;
}
@@ -178,7 +175,7 @@ int read_cpu_data( CpuData *data, unsigned int nb_cpu)
total = used+bsdidle;
if( total - data[0].previous_total != 0 )
- data[0].load = (CPU_SCALE * (double)(used - data[0].previous_total)) / (double)(total - data[0].previous_total);
+ data[0].load = (CPU_SCALE * (used - data[0].previous_total)) / (total - data[0].previous_total);
else
data[0].load = 0;
@@ -189,21 +186,20 @@ int read_cpu_data( CpuData *data, unsigned int nb_cpu)
}
#elif defined (__OpenBSD__)
-unsigned int detect_cpu_number()
+guint detect_cpu_number()
{
return 1;
}
-int read_cpu_data( CpuData *data, unsigned int nb_cpu)
+gboolean read_cpu_data( CpuData *data, guint nb_cpu)
{
- unsigned int user, nice, sys, bsdidle, idle;
- unsigned int used, total;
- static int mib[] = {CTL_KERN, KERN_CPTIME };
- u_int64_t cp_time[CPUSTATES];
- size_t len = sizeof( cp_time );
+ guint user, nice, sys, bsdidle, idle;
+ guint used, total;
+ static gint mib[] = {CTL_KERN, KERN_CPTIME };
+ guint64 cp_time[CPUSTATES];
+ gsize len = sizeof( cp_time );
if( sysctl( mib, 2, &cp_time, &len, NULL, 0) < 0 )
{
- printf( "Cannot get kern.cp_time\n" );
return FALSE;
}
@@ -217,7 +213,7 @@ int read_cpu_data( CpuData *data, unsigned int nb_cpu)
total = used+bsdidle;
if( total - data[0].previous_total != 0 )
- data[0].load = (CPU_SCALE (used - data[0].previous_total))/(total - data[0].previous_total);
+ data[0].load = (CPU_SCALE * (used - data[0].previous_total))/(total - data[0].previous_total);
else
data[0].load = 0;
data[0].previous_used = used;
diff --git a/panel-plugin/os.h b/panel-plugin/os.h
index d2e822a..726ec01 100644
--- a/panel-plugin/os.h
+++ b/panel-plugin/os.h
@@ -3,14 +3,16 @@
#define CPU_SCALE 256
+#include <glib.h>
+
typedef struct
{
- unsigned int load;
- unsigned int previous_used;
- unsigned int previous_total;
+ guint load;
+ guint previous_used;
+ guint previous_total;
} CpuData;
-unsigned int detect_cpu_number();
-int read_cpu_data( CpuData *data, unsigned int nb_cpu );
+guint detect_cpu_number();
+gboolean read_cpu_data( CpuData *data, guint nb_cpu );
#endif /* !_XFCE_OS_H */
diff --git a/panel-plugin/properties.c b/panel-plugin/properties.c
index 4f5b7e5..2fc15aa 100644
--- a/panel-plugin/properties.c
+++ b/panel-plugin/properties.c
@@ -3,14 +3,14 @@
#include "settings.h"
static GtkBox *create_tab();
-static GtkBox *create_option_line( GtkBox *tab, GtkSizeGroup *sg, const char *name );
-static void create_check_box( GtkBox *tab, GtkSizeGroup *sg, const char *name, int init, void (callback)( GtkToggleButton *, CPUGraph *), void *cb_data );
-static void create_drop_down( GtkBox *tab, GtkSizeGroup *sg, const char * name, const char **items, size_t nb_items, int init, void (callback)( GtkOptionMenu *, CPUGraph * ), void * cb_data);
+static GtkBox *create_option_line( GtkBox *tab, GtkSizeGroup *sg, const gchar *name );
+static void create_check_box( GtkBox *tab, GtkSizeGroup *sg, const gchar *name, gboolean init, void (callback)( GtkToggleButton *, CPUGraph *), void *cb_data );
+static void create_drop_down( GtkBox *tab, GtkSizeGroup *sg, const gchar * name, const gchar **items, gsize nb_items, guint init, void (callback)( GtkOptionMenu *, CPUGraph * ), void * cb_data);
static void setup_update_interval_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base );
static void setup_size_option( GtkBox *vbox, GtkSizeGroup *sg, XfcePanelPlugin *plugin, CPUGraph *base );
static void setup_command_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base );
-static void setup_color_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base, int number, const gchar *name, GCallback cb );
+static void setup_color_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base, guint number, const gchar *name, GCallback cb );
static void setup_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base );
static void setup_color_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base );
@@ -24,7 +24,7 @@ static void change_color_3( GtkColorButton *button, CPUGraph *base );
static void select_active_colors( CPUGraph * base );
static void change_mode( GtkOptionMenu *om, CPUGraph *base );
static void change_color_mode( GtkOptionMenu *om, CPUGraph *base );
-static void response_cb( GtkWidget *dlg, int response, CPUGraph *base );
+static void response_cb( GtkWidget *dlg, gint response, CPUGraph *base );
static void change_frame( GtkToggleButton *button, CPUGraph *base );
static void change_border( GtkToggleButton *button, CPUGraph *base );
static void change_bars( GtkToggleButton * button, CPUGraph * base );
@@ -104,7 +104,7 @@ static GtkBox *create_tab()
return tab;
}
-static GtkBox *create_option_line( GtkBox *tab, GtkSizeGroup *sg, const char *name )
+static GtkBox *create_option_line( GtkBox *tab, GtkSizeGroup *sg, const gchar *name )
{
GtkBox *line;
GtkWidget *label;
@@ -125,7 +125,7 @@ static GtkBox *create_option_line( GtkBox *tab, GtkSizeGroup *sg, const char *na
return line;
}
-static void create_check_box( GtkBox *tab, GtkSizeGroup *sg, const char *name, int init, void (callback)( GtkToggleButton *, CPUGraph *), void *cb_data )
+static void create_check_box( GtkBox *tab, GtkSizeGroup *sg, const gchar *name, gboolean init, void (callback)( GtkToggleButton *, CPUGraph *), void *cb_data )
{
GtkBox *hbox;
GtkWidget * checkBox;
@@ -140,13 +140,13 @@ static void create_check_box( GtkBox *tab, GtkSizeGroup *sg, const char *name, i
gtk_size_group_add_widget( sg, checkBox );
}
-static void create_drop_down( GtkBox *tab, GtkSizeGroup *sg, const char * name, const char ** items, size_t nb_items, int init, void (callback)( GtkOptionMenu *, CPUGraph * ), void * cb_data)
+static void create_drop_down( GtkBox *tab, GtkSizeGroup *sg, const gchar * name, const gchar ** items, gsize nb_items, guint init, void (callback)( GtkOptionMenu *, CPUGraph * ), void * cb_data)
{
GtkBox *hbox;
GtkWidget *Option;
GtkWidget *Menu;
GtkWidget *MenuItem;
- int i;
+ gint i;
hbox = create_option_line( tab, sg, name );
@@ -171,12 +171,12 @@ static void create_drop_down( GtkBox *tab, GtkSizeGroup *sg, const char * name,
static void setup_update_interval_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base )
{
- const char *items[] = { _("Fastest (~250ms)"),
+ const gchar *items[] = { _("Fastest (~250ms)"),
_("Fast (~500ms)"),
_("Normal (~750ms)"),
_("Slow (~1s)")
};
- size_t nb_items = sizeof( items ) / sizeof( char* );
+ gsize nb_items = sizeof( items ) / sizeof( gchar* );
create_drop_down( vbox, sg, _("Update Interval: "), items, nb_items, base->update_interval, change_update, base);
}
@@ -212,7 +212,7 @@ static void setup_command_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base
g_signal_connect( AssociateCommand, "changed", G_CALLBACK( change_command ), base );
}
-static void setup_color_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base, int number, const gchar * name, GCallback cb )
+static void setup_color_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base, guint number, const gchar * name, GCallback cb )
{
GtkBox *hbox;
@@ -227,23 +227,23 @@ static void setup_color_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base,
static void setup_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base )
{
- const char *items[] = { _("Normal"),
+ const gchar *items[] = { _("Normal"),
_("LED"),
_("No history"),
_("Grid")
};
- size_t nb_items = sizeof( items ) / sizeof( char* );
+ gsize nb_items = sizeof( items ) / sizeof( gchar* );
create_drop_down( vbox, sg, _("Mode:"), items, nb_items, base->mode, change_mode, base);
}
static void setup_color_mode_option( GtkBox *vbox, GtkSizeGroup *sg, CPUGraph *base )
{
- const char *items[] = { _("None"),
+ const gchar *items[] = { _("None"),
_("Gradient"),
_("Fire"),
};
- size_t nb_items = sizeof( items ) / sizeof( char* );
+ gsize nb_items = sizeof( items ) / sizeof( gchar* );
create_drop_down( vbox, sg, _("Color mode: "), items, nb_items, base->color_mode, change_color_mode, base);
}
@@ -263,7 +263,7 @@ static void change_command( GtkEntry *entry, CPUGraph * base )
set_command( base, gtk_entry_get_text( entry ) );
}
-static void change_color( GtkColorButton * button, CPUGraph * base, int number)
+static void change_color( GtkColorButton * button, CPUGraph * base, guint number)
{
GdkColor color;
gtk_color_button_get_color( button, &color );
@@ -315,7 +315,7 @@ static void change_color_mode( GtkOptionMenu * om, CPUGraph * base )
select_active_colors( base );
}
-static void response_cb( GtkWidget *dlg, int response, CPUGraph *base )
+static void response_cb( GtkWidget *dlg, gint response, CPUGraph *base )
{
gtk_widget_destroy( dlg );
xfce_panel_plugin_unblock_menu( base->plugin );
diff --git a/panel-plugin/settings.c b/panel-plugin/settings.c
index dd79eab..12d0036 100644
--- a/panel-plugin/settings.c
+++ b/panel-plugin/settings.c
@@ -6,11 +6,11 @@ void read_settings( XfcePanelPlugin * plugin, CPUGraph * base )
char *file;
XfceRc *rc;
- int rate = 0;
+ guint rate = 0;
gboolean nonlinear = FALSE;
- int size = 70;
- int mode = 0;
- int color_mode = 0;
+ guint size = 70;
+ guint mode = 0;
+ guint color_mode = 0;
gboolean frame = TRUE;
gboolean border = TRUE;
gboolean bars = TRUE;
More information about the Xfce4-commits
mailing list