notify: don't depend on any GTK version

If there's one in the process use it. If there's none fallback to
default VLC icon with the old code.

This not only avoids VLC builds depending on GTK, but this should
prevent crashes if GTK 2 is present in the process (e.g. through Qt plugin).
This commit is contained in:
Rémi Denis-Courmont 2020-05-05 18:48:06 +03:00
parent 2b697ae128
commit 0ebb8fa047
2 changed files with 21 additions and 14 deletions

View File

@ -4415,7 +4415,7 @@ AS_IF([test "${enable_osx_notifications}" != "no"], [
dnl
dnl Libnotify notification plugin
dnl
PKG_ENABLE_MODULES_VLC([NOTIFY], [], [libnotify gtk+-3.0], [libnotify notification], [auto])
PKG_ENABLE_MODULES_VLC([NOTIFY], [], [libnotify], [libnotify notification], [auto])
PKG_ENABLE_MODULES_VLC([MEDIALIBRARY], [medialibrary], [medialibrary >= 0.7.1], (medialibrary support), [auto])

View File

@ -35,10 +35,16 @@
#include <vlc_playlist.h>
#include <vlc_url.h>
#include <gtk/gtk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnotify/notify.h>
typedef struct GtkIconTheme GtkIconTheme;
enum GtkIconLookupFlags { dummy = 0x7fffffff };
VLC_WEAK GtkIconTheme *gtk_icon_theme_get_default(void);
VLC_WEAK GdkPixbuf *gtk_icon_theme_load_icon(GtkIconTheme *,
const char *icon_name, int size, enum GtkIconLookupFlags, GError **);
#ifndef NOTIFY_CHECK_VERSION
# define NOTIFY_CHECK_VERSION(x,y,z) 0
#endif
@ -241,23 +247,24 @@ static void on_current_media_changed(vlc_player_t *player,
72, 72, TRUE, &p_error );
free( psz_arturl );
}
else /* else we show state-of-the art logo */
else
/* else we show state-of-the art logo */
if( gtk_icon_theme_get_default != NULL
&& gtk_icon_theme_load_icon != NULL )
{
/* First try to get an icon from the current theme. */
GtkIconTheme* p_theme = gtk_icon_theme_get_default();
pix = gtk_icon_theme_load_icon( p_theme, "vlc", 72, 0, NULL);
if( !pix )
{
/* Load icon from share/ */
GError *p_error = NULL;
char *psz_pixbuf = config_GetSysPath(VLC_SYSDATA_DIR,
}
else
{ /* Load icon from share/ */
GError *p_error = NULL;
char *psz_pixbuf = config_GetSysPath(VLC_SYSDATA_DIR,
"icons/hicolor/48x48/"PACKAGE_NAME".png");
if (psz_pixbuf != NULL)
{
pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
free( psz_pixbuf );
}
if (psz_pixbuf != NULL)
{
pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
free( psz_pixbuf );
}
}