[Goodies-commits] r6828 - xfce4-power-manager/trunk/src
Ali Abdallah
aliov at xfce.org
Mon Mar 2 11:12:03 CET 2009
Author: aliov
Date: 2009-03-02 10:12:03 +0000 (Mon, 02 Mar 2009)
New Revision: 6828
Modified:
xfce4-power-manager/trunk/src/Makefile.am
xfce4-power-manager/trunk/src/xfpm-battery.c
xfce4-power-manager/trunk/src/xfpm-button.c
xfce4-power-manager/trunk/src/xfpm-cpu.c
xfce4-power-manager/trunk/src/xfpm-driver.c
xfce4-power-manager/trunk/src/xfpm-hal.c
xfce4-power-manager/trunk/src/xfpm-lcd-brightness.c
xfce4-power-manager/trunk/src/xfpm-spin-button.c
Log:
Use a function which correctly handles NULL strings to compare
Modified: xfce4-power-manager/trunk/src/Makefile.am
===================================================================
--- xfce4-power-manager/trunk/src/Makefile.am 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/Makefile.am 2009-03-02 10:12:03 UTC (rev 6828)
@@ -39,7 +39,9 @@
xfpm-notify.h \
xfpm-enums.h \
xfpm-common.c \
- xfpm-common.h
+ xfpm-common.h \
+ xfpm-string.c \
+ xfpm-string.h
xfce4_power_manager_CFLAGS = \
-DLOCALEDIR=\"$(localedir)\" \
Modified: xfce4-power-manager/trunk/src/xfpm-battery.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-battery.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -56,11 +56,8 @@
#include "xfpm-enum-types.h"
#include "xfpm-notify.h"
#include "xfpm-marshal.h"
+#include "xfpm-string.h"
-#ifndef _
-#define _(x) x
-#endif
-
#define XFPM_BATTERY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE(o,XFPM_TYPE_BATTERY,XfpmBatteryPrivate))
static void xfpm_battery_init(XfpmBattery *battery);
@@ -513,16 +510,16 @@
{
XFPM_DEBUG("arg1->name=%s\n",arg1->name);
- if (!strcmp(arg1->name,"show-tray-icon"))
+ if (!xfpm_strcmp(arg1->name,"show-tray-icon"))
{
xfpm_battery_refresh_tray_icon(XFPM_BATTERY(object));
}
- else if ( !strcmp(arg1->name,"critical-charge"))
+ else if ( !xfpm_strcmp(arg1->name,"critical-charge"))
{
xfpm_battery_refresh_critical_charge(XFPM_BATTERY(object));
}
#ifdef HAVE_LIBNOTIFY
- else if ( !strcmp(arg1->name,"enable-notification"))
+ else if ( !xfpm_strcmp(arg1->name,"enable-notification"))
{
xfpm_battery_refresh_notification(XFPM_BATTERY(object));
}
@@ -619,7 +616,7 @@
{
return;
}
- if ( !strcmp(key,"battery.charge_level.last_full") )
+ if ( !xfpm_strcmp(key,"battery.charge_level.last_full") )
{
GError *error = NULL;
guint last_full = xfpm_hal_get_int_info(priv->hal,
@@ -635,9 +632,9 @@
return;
}
- if ( strcmp(key,"battery.charge_level.current") &&
- strcmp(key,"battery.rechargeable.is_charging") &&
- strcmp(key,"battery.rechargeable.is_discharging") )
+ if ( xfpm_strcmp(key,"battery.charge_level.current") &&
+ xfpm_strcmp(key,"battery.rechargeable.is_charging") &&
+ xfpm_strcmp(key,"battery.rechargeable.is_discharging") )
{
return;
}
@@ -744,12 +741,12 @@
static void
_do_critical_action(NotifyNotification *n,gchar *action,XfpmBattery *batt)
{
- if (!strcmp(action,"shutdown"))
+ if (!xfpm_strcmp(action,"shutdown"))
{
XFPM_DEBUG("Sending shutdown request\n");
g_signal_emit(G_OBJECT(batt),signals[XFPM_ACTION_REQUEST],0,XFPM_DO_SHUTDOWN,TRUE);
}
- else if ( !strcmp(action,"hibernate"))
+ else if ( !xfpm_strcmp(action,"hibernate"))
{
XFPM_DEBUG("Sending hibernate request\n");
g_signal_emit(G_OBJECT(batt),signals[XFPM_ACTION_REQUEST],0,XFPM_DO_HIBERNATE,TRUE);
@@ -902,7 +899,7 @@
static void
xfpm_battery_state_change_cb(GObject *object,GParamSpec *arg1,gpointer data)
{
- if ( !strcmp(arg1->name,"battery-state") )
+ if ( !xfpm_strcmp(arg1->name,"battery-state") )
{
XfpmBatteryState state;
XfpmBattery *batt = XFPM_BATTERY(data);
@@ -1033,19 +1030,19 @@
static XfpmBatteryType
xfpm_battery_get_battery_type(const gchar *battery_type)
{
- if ( !strcmp("primary",battery_type) )
+ if ( !xfpm_strcmp("primary",battery_type) )
{
return PRIMARY;
}
- else if ( !strcmp("keyboard",battery_type) )
+ else if ( !xfpm_strcmp("keyboard",battery_type) )
{
return KEYBOARD;
}
- else if ( !strcmp("mouse",battery_type) )
+ else if ( !xfpm_strcmp("mouse",battery_type) )
{
return MOUSE;
}
- else if ( !strcmp("ups",battery_type) )
+ else if ( !xfpm_strcmp("ups",battery_type) )
{
return UPS;
}
Modified: xfce4-power-manager/trunk/src/xfpm-button.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-button.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-button.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -51,6 +51,7 @@
#include "xfpm-enums.h"
#include "xfpm-enum-types.h"
#include "xfpm-marshal.h"
+#include "xfpm-string.h"
#define XFPM_BUTTON_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE(o,XFPM_TYPE_BUTTON,XfpmButtonPrivate))
@@ -463,21 +464,21 @@
if ( xfpm_hal_device_have_capability(priv->hal,udi,"button") )
{
- if ( strcmp(condition_name,"ButtonPressed") )
+ if ( xfpm_strcmp(condition_name,"ButtonPressed") )
{
XFPM_DEBUG("Not processing event with condition_name=%s\n",condition_name);
return;
}
XFPM_DEBUG("proccessing event: %s %s\n",condition_name,condition_detail);
- if ( !strcmp(condition_detail,"lid") )
+ if ( !xfpm_strcmp(condition_detail,"lid") )
{
xfpm_button_lid_pressed(bt,udi);
}
- else if ( !strcmp(condition_detail,"power") )
+ else if ( !xfpm_strcmp(condition_detail,"power") )
{
xfpm_button_power_pressed(bt,udi);
}
- else if ( !strcmp(condition_detail,"sleep") )
+ else if ( !xfpm_strcmp(condition_detail,"sleep") )
{
xfpm_button_sleep_pressed(bt,udi);
}
@@ -503,7 +504,7 @@
static void
_check_button(XfpmButtonPrivate *priv,const gchar *button_type,const gchar *udi)
{
- if ( !strcmp(button_type,"lid"))
+ if ( !xfpm_strcmp(button_type,"lid"))
{
priv->have_lid_bt = TRUE;
priv->lid_button_has_state = xfpm_hal_get_bool_info(priv->hal,udi,
@@ -511,14 +512,14 @@
NULL);
}
- else if ( !strcmp(button_type,"power") )
+ else if ( !xfpm_strcmp(button_type,"power") )
{
priv->have_power_bt = TRUE;
priv->power_button_has_state = xfpm_hal_get_bool_info(priv->hal,udi,
"button.has_state",
NULL);
}
- else if ( !strcmp(button_type,"sleep"))
+ else if ( !xfpm_strcmp(button_type,"sleep"))
{
priv->have_sleep_bt = TRUE;
priv->sleep_button_has_state = xfpm_hal_get_bool_info(priv->hal,udi,
Modified: xfce4-power-manager/trunk/src/xfpm-cpu.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-cpu.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-cpu.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -48,6 +48,7 @@
#include "xfpm-debug.h"
#include "xfpm-common.h"
#include "xfpm-enum-types.h"
+#include "xfpm-string.h"
#define XFPM_CPU_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE(o,XFPM_TYPE_CPU,XfpmCpuPrivate))
@@ -314,10 +315,10 @@
{
for ( i = 0 ; govs[i] ; i++ )
{
- if ( !strcmp(govs[i],"powersave") ) governors |= POWERSAVE;
- if ( !strcmp(govs[i],"ondemand") ) governors |= ONDEMAND;
- if ( !strcmp(govs[i],"performance") ) governors |= PERFORMANCE;
- if ( !strcmp(govs[i],"conservative") ) governors |= CONSERVATIVE;
+ if ( !xfpm_strcmp(govs[i],"powersave") ) governors |= POWERSAVE;
+ if ( !xfpm_strcmp(govs[i],"ondemand") ) governors |= ONDEMAND;
+ if ( !xfpm_strcmp(govs[i],"performance") ) governors |= PERFORMANCE;
+ if ( !xfpm_strcmp(govs[i],"conservative") ) governors |= CONSERVATIVE;
}
libhal_free_string_array(govs);
}
@@ -368,7 +369,7 @@
XFPM_DEBUG("Configuration governor %s\n",config_gov);
- if ( strcmp(current_governor,config_gov) )
+ if ( xfpm_strcmp(current_governor,config_gov) )
{
XFPM_DEBUG("CPU actuel governor %s, setting=%s\n",current_governor,config_gov);
xfpm_hal_set_cpu_governor(priv->hal,config_gov,&error);
@@ -406,9 +407,9 @@
return;
}
- if ( !strcmp(arg1->name,"on-ac-adapter") ||
- !strcmp(arg1->name,"on-ac-cpu-gov") ||
- !strcmp(arg1->name,"on-batt-cpu-gov") )
+ if ( !xfpm_strcmp(arg1->name,"on-ac-adapter") ||
+ !xfpm_strcmp(arg1->name,"on-ac-cpu-gov") ||
+ !xfpm_strcmp(arg1->name,"on-batt-cpu-gov") )
{
xfpm_cpu_set_governor(cpu,cpu->ac_adapter_present);
}
Modified: xfce4-power-manager/trunk/src/xfpm-driver.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-driver.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-driver.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -66,6 +66,7 @@
#include "xfpm-popups.h"
#include "xfpm-enum-types.h"
#include "xfpm-dbus-messages.h"
+#include "xfpm-string.h"
#ifdef HAVE_LIBNOTIFY
#include "xfpm-notify.h"
@@ -348,21 +349,21 @@
priv = XFPM_DRIVER_GET_PRIVATE(drv);
- if ( !strcmp(property,CRITICAL_BATT_CFG) )
+ if ( !xfpm_strcmp(property,CRITICAL_BATT_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->batt),"critical-charge",val,NULL);
return;
}
- if ( !strcmp(property,CRITICAL_BATT_ACTION_CFG) )
+ if ( !xfpm_strcmp(property,CRITICAL_BATT_ACTION_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->batt),"critical-action",val,NULL);
return;
}
- if ( !strcmp(property,SHOW_TRAY_ICON_CFG) )
+ if ( !xfpm_strcmp(property,SHOW_TRAY_ICON_CFG) )
{
gboolean val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->batt),"show-tray-icon",val,NULL);
@@ -371,20 +372,20 @@
if ( priv->cpufreq_control )
{
- if ( !strcmp(property,CPU_FREQ_SCALING_CFG) )
+ if ( !xfpm_strcmp(property,CPU_FREQ_SCALING_CFG) )
{
gboolean val = g_value_get_boolean(value);
g_object_set(G_OBJECT(priv->cpu),"cpu-freq",val,NULL);
return;
}
- if ( !strcmp(property,ON_AC_CPU_GOV_CFG) )
+ if ( !xfpm_strcmp(property,ON_AC_CPU_GOV_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->cpu),"on-ac-cpu-gov",val,NULL);
return;
}
- if ( !strcmp(property,ON_BATT_CPU_GOV_CFG) )
+ if ( !xfpm_strcmp(property,ON_BATT_CPU_GOV_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->cpu),"on-batt-cpu-gov",val,NULL);
@@ -392,7 +393,7 @@
}
}
#ifdef HAVE_LIBNOTIFY
- if ( !strcmp(property,BATT_STATE_NOTIFICATION_CFG) )
+ if ( !xfpm_strcmp(property,BATT_STATE_NOTIFICATION_CFG) )
{
gboolean val = g_value_get_boolean(value);
g_object_set(G_OBJECT(priv->batt),"enable-notification",val,NULL);
@@ -402,7 +403,7 @@
if ( priv->lcd_brightness_control )
{
- if ( !strcmp(property,LCD_BRIGHTNESS_CFG) )
+ if ( !xfpm_strcmp(property,LCD_BRIGHTNESS_CFG) )
{
gboolean val = g_value_get_boolean(value);
g_object_set(G_OBJECT(priv->lcd),"brightness-enabled",val,NULL);
@@ -410,7 +411,7 @@
}
}
#ifdef HAVE_DPMS
- if ( !strcmp(property,DPMS_ENABLE_CFG) )
+ if ( !xfpm_strcmp(property,DPMS_ENABLE_CFG) )
{
gboolean val = g_value_get_boolean(value);
priv->dpms->dpms_enabled = val;
@@ -418,7 +419,7 @@
return;
}
- if ( !strcmp(property,ON_BATT_DPMS_TIMEOUTS_CFG) )
+ if ( !xfpm_strcmp(property,ON_BATT_DPMS_TIMEOUTS_CFG) )
{
GPtrArray *arr;
gpointer data;
@@ -442,7 +443,7 @@
return;
}
- if ( !strcmp(property,ON_AC_DPMS_TIMEOUTS_CFG) )
+ if ( !xfpm_strcmp(property,ON_AC_DPMS_TIMEOUTS_CFG) )
{
GPtrArray *arr;
gpointer data;
@@ -471,21 +472,21 @@
if ( priv->buttons_control )
{
- if ( !strcmp(property,LID_SWITCH_CFG) )
+ if ( !xfpm_strcmp(property,LID_SWITCH_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->bt),"lid-switch-action",val,NULL);
return;
}
- if ( !strcmp(property,SLEEP_SWITCH_CFG) )
+ if ( !xfpm_strcmp(property,SLEEP_SWITCH_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->bt),"sleep-switch-action",val,NULL);
return;
}
- if ( !strcmp(property,POWER_SWITCH_CFG) )
+ if ( !xfpm_strcmp(property,POWER_SWITCH_CFG) )
{
guint val = g_value_get_uint(value);
g_object_set(G_OBJECT(priv->bt),"power-switch-action",val,NULL);
@@ -493,7 +494,7 @@
}
}
- if ( !strcmp(property,POWER_SAVE_CFG) )
+ if ( !xfpm_strcmp(property,POWER_SAVE_CFG) )
{
gboolean val = g_value_get_boolean(value);
priv->enable_power_save = val;
@@ -720,19 +721,19 @@
NULL);
if (!factor ) return;
- if ( !strcmp(factor,"laptop") )
+ if ( !xfpm_strcmp(factor,"laptop") )
{
priv->formfactor = SYSTEM_LAPTOP;
}
- else if ( !strcmp(factor,"desktop") )
+ else if ( !xfpm_strcmp(factor,"desktop") )
{
priv->formfactor = SYSTEM_DESKTOP;
}
- else if ( !strcmp(factor,"server") )
+ else if ( !xfpm_strcmp(factor,"server") )
{
priv->formfactor = SYSTEM_SERVER;
}
- else if ( !strcmp(factor,"unknown") )
+ else if ( !xfpm_strcmp(factor,"unknown") )
{
priv->formfactor = SYSTEM_UNKNOWN;
}
@@ -763,7 +764,7 @@
static void
_disable_error(NotifyNotification *n,gchar *action,XfpmDriver *drv)
{
- if (strcmp(action,"confirmed")) return;
+ if (xfpm_strcmp(action,"confirmed")) return;
XfconfChannel *channel;
Modified: xfce4-power-manager/trunk/src/xfpm-hal.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-hal.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-hal.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -47,11 +47,8 @@
#include "xfpm-dbus-messages.h"
#include "xfpm-marshal.h"
+#include "xfpm-string.h"
-#ifndef _
-#define _(x) x
-#endif
-
/* Init */
static void xfpm_hal_class_init(XfpmHalClass *klass);
static void xfpm_hal_init (XfpmHal *xfpm_hal);
@@ -328,7 +325,7 @@
{
/* This is the only one place in the program we will
* be happy when we seeDBusError is set */
- if (!strcmp(error.name,"org.freedesktop.DBus.Error.UnknownMethod"))
+ if (!xfpm_strcmp(error.name,"org.freedesktop.DBus.Error.UnknownMethod"))
{
dbus_error_free(&error);
return TRUE;
@@ -368,7 +365,7 @@
if ( dbus_error_is_set(&error) )
{
- if (!strcmp(error.name,"org.freedesktop.DBus.Error.UnknownMethod"))
+ if (!xfpm_strcmp(error.name,"org.freedesktop.DBus.Error.UnknownMethod"))
{
dbus_error_free(&error);
return TRUE;
@@ -628,23 +625,23 @@
static const gchar *
_filter_error_message(const gchar *error)
{
- if(!strcmp("No back-end for your operating system",error))
+ if(!xfpm_strcmp("No back-end for your operating system",error))
{
return _("No back-end for your operating system");
}
- else if (!strcmp("No hibernate script found",error) )
+ else if (!xfpm_strcmp("No hibernate script found",error) )
{
return _("No hibernate script found");
}
- else if (!strcmp("No suspend script found",error) )
+ else if (!xfpm_strcmp("No suspend script found",error) )
{
return _("No suspend script found");
}
- else if (!strcmp("No suspend method found",error) )
+ else if (!xfpm_strcmp("No suspend method found",error) )
{
return _("No suspend method found");
}
- else if (!strcmp("No hibernate method found",error))
+ else if (!xfpm_strcmp("No hibernate method found",error))
{
return _("No hibernate method found");
}
Modified: xfce4-power-manager/trunk/src/xfpm-lcd-brightness.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-lcd-brightness.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-lcd-brightness.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -47,6 +47,7 @@
#include "xfpm-hal.h"
#include "xfpm-debug.h"
#include "xfpm-common.h"
+#include "xfpm-string.h"
#define XFPM_LCD_BRIGHTNESS_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE(o,XFPM_TYPE_LCD_BRIGHTNESS,XfpmLcdBrightnessPrivate))
@@ -458,13 +459,13 @@
if ( xfpm_hal_device_have_capability(hal,udi,"button") )
{
- if ( !strcmp(condition_name,"ButtonPressed") )
+ if ( !xfpm_strcmp(condition_name,"ButtonPressed") )
{
- if ( !strcmp(condition_detail,"brightness-down") )
+ if ( !xfpm_strcmp(condition_detail,"brightness-down") )
{
xfpm_lcd_brightness_decrease(lcd);
}
- else if ( !strcmp(condition_name,"brightness-up") )
+ else if ( !xfpm_strcmp(condition_name,"brightness-up") )
{
xfpm_lcd_brightness_increase(lcd);
}
Modified: xfce4-power-manager/trunk/src/xfpm-spin-button.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-spin-button.c 2009-03-02 09:59:29 UTC (rev 6827)
+++ xfce4-power-manager/trunk/src/xfpm-spin-button.c 2009-03-02 10:12:03 UTC (rev 6828)
@@ -43,6 +43,7 @@
#include <glib/gi18n.h>
#include "xfpm-spin-button.h"
+#include "xfpm-string.h"
#define MAX_DIGITS 20
@@ -222,7 +223,7 @@
if ( !_is_digits(new_text,new_text_length) )
{
- if ( spin->suffix && !strcmp(new_text,spin->suffix) )
+ if ( spin->suffix && !xfpm_strcmp(new_text,spin->suffix) )
{
entry_iface->insert_text(editable,spin->suffix,spin->suffix_length,position);
_spin_button_update(spin);
More information about the Goodies-commits
mailing list