Browse Source

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).
pull/106/head
Rémi Denis-Courmont 6 years ago
parent
commit
0ebb8fa047
  1. 2
      configure.ac
  2. 33
      modules/notify/notify.c

2
configure.ac

@ -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])

33
modules/notify/notify.c

@ -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 );
}
}

Loading…
Cancel
Save