summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--configure.ac39
-rw-r--r--src/Makefile.am13
-rw-r--r--src/pulsecore/proplist-util.c73
-rw-r--r--src/tests/gtk-test.c62
4 files changed, 173 insertions, 14 deletions
diff --git a/configure.ac b/configure.ac
index fbe134c4..e8098398 100644
--- a/configure.ac
+++ b/configure.ac
@@ -721,6 +721,45 @@ AC_SUBST(GLIB20_LIBS)
AC_SUBST(HAVE_GLIB20)
AM_CONDITIONAL([HAVE_GLIB20], [test "x$HAVE_GLIB20" = x1])
+if test "x$HAVE_GLIB20" = x1 ; then
+ AC_DEFINE([HAVE_GLIB], 1, [Have GLIB?])
+fi
+
+#### GTK2 support (optional) ####
+
+AC_ARG_ENABLE([gtk2],
+ AS_HELP_STRING([--disable-gtk2],[Disable optional Gtk+ 2 support]),
+ [
+ case "${enableval}" in
+ yes) gtk2=yes ;;
+ no) gtk2=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --disable-gtk2) ;;
+ esac
+ ],
+ [gtk2=auto])
+
+if test "x${gtk2}" != xno ; then
+ PKG_CHECK_MODULES(GTK20, [ gtk+-2.0 >= 2.4.0 ],
+ HAVE_GTK20=1,
+ [
+ HAVE_GTK20=0
+ if test "x$gtk2" = xyes ; then
+ AC_MSG_ERROR([*** Gtk+ 2 support not found])
+ fi
+ ])
+else
+ HAVE_GTK20=0
+fi
+
+AC_SUBST(GTK20_CFLAGS)
+AC_SUBST(GTK20_LIBS)
+AC_SUBST(HAVE_GTK20)
+AM_CONDITIONAL([HAVE_GTK20], [test "x$HAVE_GTK20" = x1])
+
+if test "x$HAVE_GTK20" = x1 ; then
+ AC_DEFINE([HAVE_GTK], 1, [Have GTK?])
+fi
+
#### GConf support (optional) ####
AC_ARG_ENABLE([gconf],
diff --git a/src/Makefile.am b/src/Makefile.am
index 811b1204..f385c0ab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -308,6 +308,11 @@ TESTS_BINARIES += \
mainloop-test-glib
endif
+if HAVE_GTK20
+TESTS_BINARIES += \
+ gtk-test
+endif
+
if BUILD_TESTS_DEFAULT
noinst_PROGRAMS = $(TESTS_BINARIES)
else
@@ -504,6 +509,11 @@ prioq_test_LDADD = $(AM_LDADD) libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecomm
prioq_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
prioq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
+gtk_test_SOURCES = tests/gtk-test.c
+gtk_test_LDADD = $(AM_LDADD) libpulse.la libpulse-mainloop-glib.la
+gtk_test_CFLAGS = $(AM_CFLAGS) $(GTK20_CFLAGS)
+gtk_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(GTK20_LIBS)
+
###################################
# Common library #
###################################
@@ -571,6 +581,9 @@ libpulsecommon_@PA_MAJORMINORMICRO@_la_CFLAGS = $(AM_CFLAGS)
libpulsecommon_@PA_MAJORMINORMICRO@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
libpulsecommon_@PA_MAJORMINORMICRO@_la_LIBADD = $(AM_LIBADD) $(LIBWRAP_LIBS) $(WINSOCK_LIBS) $(LTLIBICONV)
+# proplist-util.h uses these header files, but not the library itself!
+libpulsecommon_@PA_MAJORMINORMICRO@_la_CFLAGS += $(GLIB20_CFLAGS) $(GTK20_CFLAGS)
+
## Please note that libpulsecommon implicitly also depends on<
## libpulse! i.e. we have a cyclic dependancy here. Which is intended
## since libpulse only includes stable, official APIs, while
diff --git a/src/pulsecore/proplist-util.c b/src/pulsecore/proplist-util.c
index ae8e0802..bdae0e65 100644
--- a/src/pulsecore/proplist-util.c
+++ b/src/pulsecore/proplist-util.c
@@ -34,6 +34,7 @@
extern char **environ;
#endif
+#include <pulse/gccmacro.h>
#include <pulse/proplist.h>
#include <pulse/utf8.h>
#include <pulse/xmalloc.h>
@@ -41,8 +42,64 @@ extern char **environ;
#include <pulsecore/core-util.h>
+#if defined(HAVE_GLIB) && defined(PA_GCC_WEAKREF)
+#include <glib.h>
+static G_CONST_RETURN gchar* _g_get_application_name(void) PA_GCC_WEAKREF(g_get_application_name);
+#endif
+
+#if defined(HAVE_GTK) && defined(PA_GCC_WEAKREF)
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+static G_CONST_RETURN gchar* _gtk_window_get_default_icon_name(void) PA_GCC_WEAKREF(gtk_window_get_default_icon_name);
+static Display *_gdk_display PA_GCC_WEAKREF(gdk_display);
+#endif
+
#include "proplist-util.h"
+static void add_glib_properties(pa_proplist *p) {
+
+#if defined(HAVE_GLIB) && defined(PA_GCC_WEAKREF)
+
+ if (!pa_proplist_contains(p, PA_PROP_APPLICATION_NAME))
+ if (_g_get_application_name) {
+ const gchar *t;
+
+ /* We ignore the tiny race condition here. */
+
+ if ((t = _g_get_application_name()))
+ pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, t);
+ }
+
+#endif
+}
+
+static void add_gtk_properties(pa_proplist *p) {
+
+#if defined(HAVE_GTK) && defined(PA_GCC_WEAKREF)
+
+ if (!pa_proplist_contains(p, PA_PROP_APPLICATION_ICON_NAME))
+ if (_gtk_window_get_default_icon_name) {
+ const gchar *t;
+
+ /* We ignore the tiny race condition here. */
+
+ if ((t = _gtk_window_get_default_icon_name()))
+ pa_proplist_sets(p, PA_PROP_APPLICATION_ICON_NAME, t);
+ }
+
+ if (!pa_proplist_contains(p, PA_PROP_WINDOW_X11_DISPLAY))
+ if (&_gdk_display && _gdk_display) {
+ const char *t;
+
+ /* We ignore the tiny race condition here. */
+
+ if ((t = DisplayString(_gdk_display)))
+ pa_proplist_sets(p, PA_PROP_WINDOW_X11_DISPLAY, t);
+ }
+
+#endif
+}
+
void pa_init_proplist(pa_proplist *p) {
char **e;
const char *pp;
@@ -135,20 +192,8 @@ void pa_init_proplist(pa_proplist *p) {
}
}
-#ifdef RTLD_NOLOAD
- if (!pa_proplist_contains(p, PA_PROP_APPLICATION_NAME)) {
- void *dl;
-
- if ((dl = dlopen("libglib-2.0", RTLD_NOLOAD))) {
- const char *(*_g_get_application_name)(void);
-
- if ((*(void**) &_g_get_application_name = dlsym(dl, "g_get_application_name")))
- pa_proplist_sets(p, PA_PROP_APPLICATION_NAME, _g_get_application_name());
-
- dlclose(dl);
- }
- }
-#endif
+ add_glib_properties(p);
+ add_gtk_properties(p);
if (!pa_proplist_contains(p, PA_PROP_APPLICATION_NAME)) {
const char *t;
diff --git a/src/tests/gtk-test.c b/src/tests/gtk-test.c
new file mode 100644
index 00000000..a2d3e69a
--- /dev/null
+++ b/src/tests/gtk-test.c
@@ -0,0 +1,62 @@
+/***
+ This file is part of PulseAudio.
+
+ PulseAudio is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2 of the License,
+ or (at your option) any later version.
+
+ PulseAudio is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with PulseAudio; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+#include <glib.h>
+
+#include <pulse/context.h>
+#include <pulse/glib-mainloop.h>
+
+int main(int argc, char *argv[]) {
+
+ pa_context *c;
+ pa_glib_mainloop *m;
+ GtkWidget *window;
+ int r;
+
+ gtk_init(&argc, &argv);
+
+ g_set_application_name("This is a test");
+ gtk_window_set_default_icon_name("foobar");
+ g_setenv("PULSE_PROP_media.role", "phone", TRUE);
+
+ window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ gtk_window_set_title(GTK_WINDOW (window), g_get_application_name());
+ gtk_widget_show_all(window);
+
+ m = pa_glib_mainloop_new(NULL);
+ g_assert(m);
+
+ c = pa_context_new(pa_glib_mainloop_get_api(m), NULL);
+ g_assert(c);
+
+ r = pa_context_connect(c, NULL, 0, NULL);
+ g_assert(r == 0);
+
+ gtk_main();
+
+ pa_context_unref(c);
+ pa_glib_mainloop_free(m);
+
+ return 0;
+}