gnome-power-manager r3173 - in trunk: . src



Author: rhughes
Date: Fri Jan 23 11:52:37 2009
New Revision: 3173
URL: http://svn.gnome.org/viewvc/gnome-power-manager?rev=3173&view=rev

Log:
2009-01-23  Richard Hughes  <richard hughsie com>

* configure.ac:
* src/Makefile.am:
* src/gpm-notify.c: (gpm_notify_cancel),
(notify_general_clicked_cb), (gpm_notify_perhaps_recall),
(gpm_notify_low_capacity), (gpm_notify_inhibit_lid),
(gpm_notify_fully_charged_primary),
(gpm_notify_discharging_primary), (gpm_notify_discharging_ups),
(gpm_notify_sleep_failed), (gpm_notify_finalize),
(gpm_notify_init):
Now libnotify is a external dependency, remove the compat code.


Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/gpm-notify.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Fri Jan 23 11:52:37 2009
@@ -162,6 +162,10 @@
 AC_SUBST(XRANDR_CFLAGS)
 AC_SUBST(XRANDR_LIBS)
 
+PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
+AC_SUBST(LIBNOTIFY_CFLAGS)
+AC_SUBST(LIBNOTIFY_LIBS)
+
 AC_PATH_PROG(GCONFTOOL, gconftool-2)
 AM_GCONF_SOURCE_2
 
@@ -392,20 +396,6 @@
 AC_SUBST(DBUS_SERVICES_DIR)
 
 dnl ---------------------------------------------------------------------------
-dnl - Is a new enough libnotify available?
-dnl ---------------------------------------------------------------------------
-if $PKG_CONFIG --atleast-version $LIBNOTIFY_REQUIRED libnotify; then
-   have_libnotify=yes
-   PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
-   AC_SUBST(LIBNOTIFY_CFLAGS)
-   AC_SUBST(LIBNOTIFY_LIBS)
-   AC_DEFINE(HAVE_LIBNOTIFY, 1, [Building with libnotify support]) 
-else
-   have_libnotify=no
-fi
-AM_CONDITIONAL([HAVE_LIBNOTIFY], [test $have_libnotify = yes])
-
-dnl ---------------------------------------------------------------------------
 dnl - Is unique available?
 dnl ---------------------------------------------------------------------------
 if $PKG_CONFIG --atleast-version $UNIQUE_REQUIRED unique-1.0; then
@@ -697,7 +687,6 @@
         datadir:                   ${datadir}
         compiler:                  ${CC}
         cflags:                    ${CFLAGS}
-        libnotify support:         ${have_libnotify}
         unique support:            ${have_unique}
         Building extra applets:    ${enable_applets}
         DPMS support:              ${have_dpms}

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Fri Jan 23 11:52:37 2009
@@ -247,16 +247,11 @@
 	$(DBUS_LIBS)					\
 	$(XRANDR_LIBS)					\
 	$(CANBERRA_LIBS)				\
+	$(LIBNOTIFY_LIBS)				\
 	$(GPM_EXTRA_LIBS)				\
 	$(LOCAL_LIBHAL_LIBS)				\
 	$(NULL)
 
-if HAVE_LIBNOTIFY
-gnome_power_manager_LDADD +=				\
-	$(LIBNOTIFY_LIBS)				\
-	$(NULL)
-endif
-
 if HAVE_DK_POWER
 gnome_power_manager_LDADD +=				\
 	$(DEVKIT_POWER_LIBS)

Modified: trunk/src/gpm-notify.c
==============================================================================
--- trunk/src/gpm-notify.c	(original)
+++ trunk/src/gpm-notify.c	Fri Jan 23 11:52:37 2009
@@ -39,6 +39,7 @@
 #include <dbus/dbus-glib.h>
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
+#include <libnotify/notify.h>
 
 #include "gpm-ac-adapter.h"
 #include "gpm-common.h"
@@ -46,10 +47,6 @@
 #include "gpm-notify.h"
 #include "gpm-stock-icons.h"
 
-#ifdef HAVE_LIBNOTIFY
-#include <libnotify/notify.h>
-#endif
-
 #define GPM_NOTIFY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GPM_TYPE_NOTIFY, GpmNotifyPrivate))
 #define QUIRK_WEBSITE	"http://people.freedesktop.org/~hughsient/quirk/";
 
@@ -60,9 +57,7 @@
 	GtkStatusIcon		*status_icon;
 	gchar			*internet_url;
 	const gchar		*do_not_show_gconf;
-#ifdef HAVE_LIBNOTIFY
 	NotifyNotification	*libnotify;
