This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Mar 17th, 2011  |  syntax: None  |  size: 2.68 KB  |  views: 105  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. diff -aur pidgin-libnotify-0.14/src/pidgin-libnotify.c pidgin-libnotify-0.14.new/src/pidgin-libnotify.c
  2. --- pidgin-libnotify-0.14/src/pidgin-libnotify.c        2008-12-14 18:45:51.000000000 +0100
  3. +++ pidgin-libnotify-0.14.new/src/pidgin-libnotify.c    2011-03-17 17:02:59.000000000 +0100
  4. @@ -254,6 +254,32 @@
  5.         return purple_status_is_online (status) && purple_status_is_available (status);
  6.  }
  7.  
  8. +static gboolean
  9. +notify_supports_actions ()
  10. +{
  11. +       GList *caps;
  12. +       gint i = 0;
  13. +      
  14. +       caps = notify_get_server_caps ();
  15. +      
  16. +       do
  17. +       {
  18. +               if (g_strcmp0 (caps->data, "actions") == 0)
  19. +               {
  20. +                       g_list_free (caps);
  21. +                       return TRUE;
  22. +               }
  23. +              
  24. +               if (caps->next != NULL)
  25. +                       caps = g_list_next (caps);
  26. +
  27. +       } while (caps->next != NULL);
  28. +      
  29. +       g_list_free (caps);
  30. +      
  31. +       return FALSE;
  32. +}
  33. +
  34.  static void
  35.  notify (const gchar *title,
  36.                 const gchar *body,
  37. @@ -286,7 +312,7 @@
  38.                 g_free (tr_body);
  39.                 return;
  40.         }
  41. -       notification = notify_notification_new (title, tr_body, NULL, NULL);
  42. +       notification = notify_notification_new (title, tr_body, NULL);
  43.         purple_debug_info (PLUGIN_ID, "notify(), new: "
  44.                                          "title: '%s', body: '%s', buddy: '%s'\n",
  45.                                          title, tr_body, best_name (buddy));
  46. @@ -316,8 +342,12 @@
  47.         g_signal_connect (notification, "closed", G_CALLBACK(closed_cb), NULL);
  48.  
  49.         notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
  50. -
  51. -       notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);
  52. +      
  53. +       /* Check if notification server can use actions */
  54. +       if (notify_supports_actions ())
  55. +       {
  56. +               notify_notification_add_action (notification, "show", _("Show"), action_cb, NULL, NULL);
  57. +       }
  58.  
  59.         if (!notify_notification_show (notification, NULL)) {
  60.                 purple_debug_error (PLUGIN_ID, "notify(), failed to send notification\n");
  61. @@ -329,7 +359,7 @@
  62.  notify_buddy_signon_cb (PurpleBuddy *buddy,
  63.                                                 gpointer data)
  64.  {
  65. -       gchar *tr_name, *title;
  66. +       gchar *tr_name;
  67.         gboolean blocked;
  68.  
  69.         g_return_if_fail (buddy);
  70. @@ -349,19 +379,16 @@
  71.  
  72.         tr_name = truncate_escape_string (best_name (buddy), 25);
  73.  
  74. -       title = g_strdup_printf (_("%s signed on"), tr_name);
  75. -
  76. -       notify (title, NULL, buddy);
  77. +       notify (tr_name, "Signed on", buddy);
  78.  
  79.         g_free (tr_name);
  80. -       g_free (title);
  81.  }
  82.  
  83.  static void
  84.  notify_buddy_signoff_cb (PurpleBuddy *buddy,
  85.                                                  gpointer data)
  86.  {
  87. -       gchar *tr_name, *title;
  88. +       gchar *tr_name;
  89.         gboolean blocked;
  90.  
  91.         g_return_if_fail (buddy);
  92. @@ -381,12 +408,9 @@
  93.  
  94.         tr_name = truncate_escape_string (best_name (buddy), 25);
  95.  
  96. -       title = g_strdup_printf (_("%s signed off"), tr_name);
  97. -
  98. -       notify (title, NULL, buddy);
  99. +       notify (tr_name, "Signed off", buddy);
  100.  
  101.         g_free (tr_name);
  102. -       g_free (title);
  103.  }
  104.  
  105.  static void
clone this paste RAW Paste Data