Advertisement
Guest User

asac

a guest
Oct 1st, 2009
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.50 KB | None | 0 0
  1. === modified file 'src/bubble.c'
  2. --- a/src/bubble.c 2009-10-01 08:34:39 +0000
  3. +++ b/src/bubble.c 2009-10-01 15:03:25 +0000
  4. @@ -46,16 +46,18 @@
  5. #include "defaults.h"
  6. #include "stack.h"
  7. #include "dbus.h"
  8. #include "util.h"
  9. #include "bubble-window.h"
  10. #include "raico-blur.h"
  11. #include "tile.h"
  12.  
  13. +#define NOTIFY_OSD_ICON_PREFIX "notification"
  14. +
  15. G_DEFINE_TYPE (Bubble, bubble, G_TYPE_OBJECT);
  16.  
  17. #define GET_PRIVATE(o) \
  18. (G_TYPE_INSTANCE_GET_PRIVATE ((o), BUBBLE_TYPE, BubblePrivate))
  19.  
  20. struct _BubblePrivate {
  21. BubbleLayout layout;
  22. GtkWidget* widget;
  23. @@ -2376,37 +2378,71 @@ bubble_get_message_body (Bubble* self)
  24. {
  25. if (!self || !IS_BUBBLE (self))
  26. return NULL;
  27.  
  28. return GET_PRIVATE (self)->message_body->str;
  29. }
  30.  
  31. void
  32. +bubble_set_icon_from_path (Bubble* self,
  33. + const gchar* file_path)
  34. +{
  35. + Defaults* d;
  36. + BubblePrivate* priv;
  37. +
  38. + if (!self || !IS_BUBBLE (self) || !g_strcmp0 (file_path, ""))
  39. + return;
  40. +
  41. + priv = GET_PRIVATE (self);
  42. +
  43. + if (priv->icon_pixbuf)
  44. + {
  45. + g_object_unref (priv->icon_pixbuf);
  46. + priv->icon_pixbuf = NULL;
  47. + }
  48. +
  49. + d = self->defaults;
  50. + priv->icon_pixbuf = load_icon (file_path,
  51. + EM2PIXELS (defaults_get_icon_size (d),
  52. + d));
  53. +
  54. + _refresh_icon (self);
  55. +}
  56. +
  57. +void
  58. bubble_set_icon (Bubble* self,
  59. const gchar* filename)
  60. {
  61. Defaults* d;
  62. BubblePrivate* priv;
  63. + gchar *notify_osd_iconname;
  64.  
  65. if (!self || !IS_BUBBLE (self) || !g_strcmp0 (filename, ""))
  66. return;
  67.  
  68. priv = GET_PRIVATE (self);
  69.  
  70. if (priv->icon_pixbuf)
  71. {
  72. g_object_unref (priv->icon_pixbuf);
  73. priv->icon_pixbuf = NULL;
  74. }
  75.  
  76. + notify_osd_iconname = g_strdup_printf (NOTIFY_OSD_ICON_PREFIX "-%s", filename);
  77. d = self->defaults;
  78. - priv->icon_pixbuf = load_icon (filename,
  79. + priv->icon_pixbuf = load_icon (notify_osd_iconname,
  80. EM2PIXELS (defaults_get_icon_size (d),
  81. d));
  82. + g_free (notify_osd_iconname);
  83. + /* fallback to not notify-osd name */
  84. + if (!priv->icon_pixbuf)
  85. + priv->icon_pixbuf = load_icon (filename,
  86. + EM2PIXELS (defaults_get_icon_size (d),
  87. + d));
  88.  
  89. _refresh_icon (self);
  90. }
  91.  
  92. static GdkPixbuf *
  93. scale_pixbuf (const GdkPixbuf *pixbuf, gint size)
  94. {
  95. GdkPixbuf *scaled_icon;
  96.  
  97. === modified file 'src/bubble.h'
  98. --- a/src/bubble.h 2009-08-27 09:52:34 +0000
  99. +++ b/src/bubble.h 2009-10-01 14:58:39 +0000
  100. @@ -104,16 +104,20 @@ bubble_get_title (Bubble* self);
  101. void
  102. bubble_set_message_body (Bubble* self,
  103. const gchar* body);
  104.  
  105. const gchar*
  106. bubble_get_message_body (Bubble* self);
  107.  
  108. void
  109. +bubble_set_icon_from_path (Bubble* self,
  110. + const gchar* file_path);
  111. +
  112. +void
  113. bubble_set_icon (Bubble* self,
  114. const gchar* filename);
  115.  
  116. void
  117. bubble_set_icon_from_pixbuf (Bubble* self,
  118. GdkPixbuf* pixbuf);
  119.  
  120. GdkPixbuf*
  121.  
  122. === modified file 'src/stack.c'
  123. --- a/src/stack.c 2009-09-24 12:59:26 +0000
  124. +++ b/src/stack.c 2009-10-01 15:01:29 +0000
  125. @@ -720,17 +720,17 @@ stack_notify_handler (Stack*
  126. g_debug("Using image_data hint\n");
  127. pixbuf = process_dbus_icon_data (data);
  128. bubble_set_icon_from_pixbuf (bubble, pixbuf);
  129. }
  130. else if ((data = (GValue*) g_hash_table_lookup (hints, "image_path")))
  131. {
  132. g_debug("Using image_path hint\n");
  133. if ((data && G_VALUE_HOLDS_STRING (data)))
  134. - bubble_set_icon (bubble, g_value_get_string(data));
  135. + bubble_set_icon_from_path (bubble, g_value_get_string(data));
  136. else
  137. g_warning ("image_path hint is not a string\n");
  138. }
  139. else if (icon && *icon != '\0')
  140. {
  141. g_debug("Using icon parameter\n");
  142. bubble_set_icon (bubble, icon);
  143. }
  144.  
  145.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement