You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
3.5 KiB
102 lines
3.5 KiB
10 months ago
|
From c25400b146f7a7b3b4a29c0efa4daee9d1c49633 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net>
|
||
|
Date: Tue, 5 May 2020 18:48:06 +0300
|
||
|
Subject: [PATCH] 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).
|
||
|
|
||
|
Adapted to vlc-3.x by "Nicolas Chauvet <kwizart@gmail.com>"
|
||
|
---
|
||
|
configure.ac | 2 +-
|
||
|
modules/notify/notify.c | 38 ++++++++++++++++++++++----------------
|
||
|
2 files changed, 23 insertions(+), 17 deletions(-)
|
||
|
|
||
|
diff --git a/configure.ac b/configure.ac
|
||
|
index 09ac250ff483..a3ef64318561 100644
|
||
|
--- a/configure.ac
|
||
|
+++ b/configure.ac
|
||
|
@@ -4206,7 +4206,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])
|
||
|
|
||
|
dnl
|
||
|
dnl libplacebo support
|
||
|
diff --git a/modules/notify/notify.c b/modules/notify/notify.c
|
||
|
index bd6bba6c32c8..20b7c4acb761 100644
|
||
|
--- a/modules/notify/notify.c
|
||
|
+++ b/modules/notify/notify.c
|
||
|
@@ -36,10 +36,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 };
|
||
|
+
|
||
|
+__attribute__((weak)) GtkIconTheme *gtk_icon_theme_get_default(void);
|
||
|
+__attribute__((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
|
||
|
@@ -222,30 +228,30 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
|
||
|
GError *p_error = NULL;
|
||
|
pix = gdk_pixbuf_new_from_file_at_scale( psz_arturl,
|
||
|
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 )
|
||
|
+ }
|
||
|
+ else
|
||
|
+ { /* Load icon from share/ */
|
||
|
+ GError *p_error = NULL;
|
||
|
+ char *psz_pixbuf;
|
||
|
+ char *psz_data = config_GetDataDir();
|
||
|
+ if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 )
|
||
|
{
|
||
|
- /* Load icon from share/ */
|
||
|
- GError *p_error = NULL;
|
||
|
- char *psz_pixbuf;
|
||
|
- char *psz_data = config_GetDataDir();
|
||
|
- if( asprintf( &psz_pixbuf, "%s/icons/48x48/vlc.png", psz_data ) >= 0 )
|
||
|
- {
|
||
|
- pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
|
||
|
- free( psz_pixbuf );
|
||
|
- }
|
||
|
- free( psz_data );
|
||
|
+ pix = gdk_pixbuf_new_from_file( psz_pixbuf, &p_error );
|
||
|
+ free( psz_pixbuf );
|
||
|
}
|
||
|
+ free( psz_data );
|
||
|
}
|
||
|
|
||
|
- free( psz_arturl );
|
||
|
-
|
||
|
/* we need to replace '&' with '&' because '&' is a keyword of
|
||
|
* notification-daemon parser */
|
||
|
const int i_len = strlen( psz_tmp );
|
||
|
--
|
||
|
2.25.4
|
||
|
|