From a5f06dc69e0696c0f64246ee2debaa5d504c1c10 Mon Sep 17 00:00:00 2001
From: Stefano Karapetsas <stefano@karapetsas.com>
Date: Thu, 28 Feb 2013 00:05:01 +0100
Subject: [PATCH] Use libnotify instead of libmatenotify Fix some things in
 leave message feature

---
 configure.ac       | 20 ++++++++++----------
 src/Makefile.am    |  4 ++--
 src/gs-lock-plug.c | 22 +++++++++++-----------
 3 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/configure.ac b/configure.ac
index feb712d0..36c8e4a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -945,18 +945,18 @@ if test "x$have_libmatekbdui" = "xyes"; then
 fi
 
 dnl ---------------------------------------------------------------------------
-dnl libmatenotify
+dnl libnotify
 dnl ---------------------------------------------------------------------------
 
-have_libmatenotify=no
-AC_ARG_WITH(libmatenotify,[  --without-libmatenotify         disable libmatenotify support])
-if test x$with_libmatenotify != xno; then
-	PKG_CHECK_MODULES(LIBMATENOTIFY, libmatenotify, have_libmatenotify=yes, have_libmatenotify=no)
+have_libnotify=no
+AC_ARG_WITH(libnotify,[  --without-libnotify         disable libnotify support])
+if test x$with_libnotify != xno; then
+	PKG_CHECK_MODULES(LIBNOTIFY, libnotify > 0.7.0, have_libnotify=yes, have_libnotify=no)
 fi
-if test "x$have_libmatenotify" = "xyes"; then
-  AC_SUBST(LIBMATENOTIFY_CFLAGS)
-  AC_SUBST(LIBMATENOTIFY_LIBS)
-  AC_DEFINE(WITH_LIBMATENOTIFY, 1, [Define for libmatenotify support])
+if test "x$have_libnotify" = "xyes"; then
+  AC_SUBST(LIBNOTIFY_CFLAGS)
+  AC_SUBST(LIBNOTIFY_LIBS)
+  AC_DEFINE(WITH_LIBNOTIFY, 1, [Define for libnotify support])
 fi
 
 dnl ---------------------------------------------------------------------------
@@ -1145,7 +1145,7 @@ echo "
         Show keyboard indicator:  ${with_kbd_layout_indicator}
         systemd support:          ${use_systemd}
         ConsoleKit support:       ${use_console_kit}
-        libmatenotify support:    ${have_libmatenotify}
+        libnotify support:        ${have_libnotify}
         PAM support:              ${have_pam}
         Have shadow passwords:    ${have_shadow}
         Have adjunct shadow:      ${have_shadow_adjunct}
diff --git a/src/Makefile.am b/src/Makefile.am
index 272b931f..60aa6ea4 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,7 +30,7 @@ INCLUDES =							\
 	$(DEBUG_CFLAGS)						\
 	$(DBUS_CFLAGS)						\
 	$(LIBMATEKBDUI_CFLAGS)					\
-	$(LIBMATENOTIFY_CFLAGS)					\
+	$(LIBNOTIFY_CFLAGS)					\
 	$(SYSTEMD_CFLAGS)					\
 	$(NULL)
 
@@ -155,7 +155,7 @@ mate_screensaver_dialog_LDADD =	\
 	$(SAVER_LIBS)			\
 	$(AUTH_LIBS)			\
 	$(LIBMATEKBDUI_LIBS)		\
-	$(LIBMATENOTIFY_LIBS)		\
+	$(LIBNOTIFY_LIBS)		\
 	$(NULL)
 
 BUILT_SOURCES = 		\
diff --git a/src/gs-lock-plug.c b/src/gs-lock-plug.c
index dff9a5a1..7f95adce 100644
--- a/src/gs-lock-plug.c
+++ b/src/gs-lock-plug.c
@@ -43,8 +43,8 @@
 #include <libmatekbd/matekbd-indicator.h>
 #endif
 
-#ifdef WITH_LIBMATENOTIFY
-#include <libmatenotify/notify.h>
+#ifdef WITH_LIBNOTIFY
+#include <libnotify/notify.h>
 #endif
 
 #include "gs-lock-plug.h"
@@ -1183,7 +1183,7 @@ static void
 submit_note (GtkButton  *button,
              GSLockPlug *plug)
 {
-#ifdef WITH_LIBMATENOTIFY
+#ifdef WITH_LIBNOTIFY
 	char               *text;
 	char                summary[128];
 	char               *escaped_text;
@@ -1204,8 +1204,7 @@ submit_note (GtkButton  *button,
 	tmp = localtime (&t);
 	strftime (summary, 128, "%X", tmp);
 
-	notify_init ("mate-screensaver-dialog");
-	note = notify_notification_new (summary, escaped_text, NULL, NULL);
+	note = notify_notification_new (summary, escaped_text, NULL);
 	notify_notification_set_timeout (note, NOTIFY_EXPIRES_NEVER);
 	notify_notification_show (note, NULL);
 	g_object_unref (note);
@@ -1214,7 +1213,7 @@ submit_note (GtkButton  *button,
 	g_free (escaped_text);
 
 	gs_lock_plug_response (plug, GS_LOCK_PLUG_RESPONSE_CANCEL);
-#endif /* WITH_LIBMATENOTIFY */
+#endif /* WITH_LIBNOTIFY */
 }
 
 static void
@@ -1882,10 +1881,7 @@ on_note_text_buffer_changed (GtkTextBuffer *buffer,
 	int len;
 
 	len = gtk_text_buffer_get_char_count (buffer);
-	if (len > NOTE_BUFFER_MAX_CHARS)
-	{
-		gtk_widget_set_sensitive (plug->priv->note_text_view, FALSE);
-	}
+	gtk_widget_set_sensitive (plug->priv->note_ok_button, len <= NOTE_BUFFER_MAX_CHARS);
 }
 
 static void
@@ -1897,7 +1893,8 @@ gs_lock_plug_init (GSLockPlug *plug)
 
 	clear_clipboards (plug);
 
-#ifdef WITH_LIBMATENOTIFY
+#ifdef WITH_LIBNOTIFY
+	notify_init ("mate-screensaver-dialog");
 	plug->priv->leave_note_enabled = TRUE;
 #else
 	plug->priv->leave_note_enabled = FALSE;
@@ -2084,6 +2081,9 @@ gs_lock_plug_finalize (GObject *object)
 
 	remove_response_idle (plug);
 	remove_cancel_timeout (plug);
+#ifdef WITH_LIBNOTIFY
+	notify_uninit ();
+#endif
 
 	G_OBJECT_CLASS (gs_lock_plug_parent_class)->finalize (object);
 }
-- 
GitLab