[Pkg-utopia-commits] r469 - in packages/unstable/gnome-power-manager/debian: . patches

Riccardo Setti giskard-guest at costa.debian.org
Fri Jan 13 16:33:39 UTC 2006


Author: giskard-guest
Date: 2006-01-13 16:33:39 +0000 (Fri, 13 Jan 2006)
New Revision: 469

Added:
   packages/unstable/gnome-power-manager/debian/patches/
   packages/unstable/gnome-power-manager/debian/patches/01_port_to_the_new_libnotify.patch
Modified:
   packages/unstable/gnome-power-manager/debian/changelog
Log:
added a patch that port gpm to the new libnotify API

Modified: packages/unstable/gnome-power-manager/debian/changelog
===================================================================
--- packages/unstable/gnome-power-manager/debian/changelog	2006-01-13 16:04:28 UTC (rev 468)
+++ packages/unstable/gnome-power-manager/debian/changelog	2006-01-13 16:33:39 UTC (rev 469)
@@ -3,7 +3,9 @@
   * First Debian release.
   * Initial upload to Debian (closes: #303600)
   * based on the ubuntu package.
- 
+  * src/gpm-libnotify.{c,h}:
+  - ported to new libnotify api (taken from cvs)
+
  -- Riccardo Setti <giskard at autistici.org>  Fri, 13 Jan 2006 15:53:43 +0100
 
 gnome-power-manager (0.3.1-0ubuntu4) dapper; urgency=low

Added: packages/unstable/gnome-power-manager/debian/patches/01_port_to_the_new_libnotify.patch
===================================================================
--- packages/unstable/gnome-power-manager/debian/patches/01_port_to_the_new_libnotify.patch	2006-01-13 16:04:28 UTC (rev 468)
+++ packages/unstable/gnome-power-manager/debian/patches/01_port_to_the_new_libnotify.patch	2006-01-13 16:33:39 UTC (rev 469)
@@ -0,0 +1,288 @@
+--- gnome-power-manager-0.3.1.orig/src/gpm-prefs.c
++++ gnome-power-manager-0.3.1/src/gpm-prefs.c
+@@ -737,7 +737,7 @@
+ 		callback_gconf_key_changed, widget, NULL, NULL);
+ 
+ 	/* Initialise libnotify, if compiled in. */
+-	if (!libnotify_init (NICENAME))
++	if (!gpm_libnotify_init (NICENAME))
+ 		g_error ("Cannot initialise libnotify!");
+ 
+ 	/* check if we have GNOME Screensaver, but have disabled dpms */
+--- gnome-power-manager-0.3.1.orig/src/gpm-libnotify.c
++++ gnome-power-manager-0.3.1/src/gpm-libnotify.c
+@@ -42,14 +42,45 @@
+ #include <gnome.h>
+ #include "gpm-common.h"
+ #include "gpm-libnotify.h"
+-#ifdef HAVE_LIBNOTIFY
++#include "gpm-stock-icons.h"
++
++#if defined(HAVE_LIBNOTIFY)
+ #include <libnotify/notify.h>
+ #endif
+ 
+-#ifdef HAVE_LIBNOTIFY
++
++#if (LIBNOTIFY_VERSION_MINOR == 2)
+ static NotifyHandle *globalnotify = NULL;
++#elif (LIBNOTIFY_VERSION_MINOR >= 3)
++static NotifyNotification *globalnotify;
+ #endif
+ 
++/** Gets the position to "point" to (i.e. bottom middle of the icon)
++ *
++ *  @param	widget		the GtkWidget
++ *  @param	x		X co-ordinate return
++ *  @param	y		Y co-ordinate return
++ *  @return			Success, return FALSE when no icon present
++ */
++static gboolean
++get_widget_position (GtkWidget *widget, gint *x, gint *y)
++{
++	/* assertion checks */
++	g_assert (widget);
++	g_assert (x);
++	g_assert (y);
++
++	gdk_window_get_origin (GDK_WINDOW (widget->window), x, y);
++
++	*x += widget->allocation.x;
++	*y += widget->allocation.y;
++	*x += widget->allocation.width / 2;
++	*y += widget->allocation.height;
++
++	g_debug ("widget position x=%i, y=%i", *x, *y);
++	return TRUE;
++}
++
+ /** Convenience function to call libnotify
+  *
+  *  @param	subject		The subject text, e.g. "Battery Low"
+@@ -62,9 +93,31 @@
+  *		g_debug functions depending on the urgency.
+  */
+ gboolean
+-libnotify_event (const gchar *subject, const gchar *content, const LibNotifyEventType urgency, GtkWidget *point)
++gpm_libnotify_event (const gchar *subject, const gchar *content, const LibNotifyEventType urgency, GtkWidget *point)
+ {
+-#ifdef HAVE_LIBNOTIFY
++#if (LIBNOTIFY_VERSION_MINOR >= 3)
++	gint x, y;
++	globalnotify = notify_notification_new (subject, content, "gnome-dev-battery", NULL);
++
++        notify_notification_set_timeout (globalnotify, 5000);
++
++	if (point) {
++		get_widget_position (point, &x, &y);
++		notify_notification_set_hint_int32 (globalnotify, "x", x);
++		notify_notification_set_hint_int32 (globalnotify, "y", y);
++	}
++
++	if (urgency == LIBNOTIFY_URGENCY_CRITICAL)
++		g_warning ("libnotify: %s : %s", NICENAME, content);
++	else
++		g_debug ("libnotify: %s : %s", NICENAME, content);
++
++	if (!notify_notification_show_and_forget (globalnotify, NULL)) {
++		g_warning ("failed to send notification (%s)", content);
++		return FALSE;
++	}
++	return TRUE;
++#elif (LIBNOTIFY_VERSION_MINOR == 2)
+ 	NotifyIcon *icon = NULL;
+ 	NotifyHints *hints = NULL;
+ 	gint x, y;
+@@ -75,8 +128,8 @@
+ 	if (point) {
+ 		get_widget_position (point, &x, &y);
+ 		hints = notify_hints_new();
+-		notify_hints_set_int (hints, "x", x+12);
+-		notify_hints_set_int (hints, "y", y+24);
++		notify_hints_set_int (hints, "x", x);
++		notify_hints_set_int (hints, "y", y);
+ 	}
+ 
+ 	/* echo to terminal too */
+@@ -140,11 +193,15 @@
+  *  @return			If we removed the message.
+  */
+ gboolean
+-libnotify_clear (void)
++gpm_libnotify_clear (void)
+ {
+-#ifdef HAVE_LIBNOTIFY
++#if (LIBNOTIFY_VERSION_MINOR == 2)
+ 	if (globalnotify)
+ 		notify_close (globalnotify);
++#elif (LIBNOTIFY_VERSION_MINOR >= 3)
++	GError *error;
++	if (globalnotify)
++		notify_notification_close (globalnotify, &error);
+ #endif
+ 	return TRUE;
+ }
+@@ -156,20 +213,18 @@
+  *
+  *  @note	This function must be called before any calls to
+  *		libnotify_event are made.
+- *
+- *  @todo	When libnotify has settled down we will switch to runtime
+- *		detection like we do for gnome-screensaver
+  */
+ gboolean
+-libnotify_init (const gchar *nicename)
++gpm_libnotify_init (const gchar *nicename)
+ {
+ 	gboolean ret = TRUE;
+-
+-	/* assertion checks */
+ 	g_assert (nicename);
+-#ifdef HAVE_LIBNOTIFY
++#if (LIBNOTIFY_VERSION_MINOR == 2)
+ 	globalnotify = NULL;
+ 	ret = notify_glib_init (nicename, NULL);
++#elif (LIBNOTIFY_VERSION_MINOR >= 3)
++	globalnotify = NULL;
++	ret = notify_init (nicename);
+ #endif
+ 	return ret;
+ }
+--- gnome-power-manager-0.3.1.orig/src/gpm-common.h
++++ gnome-power-manager-0.3.1/src/gpm-common.h
+@@ -70,8 +70,6 @@
+ 
+ void g_log_ignore (const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data);
+ 
+-gboolean get_widget_position (GtkWidget *widget, gint *x, gint *y);
+-
+ ActionType convert_string_to_policy (const gchar *gconfstring);
+ DeviceType convert_haltype_to_batttype (const gchar *type);
+ gchar *convert_policy_to_string (gint value);
+--- gnome-power-manager-0.3.1.orig/src/gpm-main.c
++++ gnome-power-manager-0.3.1/src/gpm-main.c
+@@ -249,9 +249,9 @@
+ 
+ 	/* do the sleep type */
+ 	if (toDisk)
+-		hal_hibernate ();
++		g_spawn_command_line_async("gdm-signal --hibernate",NULL);
+ 	else
+-		hal_suspend (0);
++		g_spawn_command_line_async("gdm-signal --suspend",NULL);
+ 	/* Bring NetworkManager back to life */
+ 	gpm_networkmanager_wake ();
+ 
+@@ -381,7 +381,7 @@
+ 				_("You have approximately <b>%s</b> of remaining battery life (%i%%). "
+ 				  "Plug in your AC Adapter to avoid losing data."),
+ 				remaining, newCharge);
+-			libnotify_event (_("Battery Critically Low"),
++			gpm_libnotify_event (_("Battery Critically Low"),
+ 					 message,
+ 					 LIBNOTIFY_URGENCY_CRITICAL,
+ 					 get_notification_icon ());
+@@ -401,7 +401,7 @@
+ 			_("You have approximately <b>%s</b> of remaining battery life (%i%%). "
+ 			  "Plug in your AC Adapter to avoid losing data."),
+ 			remaining, newCharge);
+-		libnotify_event (_("Battery Low"),
++		gpm_libnotify_event (_("Battery Low"),
+ 			message,
+ 			LIBNOTIFY_URGENCY_CRITICAL,
+ 			get_notification_icon ());
+@@ -443,7 +443,7 @@
+ 	if (strcmp (key, "ac_adapter.present") == 0) {
+ 		hal_device_get_bool (udi, key, &onAcPower);
+ 		if (!onAcPower) {
+-			libnotify_event (_("AC Power Unplugged"),
++			gpm_libnotify_event (_("AC Power Unplugged"),
+ 					_("The AC Power has been unplugged. "
+ 					"The system is now using battery power."),
+ 					LIBNOTIFY_URGENCY_NORMAL,
+@@ -454,7 +454,7 @@
+ 			 * for where we add back the ac_adapter before
+ 			 * the "AC Power unplugged" message times out.
+ 			 */
+-			libnotify_clear ();
++			gpm_libnotify_clear ();
+ 			action_policy_do (ACTION_NOW_MAINSPOWERED);
+ 		}
+ 		/* update all states */
+@@ -515,7 +515,7 @@
+ 		hal_device_get_int (udi, key, &sds->percentageCharge);
+ 		/* give notification @100% */
+ 		if (sd->type == BATT_PRIMARY && sds->percentageCharge == 100) {
+-			libnotify_event (_("Battery Charged"), _("Your battery is now fully charged"),
++			gpm_libnotify_event (_("Battery Charged"), _("Your battery is now fully charged"),
+ 					 LIBNOTIFY_URGENCY_LOW,
+ 					 get_notification_icon ());
+ 		}
+@@ -723,7 +723,7 @@
+ 
+ 
+ 	/* Initialise libnotify, if compiled in. */
+-	if (!libnotify_init (NICENAME))
++	if (!gpm_libnotify_init (NICENAME))
+ 		g_error ("Cannot initialise libnotify!");
+ 
+ 	/* initialise stock icons */
+--- gnome-power-manager-0.3.1.orig/src/gpm-common.c
++++ gnome-power-manager-0.3.1/src/gpm-common.c
+@@ -62,31 +62,6 @@
+ 	return BATT_PRIMARY;
+ }
+ 
+-/** Gets the position to "point" to (i.e. center of the icon)
+- *
+- *  @param	widget		the GtkWidget
+- *  @param	x		X co-ordinate return
+- *  @param	y		Y co-ordinate return
+- *  @return			Success, return FALSE when no icon present
+- */
+-gboolean
+-get_widget_position (GtkWidget *widget, gint *x, gint *y)
+-{
+-	GdkPixbuf* pixbuf = NULL;
+-
+-	/* assertion checks */
+-	g_assert (widget);
+-	g_assert (x);
+-	g_assert (y);
+-
+-	gdk_window_get_origin (GDK_WINDOW (widget->window), x, y);
+-	pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (widget));
+-	*x += (gdk_pixbuf_get_width (pixbuf) / 2);
+-	*y += gdk_pixbuf_get_height (pixbuf);
+-	g_debug ("widget position x=%i, y=%i", *x, *y);
+-	return TRUE;
+-}
+-
+ /** Runs a tool in BINDIR
+  *
+  *  @param	program		The program name
+--- gnome-power-manager-0.3.1.orig/src/gpm-libnotify.h
++++ gnome-power-manager-0.3.1/src/gpm-libnotify.h
+@@ -34,7 +34,6 @@
+ /** Set the timeout of the libnotify notifications */
+ #define NOTIFY_TIMEOUT			5
+ 
+-
+ /** The libnotify urgency type */
+ typedef enum {
+ 	LIBNOTIFY_URGENCY_CRITICAL = 1,	/**< Critical warning!	*/
+@@ -42,9 +41,9 @@
+ 	LIBNOTIFY_URGENCY_LOW = 3	/**< Low urgency	*/
+ } LibNotifyEventType;
+ 
+-gboolean libnotify_clear (void);
+-gboolean libnotify_init (const gchar *nicename);
+-gboolean libnotify_event (const gchar *subject, const gchar *content, const LibNotifyEventType urgency, GtkWidget *point);
++gboolean gpm_libnotify_clear (void);
++gboolean gpm_libnotify_init (const gchar *nicename);
++gboolean gpm_libnotify_event (const gchar *subject, const gchar *content, const LibNotifyEventType urgency, GtkWidget *point);
+ 
+ #endif	/* _GPMLIBNOTIFY_H */
+ /** @} */
+ # Local variables:
+ # eval: (add-hook 'write-file-hooks 'time-stamp)




More information about the Pkg-utopia-commits mailing list