[Goodies-commits] r7108 - in xfce4-power-manager/trunk: . libxfpm panel-plugins/inhibit src

Ali Abdallah aliov at xfce.org
Sat Apr 4 13:58:11 CEST 2009


Author: aliov
Date: 2009-04-04 11:58:11 +0000 (Sat, 04 Apr 2009)
New Revision: 7108

Modified:
   xfce4-power-manager/trunk/ChangeLog
   xfce4-power-manager/trunk/TODO
   xfce4-power-manager/trunk/libxfpm/xfpm-notify.c
   xfce4-power-manager/trunk/libxfpm/xfpm-notify.h
   xfce4-power-manager/trunk/panel-plugins/inhibit/inhibit-plugin.c
   xfce4-power-manager/trunk/src/xfpm-battery.c
   xfce4-power-manager/trunk/src/xfpm-cpu.c
   xfce4-power-manager/trunk/src/xfpm-dpms.c
   xfce4-power-manager/trunk/src/xfpm-manager.c
   xfce4-power-manager/trunk/src/xfpm-supply.c
   xfce4-power-manager/trunk/src/xfpm-xfconf.c
Log:
Alpha2 release

Modified: xfce4-power-manager/trunk/ChangeLog
===================================================================
--- xfce4-power-manager/trunk/ChangeLog	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/ChangeLog	2009-04-04 11:58:11 UTC (rev 7108)
@@ -1,4 +1,7 @@
 
+2009-04-04 13:58 Ali aliov at xfce.org 
+	 * : Alpha2 release
+
 2009-04-04 11:30 Ali aliov at xfce.org 
 	 * : Fix issue with multiple suspend callback
 

Modified: xfce4-power-manager/trunk/TODO
===================================================================
--- xfce4-power-manager/trunk/TODO	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/TODO	2009-04-04 11:58:11 UTC (rev 7108)
@@ -4,9 +4,6 @@
 
 * : OnBattery and OnLowBattery DBus signals.
 
-* : Block any other notification when OnCriticalPower notification is opened, in the way that
-    we don't close it before the user close it or the Adapter is plugged in again.
-
 * : Support Suspend Hybrid! ( DeviceKit power will not support this ).
     
 * : Use the session logout when we do shutdown, probably use the shutdown session interface anyway.

Modified: xfce4-power-manager/trunk/libxfpm/xfpm-notify.c
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-notify.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-notify.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -65,6 +65,8 @@
     NotifyNotification *notification;
 };
 
+static gpointer xfpm_notify_object = NULL;
+
 G_DEFINE_TYPE(XfpmNotify, xfpm_notify, G_TYPE_OBJECT)
 
 static void
@@ -84,8 +86,6 @@
     notify->priv = XFPM_NOTIFY_GET_PRIVATE(notify);
     
     notify->priv->notification = NULL;
-        
-    notify_init ("xfce4-power-manager");
 }
 
 static void
@@ -136,9 +136,15 @@
 xfpm_notify_closed_cb (NotifyNotification *n, XfpmNotify *notify)
 {
     notify->priv->notification = NULL;
-    g_object_unref (G_OBJECT(n));
+    g_object_unref (G_OBJECT (n));
 }
 
+static void
+xfpm_notify_close_critical_cb (NotifyNotification *n, XfpmNotify *notify)
+{
+    g_object_unref (G_OBJECT (n));
+}
+
 static gboolean
 xfpm_notify_show (NotifyNotification *n)
 {
@@ -160,11 +166,18 @@
 }
 
 XfpmNotify *
-xfpm_notify_new(void)
+xfpm_notify_new (void)
 {
-    XfpmNotify *notify = NULL;
-    notify = g_object_new (XFPM_TYPE_NOTIFY, NULL);
-    return notify;
+    if ( xfpm_notify_object != NULL )
+    {
+	g_object_ref (xfpm_notify_object);
+    }
+    else
+    {
+	xfpm_notify_object = g_object_new (XFPM_TYPE_NOTIFY, NULL);
+	g_object_add_weak_pointer (xfpm_notify_object, &xfpm_notify_object);
+    }
+    return XFPM_NOTIFY (xfpm_notify_object);
 }
 
 void xfpm_notify_show_notification (XfpmNotify *notify, const gchar *title,
@@ -225,3 +238,25 @@
     
     g_idle_add ((GSourceFunc) xfpm_notify_show, n);
 }
