diff --git a/ChangeLog b/ChangeLog index b7c3c1f9aeca936d5727ffdc4b77253915772c50..42eb83ca2ccb87dc66e28bc5b93da5159c838e5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-05-18 19:40 + * : Fix inactivity sleep string in the settings dialog to + Suspend instead of suspend (same for hibernate). + * : Change the storage type of some variables used in xfpm-debug.c + * : some optimization for const fuctions. + * : use G_GNUC_NORETURN in the xfpm_start and the + xfpm_show_version functions. + 2009-05-18 18:35 * : libxfpm/xfpm-notify Remove unused parameter to some functions. * : xfpm-debug.h Check if the compiler supports variadic macros. diff --git a/libxfpm/hal-battery.c b/libxfpm/hal-battery.c index 2e293e4c1a0b2052f70646f7fbb316b5f7b4331d..8753fbaa410ec2f2380a7631705a829ebad608f5 100644 --- a/libxfpm/hal-battery.c +++ b/libxfpm/hal-battery.c @@ -325,7 +325,7 @@ hal_battery_finalize(GObject *object) G_OBJECT_CLASS(hal_battery_parent_class)->finalize(object); } -static HalDeviceType +static HalDeviceType G_GNUC_PURE hal_battery_type_enum_from_string(const gchar *string) { if ( !g_strcmp0 (string, "primary") ) @@ -375,12 +375,10 @@ hal_battery_get_device_type (HalBattery *battery) type_enum = hal_battery_type_enum_from_string(type); g_free(type); } - - //g_free (udi); return type_enum; } -static guint +static guint G_GNUC_CONST _get_battery_percentage (guint32 last_full, guint32 current) { guint val = 100; @@ -440,7 +438,7 @@ hal_battery_refresh_all (HalBattery *battery) } -static const gchar * +static const gchar * G_GNUC_PURE _translate_technology (const gchar *tech) { if ( !g_strcmp0 (tech, "lithium-ion") ) @@ -463,7 +461,7 @@ _translate_technology (const gchar *tech) return _("Unknown"); } -static const gchar * +static const gchar * G_GNUC_PURE _translate_unit (const gchar *unit) { if ( !g_strcmp0 (unit, "mWh") ) diff --git a/settings/xfpm-settings.c b/settings/xfpm-settings.c index 5901f95d43366d4793f5dfa44f88b7ad4e8e7e0b..6bec6c30b38ae1ff17543898c78678b8e7b35682 100644 --- a/settings/xfpm-settings.c +++ b/settings/xfpm-settings.c @@ -222,7 +222,7 @@ notify_toggled_cb (GtkWidget *w, XfconfChannel *channel) static void set_hibernate_inactivity (GtkWidget *w, XfconfChannel *channel) { - if (!xfconf_channel_set_string (channel, INACTIVITY_SLEEP_MODE, "hibernate") ) + if (!xfconf_channel_set_string (channel, INACTIVITY_SLEEP_MODE, "Hibernate") ) { g_critical ("Cannot set value hibernate for property %s", INACTIVITY_SLEEP_MODE); } @@ -231,7 +231,7 @@ set_hibernate_inactivity (GtkWidget *w, XfconfChannel *channel) static void set_suspend_inactivity (GtkWidget *w, XfconfChannel *channel) { - if (!xfconf_channel_set_string (channel, INACTIVITY_SLEEP_MODE, "suspend") ) + if (!xfconf_channel_set_string (channel, INACTIVITY_SLEEP_MODE, "Suspend") ) { g_critical ("Cannot set value suspend for property %s", INACTIVITY_SLEEP_MODE); } @@ -1227,10 +1227,10 @@ xfpm_settings_advanced (XfconfChannel *channel, gboolean system_laptop, gboolean g_signal_connect (inact_hibernate, "toggled", G_CALLBACK (set_hibernate_inactivity), channel); - str = xfconf_channel_get_string (channel, INACTIVITY_SLEEP_MODE, "suspend"); - if ( xfpm_strequal (str, "suspend") ) + str = xfconf_channel_get_string (channel, INACTIVITY_SLEEP_MODE, "Suspend"); + if ( xfpm_strequal (str, "Suspend") ) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_suspend), TRUE); - else if ( xfpm_strequal (str, "hibernate")) + else if ( xfpm_strequal (str, "Hibernate")) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (inact_hibernate), TRUE); else { diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c index 3cfcbbe12aa3f4f078f020e06b701cd98ed66840..d322b7992b61e78077841db57c2910c7bcf70e39 100644 --- a/src/xfpm-battery.c +++ b/src/xfpm-battery.c @@ -82,7 +82,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE(XfpmBattery, xfpm_battery, G_TYPE_OBJECT) -static const gchar * +static const gchar * G_GNUC_CONST xfpm_battery_get_icon_index (HalDeviceType type, guint percent) { if (percent < 10) { @@ -99,7 +99,7 @@ xfpm_battery_get_icon_index (HalDeviceType type, guint percent) return "100"; } -static const gchar * +static const gchar * G_GNUC_CONST xfpm_battery_get_message_from_battery_state (XfpmBatteryState state, gboolean adapter_present) { switch (state) @@ -247,7 +247,7 @@ xfpm_battery_notify (XfpmBattery *battery) } } -static const gchar * +static const gchar * G_GNUC_CONST _get_battery_name (HalDeviceType type) { if ( type == HAL_DEVICE_TYPE_UPS) @@ -264,7 +264,7 @@ _get_battery_name (HalDeviceType type) return _("Your Battery"); } -static const gchar * +static const gchar * G_GNUC_PURE xfpm_battery_get_battery_state (XfpmBatteryState *state, gboolean is_charging, gboolean is_discharging, diff --git a/src/xfpm-battery.h b/src/xfpm-battery.h index ad8a6788c897d62e8205401dcf9e1bd559aefe4f..02ab5a4b2c479bb05104b0eb6acba2c907841b53 100644 --- a/src/xfpm-battery.h +++ b/src/xfpm-battery.h @@ -56,13 +56,13 @@ typedef struct GType xfpm_battery_get_type (void) G_GNUC_CONST; XfpmBattery *xfpm_battery_new (const HalBattery *device); -const HalBattery *xfpm_battery_get_device (XfpmBattery *battery); +const HalBattery *xfpm_battery_get_device (XfpmBattery *battery) G_GNUC_PURE; -XfpmBatteryState xfpm_battery_get_state (XfpmBattery *battery); +XfpmBatteryState xfpm_battery_get_state (XfpmBattery *battery) G_GNUC_PURE; GtkStatusIcon *xfpm_battery_get_status_icon (XfpmBattery *battery); -const gchar *xfpm_battery_get_icon_name (XfpmBattery *battery); +const gchar *xfpm_battery_get_icon_name (XfpmBattery *battery) G_GNUC_PURE; G_END_DECLS diff --git a/src/xfpm-config.h b/src/xfpm-config.h index f0d425c567ca537d1892e1b7bd79266a65f76a32..0cadcd2f2c46ae69531571354b0d14ba01ce4c6a 100644 --- a/src/xfpm-config.h +++ b/src/xfpm-config.h @@ -57,12 +57,10 @@ G_BEGIN_DECLS #define GENERAL_NOTIFICATION_CFG "/xfce4-power-manager/general-notification" -#ifdef HAVE_LIBNOTIFY #define BATT_STATE_NOTIFICATION_CFG "/xfce4-power-manager/battery-state-notification" /* default TRUE */ #define SHOW_SLEEP_ERRORS_CFG "/xfce4-power-manager/show-sleep-errors" #define SHOW_POWER_MANAGEMENT_ERROR "/xfce4-power-manager/show-power-management-error" -#endif #define SHOW_TRAY_ICON_CFG "/xfce4-power-manager/show-tray-icon" /* default 0 = always,1 = when charging or discharging, 2 = when battery is present */ diff --git a/src/xfpm-debug.c b/src/xfpm-debug.c index 5cd396246e06cbc23cea3749e5b1ddb30fc970bd..dc0e48fd98cf84945533623762301065a8420f25 100644 --- a/src/xfpm-debug.c +++ b/src/xfpm-debug.c @@ -36,8 +36,8 @@ void xfpm_debug_enum (const gchar *func, const gchar *file, gint line, const gchar *text, gint v_enum, GType type) { - static gchar *content = NULL; - static GValue __value__ = { 0, }; + gchar *content = NULL; + GValue __value__ = { 0, }; g_value_init (&__value__, type); g_value_set_enum (&__value__, v_enum); @@ -57,8 +57,8 @@ void xfpm_debug_enum_full (const gchar *func, const gchar *file, gint line, va_list args; gchar *buffer; - static gchar *content = NULL; - static GValue __value__ = { 0, }; + gchar *content = NULL; + GValue __value__ = { 0, }; g_value_init (&__value__, type); g_value_set_enum (&__value__, v_enum); diff --git a/src/xfpm-main.c b/src/xfpm-main.c index 912ea40dea3408f14acbe8820cdb2f9262c4cd50..7fea6ef6016d5cb214867ec12838c259f7e0fb6a 100644 --- a/src/xfpm-main.c +++ b/src/xfpm-main.c @@ -47,7 +47,7 @@ static gchar *client_id = NULL; static gboolean no_daemon = FALSE; -static void +static void G_GNUC_NORETURN show_version (void) { g_print (_("\n" @@ -55,6 +55,8 @@ show_version (void) "Part of the Xfce Goodies Project\n" "http://goodies.xfce.org\n\n" "Licensed under the GNU GPL.\n\n"), VERSION); + + exit (EXIT_SUCCESS); } static void @@ -65,14 +67,14 @@ xfpm_quit_signal (gint sig, gpointer data) xfpm_manager_stop (manager); } -static void +static void G_GNUC_NORETURN xfpm_start (DBusGConnection *bus) { XfpmManager *manager; XfpmSession *session; GError *error = NULL; - TRACE("Starting the power manager\n"); + TRACE ("Starting the power manager"); session = xfpm_session_new (); if ( client_id != NULL ) @@ -96,7 +98,7 @@ xfpm_start (DBusGConnection *bus) } else { - g_warning("Unable to set up POSIX signal handlers: %s", error->message); + g_warning ("Unable to set up POSIX signal handlers: %s", error->message); g_error_free(error); } @@ -109,6 +111,8 @@ xfpm_start (DBusGConnection *bus) gtk_main (); g_object_unref (session); + + exit (EXIT_SUCCESS); } int main(int argc, char **argv) @@ -157,7 +161,6 @@ int main(int argc, char **argv) if ( version ) { show_version(); - return EXIT_SUCCESS; } if ( run + quit + config + version > 1 ) diff --git a/src/xfpm-network-manager.c b/src/xfpm-network-manager.c index 4c452bf23e513f9c4367a38e563bba0ee54687d3..e978d9843fb45439df24db2f8a0b3fc40db64498 100644 --- a/src/xfpm-network-manager.c +++ b/src/xfpm-network-manager.c @@ -38,6 +38,7 @@ gboolean xfpm_send_message_to_network_manager (const gchar *message) GError *error = NULL; bus = dbus_g_bus_get ( DBUS_BUS_SYSTEM, &error); + if ( error ) { g_warning("%s", error->message); @@ -45,7 +46,6 @@ gboolean xfpm_send_message_to_network_manager (const gchar *message) return FALSE; } - proxy = dbus_g_proxy_new_for_name (bus, "org.freedesktop.NetworkManager", "/org/freedesktop/NetworkManager", @@ -53,7 +53,7 @@ gboolean xfpm_send_message_to_network_manager (const gchar *message) if (!proxy) { - g_critical ("Failed to create proxy for Network Manager interface"); + g_warning ("Failed to create proxy for Network Manager interface"); return FALSE; } diff --git a/src/xfpm-shutdown.c b/src/xfpm-shutdown.c index d088de772b49abaf7daad99555a8cc199eed2011..a920d17074cfdc64cf78a95399f6deb01e1742e8 100644 --- a/src/xfpm-shutdown.c +++ b/src/xfpm-shutdown.c @@ -327,7 +327,7 @@ xfpm_shutdown_internal (DBusConnection *bus, const gchar *shutdown, GError **ger return TRUE; } -static const gchar * +static const gchar * G_GNUC_PURE _filter_error_message(const gchar *error) { if( xfpm_strequal ("No back-end for your operating system", error)) diff --git a/src/xfpm-xfconf.c b/src/xfpm-xfconf.c index c01d1182adb05acf57368fc2eb38f58f832d33d6..92c659826b183bcbf5b0d47eeba22d7a7c6d671f 100644 --- a/src/xfpm-xfconf.c +++ b/src/xfpm-xfconf.c @@ -180,7 +180,7 @@ xfpm_xfconf_property_changed_cb (XfconfChannel *channel, gchar *property, conf->priv->lock_screen = g_value_get_boolean (value); } #ifdef HAVE_DPMS - if ( xfpm_strequal (property, DPMS_ENABLED_CFG) ) + else if ( xfpm_strequal (property, DPMS_ENABLED_CFG) ) { conf->priv->dpms_enabled = g_value_get_boolean (value); g_signal_emit (G_OBJECT(conf), signals[DPMS_SETTINGS_CHANGED], 0);