[vlc-devel] commit: Do not notifications actions if the server does not support it ( Cody Russell )

git version control git at videolan.org
Wed Feb 25 17:36:41 CET 2009


vlc | branch: 0.9-bugfix | Cody Russell <bratsche at gnome.org> | Wed Feb 25 18:35:36 2009 +0200| [dbc1d7a69163e430f8452efeb8f7206c8ef2d7ba] | committer: Rémi Denis-Courmont 

Do not notifications actions if the server does not support it

Signed-off-by: Rémi Denis-Courmont <rdenis at simphalempin.com>
(cherry picked from commit b632da4ef211e214f3a1044d40bb43bf7b666b12)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=dbc1d7a69163e430f8452efeb8f7206c8ef2d7ba
---

 modules/misc/notify/notify.c |   41 ++++++++++++++++++++++++++++++++++++-----
 1 files changed, 36 insertions(+), 5 deletions(-)

diff --git a/modules/misc/notify/notify.c b/modules/misc/notify/notify.c
index ccfb05a..63f918f 100644
--- a/modules/misc/notify/notify.c
+++ b/modules/misc/notify/notify.c
@@ -272,6 +272,35 @@ static void Prev( NotifyNotification *notification, gchar *psz, gpointer p )
     pl_Release( ((vlc_object_t*) p) );
 }
 
+static gboolean
+can_support_actions ()
+{
+    static gboolean supports_actions = FALSE;
+    static gboolean have_checked = FALSE;
+
+    if( !have_checked ) {
+        GList *caps = NULL;
+        GList *c;
+
+        have_checked = TRUE;
+
+        caps = notify_get_server_caps ();
+        if( caps != NULL ) {
+            for( c = caps; c != NULL; c = c->next ) {
+                if( strcmp( (char*)c->data, "actions" ) == 0 ) {
+                    supports_actions = TRUE;
+                    break;
+                }
+            }
+        }
+
+	g_list_foreach( caps, (GFunc)g_free, NULL );
+	g_list_free( caps );
+    }
+
+    return supports_actions;
+}
+
 static int Notify( vlc_object_t *p_this, const char *psz_temp, GdkPixbuf *pix,
                    intf_thread_t *p_intf )
 {
@@ -296,11 +325,13 @@ static int Notify( vlc_object_t *p_this, const char *psz_temp, GdkPixbuf *pix,
         gdk_pixbuf_unref( pix );
     }
 
-    /* Adds previous and next buttons in the notification */
-    notify_notification_add_action( notification, "previous", _("Previous"), Prev,
-                                    (gpointer*) p_intf, NULL );
-    notify_notification_add_action( notification, "next", _("Next"), Next,
-                                    (gpointer*) p_intf, NULL );
+    /* Adds previous and next buttons in the notification if actions are supported. */
+    if( can_support_actions() ) {
+      notify_notification_add_action( notification, "previous", _("Previous"), Prev,
+				      (gpointer*) p_intf, NULL );
+      notify_notification_add_action( notification, "next", _("Next"), Next,
+				      (gpointer*) p_intf, NULL );
+    }
 
     notify_notification_show( notification, NULL);
 




More information about the vlc-devel mailing list