+
+void xfpm_notify_critical (XfpmNotify *notify, NotifyNotification *n)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY (notify));
+    
+    g_object_set_data (G_OBJECT (notify), "critical", n);
+    
+    g_signal_connect (G_OBJECT (n), "closed", 
+		      G_CALLBACK (xfpm_notify_close_critical_cb), notify);
+    g_idle_add ((GSourceFunc) xfpm_notify_show, n);
+}
+
+void xfpm_notify_close_critical (XfpmNotify *notify)
+{
+    g_return_if_fail (XFPM_IS_NOTIFY (notify));
+    
+    NotifyNotification *n;
+    n = (NotifyNotification *)  g_object_get_data (G_OBJECT (notify), "critical");
+    
+    if ( n )
+	g_object_unref (n);
+}

Modified: xfce4-power-manager/trunk/libxfpm/xfpm-notify.h
===================================================================
--- xfce4-power-manager/trunk/libxfpm/xfpm-notify.h	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/libxfpm/xfpm-notify.h	2009-04-04 11:58:11 UTC (rev 7108)
@@ -85,6 +85,11 @@
 void 			  xfpm_notify_present_notification 	    (XfpmNotify *notify, 
 								     NotifyNotification *n,
 								     gboolean simple);
+								     
+void                      xfpm_notify_critical                      (XfpmNotify *notify,
+								     NotifyNotification *n);
+
+void                      xfpm_notify_close_critical                (XfpmNotify *notify);
 G_END_DECLS
 
 #endif /* __XFPM_NOTIFY_H */

Modified: xfce4-power-manager/trunk/panel-plugins/inhibit/inhibit-plugin.c
===================================================================
--- xfce4-power-manager/trunk/panel-plugins/inhibit/inhibit-plugin.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/panel-plugins/inhibit/inhibit-plugin.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -621,6 +621,8 @@
 		      G_CALLBACK(inhibit_plugin_size_changed_cb), inhibit);
 		      
     xfce_panel_plugin_menu_show_about(plugin);
+    
+    notify_init ("inhibit-plugin");
 
     g_signal_connect (plugin, "about", G_CALLBACK(xfpm_about), _("Inhibit plugin"));
 }

Modified: xfce4-power-manager/trunk/src/xfpm-battery.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-battery.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/src/xfpm-battery.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -202,22 +202,28 @@
 xfpm_battery_refresh_state (XfpmBattery *battery, XfpmBatteryState state)
 {
     const gchar *message;
+    gboolean notify;
     
+    notify = xfpm_xfconf_get_property_bool (battery->priv->conf, GENERAL_NOTIFICATION_CFG);
+    
     if ( battery->priv->state != state)
     {
 	battery->priv->state = state;
-	message = xfpm_battery_get_message_from_battery_state (state, battery->priv->adapter_present );
-	if ( !message )
-	    goto signal;
-	xfpm_notify_show_notification (battery->priv->notify, 
-				   _("Xfce power manager"), 
-				   message, 
-				   xfpm_tray_icon_get_icon_name (battery->priv->icon),
-				   10000,
-				   battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ? FALSE : TRUE,
-				   XFPM_NOTIFY_NORMAL,
-				   xfpm_tray_icon_get_tray_icon(battery->priv->icon));
+	if ( notify )
+	{
+	    message = xfpm_battery_get_message_from_battery_state (state, battery->priv->adapter_present );
+	    if ( !message )
+		goto signal;
 	
+	    xfpm_notify_show_notification (battery->priv->notify, 
+				       _("Xfce power manager"), 
+				       message, 
+				       xfpm_tray_icon_get_icon_name (battery->priv->icon),
+				       8000,
+				       battery->priv->type == HAL_DEVICE_TYPE_PRIMARY ? FALSE : TRUE,
+				       XFPM_NOTIFY_NORMAL,
+				       xfpm_tray_icon_get_tray_icon(battery->priv->icon));
+	}
 signal:
 	g_signal_emit (G_OBJECT(battery), signals[BATTERY_STATE_CHANGED], 0, state);
 	TRACE("Emitting signal battery state changed");

Modified: xfce4-power-manager/trunk/src/xfpm-cpu.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-cpu.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/src/xfpm-cpu.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -362,6 +362,7 @@
 			  G_CALLBACK(xfpm_cpu_power_save_settings_changed_cb), cpu);
 	
 	cpu->priv->on_battery = !xfpm_adapter_get_present (cpu->priv->adapter);
+	xfpm_cpu_refresh (cpu);
     }
     
 out:
