[Goodies-commits] r5709 - in xfce4-power-manager/trunk: . src
Ali Abdallah
aliov at xfce.org
Sun Oct 19 15:45:55 CEST 2008
Author: aliov
Date: 2008-10-19 13:45:55 +0000 (Sun, 19 Oct 2008)
New Revision: 5709
Modified:
xfce4-power-manager/trunk/Makefile.am
xfce4-power-manager/trunk/configure.ac.in
xfce4-power-manager/trunk/src/Makefile.am
xfce4-power-manager/trunk/src/xfpm-ac-adapter.c
xfce4-power-manager/trunk/src/xfpm-battery-icon.c
xfce4-power-manager/trunk/src/xfpm-battery-icon.h
xfce4-power-manager/trunk/src/xfpm-battery.c
xfce4-power-manager/trunk/src/xfpm-battery.h
xfce4-power-manager/trunk/src/xfpm-common.c
xfce4-power-manager/trunk/src/xfpm-common.h
xfce4-power-manager/trunk/src/xfpm-dpms-spins.c
xfce4-power-manager/trunk/src/xfpm-dpms.c
xfce4-power-manager/trunk/src/xfpm-driver.c
xfce4-power-manager/trunk/src/xfpm-hal.c
xfce4-power-manager/trunk/src/xfpm-main.c
xfce4-power-manager/trunk/src/xfpm-settings.c
xfce4-power-manager/trunk/src/xfpm-settings.h
Log:
correct untranslated strings, dpms settings bug fixes
Modified: xfce4-power-manager/trunk/Makefile.am
===================================================================
--- xfce4-power-manager/trunk/Makefile.am 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/Makefile.am 2008-10-19 13:45:55 UTC (rev 5709)
@@ -1 +1,11 @@
-SUBDIRS = src data
\ No newline at end of file
+SUBDIRS = src data po
+
+EXTRA_DIST = \
+ intltool-extract.in \
+ intltool-merge.in \
+ intltool-update.in
+
+DISTCLEANFILES = \
+ intltool-extract \
+ intltool-merge \
+ intltool-update
Modified: xfce4-power-manager/trunk/configure.ac.in
===================================================================
--- xfce4-power-manager/trunk/configure.ac.in 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/configure.ac.in 2008-10-19 13:45:55 UTC (rev 5709)
@@ -17,6 +17,13 @@
AC_SUBST(CFLAGS)
AC_SUBST(LDFLAGS)
+# ===================================================== #
+# Check for i18n support #
+# ===================================================== #
+
+XDT_I18N([])
+
+
# ============== look for dependencies =============== #
# check for headers needed for standard interfaces #
AC_HEADER_STDC
@@ -99,4 +106,4 @@
echo
echo "----------------------------------------"
echo
-echo "Configuration finished, type make to compile"
\ No newline at end of file
+echo "Configuration finished, type make to compile"
Modified: xfce4-power-manager/trunk/src/Makefile.am
===================================================================
--- xfce4-power-manager/trunk/src/Makefile.am 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/Makefile.am 2008-10-19 13:45:55 UTC (rev 5709)
@@ -7,8 +7,10 @@
$(LIBXFCEGUI_CFLAGS) \
$(XFCONF_CFLAGS) \
$(LIBNOTIFY_CFLAGS) \
- $(DPMS_CFLAGS)
+ $(DPMS_CFLAGS) \
+ -DLOCALEDIR=\"$(localedir)\"
+
LIBS = $(GTK_LIBS) \
$(GLIB_LIBS) \
$(DBUS_LIBS) \
@@ -121,4 +123,4 @@
$(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
-
\ No newline at end of file
+
Modified: xfce4-power-manager/trunk/src/xfpm-ac-adapter.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-ac-adapter.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-ac-adapter.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -47,8 +47,6 @@
#include <libxfcegui4/libxfcegui4.h>
-#include <glib/gi18n.h>
-
#include "xfpm-common.h"
#include "xfpm-hal.h"
@@ -60,6 +58,10 @@
#include "xfpm-notify.h"
#include "xfpm-debug.h"
+#ifndef _
+#define _(x) x
+#endif
+
#define XFPM_AC_ADAPTER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE(o,XFPM_TYPE_AC_ADAPTER,XfpmAcAdapterPrivate))
Modified: xfce4-power-manager/trunk/src/xfpm-battery-icon.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery-icon.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-battery-icon.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -20,8 +20,9 @@
*/
#include <gtk/gtk.h>
-#include <glib/gi18n.h>
+#include <glib.h>
+
#include <string.h>
#include "xfpm-battery-icon.h"
@@ -30,6 +31,10 @@
#include "xfpm-common.h"
#include "xfpm-enum-types.h"
+#ifndef _
+#define _(x) x
+#endif
+
/* init */
static void xfpm_battery_icon_init(XfpmBatteryIcon *battery_icon);
static void xfpm_battery_icon_class_init(XfpmBatteryIconClass *klass);
@@ -55,7 +60,8 @@
static void xfpm_battery_icon_update (XfpmBatteryIcon *battery_icon,
XfpmBatteryState state,
- guint level);
+ guint level,
+ gboolean adapter_present);
G_DEFINE_TYPE(XfpmBatteryIcon,xfpm_battery_icon,GTK_TYPE_STATUS_ICON)
@@ -113,8 +119,8 @@
"Battery critical level",
"Low battery level",
1,
- 15,
- 8,
+ 20,
+ 10,
G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
#ifdef HAVE_LIBNOTIFY
@@ -143,7 +149,6 @@
#endif
battery_icon->icon = -1;
battery_icon->icon_loaded = FALSE;
- battery_icon->ac_adapter_present = FALSE;
}
static void xfpm_battery_icon_set_property(GObject *object,
@@ -308,7 +313,8 @@
}
static void
-xfpm_battery_icon_update(XfpmBatteryIcon *battery_icon,XfpmBatteryState state,guint level)
+xfpm_battery_icon_update(XfpmBatteryIcon *battery_icon,XfpmBatteryState state,
+ guint level,gboolean adapter_present)
{
XFPM_DEBUG(" start\n");
#ifdef HAVE_LIBNOTIFY
@@ -342,7 +348,7 @@
icon_name = g_strdup_printf("%s-%s",icon_prefix,
xfpm_battery_icon_get_index(battery_icon->type,level));
#ifdef HAVE_LIBNOTIFY
- if ( !battery_icon->ac_adapter_present )
+ if ( !adapter_present )
{
message = battery_icon->type == PRIMARY ? _("You are running on Battery"):_("Battery is discharging");
}
@@ -449,8 +455,8 @@
gboolean ac_adapter_present)
{
g_return_if_fail(XFPM_IS_BATTERY_ICON(battery_icon));
- battery_icon->ac_adapter_present = ac_adapter_present;
- battery_icon->battery_present = present;
+ battery_icon->battery_present = ac_adapter_present;
+
#ifdef DEBUG
gchar *content_is_charging;
gchar *content_is_discharging;
@@ -487,7 +493,7 @@
if ( present == FALSE )
{
- xfpm_battery_icon_update(battery_icon,NOT_PRESENT,remaining_per);
+ xfpm_battery_icon_update(battery_icon,NOT_PRESENT,remaining_per,ac_adapter_present);
sprintf(tip,"%s",_("Not present"));
gtk_status_icon_set_tooltip(GTK_STATUS_ICON(battery_icon),tip);
return;
@@ -500,21 +506,21 @@
if ( is_charging == FALSE && is_discharging == FALSE && battery_icon->last_full == charge )
{
strcat(tip,_(" Battery fully charged"));
- xfpm_battery_icon_update(battery_icon,FULL,remaining_per);
+ xfpm_battery_icon_update(battery_icon,FULL,remaining_per,ac_adapter_present);
}
// battery is not dis/charging but is not full also
if ( is_charging == FALSE && is_discharging == FALSE && battery_icon->last_full != charge )
{
strcat(tip,_(" Battery charge"));
- xfpm_battery_icon_update(battery_icon,NOT_FULL,remaining_per);
+ xfpm_battery_icon_update(battery_icon,NOT_FULL,remaining_per,ac_adapter_present);
}
//battery is charging
if ( is_charging == TRUE && is_discharging == FALSE )
{
strcat(tip,_(" Battery is charging "));
- xfpm_battery_icon_update(battery_icon,CHARGING,remaining_per);
+ xfpm_battery_icon_update(battery_icon,CHARGING,remaining_per,ac_adapter_present);
}
// battery is discharging
@@ -522,40 +528,60 @@
{
if ( remaining_per > ( battery_icon->critical_level + 10 ) )
{
- if ( !battery_icon->ac_adapter_present )
+ if ( !ac_adapter_present )
{
strcat(tip,
battery_icon->type == PRIMARY ? _(" Running on battery"): _(" Battery is discharging"));
}
- xfpm_battery_icon_update(battery_icon,DISCHARGING,remaining_per);
+ else
+ {
+ strcat(tip,_(" Battery is discharging"));
+ }
+ xfpm_battery_icon_update(battery_icon,DISCHARGING,remaining_per,ac_adapter_present);
}
else if ( remaining_per <= ( battery_icon->critical_level+10 ) && remaining_per > battery_icon->critical_level )
{
strcat(tip,_(" Battery charge level is low"));
- xfpm_battery_icon_update(battery_icon,LOW,remaining_per);
+ xfpm_battery_icon_update(battery_icon,LOW,remaining_per,ac_adapter_present);
}
else if ( remaining_per <= battery_icon->critical_level )
{
strcat(tip,_(" Battery charge level is critical"));
- xfpm_battery_icon_update(battery_icon,CRITICAL,remaining_per);
+ xfpm_battery_icon_update(battery_icon,CRITICAL,remaining_per,ac_adapter_present);
}
}
if ( remaining_time != 0 )
{
- gchar time_str[80] = "";
- gchar hours_str[20] = "";
- gchar minutes_str[20] = "";
+ gchar *time_str;
+ gchar *est_time = NULL;
+
gint minutes,hours,minutes_left;
hours = remaining_time / 3600;
minutes = remaining_time / 60;
minutes_left = minutes % 60;
- strcat(hours_str,hours > 1 ? _("hours") : _("hour") );
- strcat(minutes_str,minutes > 1 ? _("minutes") : _("minute"));
-
- sprintf(time_str,_("\nEstimated Time Left: %d %s %d %s"),hours,hours_str,minutes_left,minutes_str);
+ if ( battery_icon->state == DISCHARGING ||
+ battery_icon->state == LOW ||
+ battery_icon->state == CRITICAL )
+ {
+ est_time = g_strdup(_("\nEstimated time left"));
+
+ }
+ else if ( battery_icon->state == CHARGING )
+ {
+ est_time = g_strdup(_("\nEstimated time to charge"));
+
+ }
+ time_str = g_strdup_printf("%s: %d %s %d %s",est_time,
+ hours,hours > 1 ? _("hours") : _("hour") ,
+ minutes_left, minutes_left > 1 ? _("minutes") : _("minute"));
+
strcat(tip,time_str);
+ g_free(time_str);
+ g_free(est_time);
}
+
gtk_status_icon_set_tooltip(GTK_STATUS_ICON(battery_icon),tip);
+
}
Modified: xfce4-power-manager/trunk/src/xfpm-battery-icon.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery-icon.h 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-battery-icon.h 2008-10-19 13:45:55 UTC (rev 5709)
@@ -48,11 +48,11 @@
GQuark icon;
gboolean icon_loaded;
-
+
+ gboolean battery_present;
+
guint last_full;
guint critical_level;
- gboolean ac_adapter_present;
- gboolean battery_present;
#ifdef HAVE_LIBNOTIFY
gboolean notify;
Modified: xfce4-power-manager/trunk/src/xfpm-battery.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-battery.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -43,7 +43,6 @@
#include <gtk/gtk.h>
#include <glib.h>
-#include <glib/gi18n.h>
#include <libxfcegui4/libxfcegui4.h>
#include <xfconf/xfconf.h>
@@ -57,6 +56,10 @@
#include "xfpm-notify.h"
#include "xfpm-marshal.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);
@@ -134,6 +137,8 @@
GHashTable *batteries;
guint8 power_management;
+
+ gboolean ups_found;
};
@@ -201,9 +206,9 @@
"Critical charge",
"Critical battery charge",
1,
- 15,
- 8,
- G_PARAM_READWRITE|G_PARAM_CONSTRUCT));
+ 20,
+ 10,
+ G_PARAM_READWRITE));
g_object_class_install_property(gobject_class,
PROP_CRITICAL_ACTION,
@@ -359,6 +364,16 @@
G_OBJECT_CLASS(xfpm_battery_parent_class)->finalize(object);
}
+#ifdef HAVE_LIBNOTIFY
+static gboolean
+_hide_battery(gpointer data)
+{
+ XfpmBatteryIcon *icon = (XfpmBatteryIcon*) data;
+ g_object_set(G_OBJECT(icon),"visible",FALSE,NULL);
+ return FALSE;
+}
+#endif
+
static void
xfpm_battery_refresh_tray_icon(XfpmBattery *batt)
{
@@ -419,13 +434,20 @@
{
if ( XFPM_BATTERY_ICON(icon)->state == CHARGING ||
XFPM_BATTERY_ICON(icon)->state == DISCHARGING ||
- XFPM_BATTERY_ICON(icon)->state == NOT_FULL )
+ XFPM_BATTERY_ICON(icon)->state == NOT_FULL ||
+ XFPM_BATTERY_ICON(icon)->state == LOW ||
+ XFPM_BATTERY_ICON(icon)->state == CRITICAL)
{
g_object_set(G_OBJECT(icon),"visible",TRUE,NULL);
}
else
{
+#ifdef HAVE_LIBNOTIFY
+ if ( batt->notify_enabled ) g_timeout_add_seconds(6,(GSourceFunc)_hide_battery,icon);
+ else g_object_set(G_OBJECT(icon),"visible",FALSE,NULL);
+#else
g_object_set(G_OBJECT(icon),"visible",FALSE,NULL);
+#endif
}
}
}
@@ -549,7 +571,6 @@
xfconf_shutdown();
}
-
static void
xfpm_battery_handle_device_added(XfpmHal *hal,const gchar *udi,XfpmBattery *batt)
{
@@ -577,6 +598,11 @@
}
XFPM_DEBUG("Removing battery device %s\n",udi);
+ XfpmBatteryType battery_type;
+ g_object_get(G_OBJECT(icon),"battery-type",&battery_type,NULL);
+
+ if ( battery_type == UPS ) priv->ups_found = FALSE;
+
g_hash_table_remove(priv->batteries,udi);
g_object_unref(icon);
xfpm_battery_refresh(batt);
@@ -854,7 +880,7 @@
/* refresh here for the tray icon hiding if option
* show icon is charging or discharging and battery is fully charged
*/
- xfpm_battery_refresh(batt);
+ xfpm_battery_refresh_tray_icon(batt);
#ifdef DEBUG
gchar *content;
GValue value = { 0, };
@@ -1122,6 +1148,7 @@
xfpm_battery_get_battery_type(battery_type);
if ( battery_type )
libhal_free_string(battery_type);
+ if ( type == UPS ) priv->ups_found = TRUE;
GtkStatusIcon *batt_icon;
batt_icon = xfpm_battery_icon_new(last_full,
@@ -1252,3 +1279,12 @@
priv->power_management = power_management;
}
+gboolean
+xfpm_battery_ups_found (XfpmBattery *batt)
+{
+ g_return_val_if_fail(XFPM_IS_BATTERY(batt),FALSE);
+ XfpmBatteryPrivate *priv;
+ priv = XFPM_BATTERY_GET_PRIVATE(batt);
+
+ return priv->ups_found;
+}
Modified: xfce4-power-manager/trunk/src/xfpm-battery.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery.h 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-battery.h 2008-10-19 13:45:55 UTC (rev 5709)
@@ -67,17 +67,18 @@
} XfpmBatteryClass;
-GType xfpm_battery_get_type(void) G_GNUC_CONST;
-XfpmBattery *xfpm_battery_new (void);
-void xfpm_battery_monitor (XfpmBattery *batt);
+GType xfpm_battery_get_type (void) G_GNUC_CONST;
+XfpmBattery *xfpm_battery_new (void);
+void xfpm_battery_monitor (XfpmBattery *batt);
#ifdef HAVE_LIBNOTIFY
-void xfpm_battery_show_error(XfpmBattery *batt,
- const gchar *icon_name,
- const gchar *error);
+void xfpm_battery_show_error (XfpmBattery *batt,
+ const gchar *icon_name,
+ const gchar *error);
#endif
void xfpm_battery_set_power_info(XfpmBattery *batt,
guint8 power_management);
+gboolean xfpm_battery_ups_found (XfpmBattery *batt);
G_END_DECLS
#endif
Modified: xfce4-power-manager/trunk/src/xfpm-common.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-common.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-common.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -20,11 +20,14 @@
*/
#include <glib.h>
-#include <glib/gi18n.h>
#include "xfpm-common.h"
#include "xfpm-debug.h"
+#ifndef _
+#define _(x) x
+#endif
+
GdkPixbuf *
xfpm_load_icon(const char *icon_name,gint size)
{
Modified: xfce4-power-manager/trunk/src/xfpm-common.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-common.h 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-common.h 2008-10-19 13:45:55 UTC (rev 5709)
@@ -32,7 +32,7 @@
/* Configuration */
#define XFPM_CHANNEL_CFG "xfce4-power-manager"
-#define CRITICAL_BATT_CFG "/xfce4-power-manager/critical-battery-charge" /* default 12% */
+#define CRITICAL_BATT_CFG "/xfce4-power-manager/critical-battery-charge" /* default 10% */
#define CRITICAL_BATT_ACTION_CFG "/xfce4-power-manager/critical-battery-action" /* default 0 nothing, 1 = shutdown, 2 = hibernate if supported) */
#define CPU_FREQ_SCALING_CFG "/xfce4-power-manager/cpu-scaling-gov"
Modified: xfce4-power-manager/trunk/src/xfpm-dpms-spins.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-dpms-spins.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-dpms-spins.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -37,12 +37,14 @@
#include <unistd.h>
#endif
-#include <glib/gi18n.h>
-
#include "xfpm-dpms-spins.h"
#include "xfpm-spin-button.h"
#include "xfpm-marshal.h"
+#ifndef _
+#define _(x) x
+#endif
+
#ifdef HAVE_DPMS
/* init */
@@ -178,9 +180,11 @@
value1,value2,value3);
return;
}
+
if ( priv->spin_value_1 == 0 )
{
xfpm_spin_button_set_suffix(XFPM_SPIN_BUTTON(spin_1),_(" min"));
+ priv->spin_value_1 = value1;
if ( priv->spin_value_2 == 0 )
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->spin_2),value1+1);
}
@@ -229,9 +233,11 @@
return;
}
+
if ( priv->spin_value_2 == 0 )
{
xfpm_spin_button_set_suffix(XFPM_SPIN_BUTTON(spin_2),_(" min"));
+ priv->spin_value_2 = value2;
if ( priv->spin_value_3 == 0 )
gtk_spin_button_set_value(GTK_SPIN_BUTTON(priv->spin_3),value2+1);
}
@@ -281,6 +287,7 @@
if ( priv->spin_value_3 == 0 )
{
xfpm_spin_button_set_suffix(XFPM_SPIN_BUTTON(spin_3),_(" min"));
+ priv->spin_value_3 = value3;
}
if ( value3 <= value2 )
Modified: xfce4-power-manager/trunk/src/xfpm-dpms.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-dpms.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-dpms.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -48,8 +48,6 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
-#include <glib/gi18n.h>
-
#include <X11/Xproto.h>
#include <X11/extensions/dpms.h>
#include <X11/extensions/dpmsstr.h>
@@ -59,6 +57,10 @@
#include "xfpm-common.h"
#include "xfpm-debug.h"
+#ifndef _
+#define _(x) x
+#endif
+
#define DPMS_TIMEOUT 120
#define XFPM_DPMS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o),XFPM_TYPE_DPMS,XfpmDpmsPrivate))
Modified: xfce4-power-manager/trunk/src/xfpm-driver.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-driver.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-driver.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -43,7 +43,6 @@
#include <gtk/gtk.h>
#include <glib.h>
-#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
@@ -76,6 +75,10 @@
#include "xfpm-dpms-spins.h"
#endif
+#ifndef _
+#define _(x) x
+#endif
+
/*init*/
static void xfpm_driver_init (XfpmDriver *drv);
static void xfpm_driver_class_init (XfpmDriverClass *klass);
@@ -596,6 +599,7 @@
{
switch_buttons = xfpm_button_get_available_buttons(priv->bt);
}
+ gboolean ups_found = xfpm_battery_ups_found(priv->batt);
dialog = xfpm_settings_new(channel,
priv->formfactor == SYSTEM_LAPTOP ? TRUE : FALSE,
@@ -603,7 +607,8 @@
with_dpms,
gov,
switch_buttons,
- priv->lcd_brightness_control);
+ priv->lcd_brightness_control,
+ ups_found);
xfce_gtk_window_center_on_monitor_with_pointer(GTK_WINDOW(dialog));
gtk_window_set_modal(GTK_WINDOW(dialog), FALSE);
Modified: xfce4-power-manager/trunk/src/xfpm-hal.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-hal.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-hal.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -22,8 +22,6 @@
#include <dbus/dbus.h>
#include <dbus/dbus-glib-lowlevel.h>
-#include <glib/gi18n.h>
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -34,6 +32,10 @@
#include "xfpm-marshal.h"
+#ifndef _
+#define _(x) x
+#endif
+
/* Init */
static void xfpm_hal_class_init(XfpmHalClass *klass);
static void xfpm_hal_init (XfpmHal *xfpm_hal);
Modified: xfce4-power-manager/trunk/src/xfpm-main.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-main.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-main.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -38,11 +38,18 @@
#endif
#include <gtk/gtk.h>
+#include <glib.h>
+#include <libxfcegui4/libxfcegui4.h>
+
#include "xfpm-driver.h"
#include "xfpm-hal.h"
#include "xfpm-dbus-messages.h"
+#ifndef _
+#define _(x) x
+#endif
+
enum
{
PM_HELP,
@@ -67,6 +74,76 @@
}
+static void
+autostart()
+{
+ const gchar *home;
+
+ if ( ( home = getenv("HOME")) == NULL )
+ {
+ g_error("Unable to read HOME evironment variable, autostart will not work\n");
+ return;
+ }
+
+ gchar *file;
+ file = g_strdup_printf("%s/.config/autostart",home);
+
+ if ( !g_file_test(file,G_FILE_TEST_IS_DIR) )
+ {
+ g_error("Home directory doesn't contains .config/autostart subdirs\n");
+ g_free(file);
+ return;
+ }
+
+ file = g_strdup_printf("%s/xfce4-power-manager.desktop",file);
+
+ if ( g_file_test(file,G_FILE_TEST_EXISTS) )
+ {
+ g_print("xfce4 power manager autostart.desktop file already exists\n");
+ g_free(file);
+ return;
+ }
+
+ GKeyFile *key;
+ GError *error = NULL;
+
+ key = g_key_file_new();
+
+ g_key_file_set_value(key,"Desktop Entry","Version","1.0");
+ g_key_file_set_string(key,"Desktop Entry","Type","Application");
+ g_key_file_set_string(key,"Desktop Entry","Name","Xfce4 Power Manager");
+ g_key_file_set_string(key,"Desktop Entry","Icon","gpm-ac-adapter");
+ g_key_file_set_string(key,"Desktop Entry","Exec","xfce4-power-manager -r");
+ g_key_file_set_boolean(key,"Desktop Entry","StartupNotify",FALSE);
+ g_key_file_set_boolean(key,"Desktop Entry","Terminal",FALSE);
+ g_key_file_set_boolean(key,"Desktop Entry","Hidden",FALSE);
+
+ gchar *content = g_key_file_to_data(key,NULL,&error);
+
+ if ( error )
+ {
+ g_critical("%s\n",error->message);
+ g_error_free(error);
+ g_free(file);
+ g_key_file_free(key);
+ return;
+ }
+
+ g_file_set_contents(file,content,-1,&error);
+
+ if ( error )
+ {
+ g_critical("Unable to set content for the autostart desktop file%s\n",error->message);
+ g_error_free(error);
+ g_free(file);
+ g_key_file_free(key);
+ return;
+ }
+
+ g_free(file);
+ g_key_file_free(key);
+}
+
static int
handle_arguments(int argc,char **argv)
{
@@ -116,6 +193,10 @@
int main(int argc,char **argv)
{
+ xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
+
+ gtk_init(&argc,&argv);
+
int msg = handle_arguments(argc,argv);
if ( msg == PM_HELP ) return 0;
@@ -130,6 +211,14 @@
if ( reply != 1 )
{
g_print("Xfce power manager is not running\n");
+ gboolean ret =
+ xfce_confirm(_("Xfce4 Power Manager is not running, do you want to launch it now"),
+ GTK_STOCK_YES,
+ _("Run"));
+ if ( ret )
+ {
+ g_spawn_command_line_async("xfce4-power-manager -r",NULL);
+ }
return 0;
}
xfpm_dbus_send_message("Customize");
@@ -154,7 +243,6 @@
if ( msg == PM_RUN )
{
- gtk_init(&argc,&argv);
int reply;
if (!xfpm_dbus_send_message_with_reply("Running",&reply))
{
@@ -167,6 +255,7 @@
return 0;
}
XfpmDriver *driver = xfpm_driver_new();
+ autostart();
if (!xfpm_driver_monitor(driver))
{
/* g_disaster */
Modified: xfce4-power-manager/trunk/src/xfpm-settings.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-settings.c 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-settings.c 2008-10-19 13:45:55 UTC (rev 5709)
@@ -417,7 +417,7 @@
/// Settings frames ///
static GtkWidget *
-xfpm_settings_battery(XfconfChannel *channel, guint8 power_management)
+xfpm_settings_battery(XfconfChannel *channel, guint8 power_management,gboolean ups_found)
{
GtkWidget *table;
GtkWidget *frame,*align;
@@ -427,27 +427,28 @@
table = gtk_table_new(4,2,TRUE);
gtk_widget_show(table);
- frame = xfce_create_framebox(_("Battery configuration"), &align);
+ frame = xfce_create_framebox(ups_found ? _("Ups configuration") :_("Battery configuration"), &align);
gtk_widget_show(frame);
gtk_container_set_border_width(GTK_CONTAINER(frame),BORDER);
- label = gtk_label_new(_("Consider battery charge critical"));
+ label = gtk_label_new(ups_found ? ("Consider ups charge critical"):_("Consider battery charge critical"));
gtk_widget_show(label);
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,1);
- critical_spin = xfpm_spin_button_new_with_range(1,15,1);
+ critical_spin = xfpm_spin_button_new_with_range(1,20,1);
xfpm_spin_button_set_suffix(XFPM_SPIN_BUTTON(critical_spin),_(" percent"));
gtk_widget_show(critical_spin);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(critical_spin),
- xfconf_channel_get_uint(channel,CRITICAL_BATT_CFG,8));
+ xfconf_channel_get_uint(channel,CRITICAL_BATT_CFG,10));
g_signal_connect(critical_spin,"value-changed",
G_CALLBACK(set_battery_critical_charge_cb),channel);
gtk_table_attach(GTK_TABLE(table),critical_spin,1,2,0,1,GTK_SHRINK,GTK_SHRINK,0,0);
label = gtk_label_new(_("When battery charge level is critical do"));
gtk_widget_show(label);
- gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
-
+ if ( !ups_found )
+ gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2);
+
action = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(action),_("Nothing"));
if ( power_management != 0 )
@@ -465,11 +466,12 @@
gtk_widget_show(action);
g_signal_connect(action,"changed",G_CALLBACK(set_critical_action_cb),channel);
- gtk_table_attach(GTK_TABLE(table),action,1,2,1,2,GTK_SHRINK,GTK_SHRINK,0,0);
+
+ !ups_found ? gtk_table_attach(GTK_TABLE(table),action,1,2,1,2,GTK_SHRINK,GTK_SHRINK,0,0) : gtk_widget_hide(action);
// Power Save Profile
GtkWidget *power_save;
- label = gtk_label_new(_("Enable power save on battery power"));
+ label = gtk_label_new(ups_found ? _("Enable power save on ups power") : _("Enable power save on battery power"));
gtk_widget_show(label);
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,2,3);
power_save = gtk_check_button_new();
@@ -491,7 +493,7 @@
#ifdef HAVE_LIBNOTIFY
GtkWidget *notify_bt;
- label = gtk_label_new(_("Enable battery state notification"));
+ label = gtk_label_new(ups_found ? _("Enable ups charge notification") :_("Enable battery state notification"));
gtk_widget_show(label);
gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,3,4);
notify_bt = gtk_check_button_new();
@@ -601,7 +603,7 @@
}
static GtkWidget *
-xfpm_settings_cpu_on_battery_power(XfconfChannel *channel,guint8 govs)
+xfpm_settings_cpu_on_battery_power(XfconfChannel *channel,guint8 govs,gboolean ups)
{
GtkWidget *frame;
GtkWidget *align;
@@ -611,7 +613,7 @@
guint current_governor = xfconf_channel_get_uint(channel,ON_BATT_CPU_GOV_CFG,ONDEMAND);
gboolean enable = xfconf_channel_get_bool(channel,CPU_FREQ_SCALING_CFG,TRUE);
- frame = xfce_create_framebox(_("CPU governor settings on battery power"), &align);
+ frame = xfce_create_framebox(ups ? _("CPU governor settings on ups power") : _("CPU governor settings on battery power"), &align);
gtk_container_set_border_width(GTK_CONTAINER(frame),BORDER);
gtk_widget_show(frame);
@@ -695,7 +697,7 @@
}
static GtkWidget *
-xfpm_settings_cpu_freq(XfconfChannel *channel,guint8 govs,gboolean laptop)
+xfpm_settings_cpu_freq(XfconfChannel *channel,guint8 govs,gboolean laptop,gboolean ups)
{
GtkWidget *hbox;
hbox = gtk_hbox_new(FALSE,2);
@@ -721,12 +723,12 @@
GtkWidget *frame;
frame = xfpm_settings_cpu_on_ac_adapter(channel,
govs,
- laptop ? _("Cpu freq settings on AC power") : _("Cpu freq settings"));
+ laptop || ups ? _("Cpu freq settings on electric power") : _("Cpu freq settings"));
gtk_box_pack_start(GTK_BOX(hbox),frame,FALSE,FALSE,0);
- if ( laptop )
+ if ( laptop || ups )
{
- frame = xfpm_settings_cpu_on_battery_power(channel,govs);
+ frame = xfpm_settings_cpu_on_battery_power(channel,govs,ups);
gtk_box_pack_start(GTK_BOX(hbox),frame,FALSE,FALSE,0);
}
}
@@ -762,10 +764,10 @@
#ifdef HAVE_DPMS
static GtkWidget *
-xfpm_settings_dpms_on_battery(XfconfChannel *channel)
+xfpm_settings_dpms_on_battery(XfconfChannel *channel,gboolean ups)
{
GtkWidget *frame,*align;
- frame = xfce_create_framebox(_("Monitor DPMS settings on battery power"), &align);
+ frame = xfce_create_framebox(ups ? _("Monitor DPMS settings on ups power") : _("Monitor DPMS settings on battery power"), &align);
gtk_widget_show(frame);
gtk_container_set_border_width(GTK_CONTAINER(frame),BORDER);
@@ -841,7 +843,7 @@
static GtkWidget *
xfpm_settings_monitor(XfconfChannel *channel,gboolean laptop,
- gboolean dpms_capable,gboolean lcd)
+ gboolean dpms_capable,gboolean lcd,gboolean ups)
{
GtkWidget *hbox;
hbox = gtk_hbox_new(FALSE,2);
@@ -853,13 +855,13 @@
#ifdef HAVE_DPMS
GtkWidget *frame;
frame = xfpm_settings_dpms_on_ac_adapter(channel,
- laptop ? _("Monitor settings on AC power") : _("Monitor settings"));
+ laptop || ups ? _("Monitor settings on electric power") : _("Monitor settings"));
gtk_box_pack_start(GTK_BOX(hbox),frame,FALSE,FALSE,0);
gtk_box_pack_start(GTK_BOX(vbox),hbox,TRUE,TRUE,0);
- if ( laptop )
+ if ( laptop || ups )
{
- frame = xfpm_settings_dpms_on_battery(channel);
+ frame = xfpm_settings_dpms_on_battery(channel,ups);
gtk_box_pack_start(GTK_BOX(hbox),frame,FALSE,FALSE,0);
}
@@ -990,7 +992,7 @@
}
static GtkWidget *
-xfpm_settings_general(XfconfChannel *channel,gboolean battery_settings)
+xfpm_settings_general(XfconfChannel *channel,gboolean battery_settings,gboolean ups)
{
GtkWidget *table;
GtkWidget *show_icon;
@@ -1012,7 +1014,7 @@
show_icon = gtk_combo_box_new_text();
gtk_combo_box_append_text(GTK_COMBO_BOX(show_icon),_("Always Display an icon"));
gtk_combo_box_append_text(GTK_COMBO_BOX(show_icon),_("When battery is present"));
- if ( battery_settings )
+ if ( battery_settings || ups )
{
gtk_combo_box_append_text(GTK_COMBO_BOX(show_icon),_("When battery is charging or discharging"));
@@ -1087,7 +1089,7 @@
}
static GtkWidget *
-xfpm_settings_tree_view(gboolean is_laptop)
+xfpm_settings_tree_view(gboolean is_laptop,gboolean ups)
{
GdkPixbuf *pix;
GtkWidget *view;
@@ -1126,9 +1128,9 @@
}
/// Battery Settings
- if ( is_laptop )
+ if ( is_laptop || ups )
{
- pix = xfpm_load_icon("gpm-primary-100",38);
+ pix = xfpm_load_icon(ups ? "gpm-ups-100" : "gpm-primary-100",38);
gtk_list_store_append(list_store,&iter);
if ( pix )
{
@@ -1191,7 +1193,8 @@
gboolean dpms_capable,
guint8 govs,
guint8 switch_buttons,
- gboolean lcd)
+ gboolean lcd,
+ gboolean ups_found)
{
GtkWidget *Dialog; /* Main dialog window */
GtkWidget *mainbox; /* Box to get (Dialog)->vbox */
@@ -1212,9 +1215,12 @@
gtk_dialog_set_default_response(GTK_DIALOG(Dialog),GTK_RESPONSE_CLOSE);
mainbox = GTK_DIALOG(Dialog)->vbox;
-
+
+ gboolean ups;
+ ups = is_laptop ? FALSE : ups_found;
+
/// General Options Frame
- box = xfpm_settings_general(channel,is_laptop);
+ box = xfpm_settings_general(channel,is_laptop,ups);
gtk_box_pack_start (GTK_BOX (mainbox), box, FALSE, FALSE, 0);
/// Notebook container
@@ -1224,17 +1230,18 @@
table = gtk_table_new(1,2,FALSE);
gtk_widget_show(table);
gtk_box_pack_start (GTK_BOX (mainbox), table, FALSE, FALSE, 0);
- view = xfpm_settings_tree_view(is_laptop);
+ view = xfpm_settings_tree_view(is_laptop,ups_found);
gtk_table_attach_defaults(GTK_TABLE(table),view,0,1,0,1);
gtk_widget_show(view);
gtk_table_attach_defaults(GTK_TABLE(table),nt,1,2,0,1);
/// Cpu freq settings
- box = xfpm_settings_cpu_freq(channel,govs,is_laptop);
+ box = xfpm_settings_cpu_freq(channel,govs,is_laptop,ups);
gtk_notebook_append_page(GTK_NOTEBOOK(nt),box,NULL);
+
/// Battery settings
- box = xfpm_settings_battery(channel,power_management);
+ box = xfpm_settings_battery(channel,power_management,ups);
gtk_notebook_append_page(GTK_NOTEBOOK(nt),box,NULL);
/// Keyboard buttons settings
@@ -1242,7 +1249,7 @@
gtk_notebook_append_page(GTK_NOTEBOOK(nt),box,NULL);
/// Dpms settings && LCD brightness settings DPMS existence is checked above
- box = xfpm_settings_monitor(channel,is_laptop,dpms_capable,lcd);
+ box = xfpm_settings_monitor(channel,is_laptop,dpms_capable,lcd,ups);
gtk_notebook_append_page(GTK_NOTEBOOK(nt),box,NULL);
return Dialog;
Modified: xfce4-power-manager/trunk/src/xfpm-settings.h
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-settings.h 2008-10-19 11:36:25 UTC (rev 5708)
+++ xfce4-power-manager/trunk/src/xfpm-settings.h 2008-10-19 13:45:55 UTC (rev 5709)
@@ -28,7 +28,8 @@
gboolean dpms_capable,
guint8 govs,
guint8 switch_buttons,
- gboolean lcd);
+ gboolean lcd,
+ gboolean ups_found);
#endif /* __XFPM_SETTINGS_H */
More information about the Goodies-commits
mailing list