-#endif
 };
 
 enum {
@@ -75,7 +70,6 @@
 
 G_DEFINE_TYPE (GpmNotify, gpm_notify, G_TYPE_OBJECT)
 
-#ifdef HAVE_LIBNOTIFY
 /**
  * notify_closed_cb:
  * @notify: our libnotify instance
@@ -166,85 +160,6 @@
 	return TRUE;
 }
 
-#else
-
-/**
- * gpm_notify_show:
- *
- * Stub.
- **/
-static gboolean
-gpm_notify_show (GpmNotify *notify)
-{
-	return TRUE;
-}
-
-/**
- * gpm_notify_create:
- *
- * Stub.
- **/
-gboolean
-gpm_notify_create (GpmNotify 	 *notify,
-	 	   const gchar	 *title,
-		   const gchar	 *content,
-		   GpmNotifyTimeout timeout,
-		   const gchar	 *msgicon,
-		   GpmNotifyUrgency urgency)
-{
-	gpm_notify_display (notify, title, content, timeout, msgicon, urgency);
-	return TRUE;
-}
-
-/**
- * gpm_notify_display:
- * @notify: This class instance
- * @title: The title, e.g. "Battery Low"
- * @content: The contect, e.g. "17 minutes remaining"
- * @timeout: The time we should remain on screen in seconds
- * @msgicon: The icon to display, or NULL, e.g. GPM_STOCK_UPS_CHARGING_080
- * @urgency: The urgency type, e.g. GPM_NOTIFY_URGENCY_CRITICAL
- *
- * Does a gtk messagebox dialogue.
- * Return value: success
- **/
-gboolean
-gpm_notify_display (GpmNotify 	 *notify,
-	 	    const gchar	 *title,
-		    const gchar	 *content,
-		    GpmNotifyTimeout timeout,
-		    const gchar	 *msgicon,
-		    GpmNotifyUrgency urgency)
-{
-	GtkWidget     *dialog;
-	GtkMessageType msg_type;
-
-	if (urgency == GPM_NOTIFY_URGENCY_CRITICAL) {
-		msg_type = GTK_MESSAGE_WARNING;
-	} else {
-		msg_type = GTK_MESSAGE_INFO;
-	}
-
-	dialog = gtk_message_dialog_new_with_markup (NULL,
-						     GTK_DIALOG_DESTROY_WITH_PARENT,
-						     msg_type,
-						     GTK_BUTTONS_CLOSE,
-						     "<span size='larger'><b>%s</b></span>",
-						     GPM_NAME);
-
-	gtk_message_dialog_format_secondary_markup (GTK_MESSAGE_DIALOG (dialog), "%s", content);
-
-	g_signal_connect_swapped (dialog,
-				  "response",
-				  G_CALLBACK (gtk_widget_destroy),
-				  dialog);
-
-	gtk_window_present (GTK_WINDOW (dialog));
-
-	return TRUE;
-}
-#endif
-
 /**
  * gpm_notify_cancel:
  * @notify: This class instance
@@ -256,13 +171,11 @@
 {
 	g_return_if_fail (GPM_IS_NOTIFY (notify));
 
-#ifdef HAVE_LIBNOTIFY
 	if (notify->priv->libnotify != NULL) {
 		notify_notification_close (notify->priv->libnotify, NULL);
 		g_object_unref (notify->priv->libnotify);
 		notify->priv->libnotify = NULL;
 	}
-#endif
 }
 
 /**
@@ -297,7 +210,6 @@
 	notify->priv->status_icon = status_icon;
 }
 
-#ifdef HAVE_LIBNOTIFY
 static void
 notify_general_clicked_cb (NotifyNotification *libnotify,
                            gchar *action, GpmNotify *notify)
@@ -347,7 +259,6 @@
 	}
 	egg_debug ("action %s unknown", action);
 }
-#endif
 
 /**
  * gpm_notify_perhaps_recall:
@@ -379,7 +290,6 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->internet_url = g_strdup (website);
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "visit-website",
@@ -392,7 +302,6 @@
 	                                 _("Do not show me this again"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	g_free (msg);
@@ -425,14 +334,12 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_LOW_CAPACITY;
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "dont-show-again",
 	                                 _("Do not show me this again"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	g_free (msg);
@@ -465,14 +372,12 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_INHIBIT_LID;
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "dont-show-again",
 	                                 _("Do not show me this again"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	g_free (msg);
@@ -496,14 +401,12 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_FULLY_CHARGED;
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "dont-show-again",
 	                                 _("Do not show me this again"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	return TRUE;
@@ -526,14 +429,12 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_DISCHARGING;
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "dont-show-again",
 	                                 _("Do not show me this again"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	return TRUE;
@@ -556,14 +457,12 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_DISCHARGING;
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "dont-show-again",
 	                                 _("Do not show me this again"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	return TRUE;
@@ -592,7 +491,6 @@
 			   GPM_NOTIFY_URGENCY_CRITICAL);
 
 	/* add extra stuff */
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->do_not_show_gconf = GPM_CONF_NOTIFY_SLEEP_FAILED;
 	notify_notification_add_action  (notify->priv->libnotify,
 	                                 "dont-show-again",
@@ -612,7 +510,6 @@
 	                                 _("Visit quirk website"),
 	                                 (NotifyActionCallback) notify_general_clicked_cb,
 	                                 notify, NULL);
-#endif
 
 	gpm_notify_show (notify);
 	return TRUE;
@@ -630,15 +527,11 @@
 	notify = GPM_NOTIFY (object);
 	g_return_if_fail (notify->priv != NULL);
 
-#ifdef HAVE_LIBNOTIFY
-	if (notify->priv->libnotify != NULL) {
+	if (notify->priv->libnotify != NULL)
 		notify_notification_close (notify->priv->libnotify, NULL);
-	}
-#endif
 	g_object_unref (notify->priv->conf);
-	if (notify->priv->ac_adapter != NULL) {
+	if (notify->priv->ac_adapter != NULL)
 		g_object_unref (notify->priv->ac_adapter);
-	}
 
 	G_OBJECT_CLASS (gpm_notify_parent_class)->finalize (object);
 }
@@ -677,10 +570,8 @@
 			  G_CALLBACK (ac_adapter_changed_cb), notify);
 
 	notify->priv->status_icon = NULL;
-#ifdef HAVE_LIBNOTIFY
 	notify->priv->libnotify = NULL;
 	notify_init (GPM_NAME);
-#endif
 }
 
 /**



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]