@@ -375,11 +376,9 @@
 
     cpu = XFPM_CPU(object);
     
-    if ( cpu->priv->conf )
-	g_object_unref (cpu->priv->conf);
+    g_object_unref (cpu->priv->conf);
 	
-    if ( cpu->priv->adapter)
-	g_object_unref (cpu->priv->adapter);
+    g_object_unref (cpu->priv->adapter);
 	
     if ( cpu->priv->bus )
 	dbus_g_connection_unref (cpu->priv->bus);

Modified: xfce4-power-manager/trunk/src/xfpm-dpms.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-dpms.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/src/xfpm-dpms.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -24,19 +24,9 @@
 #endif
 
 #include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
-#endif
-
-#ifdef HAVE_STRING_H
 #include <string.h>
-#endif
 
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
 
@@ -248,6 +238,9 @@
 			  
 	g_signal_connect (dpms->priv->conf, "dpms-settings-changed",
 			  G_CALLBACK (xfpm_dpms_settings_changed_cb), dpms);
+			  
+	dpms->priv->on_battery = !xfpm_adapter_get_present (dpms->priv->adapter);
+	xfpm_dpms_refresh (dpms);
     }
     else
     {

Modified: xfce4-power-manager/trunk/src/xfpm-manager.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-manager.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/src/xfpm-manager.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -35,6 +35,8 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
+#include <libnotify/notify.h>
+
 #include "libxfpm/hal-monitor.h"
 #include "libxfpm/xfpm-string.h"
 #include "libxfpm/xfpm-dbus.h"
@@ -104,6 +106,8 @@
     manager->priv->session_bus   = NULL;
     manager->priv->engine        = NULL;
     manager->priv->monitor       = NULL;
+    
+    notify_init ("xfce4-power-manager");
 }
 
 static void

Modified: xfce4-power-manager/trunk/src/xfpm-supply.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-supply.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/src/xfpm-supply.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -66,6 +66,7 @@
     HalPower      *power;
     GHashTable    *hash;
     
+    gboolean       low_power;
     gboolean       adapter_present;
     gboolean       inhibited;
     guint8         power_management;
@@ -105,7 +106,7 @@
 
     object_class->finalize = xfpm_supply_finalize;
 
-    g_type_class_add_private(klass,sizeof(XfpmSupplyPrivate));
+    g_type_class_add_private (klass, sizeof (XfpmSupplyPrivate));
 }
 
 static void
@@ -121,6 +122,7 @@
     supply->priv->tray    = xfpm_tray_icon_new ();
     supply->priv->inhibit = xfpm_inhibit_new   ();
     supply->priv->inhibited = FALSE;
+    supply->priv->low_power = FALSE;
     
     xfpm_tray_icon_set_visible (supply->priv->tray, FALSE);
     xfpm_tray_icon_set_icon (supply->priv->tray, "gpm-ac-adapter");
@@ -283,7 +285,7 @@
 				      
     xfpm_supply_add_actions_to_notification (supply, battery, n);
     
-    xfpm_notify_present_notification (supply->priv->notify, n, FALSE);
+    xfpm_notify_critical (supply->priv->notify, n);
 }
 
 static void
@@ -300,13 +302,12 @@
 				      _("Xfce power manager"), 
 				      message, 
 				      xfpm_battery_get_icon_name (battery),
