[systemd-devel] [PATCH] buildsys: allow building without libnotify

Kay Sievers kay.sievers at vrfy.org
Thu Nov 25 09:49:57 PST 2010


On Wed, 2010-11-24 at 21:20 +0100, Lennart Poettering wrote:
> On Wed, 24.11.10 11:57, Kay Sievers (kay.sievers at vrfy.org) wrote:
> > On Wed, Nov 24, 2010 at 08:36, Thierry Reding
> > <thierry.reding at avionic-design.de> wrote:
> > > This patch makes the libnotify dependency optional and doesn't build the
> > > systemd-gnome-ask-password-agent utility if libnotify is not available.
> > >
> > > Since libnotify >= 0.7.0 requires gtk+-3.0, this patch may be useful for
> > > environments where upgrading Gtk is not an option.
> > 
> > Yeah, would be good to solve that. Maybe that's the simplest way to do it.
> > 
> > One other option would be to use some #ifdef in vala und also support
> > the still common older libnotify.
> 
> I'd be happy to take a patch which uses vala's new ifdef support to
> make the gtk stuff buildable on both old and new libnotify. If somebody
> cares enough.

Untested and really ugly. :)

Kay


diff --git a/Makefile.am b/Makefile.am
index 471954b..4b1675f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -965,6 +965,11 @@ systemd_gnome_ask_password_agent_VALAFLAGS = \
 	--pkg=libnotify \
 	-g
 
+if LIBNOTIFYNEW
+systemd_gnome_ask_password_agent_VALAFLAGS += \
+	-D LIBNOTIFYNEW
+endif
+
 systemd_gnome_ask_password_agent_LDADD = \
 	$(DBUSGLIB_LIBS) \
 	$(LIBNOTIFY_LIBS) \
diff --git a/configure.ac b/configure.ac
index 5a6f3c7..87262ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,12 +259,16 @@ if test "$have_gtk" = "yes"; then
         AC_SUBST(DBUSGLIB_CFLAGS)
         AC_SUBST(DBUSGLIB_LIBS)
 
-        PKG_CHECK_MODULES(LIBNOTIFY, [ libnotify >= 0.7.0 ])
+        PKG_CHECK_MODULES(LIBNOTIFY, [ libnotify >= 0.7.0 ],
+          [ libnotifynew=yes ],
+          [ PKG_CHECK_MODULES(LIBNOTIFY, [ libnotify ]) ]
+        )
+        AM_CONDITIONAL(LIBNOTIFYNEW, [ test "$libnotifynew" = "yes" ])
         AC_SUBST(LIBNOTIFY_CFLAGS)
         AC_SUBST(LIBNOTIFY_LIBS)
 fi
 
-AM_PROG_VALAC([0.11])
+AM_PROG_VALAC([0.10])
 AC_SUBST(VAPIDIR)
 AM_CONDITIONAL(HAVE_VALAC, test x"$VALAC" != x)
 
diff --git a/src/gnome-ask-password-agent.vala b/src/gnome-ask-password-agent.vala
index 6cab6f9..91b5a6d 100644
--- a/src/gnome-ask-password-agent.vala
+++ b/src/gnome-ask-password-agent.vala
@@ -38,8 +38,13 @@ public class PasswordDialog : Dialog {
                 set_default_response(ResponseType.OK);
                 set_icon_name(icon);
 
+#if LIBNOTIFY_NEW
                 add_button(Stock.CANCEL, ResponseType.CANCEL);
                 add_button(Stock.OK, ResponseType.OK);
+#else
+                add_button(STOCK_CANCEL, ResponseType.CANCEL);
+                add_button(STOCK_OK, ResponseType.OK);
+#endif
 
                 Container content = (Container) get_content_area();
 
@@ -181,7 +186,12 @@ public class MyStatusIcon : StatusIcon {
 
                 set_visible(true);
 
+#if LIBNOTIFY_NEW
                 Notification n = new Notification(title, message, icon);
+#else
+                Notification n = new Notification(title, message, icon, null);
+#endif
+                n.attach_to_status_icon(this);
                 n.set_timeout(5000);
                 n.show();
 
@@ -225,7 +235,11 @@ public class MyStatusIcon : StatusIcon {
 
                 OutputStream stream = new UnixOutputStream(to_process, true);
 
+#if LIBNOTIFYNEW
                 stream.write(password.data, null);
+#else
+                stream.write(password, password.length, null);
+#endif
         }
 }
 



More information about the systemd-devel mailing list