-				      15000,
+				      20000,
 				      XFPM_NOTIFY_CRITICAL,
 				      xfpm_battery_get_status_icon (battery));
     
     xfpm_supply_add_actions_to_notification (supply, battery, n);
-    
-    xfpm_notify_present_notification (supply->priv->notify, n, FALSE);
+    xfpm_notify_critical (supply->priv->notify, n);
 }
 
 static void
@@ -318,6 +319,7 @@
     if ( xfpm_supply_on_low_power (supply) )
     {
 	TRACE ("System is running on low power");
+	supply->priv->low_power = TRUE;
 	if ( supply->priv->inhibited )
 	{
 	    xfpm_supply_show_critical_action_inhibited (supply, battery);
@@ -334,21 +336,24 @@
 }
 
 static void
-xfpm_supply_primary_critical (XfpmSupply *supply, XfpmBattery *battery, XfpmBatteryState state)
+xfpm_supply_battery_state_changed_cb (XfpmBattery *battery, XfpmBatteryState state, XfpmSupply *supply)
 {
     if ( state == BATTERY_CHARGE_CRITICAL )
+	xfpm_supply_handle_primary_critical (supply, battery);
+    else if ( supply->priv->low_power == TRUE )
     {
-	xfpm_supply_handle_primary_critical (supply, battery);
+	if ( xfpm_supply_on_low_power (supply) )
+	{
+	    xfpm_supply_handle_primary_critical (supply, battery);
+	}
+	else
+	{
+	    supply->priv->low_power = FALSE;
+	    xfpm_notify_close_critical (supply->priv->notify);
+	}
     }
 }
 
-static void
-xfpm_supply_battery_state_changed_cb (XfpmBattery *battery, XfpmBatteryState state, XfpmSupply *supply)
-{
-    if ( state == BATTERY_CHARGE_CRITICAL )
-	xfpm_supply_primary_critical (supply, battery, state);
-}
-
 static XfpmBattery *
 xfpm_supply_get_battery (XfpmSupply *supply, const gchar *udi)
 {

Modified: xfce4-power-manager/trunk/src/xfpm-xfconf.c
===================================================================
--- xfce4-power-manager/trunk/src/xfpm-xfconf.c	2009-04-04 09:30:12 UTC (rev 7107)
+++ xfce4-power-manager/trunk/src/xfpm-xfconf.c	2009-04-04 11:58:11 UTC (rev 7108)
@@ -75,6 +75,7 @@
     
     XfpmShowIcon     	 show_icon;
     guint                critical_level;
+    gboolean             general_notification;
 };
 
 enum
@@ -115,6 +116,10 @@
 	else
 	    conf->priv->sleep_button = val;
     }
+    else if ( xfpm_strequal (property, GENERAL_NOTIFICATION_CFG) )
+    {
+	conf->priv->general_notification = g_value_get_boolean (value);
+    }
     else if ( xfpm_strequal (property, POWER_SWITCH_CFG ) )
     {
 	str = g_value_get_string (value);
@@ -289,6 +294,8 @@
     
     g_free (str);
     
+    conf->priv->general_notification = xfconf_channel_get_bool (conf->priv->channel, GENERAL_NOTIFICATION_CFG, TRUE);
+    
     str = xfconf_channel_get_string (conf->priv->channel, LID_SWITCH_ON_AC_CFG, "Nothing");
     val = xfpm_shutdown_string_to_int (str);
 
@@ -499,6 +506,8 @@
 	return conf->priv->lock_screen;
     else if ( xfpm_strequal (property, POWER_SAVE_ON_BATTERY ) )
 	return conf->priv->power_save_on_battery;
+    else if ( xfpm_strequal (property, GENERAL_NOTIFICATION_CFG ) )
+	return conf->priv->general_notification;
 #ifdef HAVE_DPMS
     else if ( xfpm_strequal (property, DPMS_SLEEP_MODE ))
 	return conf->priv->sleep_dpms_mode;




More information about the Goodies-commits mailing list